From bbf1b09c8e1a739b06a3a185d4054d987036f826 Mon Sep 17 00:00:00 2001 From: mcapsali Date: Wed, 1 Feb 2017 16:42:16 +0200 Subject: [PATCH 1/2] OVS unit tests. JJB yaml file. --- jjb/ovs-unit.yaml | 113 +++++++ scripts/unit-tests/linux/ovs-git.sh | 44 +++ scripts/unit-tests/windows/ovs-build.ps1 | 408 +++++++++++++++++++++++ scripts/unit-tests/windows/ovs-email.ps1 | 87 +++++ scripts/unit-tests/windows/ovs-req.ps1 | 110 ++++++ 5 files changed, 762 insertions(+) create mode 100644 jjb/ovs-unit.yaml create mode 100644 scripts/unit-tests/linux/ovs-git.sh create mode 100644 scripts/unit-tests/windows/ovs-build.ps1 create mode 100644 scripts/unit-tests/windows/ovs-email.ps1 create mode 100644 scripts/unit-tests/windows/ovs-req.ps1 diff --git a/jjb/ovs-unit.yaml b/jjb/ovs-unit.yaml new file mode 100644 index 0000000..f25df93 --- /dev/null +++ b/jjb/ovs-unit.yaml @@ -0,0 +1,113 @@ +- job: + name: "ovs-git-job" + project-type: freestyle + concurrent: true + node: ovs-slave.openstack.tld + logrotate: + daysToKeep: 7 + numToKeep: 200 + artifactDaysToKeep: -1 + artifactNumToKeep: -1 + scm: + - git: + url: https://github.com/openvswitch/ovs.git + branches: + - master + browser: auto + basedir: ovs + triggers: + - pollscm: + cron: "*/30 * * * *" + builders: + - shell: | + #!/bin/bash + set -e + function Check-LastRanFile { + lastranfile="$WORKSPACE/lastrancommit.txt" + if [ ! -e $lastranfile ]; then + echo "LastRanFile doesn't exist. Creating it." + cd $WORKSPACE/ovs + git rev-parse HEAD | tee $WORKSPACE/lastrancommit.txt + fi + } + function Get-GitLog { + currentcommit=`cat $WORKSPACE/lastrancommit.txt` + commitlog=`git rev-list $currentcommit...HEAD` + if [ ! "$commitlog" ]; then + echo "There are no new commits to OVS master. Existing Job." + exit 0 + fi + echo "$commitlog" | tee $WORKSPACE/gitlog.txt + head -1 $WORKSPACE/gitlog.txt | tee $WORKSPACE/lastrancommit.txt + } + function Start-CommitJob { + while read line + do + echo "Starting job for commitID $line" + curl -X POST "http://$jenk_user:jenk_api@10.20.1.3:8080/job/ovs-build-job/buildWithParameters?token=b204eee759ab38ebb986d223f6c5b4ce&commitid=$line" + echo "Job for commitID $line started" + done < $WORKSPACE/gitlog.txt + } + export WORKSPACE="/var/lib/jenkins/jobs/master-job/workspace" + echo "Getting commit ID's and writing them to $WORKSPACE/gitlog.txt" + Check-LastRanFile + cd $WORKSPACE/ovs + Get-GitLog + Start-CommitJob + wrappers: + - timeout: + timeout: 30 + fail: true + - timestamps +- job: + name: "ovs-build-job" + project-type: freestyle + concurrent: true + auth-token: b204eee759ab38ebb986d223f6c5b4ce + node: ovs-unit-test + logrotate: + daysToKeep: 7 + numToKeep: 200 + artifactDaysToKeep: -1 + artifactNumToKeep: -1 + parameters: + - string: + name: commitid + default: + description: "CommitID to build from" + builders: + - batch: | + powershell -command "& ""C:\scripts\ovs-build.ps1""" + wrappers: + - timeout: + timeout: 480 + fail: true + - timestamps +- job: + name: "ovs-email-job" + project-type: freestyle + concurrent: true + auth-token: b204eee759ab38ebb986d223f6c5b4ce + node: ovs-unit-test + logrotate: + daysToKeep: 7 + numToKeep: 200 + artifactDaysToKeep: -1 + artifactNumToKeep: -1 + parameters: + - string: + name: commitid + default: + description: "CommitID to build from" + - string: + name: status + default: + description: "Last Build status" + builders: + - batch: | + powershell -command "& ""C:\scripts\ovs-email.ps1""" + wrappers: + - timeout: + timeout: 30 + fail: true + - timestamps \ No newline at end of file diff --git a/scripts/unit-tests/linux/ovs-git.sh b/scripts/unit-tests/linux/ovs-git.sh new file mode 100644 index 0000000..7b4b657 --- /dev/null +++ b/scripts/unit-tests/linux/ovs-git.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +set -e + +function Check-LastRanFile { + lastranfile="$WORKSPACE/lastrancommit.txt" + if [ ! -e $lastranfile ]; then + echo "LastRanFile doesn't exist. Creating it." + cd $WORKSPACE/ovs + git rev-parse HEAD | tee $WORKSPACE/lastrancommit.txt + fi +} + +function Get-GitLog { + currentcommit=`cat $WORKSPACE/lastrancommit.txt` + commitlog=`git rev-list $currentcommit...HEAD` + if [ ! "$commitlog" ]; then + echo "There are no new commits to OVS master. Existing Job." + exit 0 + fi + echo "$commitlog" | tee $WORKSPACE/gitlog.txt + head -1 $WORKSPACE/gitlog.txt | tee $WORKSPACE/lastrancommit.txt +} + +function Start-CommitJob { + while read line + do + echo "Starting job for commitID $line" + curl -X POST "http://$jenk_user:$jenk_api@10.20.1.3:8080/job/ovs-build-job/buildWithParameters?token=b204eee759ab38ebb986d223f6c5b4ce&commitid=$line" + echo "Job for commitID $line started" + done < $WORKSPACE/gitlog.txt +} + +export WORKSPACE="/var/lib/jenkins/jobs/master-job/workspace" + +echo "Getting commit ID's and writing them to $WORKSPACE/gitlog.txt" + +Check-LastRanFile + +cd $WORKSPACE/ovs + +Get-GitLog + +Start-CommitJob \ No newline at end of file diff --git a/scripts/unit-tests/windows/ovs-build.ps1 b/scripts/unit-tests/windows/ovs-build.ps1 new file mode 100644 index 0000000..393ab64 --- /dev/null +++ b/scripts/unit-tests/windows/ovs-build.ps1 @@ -0,0 +1,408 @@ +Param( +) +$ErrorActionPreference = "Stop" + +function CheckRemoveDir($path) { + if (Test-Path $path) { + Remove-Item -Recurse -Force $path + } +} + +function CheckCopyDir($src, $dest) { + CheckRemoveDir $dest + Copy-Item $src $dest -Recurse +} + +function CheckDir($path) { + if (!(Test-Path -path $path)) + { + mkdir $path + } +} + +function GitClonePull($path, $url, $branch="master") { + Write-Host "Cloning / pulling: $url" + + $needspull = $true + + if (!(Test-Path -path $path)) + { + git clone -b $branch $url + if ($LastExitCode) { throw "git clone failed" } + $needspull = $false + } + + if ($needspull) + { + pushd . + try + { + cd $path + + $branchFound = (git branch) -match "(.*\s)?$branch" + if ($LastExitCode) { throw "git branch failed" } + + if($branchFound) + { + git checkout $branch + if ($LastExitCode) { throw "git checkout failed" } + } + else + { + git checkout -b $branch origin/$branch + if ($LastExitCode) { throw "git checkout failed" } + } + + git reset --hard + if ($LastExitCode) { throw "git reset failed" } + + git clean -f -d + if ($LastExitCode) { throw "git clean failed" } + + git pull + if ($LastExitCode) { throw "git pull failed" } + } + finally + { + popd + } + } +} + +function Start-GitClone { + ExecRetry { + # Make sure to have a private key that matches a github deployer key in $ENV:HOME\.ssh\id_rsa + GitClonePull $gitcloneDir "https://github.com/openvswitch/ovs.git" + } +} + +function Change-GitCommidID ( $commitID ) { + git checkout $commitID + write-host "this is the CommitID that we are working on" + git rev-parse HEAD +} + +function Set-commitInfo { + write-host "Reading and saving commit author and message." + pushd "$commitDir/$gitcloneDir" + git log -n 1 $commitID | Out-File "$localLogs\message-$commitID.txt" + Copy-Item "$localLogs\message-$commitID.txt" -Destination "$commitlogDir\commitmessage.txt" -Force + popd +} + +function SetVCVars($version="12.0", $platform="amd64") { + pushd "$ENV:ProgramFiles (x86)\Microsoft Visual Studio $version\VC\" + try + { + cmd /c "vcvarsall.bat $platform & set" | + foreach { + if ($_ -match "=") { + $v = $_.split("="); set-item -force -path "ENV:\$($v[0])" -value "$($v[1])" + } + } + } + finally + { + popd + } +} + +function ExecRetry($command, $maxRetryCount = 10, $retryInterval=2) { + $currErrorActionPreference = $ErrorActionPreference + $ErrorActionPreference = "Continue" + + $retryCount = 0 + while ($true) + { + try + { + & $command + break + } + catch [System.Exception] + { + $retryCount++ + if ($retryCount -ge $maxRetryCount) + { + $ErrorActionPreference = $currErrorActionPreference + throw + } + else + { + Write-Error $_.Exception + Start-Sleep $retryInterval + } + } + } + + $ErrorActionPreference = $currErrorActionPreference +} + +function Start-CheckPath { + CheckDir $basePath + CheckDir $localLogs + CheckRemoveDir $commitlogDir + mkdir -Force $commitlogDir + CheckRemoveDir $commitDir + mkdir -Force $commitDir + CheckRemoveDir $commitmsiDir + mkdir -Force $commitmsiDir + CheckRemoveDir $outputSymbolsPath + mkdir -Force $outputSymbolsPath + mkdir -Force $outputPath +} + +function Start-CopyTestLog { + $testlogPath = "$commitDir\ovs\tests\testsuite.log" + $testdirPath = "$commitDir\ovs\tests\testsuite.dir" + if ((Test-Path -path $testlogPath)) { + copy-item -Force "$testlogPath" "$commitlogDir\testsuite.log" + } + else { write-host "No testsuite.log found." } + if ((Test-Path -path $testdirPath)) { + copy-item -Force -recurse "$testdirPath" "$commitlogDir\testsuite.dir" + } + else { write-host "No testsuite.dir found." } +} + +function Start-CopyMsi { + $msiPath = "$commitDir\ovs\windows\ovs-windows-installer\bin\Release\OpenvSwitch.msi" + if ((Test-Path -path $msiPath)) { + copy -Force "$msiPath" "$commitmsiDir\OpenvSwitch.msi" + } + else { write-host "No msi found."} +} + +function Start-CompressLogs ( $logsPath ) { + $logfiles = Get-ChildItem -File -Recurse -Path $logsPath | Where-Object { $_.Extension -ne ".gz" } + foreach ($file in $logfiles) { + $filename = $file.name + $directory = $file.DirectoryName + $extension = $file.extension + if (!$extension) { + $name = $file.name + ".txt" + } + else { + $name = $file.name + } + &7z.exe a -tgzip "$directory\$name.gz" "$directory\$filename" -sdel + } +} + +function Set-RemoteVars { + Set-Variable -Name server -Value "10.20.1.14" -Scope Script + Set-Variable -Name user -Value "logs" -Scope Script + Set-Variable -Name key -Value "C:\scripts\ssh\norman.ppk" -Scope Script + Set-Variable -Name remotelogDir -Value "/srv/logs/ovs" -Scope Script + Set-Variable -Name remotemsiDir -Value "/srv/dl/ovs" -Scope Script +} + +function Start-SSHCMD ($server, $user, $key, $cmd) { + write-host "Running ssh command $cmd on remote server $server" +# &plink -batch $server -l $user -i $key $cmd + echo Y | plink.exe $server -l $user -i $key $cmd +} + +function Start-SCP ($server, $user, $key, $localPath, $remotePath) { + write-host "Starting copying $localPath to remote location ${server}:${remotePath}" +# &pscp -batch -scp -r -i $key $localPath $user@${server}:${remotePath} + echo Y | pscp.exe -scp -r -i $key $localPath $user@${server}:${remotePath} +} + +function Start-CreateRemoteDir { + Set-RemoteVars + $logCMD = "mkdir -p $remotelogDir/$commitID" + $msiCMD = "mkdir -p $remotemsiDir/$commitID" + Start-SSHCMD $server $user $key $logCMD + Start-SSHCMD $server $user $key $msiCMD +} + +function Start-RemoteLogCopy ($locallogPath) { + Set-RemoteVars + $remotelogPath = "$remotelogDir/$commitID" + write-host "Started copying logs for commit ID $commitID unit tests to remote location ${server}:${remotelogPath}" + Start-SCP $server $user $key $locallogPath $remotelogPath +} + +function Start-RemoteMsiCopy ($localmsiPath) { + Set-RemoteVars + $remotemsiPath = "$remotemsiDir/$commitID" + write-host "Started copying generated msi for commit ID $commitID to remote location ${server}:${remotemsiPath}" + Start-SCP $server $user $key $localmsiPath $remotemsiPath +} + +function Start-Cleanup { + $ovsprocess = Get-Process ovs* -ErrorAction SilentlyContinue + $ovnprocess = Get-Process ovn* -ErrorAction SilentlyContinue + if ($ovsprocess) { + Stop-Process -name ovs* + } + if ($ovnprocess) { + Stop-Process -name ovn* + } + cd $buildDir + CheckRemoveDir $commitDir +} + +function Start-MailJob ($user, $pass, $status) { + $uri = "http://10.20.1.3:8080/job/ovs-email-job/buildWithParameters?token=b204eee759ab38ebb986d223f6c5b4ce&commitid=$commitID&status=$status" + $pair = "${user}:${pass}" + $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair) + $base64 = [System.Convert]::ToBase64String($bytes) + $basicAuthValue = "Basic $base64" + $headers = @{ Authorization = $basicAuthValue } + write-host "Starting the Mail Job for status $status" + Invoke-WebRequest -uri $uri -Headers $headers -UseBasicParsing +} + +function Set-MakeSh { +$makeScript = @" +#!/bin/bash +set -e +cd $msysCwd +echo `$INCLUDE +./boot.sh +./configure CC=./build-aux/cccl LD="C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/BIN/x86_amd64/link.exe" LIBS="-lws2_32 -liphlpapi -lwbemuuid -lole32 -loleaut32" --prefix="C:/ProgramData/openvswitch" \ +--localstatedir="C:/ProgramData/openvswitch" --sysconfdir="C:/ProgramData/openvswitch" \ +--with-pthread="$pthreadDir" --with-vstudiotarget="Debug" +make clean && make -j4 +exit `$? +"@ + +$makeScriptPath = Join-Path $pwd "make.sh" +$makeScript.Replace("`r`n","`n") | Set-Content $makeScriptPath -Force +return $makeScriptPath +} + +function Set-UnitSh { +$unitScript = @" +#!/bin/bash +set -e +cd $msysCwd +echo `$INCLUDE +make check RECHECK=yes || make check TESTSUITEFLAGS="--recheck" || make check TESTSUITEFLAGS="--recheck" || make check TESTSUITEFLAGS="--recheck" || make check TESTSUITEFLAGS="--recheck" +exit `$? +"@ + +$unitScriptPath = Join-Path $pwd "unit.sh" +$unitScript.Replace("`r`n","`n") | Set-Content $unitScriptPath -Force +return $unitScriptPath +} + +function Set-MsiSh { +$msiScript = @" +#!/bin/bash +set -e +cd $msysCwd +echo `$INCLUDE +make windows_installer +exit `$? +"@ + +$msiScriptPath = Join-Path $pwd "msi.sh" +$msiScript.Replace("`r`n","`n") | Set-Content $msiScriptPath -Force +return $msiScriptPath +} + +# Make sure ActivePerl comes before MSYS Perl, otherwise +# the OpenSSL build will fail +$ENV:PATH = "C:\Perl64\bin;$ENV:PATH" +$ENV:PATH += ";${ENV:ProgramFiles}\7-Zip" +$ENV:PATH += ";${ENV:ProgramFiles}\Git\bin" +$ENV:PATH += ";${ENV:ProgramFiles(x86)}\CMake\bin" +$ENV:PATH += ";C:\Python27" +$ENV:PATH += ";C:\Python3" +$ENV:PATH += ";${ENV:ProgramFiles(x86)}\PuTTY" + + +$msysBinDir = "C:\mingw\msys\1.0\bin" +$basePath = "C:\OpenStack\OpenvSwitch" +$buildDir = "$basePath\Build" +$commitID = $env:commitid +$commitDir = "$buildDir\$commitID" +$outputPath = "$commitDir\bin" +$installerDir = "$basePath\installer" +$commitmsiDir = "$installerDir\$commitID" +$localLogs = "$basePath\logs" +$commitlogDir = "$localLogs\$commitID" +$outputSymbolsPath = "$commitDir\symbols" +#automake already appends \lib\ to the pthread library +$winPthreadLibDir = "$basePath\pthread" +#Git clone Dir +$gitcloneDir = "ovs" + +Start-CheckPath +Start-CreateRemoteDir +cd $commitDir +Start-GitClone +cd $gitcloneDir +Change-GitCommidID $commitID +Set-commitInfo + +$vsVersion = "12.0" +$platform = "x86_amd64" +SetVCVars $vsVersion $platform + +$msysCwd = "/" + $pwd.path.Replace("\", "/").Replace(":", "") +$pthreadDir = $winPthreadLibDir.Replace("\", "/") +# This must be the Visual Studio version of link.exe, not MinGW +$vsLink = $(Get-Command link.exe).path +$vsLinkPath = $vsLink.Replace("\", "/").Replace(":", "") + +$ENV:PATH = "$msysBinDir;$ENV:PATH" + +$makeScriptPath = Set-MakeSh +Get-Content $makeScriptPath +write-host "Running make on OVS commit $commitid" +&bash.exe $makeScriptPath | Tee-Object -FilePath "$commitlogDir\makeoutput.log" + if ($LastExitCode) { + Start-CompressLogs "$commitlogDir" + Start-RemoteLogCopy "$commitlogDir\*" + Start-MailJob "$jenk_user" "$jenk_api" "ERROR" + Start-Cleanup + throw "make.sh failed" + } + else { +# Start-RemoteLogCopy "$commitlogDir\makeoutput.log" + write-host "Finished compiling. Moving on..." + } + +$unitScriptPath = Set-UnitSh +Get-Content $unitScriptPath +write-host "Running unit tests!" +&bash.exe $unitScriptPath | Tee-Object -FilePath "$commitlogDir\unitsoutput.log" + if ($LastExitCode) { + Start-CopyTestLog + Start-CompressLogs "$commitlogDir" + Start-RemoteLogCopy "$commitlogDir\*" + Start-MailJob "$jenk_user" "$jenk_api" "UNITFAIL" + Start-Cleanup + throw "Unit tests failed. The logs have been saved." + } + else { + write-host "unit tests succeded. Moving on" + Start-CopyTestLog + Start-CompressLogs "$commitlogDir" + Start-RemoteLogCopy "$commitlogDir\*" + Start-MailJob "$jenk_user" "$jenk_api" "UNITPASS" + } + +$msiScriptPath = Set-MsiSh +Get-Content $msiScriptPath +write-host "Building OVS MSI." +&bash.exe $msiScriptPath | Tee-Object -FilePath "$commitlogDir\msioutput.log" + if ($LastExitCode) { + cd $buildDir + Start-CompressLogs "$commitlogDir" + Start-RemoteLogCopy "$commitlogDir\msioutput.log.gz" + Start-Cleanup + throw "Failed to create OVS msi." + } + else { + write-host "OVS msi created." + Start-CompressLogs "$commitlogDir" + Start-CopyMsi + Start-RemoteLogCopy "$commitlogDir\msioutput.log.gz" + Start-RemoteMsiCopy "$commitDir\ovs\windows\ovs-windows-installer\bin\Release\OpenvSwitch.msi" + Start-Cleanup + } \ No newline at end of file diff --git a/scripts/unit-tests/windows/ovs-email.ps1 b/scripts/unit-tests/windows/ovs-email.ps1 new file mode 100644 index 0000000..d44f8df --- /dev/null +++ b/scripts/unit-tests/windows/ovs-email.ps1 @@ -0,0 +1,87 @@ +function Send-PassEmail ($from, $to, $smtpServer, $commitLink, $logLink) { + $subject = "[ovs-build] Passed: openvswitch/ovs (master - $commitID)" + $body = @" +
+Status: Passed
+
+
+$commitMessage
+
+
+View the changeset:
+$commitLink
+
+View the full build log and details:
+$logLink
+"@ + Send-MailMessage -from $from -to $to -subject $subject -body $body -BodyAsHtml -smtpServer $smtpServer +} + +function Send-FailEmail ($from, $to, $smtpServer, $commitLink, $logLink) { + $subject = "[ovs-build] Failed: openvswitch/ovs (master - $commitID)" + $body = @" +
+Status: Failed
+
+
+$commitMessage
+
+
+View the changeset:
+$commitLink
+
+View the full build log and details:
+$logLink
+"@ + Send-MailMessage -from $from -to $to -subject $subject -body $body -BodyAsHtml -smtpServer $smtpServer +} + +function Send-ErrorEmail ($from, $to, $smtpServer, $commitLink, $logLink) { + $subject = "[ovs-make] Error: openvswitch/ovs (master - $commitID)" + $body = @" +
+Status: Error
+
+
+$commitMessage
+
+
+View the changeset:
+$commitLink
+
+View the full build log and details:
+$logLink
+"@ + Send-MailMessage -from $from -to $to -subject $subject -body $body -BodyAsHtml -smtpServer $smtpServer +} + + +$Status = $env:status +$commitID = $env:commitid +$basePath = "C:\OpenStack\OpenvSwitch" +$localLogs = "$basePath\logs" +$commitlogDir = "$localLogs\$commitID" +$commitMessage = Get-Content "$localLogs\message-$commitID.txt" -Raw +$smtpServer = "mail.cloudbasesolutions.com" +$from = "microsoft_ovs_ci@microsoft.com" +$to = "aserdean@cloudbasesolutions.com","ociuhandu@cloudbasesolutions.com","mgheorghe@cloudbasesolutions.com" +$commitLink = "https://github.com/openvswitch/ovs/commit/$commitID" +$logLink = "http://64.119.130.115/ovs/$commitID" +#$msiLink = "http://10.20.1.14:8080/ovs/$commitID" + +if ( $Status -eq "UNITPASS" ) { + write-host "Sending Unit Tests Pass E-mail for $commitID" + Send-PassEmail $from $to $smtpServer $commitLink $logLink +} + +if ( $Status -eq "UNITFAIL" ) { + write-host "Sending Unit Tests Fail E-mail for $commitID" + Send-FailEmail $from $to $smtpServer $commitLink $logLink +} + +if ( $Status -eq "ERROR" ) { + write-host "Sending make error E-mail for $commitID" + Send-PassEmail $from "mgheorghe@cloudbasesolutions.com" $smtpServer $commitLink $logLink +} + +Remove-Item -Path "$localLogs\message-$commitID.txt" -Force \ No newline at end of file diff --git a/scripts/unit-tests/windows/ovs-req.ps1 b/scripts/unit-tests/windows/ovs-req.ps1 new file mode 100644 index 0000000..a5c780c --- /dev/null +++ b/scripts/unit-tests/windows/ovs-req.ps1 @@ -0,0 +1,110 @@ +$ErrorActionPreference = "Stop" + +# Make directory structure +$redistDir = "C:\Openstack\OpenvSwitch\Redist\" +if (Test-Path $redistDir) { + Remove-Item -Recurse -Force $redistDir + } +New-Item -ItemType directory -Path $redistDir + +# Download installers +Invoke-WebRequest -Uri "http://www.7-zip.org/a/7z1602-x64.msi" -OutFile "$redistDir\7zip-x64.msi" +Invoke-WebRequest -Uri "https://github.com/git-for-windows/git/releases/download/v2.8.3.windows.1/Git-2.8.3-64-bit.exe" -OutFile "$redistDir\git-x64.exe" +Invoke-WebRequest -Uri "https://cmake.org/files/v3.5/cmake-3.5.2-win32-x86.msi" -OutFile "$redistDir\cmake.msi" +Invoke-WebRequest -Uri "https://wix.codeplex.com/downloads/get/1540240" -OutFile "$redistDir\wix310.exe" +Invoke-WebRequest -Uri "http://freefr.dl.sourceforge.net/project/mingw/Installer/mingw-get/mingw-get-0.6.2-beta-20131004-1/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip" -OutFile "$redistDir\msys.zip" +Invoke-WebRequest -Uri "https://www.python.org/ftp/python/2.7.11/python-2.7.11.amd64.msi" -OutFile "$redistDir\python-2.7.1.amd64.msi" +Invoke-WebRequest -Uri "https://www.python.org/ftp/python/3.6.0/python-3.6.0-embed-amd64.zip" -OutFile "$redistDir\python-3.6.0.amd64.zip" +Invoke-WebRequest -Uri "https://download.microsoft.com/download/9/6/4/96442E58-C65C-4122-A956-CCA83EECCD03/wdexpress_full.exe" -OutFile "$redistDir\wdexpress_full.exe" +Invoke-WebRequest -Uri "https://download.microsoft.com/download/0/8/C/08C7497F-8551-4054-97DE-60C0E510D97A/wdk/wdksetup.exe" -OutFile "$redistDir\wdksetup.exe" +Invoke-WebRequest -Uri "https://netix.dl.sourceforge.net/project/pthreads4w/pthreads-w32-2-9-1-release.zip" -OutFile "$redistDir\pthreads-w32.zip" +Invoke-WebRequest -Uri "http://downloads.activestate.com/ActivePerl/releases/5.22.1.2201/ActivePerl-5.22.1.2201-MSWin32-x64-299574.msi" -OutFile "$redistDir\activeperl-x64.msi" +Invoke-WebRequest -Uri "http://download.microsoft.com/download/A/A/D/AAD1AA11-FF9A-4B3C-8601-054E89260B78/vs_community.exe" -OutFile "$redistDir\vs_community.exe" +Invoke-WebRequest -Uri "https://the.earth.li/~sgtatham/putty/0.67/x86/putty-0.67-installer.msi" -OutFile "$redistDir\Redist\putty.msi" +Invoke-WebRequest -Uri "https://gallery.technet.microsoft.com/scriptcenter/Powershell-module-to-send-44b0716a/file/136703/1/SBeMail.rar" -OutFile "$redistDir\SBeMail.rar" +# Install prerequisite +Set-Location C:\Openstack\OpenvSwitch\Redist\ + +# Install 7zip-x64 +$7zip_msi = "$redistDir\7zip-x64.msi" +Start-Process -FilePath msiexec.exe -ArgumentList "/q","/i","$7zip_msi" -Wait -PassThru + +# Install Git +$git_exe = "$redistDir\git-x64.exe" +Start-Process -FilePath $git_exe -ArgumentList "/SILENT","/COMPONENTS='icons,ext\reg\shellhere,assoc,assoc_sh'","/i" -Wait -PassThru + +# Install Putty +$putty_msi = "$redistDir\Redist\putty.msi" +Start-Process -FilePath $putty_msi -ArgumentList "/q" -Wait -PassThru + +# Install cmake +$cmake_msi = "$redistDir\cmake.msi" +Start-Process -FilePath msiexec.exe -ArgumentList "/q","/i","$cmake_msi" -Wait -PassThru + +# Install Python2.7 +$python_msi = "$redistDir\python-2.7.1.amd64.msi" +Start-Process -FilePath msiexec.exe -ArgumentList "/qn","/i","$python_msi" -Wait -PassThru + +# Install Python3 +$python3_zip = "$redistDir\python-3.6.0.amd64.zip" +Get-ChildItem $python3_zip | % {& "C:\Program Files\7-Zip\7z.exe" "x" $_.fullname "-oC:\Python3"} +Rename-Item C:\Python3\python.exe python3.exe + +# Install six for python +$ENV:PATH += ";C:\Python27" +python -m pip install six +python -m pip install pypiwin32 + +# Install ActivePerl +$activeperl_msi = "$redistDir\activeperl-x64.msi" +Start-Process -FilePath msiexec.exe -ArgumentList "/q","/i","$activeperl_msi" -Wait -PassThru + + +# Install Pthreads +$pthreads_zip = "$redistDir\pthreads-w32.zip" +Get-ChildItem $pthreads_zip | % {& "C:\Program Files\7-Zip\7z.exe" "x" $_.fullname "-oC:\Openstack\OpenvSwitch\Redist\pthreads"} +Move-Item $redistDir\pthreads\Pre-built.2 C:\Openstack\OpenvSwitch\pthread +# Copy pthread.dll to system path. +Copy-Item C:\Openstack\OpenvSwitch\pthread\dll\x64\* C:\Windows + +# Install Vstudio2013 +$vs_exe = "$redistDir\vs_community.exe" +Start-Process -FilePath $vs_exe -ArgumentList "/Quiet","/Norestart" -Wait -PassThru + +# Install WDK +$wdk_exe = "$redistDir\wdksetup.exe" +Start-Process -FilePath $wdk_exe -ArgumentList "/q" -Wait -PassThru + +# Install WIX +$wix_exe = "$redistDir\wix310.exe" +Start-Process -FilePath $wix_exe -ArgumentList "/q" -Wait -PassThru + +# Install Msys +Get-ChildItem $redistDir\msys.zip | % {& "C:\Program Files\7-Zip\7z.exe" "x" $_.fullname "-oC:\mingw"} + +# Install Msys req +$ENV:PATH += ";C:\mingw\bin" + +mingw-get update + +mingw-get upgrade + +mingw-get install msys msys-coreutils + +mingw-get install msys-binutils msys-libtool msys-automake msys-autoconf msys-make msys-patch + +mingw-get upgrade msys-core-bin=1.0.17-1 + +# Mount /mingw into msys (not sure is needed at all!) +#Rename-Item C:\mingw\msys\1.0\etc\fstab.sample fstab + +# Make sure msys get the link.exe from VS12 and not the default one. +Rename-Item C:\mingw\msys\1.0\bin\link.exe linkbak.exe + +# Set WinRM concurrent processes per shell +winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="2048"}' +winrm set winrm/config/winrs '@{MaxProcessesPerShell="10000"}' +winrm set winrm/config/winrs '@{MaxShellsPerUser="100"}' + +# Restart Windows so that all $env variables are set. +Restart-Computer From 1e8dd65e20be4569709ae3e7876174952af929a5 Mon Sep 17 00:00:00 2001 From: mcapsali Date: Wed, 5 Apr 2017 12:30:38 +0300 Subject: [PATCH 2/2] Changed directory structure. Made changes according to review. Removed jjb file since it will be hosted in another repo --- jjb/ovs-unit.yaml | 113 ----- scripts/{unit-tests/linux => job}/ovs-git.sh | 21 +- scripts/unit-tests/config.ps1 | 55 +++ scripts/unit-tests/ovs-build.ps1 | 90 ++++ scripts/unit-tests/ovs-email.ps1 | 22 + scripts/unit-tests/{windows => }/ovs-req.ps1 | 20 +- scripts/unit-tests/utils.ps1 | 260 ++++++++++++ scripts/unit-tests/windows/ovs-build.ps1 | 408 ------------------- scripts/unit-tests/windows/ovs-email.ps1 | 87 ---- 9 files changed, 447 insertions(+), 629 deletions(-) delete mode 100644 jjb/ovs-unit.yaml rename scripts/{unit-tests/linux => job}/ovs-git.sh (50%) create mode 100644 scripts/unit-tests/config.ps1 create mode 100644 scripts/unit-tests/ovs-build.ps1 create mode 100644 scripts/unit-tests/ovs-email.ps1 rename scripts/unit-tests/{windows => }/ovs-req.ps1 (88%) create mode 100644 scripts/unit-tests/utils.ps1 delete mode 100644 scripts/unit-tests/windows/ovs-build.ps1 delete mode 100644 scripts/unit-tests/windows/ovs-email.ps1 diff --git a/jjb/ovs-unit.yaml b/jjb/ovs-unit.yaml deleted file mode 100644 index f25df93..0000000 --- a/jjb/ovs-unit.yaml +++ /dev/null @@ -1,113 +0,0 @@ -- job: - name: "ovs-git-job" - project-type: freestyle - concurrent: true - node: ovs-slave.openstack.tld - logrotate: - daysToKeep: 7 - numToKeep: 200 - artifactDaysToKeep: -1 - artifactNumToKeep: -1 - scm: - - git: - url: https://github.com/openvswitch/ovs.git - branches: - - master - browser: auto - basedir: ovs - triggers: - - pollscm: - cron: "*/30 * * * *" - builders: - - shell: | - #!/bin/bash - set -e - function Check-LastRanFile { - lastranfile="$WORKSPACE/lastrancommit.txt" - if [ ! -e $lastranfile ]; then - echo "LastRanFile doesn't exist. Creating it." - cd $WORKSPACE/ovs - git rev-parse HEAD | tee $WORKSPACE/lastrancommit.txt - fi - } - function Get-GitLog { - currentcommit=`cat $WORKSPACE/lastrancommit.txt` - commitlog=`git rev-list $currentcommit...HEAD` - if [ ! "$commitlog" ]; then - echo "There are no new commits to OVS master. Existing Job." - exit 0 - fi - echo "$commitlog" | tee $WORKSPACE/gitlog.txt - head -1 $WORKSPACE/gitlog.txt | tee $WORKSPACE/lastrancommit.txt - } - function Start-CommitJob { - while read line - do - echo "Starting job for commitID $line" - curl -X POST "http://$jenk_user:jenk_api@10.20.1.3:8080/job/ovs-build-job/buildWithParameters?token=b204eee759ab38ebb986d223f6c5b4ce&commitid=$line" - echo "Job for commitID $line started" - done < $WORKSPACE/gitlog.txt - } - export WORKSPACE="/var/lib/jenkins/jobs/master-job/workspace" - echo "Getting commit ID's and writing them to $WORKSPACE/gitlog.txt" - Check-LastRanFile - cd $WORKSPACE/ovs - Get-GitLog - Start-CommitJob - wrappers: - - timeout: - timeout: 30 - fail: true - - timestamps -- job: - name: "ovs-build-job" - project-type: freestyle - concurrent: true - auth-token: b204eee759ab38ebb986d223f6c5b4ce - node: ovs-unit-test - logrotate: - daysToKeep: 7 - numToKeep: 200 - artifactDaysToKeep: -1 - artifactNumToKeep: -1 - parameters: - - string: - name: commitid - default: - description: "CommitID to build from" - builders: - - batch: | - powershell -command "& ""C:\scripts\ovs-build.ps1""" - wrappers: - - timeout: - timeout: 480 - fail: true - - timestamps -- job: - name: "ovs-email-job" - project-type: freestyle - concurrent: true - auth-token: b204eee759ab38ebb986d223f6c5b4ce - node: ovs-unit-test - logrotate: - daysToKeep: 7 - numToKeep: 200 - artifactDaysToKeep: -1 - artifactNumToKeep: -1 - parameters: - - string: - name: commitid - default: - description: "CommitID to build from" - - string: - name: status - default: - description: "Last Build status" - builders: - - batch: | - powershell -command "& ""C:\scripts\ovs-email.ps1""" - wrappers: - - timeout: - timeout: 30 - fail: true - - timestamps \ No newline at end of file diff --git a/scripts/unit-tests/linux/ovs-git.sh b/scripts/job/ovs-git.sh similarity index 50% rename from scripts/unit-tests/linux/ovs-git.sh rename to scripts/job/ovs-git.sh index 7b4b657..0214639 100644 --- a/scripts/unit-tests/linux/ovs-git.sh +++ b/scripts/job/ovs-git.sh @@ -6,14 +6,17 @@ function Check-LastRanFile { lastranfile="$WORKSPACE/lastrancommit.txt" if [ ! -e $lastranfile ]; then echo "LastRanFile doesn't exist. Creating it." - cd $WORKSPACE/ovs - git rev-parse HEAD | tee $WORKSPACE/lastrancommit.txt + git -C $WORKSPACE/ovs rev-parse HEAD | tee $WORKSPACE/lastrancommit.txt + echo "Starting first job for OVS unit tests" + firstcommit=$(cat $WORKSPACE/lastrancommit.txt) + curl -X POST "http://{jenkins_user}:{jenkins_pass}@{jenkins_ip}:8080/job/ovs-build-job/buildWithParameters?token={token}&commitid=$firstcommit" + echo "Job for first commitID $firstcommit started" fi } function Get-GitLog { - currentcommit=`cat $WORKSPACE/lastrancommit.txt` - commitlog=`git rev-list $currentcommit...HEAD` + currentcommit=$(cat $WORKSPACE/lastrancommit.txt) + commitlog=$(git -C $WORKSPACE/ovs rev-list $currentcommit...HEAD) if [ ! "$commitlog" ]; then echo "There are no new commits to OVS master. Existing Job." exit 0 @@ -22,23 +25,19 @@ function Get-GitLog { head -1 $WORKSPACE/gitlog.txt | tee $WORKSPACE/lastrancommit.txt } -function Start-CommitJob { +function Start-OVSBuildJob { while read line do echo "Starting job for commitID $line" - curl -X POST "http://$jenk_user:$jenk_api@10.20.1.3:8080/job/ovs-build-job/buildWithParameters?token=b204eee759ab38ebb986d223f6c5b4ce&commitid=$line" + curl -X POST "http://{jenkins_user}:{jenkins_pass}@{jenkins_ip}:8080/job/ovs-build-job/buildWithParameters?token={token}&commitid=$line" echo "Job for commitID $line started" done < $WORKSPACE/gitlog.txt } -export WORKSPACE="/var/lib/jenkins/jobs/master-job/workspace" - echo "Getting commit ID's and writing them to $WORKSPACE/gitlog.txt" Check-LastRanFile -cd $WORKSPACE/ovs - Get-GitLog -Start-CommitJob \ No newline at end of file +Start-OVSBuildJob \ No newline at end of file diff --git a/scripts/unit-tests/config.ps1 b/scripts/unit-tests/config.ps1 new file mode 100644 index 0000000..6b73261 --- /dev/null +++ b/scripts/unit-tests/config.ps1 @@ -0,0 +1,55 @@ +# Environment variables +$ENV:PATH = "C:\Perl64\bin;$ENV:PATH" +$ENV:PATH += ";${ENV:ProgramFiles}\7-Zip" +$ENV:PATH += ";${ENV:ProgramFiles}\Git\bin" +$ENV:PATH += ";${ENV:ProgramFiles(x86)}\CMake\bin" +$ENV:PATH += ";C:\Python27" +$ENV:PATH += ";C:\Python3" +$ENV:PATH += ";${ENV:ProgramFiles(x86)}\PuTTY" +$ENV:PATH = "C:\mingw\msys\1.0\bin;$ENV:PATH" + +# Jenkins Job Variables +$commitID = $env:commitid +$unitStatus = $env:unitStatus +$makeStatus = $env:makeStatus +$workspace = $env:WORKSPACE + +# OVS git URL +$OVS_URL = "https://github.com/openvswitch/ovs.git" + +# Path variables +$basePath = "C:\OpenStack\OpenvSwitch" +$buildDir = "$basePath\Build" +$commitDir = "$buildDir\$commitID" +$outputPath = "$commitDir\bin" +$commitmsiDir = "$basePath\installer\$commitID" +$localLogs = "$basePath\logs" +$commitlogDir = "$localLogs\$commitID" +$outputSymbolsPath = "$commitDir\symbols" +#automake already appends \lib\ to the pthread library +$winPthreadLibDir = "$basePath\pthread" +$pthreadDir = $winPthreadLibDir.Replace("\", "/") +#Git clone Dir +$gitcloneDir = "$commitDir\ovs" + +# Visual Studio version +$vsVersion = "12.0" +$platform = "x86_amd64" + +# Remote Log Server Variables +$remoteServer = "10.20.1.14" +$remoteUser = "logs" +$remoteKey = "C:\ovs-ci\scripts\unit-tests\ssh\norman.ppk" +$remotelogDir = "/srv/logs/unit-tests/ovs" +$remotemsiDir = "/srv/dl/ovs" +$remotelogdirPath = "$remotelogDir/$commitID" +$remotemsidirPath = "$remotemsiDir/$commitID" + +# Email Job Variables +$smtpServer = "192.168.1.3" +$from = "microsoft_ovs_ci@microsoft.com" +$to = "aserdean@cloudbasesolutions.com","ociuhandu@cloudbasesolutions.com","mgheorghe@cloudbasesolutions.com","ovs-build@openvswitch.org" +$msito = "aserdean@cloudbasesolutions.com","ociuhandu@cloudbasesolutions.com","mgheorghe@cloudbasesolutions.com" +$commitLink = "https://github.com/openvswitch/ovs/commit/$commitID" +$privatelogLink = "http://$remoteServer/ovs/unit-tests/$commitID" +$publiclogLink = "http://64.119.130.115/ovs/unit-tests/$commitID" diff --git a/scripts/unit-tests/ovs-build.ps1 b/scripts/unit-tests/ovs-build.ps1 new file mode 100644 index 0000000..5f4a38b --- /dev/null +++ b/scripts/unit-tests/ovs-build.ps1 @@ -0,0 +1,90 @@ +Param( +) +$ErrorActionPreference = "Stop" + +# Source the config and utils scripts. +$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition +. "$scriptPath\config.ps1" +. "$scriptPath\utils.ps1" + +CheckLocalPaths +# Create the log paths on the remote log server +CreateRemotePaths $remotelogdirPath + +pushd $commitDir +GitClonePull $gitcloneDir $OVS_URL +popd +pushd $gitcloneDir +Set-GitCommidID $commitID +Set-commitInfo + +$msysCwd = "/" + $pwd.path.Replace("\", "/").Replace(":", "") + +# Make Visual Studio Paths available to msys. +Set-VCVars $vsVersion $platform +# This must be the Visual Studio version of link.exe, not MinGW +$vsLink = $(Get-Command link.exe).path +$vsLinkPath = $vsLink.Replace("\", "/").Replace(":", "") + +$makeScriptPath = Set-MakeScript +Get-Content $makeScriptPath +write-host "Running make on OVS commit $commitid" +&bash.exe $makeScriptPath + if ($LastExitCode) { + copy-item -Force "$gitcloneDir\makeoutput.log" "$commitlogDir\makeoutput.log" + CompressLogs "$commitlogDir" + Copy-RemoteLogs "$commitlogDir\*" $remotelogdirPath + New-Item -Type file -Force -Path "$workspace\params.txt" -Value "makeStatus=ERROR" + popd + Cleanup + throw "make.sh failed" + } + else { + write-host "Finished compiling. Moving on..." + } + +$unitScriptPath = Set-UnitScript +Get-Content $unitScriptPath +write-host "Running unit tests!" +&bash.exe $unitScriptPath | Tee-Object -FilePath "$commitlogDir\unitsoutput.log" + if ($LastExitCode) { + Copy-LocalLogs + CompressLogs "$commitlogDir" + Copy-RemoteLogs "$commitlogDir\*" $remotelogdirPath + New-Item -Type file -Force -Path "$workspace\params.txt" -Value "unitStatus=FAILED" + popd + Cleanup + throw "Unit tests failed. The logs have been saved." + } + else { + write-host "unit tests succeded. Moving on" + Copy-LocalLogs + CompressLogs "$commitlogDir" + Copy-RemoteLogs "$commitlogDir\*" $remotelogdirPath + New-Item -Type file -Force -Path "$workspace\params.txt" -Value "unitStatus=PASSED" + } + +$msiScriptPath = Set-MsiScript +Get-Content $msiScriptPath +write-host "Building OVS MSI." +&bash.exe $msiScriptPath | Tee-Object -FilePath "$commitlogDir\msioutput.log" + if ($LastExitCode) { + cd $buildDir + CompressLogs "$commitlogDir" + Copy-RemoteLogs "$commitlogDir\msioutput.log.gz" $remotelogdirPath + popd + Cleanup + throw "Failed to create OVS msi." + } + else { + write-host "OVS msi created." + # Create the msi remote log paths + CreateRemotePaths $remotemsidirPath + CompressLogs "$commitlogDir" + Copy-LocalMsi + Copy-RemoteLogs "$commitlogDir\msioutput.log.gz" $remotelogdirPath + Copy-RemoteMSI "$gitcloneDir\windows\ovs-windows-installer\bin\Release\OpenvSwitch.msi" $remotemsidirPath + Copy-RemoteMSI "$gitcloneDir\datapath-windows\x64\Win8.1Debug\package.cer" $remotemsidirPath + popd + Cleanup + } diff --git a/scripts/unit-tests/ovs-email.ps1 b/scripts/unit-tests/ovs-email.ps1 new file mode 100644 index 0000000..880e6f1 --- /dev/null +++ b/scripts/unit-tests/ovs-email.ps1 @@ -0,0 +1,22 @@ +# Source the config and utils scripts. +$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition +. "$scriptPath\config.ps1" +. "$scriptPath\utils.ps1" + + +$messageUri = "$privatelogLink/commitmessage.txt.gz" +$messageOutFile = "$localLogs\message-$commitID.txt" +write-host "connecting to $messageUri" +ExecRetry {Invoke-WebRequest -Uri $messageUri -OutFile $messageOutFile} +$commitMessage = Get-Content $messageOutFile -Raw + +if ($makeStatus) { + write-host "Sending Unit Tests E-mail for $commitID with status $unitStatus" + Send-Email $from $msito $unitStatus $commitLink $publiclogLink +} +if ($unitStatus) { + write-host "Sending Unit Tests E-mail for $commitID with status $unitStatus" + Send-Email $from $to $unitStatus $commitLink $publiclogLink +} + +Remove-Item -Force -Path $messageOutFile \ No newline at end of file diff --git a/scripts/unit-tests/windows/ovs-req.ps1 b/scripts/unit-tests/ovs-req.ps1 similarity index 88% rename from scripts/unit-tests/windows/ovs-req.ps1 rename to scripts/unit-tests/ovs-req.ps1 index a5c780c..f0d95d8 100644 --- a/scripts/unit-tests/windows/ovs-req.ps1 +++ b/scripts/unit-tests/ovs-req.ps1 @@ -1,5 +1,3 @@ -$ErrorActionPreference = "Stop" - # Make directory structure $redistDir = "C:\Openstack\OpenvSwitch\Redist\" if (Test-Path $redistDir) { @@ -18,10 +16,10 @@ Invoke-WebRequest -Uri "https://www.python.org/ftp/python/3.6.0/python-3.6.0-emb Invoke-WebRequest -Uri "https://download.microsoft.com/download/9/6/4/96442E58-C65C-4122-A956-CCA83EECCD03/wdexpress_full.exe" -OutFile "$redistDir\wdexpress_full.exe" Invoke-WebRequest -Uri "https://download.microsoft.com/download/0/8/C/08C7497F-8551-4054-97DE-60C0E510D97A/wdk/wdksetup.exe" -OutFile "$redistDir\wdksetup.exe" Invoke-WebRequest -Uri "https://netix.dl.sourceforge.net/project/pthreads4w/pthreads-w32-2-9-1-release.zip" -OutFile "$redistDir\pthreads-w32.zip" -Invoke-WebRequest -Uri "http://downloads.activestate.com/ActivePerl/releases/5.22.1.2201/ActivePerl-5.22.1.2201-MSWin32-x64-299574.msi" -OutFile "$redistDir\activeperl-x64.msi" +Invoke-WebRequest -Uri "http://downloads.activestate.com/ActivePerl/releases/5.24.1.2402/ActivePerl-5.24.1.2402-MSWin32-x64-401627.exe" -OutFile "$redistDir\activeperl-x64.exe" Invoke-WebRequest -Uri "http://download.microsoft.com/download/A/A/D/AAD1AA11-FF9A-4B3C-8601-054E89260B78/vs_community.exe" -OutFile "$redistDir\vs_community.exe" -Invoke-WebRequest -Uri "https://the.earth.li/~sgtatham/putty/0.67/x86/putty-0.67-installer.msi" -OutFile "$redistDir\Redist\putty.msi" -Invoke-WebRequest -Uri "https://gallery.technet.microsoft.com/scriptcenter/Powershell-module-to-send-44b0716a/file/136703/1/SBeMail.rar" -OutFile "$redistDir\SBeMail.rar" +Invoke-WebRequest -Uri "https://the.earth.li/~sgtatham/putty/0.67/x86/putty-0.67-installer.msi" -OutFile "$redistDir\putty.msi" + # Install prerequisite Set-Location C:\Openstack\OpenvSwitch\Redist\ @@ -34,7 +32,7 @@ $git_exe = "$redistDir\git-x64.exe" Start-Process -FilePath $git_exe -ArgumentList "/SILENT","/COMPONENTS='icons,ext\reg\shellhere,assoc,assoc_sh'","/i" -Wait -PassThru # Install Putty -$putty_msi = "$redistDir\Redist\putty.msi" +$putty_msi = "$redistDir\putty.msi" Start-Process -FilePath $putty_msi -ArgumentList "/q" -Wait -PassThru # Install cmake @@ -56,9 +54,8 @@ python -m pip install six python -m pip install pypiwin32 # Install ActivePerl -$activeperl_msi = "$redistDir\activeperl-x64.msi" -Start-Process -FilePath msiexec.exe -ArgumentList "/q","/i","$activeperl_msi" -Wait -PassThru - +$activeperl_exe = "$redistDir\activeperl-x64.exe" +Start-Process -FilePath $activeperl_exe -ArgumentList "/q","/i" -Wait -PassThru # Install Pthreads $pthreads_zip = "$redistDir\pthreads-w32.zip" @@ -99,12 +96,15 @@ mingw-get upgrade msys-core-bin=1.0.17-1 #Rename-Item C:\mingw\msys\1.0\etc\fstab.sample fstab # Make sure msys get the link.exe from VS12 and not the default one. -Rename-Item C:\mingw\msys\1.0\bin\link.exe linkbak.exe +Rename-Item -Force C:\mingw\msys\1.0\bin\link.exe linkbak.exe # Set WinRM concurrent processes per shell winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="2048"}' winrm set winrm/config/winrs '@{MaxProcessesPerShell="10000"}' winrm set winrm/config/winrs '@{MaxShellsPerUser="100"}' +# Set power scheme to performance +powercfg.exe /setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c + # Restart Windows so that all $env variables are set. Restart-Computer diff --git a/scripts/unit-tests/utils.ps1 b/scripts/unit-tests/utils.ps1 new file mode 100644 index 0000000..01323e2 --- /dev/null +++ b/scripts/unit-tests/utils.ps1 @@ -0,0 +1,260 @@ +function CheckCopyDir($src, $dest) { + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path $dest + Copy-Item -Recurse $src $dest +} + + +function GitClonePull($path, $url, $branch="master") { + Write-Host "Cloning / pulling: $url" + + if (Test-Path -path $path) { + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path $path + } + + # Start git clone + &git clone $url $path + if ($LastExitCode) { + throw "git clone failed" + } + + # Change branch + &git -C $path checkout $branch + if ($LastExitCode) { + throw "git checkout for branch $branch failed" + } +} + + +function Set-GitCommidID ( $commitID ) { + pushd "$gitcloneDir" + &git checkout $commitID + write-host "this is the CommitID that we are working on" + &git rev-parse HEAD + popd +} + +function Set-commitInfo { + write-host "Reading and saving commit author and message." + pushd "$gitcloneDir" + &git log -n 1 $commitID | Out-File "$localLogs\message-$commitID.txt" + Copy-Item "$localLogs\message-$commitID.txt" -Destination "$commitlogDir\commitmessage.txt" -Force + popd +} + +function Set-VCVars($version="12.0", $platform="amd64") { + pushd "$ENV:ProgramFiles (x86)\Microsoft Visual Studio $version\VC\" + try + { + cmd /c "vcvarsall.bat $platform & set" | + foreach { + if ($_ -match "=") { + $v = $_.split("="); set-item -force -path "ENV:\$($v[0])" -value "$($v[1])" + } + } + } + finally + { + popd + } +} + +function ExecRetry ($command, $maxRetryCount = 10, $retryInterval=2) { + $currErrorActionPreference = $ErrorActionPreference + $ErrorActionPreference = "Continue" + + $retryCount = 0 + while ($true) + { + try + { + & $command + break + } + catch [System.Exception] + { + $retryCount++ + if ($retryCount -ge $maxRetryCount) + { + $ErrorActionPreference = $currErrorActionPreference + throw + } + else + { + Write-Error $_.Exception + Start-Sleep $retryInterval + } + } + } + + $ErrorActionPreference = $currErrorActionPreference +} + +function ExecSSHCmd ($server, $user, $key, $cmd) { + write-host "Running ssh command $cmd on remote server $server" + echo Y | plink.exe $server -l $user -i $key $cmd +} + +function ExecSCPCmd ($server, $user, $key, $localPath, $remotePath) { + write-host "Starting copying $localPath to remote location ${server}:${remotePath}" + echo Y | pscp.exe -scp -r -i $key $localPath $user@${server}:${remotePath} +} + +function CheckLocalPaths { + New-Item -ItemType Directory -ErrorAction SilentlyContinue -Path $basePath + New-Item -ItemType Directory -ErrorAction SilentlyContinue -Path $localLogs + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path $commitlogDir + New-Item -ItemType Directory -Force -ErrorAction SilentlyContinue -Path $commitlogDir + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path $commitDir + New-Item -ItemType Directory -Force -ErrorAction SilentlyContinue -Path $commitDir + New-Item -ItemType Directory -Force -ErrorAction SilentlyContinue -Path $outputSymbolsPath + New-Item -ItemType Directory -Force -ErrorAction SilentlyContinue -Path $outputPath + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path $commitmsiDir + New-Item -ItemType Directory -Force -ErrorAction SilentlyContinue -Path $commitmsiDir +} + +function CreateRemotePaths ($remotedirPath) { + $remoteCMD = "mkdir -p $remotedirPath" + ExecSSHCmd $remoteServer $remoteUser $remoteKey $remoteCMD +} + +function Copy-LocalLogs { + $testlogPath = "$commitDir\ovs\tests\testsuite.log" + $testdirPath = "$commitDir\ovs\tests\testsuite.dir" + if ((Test-Path -path $testlogPath)) { + copy-item -Force "$testlogPath" "$commitlogDir\testsuite.log" + } + else { write-host "No testsuite.log found." } + if ((Test-Path -path $testdirPath)) { + copy-item -Force -recurse "$testdirPath" "$commitlogDir\testsuite.dir" + } + else { write-host "No testsuite.dir found." } +} + +function Copy-LocalMsi { + $msiPath = "$commitDir\ovs\windows\ovs-windows-installer\bin\Release\OpenvSwitch.msi" + if ((Test-Path -path $msiPath)) { + copy-item -Force "$msiPath" "$commitmsiDir\OpenvSwitch.msi" + } + else { write-host "No msi found."} +} + +function Copy-RemoteLogs ($locallogPath, $remotelogPath) { + write-host "Started copying logs for commit ID $commitID unit tests to remote location ${server}:${remotelogPath}" + ExecSCPCmd $remoteServer $remoteUser $remoteKey $locallogPath $remotelogPath +} + +function Copy-RemoteMSI ($localmsiPath) { + write-host "Started copying generated msi for commit ID $commitID to remote location ${server}:${remotemsiPath}" + ExecSCPCmd $remoteServer $remoteUser $remoteKey $localmsiPath $remotemsiPath +} + +function CompressLogs ( $logsPath ) { + $logfiles = Get-ChildItem -File -Recurse -Path $logsPath | Where-Object { $_.Extension -ne ".gz" } + foreach ($file in $logfiles) { + $filename = $file.name + $directory = $file.DirectoryName + $extension = $file.extension + if (!$extension) { + $name = $file.name + ".txt" + } + else { + $name = $file.name + } + &7z.exe a -tgzip "$directory\$name.gz" "$directory\$filename" -sdel + } +} + +function Cleanup { + $ovsprocess = Get-Process ovs* -ErrorAction SilentlyContinue + $ovnprocess = Get-Process ovn* -ErrorAction SilentlyContinue + if ($ovsprocess) { + Stop-Process -name ovs* + } + if ($ovnprocess) { + Stop-Process -name ovn* + } + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path $commitDir +} + +function Start-MailJob ($user, $pass, $status) { + $uri = "http://10.20.1.3:8080/job/ovs-email-job/buildWithParameters?token=b204eee759ab38ebb986d223f6c5b4ce&commitid=$commitID&status=$status" + $pair = "${user}:${pass}" + $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair) + $base64 = [System.Convert]::ToBase64String($bytes) + $basicAuthValue = "Basic $base64" + $headers = @{ Authorization = $basicAuthValue } + write-host "Starting the Mail Job for status $status" + Invoke-WebRequest -uri $uri -Headers $headers -UseBasicParsing +} + +function Set-MakeScript { +$makeScript = @" +#!/bin/bash +set -e +set -o pipefail +cd $msysCwd +echo `$INCLUDE +./boot.sh +./configure CC=./build-aux/cccl LD="C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/BIN/x86_amd64/link.exe" LIBS="-lws2_32 -liphlpapi -lwbemuuid -lole32 -loleaut32" --prefix="C:/ProgramData/openvswitch" \ +--localstatedir="C:/ProgramData/openvswitch" --sysconfdir="C:/ProgramData/openvswitch" \ +--with-pthread="$pthreadDir" --with-vstudiotarget="Debug" +make clean 2>&1 | tee makeoutput.log +make -j4 2>&1 | tee -a makeoutput.log +exit `$? +"@ + +$makeScriptPath = Join-Path $pwd "make.sh" +$makeScript.Replace("`r`n","`n") | Set-Content $makeScriptPath -Force +return $makeScriptPath +} + +function Set-UnitScript { +$unitScript = @" +#!/bin/bash +set -e +cd $msysCwd +echo `$INCLUDE +make check TESTSUITEFLAGS="-j3" RECHECK=yes || make check TESTSUITEFLAGS="--recheck" || make check TESTSUITEFLAGS="--recheck" || make check TESTSUITEFLAGS="--recheck" || make check TESTSUITEFLAGS="--recheck" +exit `$? +"@ + +$unitScriptPath = Join-Path $pwd "unit.sh" +$unitScript.Replace("`r`n","`n") | Set-Content $unitScriptPath -Force +return $unitScriptPath +} + +function Set-MsiScript { +$msiScript = @" +#!/bin/bash +set -e +cd $msysCwd +echo `$INCLUDE +make windows_installer +exit `$? +"@ + +$msiScriptPath = Join-Path $pwd "msi.sh" +$msiScript.Replace("`r`n","`n") | Set-Content $msiScriptPath -Force +return $msiScriptPath +} + + +# Email job functions +function Send-Email ($from, $to, $status, $commitLink, $publiclogLink) { + $subject = "[ovs-build] ${status}: openvswitch/ovs (master - $commitID)" + $body = @" +
+Status: $status
+
+
+$commitMessage
+
+
+View the changeset:
+$commitLink
+
+View the full build log and details:
+$publiclogLink
+"@ + Send-MailMessage -from $from -to $to -subject $subject -body $body -BodyAsHtml -smtpServer $smtpServer +} diff --git a/scripts/unit-tests/windows/ovs-build.ps1 b/scripts/unit-tests/windows/ovs-build.ps1 deleted file mode 100644 index 393ab64..0000000 --- a/scripts/unit-tests/windows/ovs-build.ps1 +++ /dev/null @@ -1,408 +0,0 @@ -Param( -) -$ErrorActionPreference = "Stop" - -function CheckRemoveDir($path) { - if (Test-Path $path) { - Remove-Item -Recurse -Force $path - } -} - -function CheckCopyDir($src, $dest) { - CheckRemoveDir $dest - Copy-Item $src $dest -Recurse -} - -function CheckDir($path) { - if (!(Test-Path -path $path)) - { - mkdir $path - } -} - -function GitClonePull($path, $url, $branch="master") { - Write-Host "Cloning / pulling: $url" - - $needspull = $true - - if (!(Test-Path -path $path)) - { - git clone -b $branch $url - if ($LastExitCode) { throw "git clone failed" } - $needspull = $false - } - - if ($needspull) - { - pushd . - try - { - cd $path - - $branchFound = (git branch) -match "(.*\s)?$branch" - if ($LastExitCode) { throw "git branch failed" } - - if($branchFound) - { - git checkout $branch - if ($LastExitCode) { throw "git checkout failed" } - } - else - { - git checkout -b $branch origin/$branch - if ($LastExitCode) { throw "git checkout failed" } - } - - git reset --hard - if ($LastExitCode) { throw "git reset failed" } - - git clean -f -d - if ($LastExitCode) { throw "git clean failed" } - - git pull - if ($LastExitCode) { throw "git pull failed" } - } - finally - { - popd - } - } -} - -function Start-GitClone { - ExecRetry { - # Make sure to have a private key that matches a github deployer key in $ENV:HOME\.ssh\id_rsa - GitClonePull $gitcloneDir "https://github.com/openvswitch/ovs.git" - } -} - -function Change-GitCommidID ( $commitID ) { - git checkout $commitID - write-host "this is the CommitID that we are working on" - git rev-parse HEAD -} - -function Set-commitInfo { - write-host "Reading and saving commit author and message." - pushd "$commitDir/$gitcloneDir" - git log -n 1 $commitID | Out-File "$localLogs\message-$commitID.txt" - Copy-Item "$localLogs\message-$commitID.txt" -Destination "$commitlogDir\commitmessage.txt" -Force - popd -} - -function SetVCVars($version="12.0", $platform="amd64") { - pushd "$ENV:ProgramFiles (x86)\Microsoft Visual Studio $version\VC\" - try - { - cmd /c "vcvarsall.bat $platform & set" | - foreach { - if ($_ -match "=") { - $v = $_.split("="); set-item -force -path "ENV:\$($v[0])" -value "$($v[1])" - } - } - } - finally - { - popd - } -} - -function ExecRetry($command, $maxRetryCount = 10, $retryInterval=2) { - $currErrorActionPreference = $ErrorActionPreference - $ErrorActionPreference = "Continue" - - $retryCount = 0 - while ($true) - { - try - { - & $command - break - } - catch [System.Exception] - { - $retryCount++ - if ($retryCount -ge $maxRetryCount) - { - $ErrorActionPreference = $currErrorActionPreference - throw - } - else - { - Write-Error $_.Exception - Start-Sleep $retryInterval - } - } - } - - $ErrorActionPreference = $currErrorActionPreference -} - -function Start-CheckPath { - CheckDir $basePath - CheckDir $localLogs - CheckRemoveDir $commitlogDir - mkdir -Force $commitlogDir - CheckRemoveDir $commitDir - mkdir -Force $commitDir - CheckRemoveDir $commitmsiDir - mkdir -Force $commitmsiDir - CheckRemoveDir $outputSymbolsPath - mkdir -Force $outputSymbolsPath - mkdir -Force $outputPath -} - -function Start-CopyTestLog { - $testlogPath = "$commitDir\ovs\tests\testsuite.log" - $testdirPath = "$commitDir\ovs\tests\testsuite.dir" - if ((Test-Path -path $testlogPath)) { - copy-item -Force "$testlogPath" "$commitlogDir\testsuite.log" - } - else { write-host "No testsuite.log found." } - if ((Test-Path -path $testdirPath)) { - copy-item -Force -recurse "$testdirPath" "$commitlogDir\testsuite.dir" - } - else { write-host "No testsuite.dir found." } -} - -function Start-CopyMsi { - $msiPath = "$commitDir\ovs\windows\ovs-windows-installer\bin\Release\OpenvSwitch.msi" - if ((Test-Path -path $msiPath)) { - copy -Force "$msiPath" "$commitmsiDir\OpenvSwitch.msi" - } - else { write-host "No msi found."} -} - -function Start-CompressLogs ( $logsPath ) { - $logfiles = Get-ChildItem -File -Recurse -Path $logsPath | Where-Object { $_.Extension -ne ".gz" } - foreach ($file in $logfiles) { - $filename = $file.name - $directory = $file.DirectoryName - $extension = $file.extension - if (!$extension) { - $name = $file.name + ".txt" - } - else { - $name = $file.name - } - &7z.exe a -tgzip "$directory\$name.gz" "$directory\$filename" -sdel - } -} - -function Set-RemoteVars { - Set-Variable -Name server -Value "10.20.1.14" -Scope Script - Set-Variable -Name user -Value "logs" -Scope Script - Set-Variable -Name key -Value "C:\scripts\ssh\norman.ppk" -Scope Script - Set-Variable -Name remotelogDir -Value "/srv/logs/ovs" -Scope Script - Set-Variable -Name remotemsiDir -Value "/srv/dl/ovs" -Scope Script -} - -function Start-SSHCMD ($server, $user, $key, $cmd) { - write-host "Running ssh command $cmd on remote server $server" -# &plink -batch $server -l $user -i $key $cmd - echo Y | plink.exe $server -l $user -i $key $cmd -} - -function Start-SCP ($server, $user, $key, $localPath, $remotePath) { - write-host "Starting copying $localPath to remote location ${server}:${remotePath}" -# &pscp -batch -scp -r -i $key $localPath $user@${server}:${remotePath} - echo Y | pscp.exe -scp -r -i $key $localPath $user@${server}:${remotePath} -} - -function Start-CreateRemoteDir { - Set-RemoteVars - $logCMD = "mkdir -p $remotelogDir/$commitID" - $msiCMD = "mkdir -p $remotemsiDir/$commitID" - Start-SSHCMD $server $user $key $logCMD - Start-SSHCMD $server $user $key $msiCMD -} - -function Start-RemoteLogCopy ($locallogPath) { - Set-RemoteVars - $remotelogPath = "$remotelogDir/$commitID" - write-host "Started copying logs for commit ID $commitID unit tests to remote location ${server}:${remotelogPath}" - Start-SCP $server $user $key $locallogPath $remotelogPath -} - -function Start-RemoteMsiCopy ($localmsiPath) { - Set-RemoteVars - $remotemsiPath = "$remotemsiDir/$commitID" - write-host "Started copying generated msi for commit ID $commitID to remote location ${server}:${remotemsiPath}" - Start-SCP $server $user $key $localmsiPath $remotemsiPath -} - -function Start-Cleanup { - $ovsprocess = Get-Process ovs* -ErrorAction SilentlyContinue - $ovnprocess = Get-Process ovn* -ErrorAction SilentlyContinue - if ($ovsprocess) { - Stop-Process -name ovs* - } - if ($ovnprocess) { - Stop-Process -name ovn* - } - cd $buildDir - CheckRemoveDir $commitDir -} - -function Start-MailJob ($user, $pass, $status) { - $uri = "http://10.20.1.3:8080/job/ovs-email-job/buildWithParameters?token=b204eee759ab38ebb986d223f6c5b4ce&commitid=$commitID&status=$status" - $pair = "${user}:${pass}" - $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair) - $base64 = [System.Convert]::ToBase64String($bytes) - $basicAuthValue = "Basic $base64" - $headers = @{ Authorization = $basicAuthValue } - write-host "Starting the Mail Job for status $status" - Invoke-WebRequest -uri $uri -Headers $headers -UseBasicParsing -} - -function Set-MakeSh { -$makeScript = @" -#!/bin/bash -set -e -cd $msysCwd -echo `$INCLUDE -./boot.sh -./configure CC=./build-aux/cccl LD="C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/BIN/x86_amd64/link.exe" LIBS="-lws2_32 -liphlpapi -lwbemuuid -lole32 -loleaut32" --prefix="C:/ProgramData/openvswitch" \ ---localstatedir="C:/ProgramData/openvswitch" --sysconfdir="C:/ProgramData/openvswitch" \ ---with-pthread="$pthreadDir" --with-vstudiotarget="Debug" -make clean && make -j4 -exit `$? -"@ - -$makeScriptPath = Join-Path $pwd "make.sh" -$makeScript.Replace("`r`n","`n") | Set-Content $makeScriptPath -Force -return $makeScriptPath -} - -function Set-UnitSh { -$unitScript = @" -#!/bin/bash -set -e -cd $msysCwd -echo `$INCLUDE -make check RECHECK=yes || make check TESTSUITEFLAGS="--recheck" || make check TESTSUITEFLAGS="--recheck" || make check TESTSUITEFLAGS="--recheck" || make check TESTSUITEFLAGS="--recheck" -exit `$? -"@ - -$unitScriptPath = Join-Path $pwd "unit.sh" -$unitScript.Replace("`r`n","`n") | Set-Content $unitScriptPath -Force -return $unitScriptPath -} - -function Set-MsiSh { -$msiScript = @" -#!/bin/bash -set -e -cd $msysCwd -echo `$INCLUDE -make windows_installer -exit `$? -"@ - -$msiScriptPath = Join-Path $pwd "msi.sh" -$msiScript.Replace("`r`n","`n") | Set-Content $msiScriptPath -Force -return $msiScriptPath -} - -# Make sure ActivePerl comes before MSYS Perl, otherwise -# the OpenSSL build will fail -$ENV:PATH = "C:\Perl64\bin;$ENV:PATH" -$ENV:PATH += ";${ENV:ProgramFiles}\7-Zip" -$ENV:PATH += ";${ENV:ProgramFiles}\Git\bin" -$ENV:PATH += ";${ENV:ProgramFiles(x86)}\CMake\bin" -$ENV:PATH += ";C:\Python27" -$ENV:PATH += ";C:\Python3" -$ENV:PATH += ";${ENV:ProgramFiles(x86)}\PuTTY" - - -$msysBinDir = "C:\mingw\msys\1.0\bin" -$basePath = "C:\OpenStack\OpenvSwitch" -$buildDir = "$basePath\Build" -$commitID = $env:commitid -$commitDir = "$buildDir\$commitID" -$outputPath = "$commitDir\bin" -$installerDir = "$basePath\installer" -$commitmsiDir = "$installerDir\$commitID" -$localLogs = "$basePath\logs" -$commitlogDir = "$localLogs\$commitID" -$outputSymbolsPath = "$commitDir\symbols" -#automake already appends \lib\ to the pthread library -$winPthreadLibDir = "$basePath\pthread" -#Git clone Dir -$gitcloneDir = "ovs" - -Start-CheckPath -Start-CreateRemoteDir -cd $commitDir -Start-GitClone -cd $gitcloneDir -Change-GitCommidID $commitID -Set-commitInfo - -$vsVersion = "12.0" -$platform = "x86_amd64" -SetVCVars $vsVersion $platform - -$msysCwd = "/" + $pwd.path.Replace("\", "/").Replace(":", "") -$pthreadDir = $winPthreadLibDir.Replace("\", "/") -# This must be the Visual Studio version of link.exe, not MinGW -$vsLink = $(Get-Command link.exe).path -$vsLinkPath = $vsLink.Replace("\", "/").Replace(":", "") - -$ENV:PATH = "$msysBinDir;$ENV:PATH" - -$makeScriptPath = Set-MakeSh -Get-Content $makeScriptPath -write-host "Running make on OVS commit $commitid" -&bash.exe $makeScriptPath | Tee-Object -FilePath "$commitlogDir\makeoutput.log" - if ($LastExitCode) { - Start-CompressLogs "$commitlogDir" - Start-RemoteLogCopy "$commitlogDir\*" - Start-MailJob "$jenk_user" "$jenk_api" "ERROR" - Start-Cleanup - throw "make.sh failed" - } - else { -# Start-RemoteLogCopy "$commitlogDir\makeoutput.log" - write-host "Finished compiling. Moving on..." - } - -$unitScriptPath = Set-UnitSh -Get-Content $unitScriptPath -write-host "Running unit tests!" -&bash.exe $unitScriptPath | Tee-Object -FilePath "$commitlogDir\unitsoutput.log" - if ($LastExitCode) { - Start-CopyTestLog - Start-CompressLogs "$commitlogDir" - Start-RemoteLogCopy "$commitlogDir\*" - Start-MailJob "$jenk_user" "$jenk_api" "UNITFAIL" - Start-Cleanup - throw "Unit tests failed. The logs have been saved." - } - else { - write-host "unit tests succeded. Moving on" - Start-CopyTestLog - Start-CompressLogs "$commitlogDir" - Start-RemoteLogCopy "$commitlogDir\*" - Start-MailJob "$jenk_user" "$jenk_api" "UNITPASS" - } - -$msiScriptPath = Set-MsiSh -Get-Content $msiScriptPath -write-host "Building OVS MSI." -&bash.exe $msiScriptPath | Tee-Object -FilePath "$commitlogDir\msioutput.log" - if ($LastExitCode) { - cd $buildDir - Start-CompressLogs "$commitlogDir" - Start-RemoteLogCopy "$commitlogDir\msioutput.log.gz" - Start-Cleanup - throw "Failed to create OVS msi." - } - else { - write-host "OVS msi created." - Start-CompressLogs "$commitlogDir" - Start-CopyMsi - Start-RemoteLogCopy "$commitlogDir\msioutput.log.gz" - Start-RemoteMsiCopy "$commitDir\ovs\windows\ovs-windows-installer\bin\Release\OpenvSwitch.msi" - Start-Cleanup - } \ No newline at end of file diff --git a/scripts/unit-tests/windows/ovs-email.ps1 b/scripts/unit-tests/windows/ovs-email.ps1 deleted file mode 100644 index d44f8df..0000000 --- a/scripts/unit-tests/windows/ovs-email.ps1 +++ /dev/null @@ -1,87 +0,0 @@ -function Send-PassEmail ($from, $to, $smtpServer, $commitLink, $logLink) { - $subject = "[ovs-build] Passed: openvswitch/ovs (master - $commitID)" - $body = @" -
-Status: Passed
-
-
-$commitMessage
-
-
-View the changeset:
-$commitLink
-
-View the full build log and details:
-$logLink
-"@ - Send-MailMessage -from $from -to $to -subject $subject -body $body -BodyAsHtml -smtpServer $smtpServer -} - -function Send-FailEmail ($from, $to, $smtpServer, $commitLink, $logLink) { - $subject = "[ovs-build] Failed: openvswitch/ovs (master - $commitID)" - $body = @" -
-Status: Failed
-
-
-$commitMessage
-
-
-View the changeset:
-$commitLink
-
-View the full build log and details:
-$logLink
-"@ - Send-MailMessage -from $from -to $to -subject $subject -body $body -BodyAsHtml -smtpServer $smtpServer -} - -function Send-ErrorEmail ($from, $to, $smtpServer, $commitLink, $logLink) { - $subject = "[ovs-make] Error: openvswitch/ovs (master - $commitID)" - $body = @" -
-Status: Error
-
-
-$commitMessage
-
-
-View the changeset:
-$commitLink
-
-View the full build log and details:
-$logLink
-"@ - Send-MailMessage -from $from -to $to -subject $subject -body $body -BodyAsHtml -smtpServer $smtpServer -} - - -$Status = $env:status -$commitID = $env:commitid -$basePath = "C:\OpenStack\OpenvSwitch" -$localLogs = "$basePath\logs" -$commitlogDir = "$localLogs\$commitID" -$commitMessage = Get-Content "$localLogs\message-$commitID.txt" -Raw -$smtpServer = "mail.cloudbasesolutions.com" -$from = "microsoft_ovs_ci@microsoft.com" -$to = "aserdean@cloudbasesolutions.com","ociuhandu@cloudbasesolutions.com","mgheorghe@cloudbasesolutions.com" -$commitLink = "https://github.com/openvswitch/ovs/commit/$commitID" -$logLink = "http://64.119.130.115/ovs/$commitID" -#$msiLink = "http://10.20.1.14:8080/ovs/$commitID" - -if ( $Status -eq "UNITPASS" ) { - write-host "Sending Unit Tests Pass E-mail for $commitID" - Send-PassEmail $from $to $smtpServer $commitLink $logLink -} - -if ( $Status -eq "UNITFAIL" ) { - write-host "Sending Unit Tests Fail E-mail for $commitID" - Send-FailEmail $from $to $smtpServer $commitLink $logLink -} - -if ( $Status -eq "ERROR" ) { - write-host "Sending make error E-mail for $commitID" - Send-PassEmail $from "mgheorghe@cloudbasesolutions.com" $smtpServer $commitLink $logLink -} - -Remove-Item -Path "$localLogs\message-$commitID.txt" -Force \ No newline at end of file