- If unit tests fails
- If intergration tests fails
Signed-off-by: Olli Janatuinen <olli.janatuinen@gmail.com>
... | ... |
@@ -166,7 +166,7 @@ FROM microsoft/windowsservercore |
166 | 166 |
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] |
167 | 167 |
|
168 | 168 |
ARG GO_VERSION=1.13.15 |
169 |
-ARG GOTESTSUM_COMMIT=v0.3.5 |
|
169 |
+ARG GOTESTSUM_COMMIT=v0.5.3 |
|
170 | 170 |
|
171 | 171 |
# Environment variable notes: |
172 | 172 |
# - GO_VERSION must be consistent with 'Dockerfile' used by Linux. |
... | ... |
@@ -1014,11 +1014,12 @@ pipeline { |
1014 | 1014 |
junit testResults: 'bundles/junit-report-*.xml', allowEmptyResults: true |
1015 | 1015 |
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') { |
1016 | 1016 |
powershell ''' |
1017 |
+ cd $env:WORKSPACE |
|
1017 | 1018 |
$bundleName="windowsRS1-integration" |
1018 | 1019 |
Write-Host -ForegroundColor Green "Creating ${bundleName}-bundles.zip" |
1019 | 1020 |
|
1020 | 1021 |
# archiveArtifacts does not support env-vars to , so save the artifacts in a fixed location |
1021 |
- Compress-Archive -Path "${env:TEMP}/CIDUT.out", "${env:TEMP}/CIDUT.err", "${env:TEMP}/testresults/unittests/junit-report-unit-tests.xml" -CompressionLevel Optimal -DestinationPath "${bundleName}-bundles.zip" |
|
1022 |
+ Compress-Archive -Path "bundles/CIDUT.out", "bundles/CIDUT.err", "bundles/junit-report-*.xml" -CompressionLevel Optimal -DestinationPath "${bundleName}-bundles.zip" |
|
1022 | 1023 |
''' |
1023 | 1024 |
|
1024 | 1025 |
archiveArtifacts artifacts: '*-bundles.zip', allowEmptyArchive: true |
... | ... |
@@ -1075,11 +1076,12 @@ pipeline { |
1075 | 1075 |
junit testResults: 'bundles/junit-report-*.xml', allowEmptyResults: true |
1076 | 1076 |
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') { |
1077 | 1077 |
powershell ''' |
1078 |
+ cd $env:WORKSPACE |
|
1078 | 1079 |
$bundleName="windowsRS5-integration" |
1079 | 1080 |
Write-Host -ForegroundColor Green "Creating ${bundleName}-bundles.zip" |
1080 | 1081 |
|
1081 | 1082 |
# archiveArtifacts does not support env-vars to , so save the artifacts in a fixed location |
1082 |
- Compress-Archive -Path "${env:TEMP}/CIDUT.out", "${env:TEMP}/CIDUT.err", "${env:TEMP}/junit-report-*.xml" -CompressionLevel Optimal -DestinationPath "${bundleName}-bundles.zip" |
|
1083 |
+ Compress-Archive -Path "bundles/CIDUT.out", "bundles/CIDUT.err", "bundles/junit-report-*.xml" -CompressionLevel Optimal -DestinationPath "${bundleName}-bundles.zip" |
|
1083 | 1084 |
''' |
1084 | 1085 |
|
1085 | 1086 |
archiveArtifacts artifacts: '*-bundles.zip', allowEmptyArchive: true |
... | ... |
@@ -789,26 +789,19 @@ Try { |
789 | 789 |
$TestRunExitCode = $LastExitCode |
790 | 790 |
$ErrorActionPreference = "Stop" |
791 | 791 |
|
792 |
- # Saving for artifacts...... |
|
792 |
+ # Saving where jenkins will take a look at..... |
|
793 |
+ New-Item -Force -ItemType Directory bundles | Out-Null |
|
793 | 794 |
$unitTestsContPath="$ContainerNameForUnitTests`:c`:\gopath\src\github.com\docker\docker\bundles" |
794 | 795 |
$JunitExpectedContFilePath = "$unitTestsContPath\junit-report-unit-tests.xml" |
795 |
- docker cp $JunitExpectedContFilePath "$TEMPORIG" |
|
796 |
+ docker cp $JunitExpectedContFilePath "bundles" |
|
796 | 797 |
if (-not($LastExitCode -eq 0)) { |
797 |
- Throw "ERROR: Failed to docker cp the unit tests report ($JunitExpectedContFilePath) to $TEMPORIG" |
|
798 |
+ Throw "ERROR: Failed to docker cp the unit tests report ($JunitExpectedContFilePath) to bundles" |
|
798 | 799 |
} |
799 | 800 |
|
800 |
- if (Test-Path "$TEMPORIG\junit-report-unit-tests.xml") { |
|
801 |
- Write-Host -ForegroundColor Magenta "INFO: Unit tests results($TEMPORIG\junit-report-unit-tests.xml) exist. pwd=$pwd" |
|
801 |
+ if (Test-Path "bundles\junit-report-unit-tests.xml") { |
|
802 |
+ Write-Host -ForegroundColor Magenta "INFO: Unit tests results(bundles\junit-report-unit-tests.xml) exist. pwd=$pwd" |
|
802 | 803 |
} else { |
803 |
- Write-Host -ForegroundColor Magenta "ERROR: Unit tests results($TEMPORIG\junit-report-unit-tests.xml) do not exist. pwd=$pwd" |
|
804 |
- } |
|
805 |
- |
|
806 |
- # Saving where jenkins will take a look at..... |
|
807 |
- $bundlesDir = "bundles" |
|
808 |
- New-Item -Force -ItemType Directory $bundlesDir | Out-Null |
|
809 |
- docker cp $JunitExpectedContFilePath "$bundlesDir" |
|
810 |
- if (-not($LastExitCode -eq 0)) { |
|
811 |
- Throw "ERROR: Failed to docker cp the unit tests report ($JunitExpectedContFilePath) to $bundlesDir" |
|
804 |
+ Write-Host -ForegroundColor Magenta "ERROR: Unit tests results(bundles\junit-report-unit-tests.xml) do not exist. pwd=$pwd" |
|
812 | 805 |
} |
813 | 806 |
|
814 | 807 |
if (-not($TestRunExitCode -eq 0)) { |
... | ... |
@@ -855,8 +848,7 @@ Try { |
855 | 855 |
#https://blogs.technet.microsoft.com/heyscriptingguy/2011/09/20/solve-problems-with-external-command-lines-in-powershell/ is useful to see tokenising |
856 | 856 |
$jsonFilePath = "..\\bundles\\go-test-report-intcli-tests.json" |
857 | 857 |
$xmlFilePath = "..\\bundles\\junit-report-intcli-tests.xml" |
858 |
- $c = "gotestsum --format=standard-quiet --jsonfile=$jsonFilePath --junitfile=$xmlFilePath -- " |
|
859 |
- $c += "`"-test.v`" " |
|
858 |
+ $c = "gotestsum --format=standard-verbose --jsonfile=$jsonFilePath --junitfile=$xmlFilePath -- " |
|
860 | 859 |
if ($null -ne $env:INTEGRATION_TEST_NAME) { # Makes is quicker for debugging to be able to run only a subset of the integration tests |
861 | 860 |
$c += "`"-test.run`" " |
862 | 861 |
$c += "`"$env:INTEGRATION_TEST_NAME`" " |
... | ... |
@@ -886,14 +878,9 @@ Try { |
886 | 886 |
|
887 | 887 |
$ErrorActionPreference = "SilentlyContinue" |
888 | 888 |
Write-Host -ForegroundColor Cyan "INFO: Integration API tests being run from the host:" |
889 |
- if (!($env:INTEGRATION_TESTFLAGS)) { |
|
890 |
- $env:INTEGRATION_TESTFLAGS = "-test.v" |
|
891 |
- } |
|
892 | 889 |
$start=(Get-Date); Invoke-Expression ".\hack\make.ps1 -TestIntegration"; $Duration=New-Timespan -Start $start -End (Get-Date) |
893 | 890 |
$IntTestsRunResult = $LastExitCode |
894 | 891 |
$ErrorActionPreference = "Stop" |
895 |
- # Copy all the test results to TEMPORIG for archival |
|
896 |
- Copy-Item -Path "$env:SOURCES_DRIVE`:\$env:SOURCES_SUBDIR\src\github.com\docker\docker\bundles\junit-report*xml" -Destination $TEMPORIG |
|
897 | 892 |
if (-not($IntTestsRunResult -eq 0)) { |
898 | 893 |
Throw "ERROR: Integration API tests failed at $(Get-Date). Duration`:$Duration" |
899 | 894 |
} |
... | ... |
@@ -904,7 +891,6 @@ Try { |
904 | 904 |
Set-Location "$env:SOURCES_DRIVE`:\$env:SOURCES_SUBDIR\src\github.com\docker\docker\integration-cli" |
905 | 905 |
# Explicit to not use measure-command otherwise don't get output as it goes |
906 | 906 |
$start=(Get-Date); Invoke-Expression $c; $Duration=New-Timespan -Start $start -End (Get-Date) |
907 |
- Copy-Item -Path $xmlFilePath -Destination $TEMPORIG |
|
908 | 907 |
} |
909 | 908 |
$ErrorActionPreference = "Stop" |
910 | 909 |
if (-not($LastExitCode -eq 0)) { |
... | ... |
@@ -1052,10 +1038,10 @@ Finally { |
1052 | 1052 |
|
1053 | 1053 |
# Save the daemon under test log |
1054 | 1054 |
if ($daemonStarted -eq 1) { |
1055 |
- Write-Host -ForegroundColor Green "INFO: Saving daemon under test log ($env:TEMP\dut.out) to $TEMPORIG\CIDUT.out" |
|
1056 |
- Copy-Item "$env:TEMP\dut.out" "$TEMPORIG\CIDUT.out" -Force -ErrorAction SilentlyContinue |
|
1057 |
- Write-Host -ForegroundColor Green "INFO: Saving daemon under test log ($env:TEMP\dut.err) to $TEMPORIG\CIDUT.err" |
|
1058 |
- Copy-Item "$env:TEMP\dut.err" "$TEMPORIG\CIDUT.err" -Force -ErrorAction SilentlyContinue |
|
1055 |
+ Write-Host -ForegroundColor Green "INFO: Saving daemon under test log ($env:TEMP\dut.out) to bundles\CIDUT.out" |
|
1056 |
+ Copy-Item "$env:TEMP\dut.out" "bundles\CIDUT.out" -Force -ErrorAction SilentlyContinue |
|
1057 |
+ Write-Host -ForegroundColor Green "INFO: Saving daemon under test log ($env:TEMP\dut.err) to bundles\CIDUT.err" |
|
1058 |
+ Copy-Item "$env:TEMP\dut.err" "bundles\CIDUT.err" -Force -ErrorAction SilentlyContinue |
|
1059 | 1059 |
} |
1060 | 1060 |
|
1061 | 1061 |
Set-Location "$env:SOURCES_DRIVE\$env:SOURCES_SUBDIR" -ErrorAction SilentlyContinue |
... | ... |
@@ -320,10 +320,19 @@ Function Run-UnitTests() { |
320 | 320 |
$pkgList = $pkgList | Select-String -NotMatch "github.com/docker/docker/man" |
321 | 321 |
$pkgList = $pkgList | Select-String -NotMatch "github.com/docker/docker/integration" |
322 | 322 |
$pkgList = $pkgList -replace "`r`n", " " |
323 |
- $goTestCommand = "$GOTESTSUM_LOCATION\gotestsum.exe --format=standard-quiet --jsonfile=bundles\go-test-report-unit-tests.json --junitfile=bundles\junit-report-unit-tests.xml -- " + $raceParm + " -cover -ldflags -w -a """ + "-test.timeout=10m" + """ $pkgList" |
|
324 |
- Write-Host "INFO: Invoking unit tests run with $goTestCommand" |
|
325 |
- Invoke-Expression $goTestCommand |
|
326 |
- if ($LASTEXITCODE -ne 0) { Throw "Unit tests failed" } |
|
323 |
+ |
|
324 |
+ $goTestArg = "--format=standard-verbose --jsonfile=bundles\go-test-report-unit-tests.json --junitfile=bundles\junit-report-unit-tests.xml -- " + $raceParm + " -cover -ldflags -w -a """ + "-test.timeout=10m" + """ $pkgList" |
|
325 |
+ Write-Host "INFO: Invoking unit tests run with $GOTESTSUM_LOCATION\gotestsum.exe $goTestArg" |
|
326 |
+ $pinfo = New-Object System.Diagnostics.ProcessStartInfo |
|
327 |
+ $pinfo.FileName = "$GOTESTSUM_LOCATION\gotestsum.exe" |
|
328 |
+ $pinfo.WorkingDirectory = "$($PWD.Path)" |
|
329 |
+ $pinfo.UseShellExecute = $false |
|
330 |
+ $pinfo.Arguments = $goTestArg |
|
331 |
+ $p = New-Object System.Diagnostics.Process |
|
332 |
+ $p.StartInfo = $pinfo |
|
333 |
+ $p.Start() | Out-Null |
|
334 |
+ $p.WaitForExit() |
|
335 |
+ if ($p.ExitCode -ne 0) { Throw "Unit tests failed" } |
|
327 | 336 |
} |
328 | 337 |
|
329 | 338 |
# Run the integration tests |
... | ... |
@@ -353,19 +362,13 @@ Function Run-IntegrationTests() { |
353 | 353 |
$pinfo = New-Object System.Diagnostics.ProcessStartInfo |
354 | 354 |
$pinfo.FileName = "gotestsum.exe" |
355 | 355 |
$pinfo.WorkingDirectory = "$($PWD.Path)" |
356 |
- $pinfo.RedirectStandardError = $true |
|
357 | 356 |
$pinfo.UseShellExecute = $false |
358 |
- $pinfo.Arguments = "--format=standard-quiet --jsonfile=$jsonFilePath --junitfile=$xmlFilePath -- $env:INTEGRATION_TESTFLAGS" |
|
357 |
+ $pinfo.Arguments = "--format=standard-verbose --jsonfile=$jsonFilePath --junitfile=$xmlFilePath -- $env:INTEGRATION_TESTFLAGS" |
|
359 | 358 |
$p = New-Object System.Diagnostics.Process |
360 | 359 |
$p.StartInfo = $pinfo |
361 | 360 |
$p.Start() | Out-Null |
362 | 361 |
$p.WaitForExit() |
363 |
- $err = $p.StandardError.ReadToEnd() |
|
364 |
- if (($LASTEXITCODE -ne 0) -and ($err -notlike "*warning: no tests to run*")) { |
|
365 |
- Throw "Integration tests failed: $err" |
|
366 |
- } else { |
|
367 |
- Write-Host "$err" |
|
368 |
- } |
|
362 |
+ if ($p.ExitCode -ne 0) { Throw "Integration tests failed" } |
|
369 | 363 |
} |
370 | 364 |
} |
371 | 365 |
|
... | ... |
@@ -506,7 +509,7 @@ Catch [Exception] { |
506 | 506 |
Write-Host -ForegroundColor Red " \/ \/ \/ \/ " |
507 | 507 |
Write-Host |
508 | 508 |
|
509 |
- Throw $_ |
|
509 |
+ exit 1 |
|
510 | 510 |
} |
511 | 511 |
Finally { |
512 | 512 |
Pop-Location # As we pushed to the root of the repo as the very first thing |