mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Windows CI: Make sure that CI fails on any error
- If unit tests fails - If intergration tests fails Signed-off-by: Olli Janatuinen <olli.janatuinen@gmail.com>
This commit is contained in:
parent
1155b6bc7a
commit
82b5ff8026
5 changed files with 34 additions and 43 deletions
|
@ -166,7 +166,7 @@ FROM microsoft/windowsservercore
|
||||||
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||||
|
|
||||||
ARG GO_VERSION=1.13.15
|
ARG GO_VERSION=1.13.15
|
||||||
ARG GOTESTSUM_COMMIT=v0.3.5
|
ARG GOTESTSUM_COMMIT=v0.5.3
|
||||||
|
|
||||||
# Environment variable notes:
|
# Environment variable notes:
|
||||||
# - GO_VERSION must be consistent with 'Dockerfile' used by Linux.
|
# - GO_VERSION must be consistent with 'Dockerfile' used by Linux.
|
||||||
|
|
6
Jenkinsfile
vendored
6
Jenkinsfile
vendored
|
@ -1014,11 +1014,12 @@ pipeline {
|
||||||
junit testResults: 'bundles/junit-report-*.xml', allowEmptyResults: true
|
junit testResults: 'bundles/junit-report-*.xml', allowEmptyResults: true
|
||||||
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
|
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
|
||||||
powershell '''
|
powershell '''
|
||||||
|
cd $env:WORKSPACE
|
||||||
$bundleName="windowsRS1-integration"
|
$bundleName="windowsRS1-integration"
|
||||||
Write-Host -ForegroundColor Green "Creating ${bundleName}-bundles.zip"
|
Write-Host -ForegroundColor Green "Creating ${bundleName}-bundles.zip"
|
||||||
|
|
||||||
# archiveArtifacts does not support env-vars to , so save the artifacts in a fixed location
|
# archiveArtifacts does not support env-vars to , so save the artifacts in a fixed location
|
||||||
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"
|
Compress-Archive -Path "bundles/CIDUT.out", "bundles/CIDUT.err", "bundles/junit-report-*.xml" -CompressionLevel Optimal -DestinationPath "${bundleName}-bundles.zip"
|
||||||
'''
|
'''
|
||||||
|
|
||||||
archiveArtifacts artifacts: '*-bundles.zip', allowEmptyArchive: true
|
archiveArtifacts artifacts: '*-bundles.zip', allowEmptyArchive: true
|
||||||
|
@ -1075,11 +1076,12 @@ pipeline {
|
||||||
junit testResults: 'bundles/junit-report-*.xml', allowEmptyResults: true
|
junit testResults: 'bundles/junit-report-*.xml', allowEmptyResults: true
|
||||||
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
|
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
|
||||||
powershell '''
|
powershell '''
|
||||||
|
cd $env:WORKSPACE
|
||||||
$bundleName="windowsRS5-integration"
|
$bundleName="windowsRS5-integration"
|
||||||
Write-Host -ForegroundColor Green "Creating ${bundleName}-bundles.zip"
|
Write-Host -ForegroundColor Green "Creating ${bundleName}-bundles.zip"
|
||||||
|
|
||||||
# archiveArtifacts does not support env-vars to , so save the artifacts in a fixed location
|
# archiveArtifacts does not support env-vars to , so save the artifacts in a fixed location
|
||||||
Compress-Archive -Path "${env:TEMP}/CIDUT.out", "${env:TEMP}/CIDUT.err", "${env:TEMP}/junit-report-*.xml" -CompressionLevel Optimal -DestinationPath "${bundleName}-bundles.zip"
|
Compress-Archive -Path "bundles/CIDUT.out", "bundles/CIDUT.err", "bundles/junit-report-*.xml" -CompressionLevel Optimal -DestinationPath "${bundleName}-bundles.zip"
|
||||||
'''
|
'''
|
||||||
|
|
||||||
archiveArtifacts artifacts: '*-bundles.zip', allowEmptyArchive: true
|
archiveArtifacts artifacts: '*-bundles.zip', allowEmptyArchive: true
|
||||||
|
|
|
@ -789,26 +789,19 @@ Try {
|
||||||
$TestRunExitCode = $LastExitCode
|
$TestRunExitCode = $LastExitCode
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
# Saving for artifacts......
|
# Saving where jenkins will take a look at.....
|
||||||
|
New-Item -Force -ItemType Directory bundles | Out-Null
|
||||||
$unitTestsContPath="$ContainerNameForUnitTests`:c`:\gopath\src\github.com\docker\docker\bundles"
|
$unitTestsContPath="$ContainerNameForUnitTests`:c`:\gopath\src\github.com\docker\docker\bundles"
|
||||||
$JunitExpectedContFilePath = "$unitTestsContPath\junit-report-unit-tests.xml"
|
$JunitExpectedContFilePath = "$unitTestsContPath\junit-report-unit-tests.xml"
|
||||||
docker cp $JunitExpectedContFilePath "$TEMPORIG"
|
docker cp $JunitExpectedContFilePath "bundles"
|
||||||
if (-not($LastExitCode -eq 0)) {
|
if (-not($LastExitCode -eq 0)) {
|
||||||
Throw "ERROR: Failed to docker cp the unit tests report ($JunitExpectedContFilePath) to $TEMPORIG"
|
Throw "ERROR: Failed to docker cp the unit tests report ($JunitExpectedContFilePath) to bundles"
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Test-Path "$TEMPORIG\junit-report-unit-tests.xml") {
|
if (Test-Path "bundles\junit-report-unit-tests.xml") {
|
||||||
Write-Host -ForegroundColor Magenta "INFO: Unit tests results($TEMPORIG\junit-report-unit-tests.xml) exist. pwd=$pwd"
|
Write-Host -ForegroundColor Magenta "INFO: Unit tests results(bundles\junit-report-unit-tests.xml) exist. pwd=$pwd"
|
||||||
} else {
|
} else {
|
||||||
Write-Host -ForegroundColor Magenta "ERROR: Unit tests results($TEMPORIG\junit-report-unit-tests.xml) do not exist. pwd=$pwd"
|
Write-Host -ForegroundColor Magenta "ERROR: Unit tests results(bundles\junit-report-unit-tests.xml) do not exist. pwd=$pwd"
|
||||||
}
|
|
||||||
|
|
||||||
# Saving where jenkins will take a look at.....
|
|
||||||
$bundlesDir = "bundles"
|
|
||||||
New-Item -Force -ItemType Directory $bundlesDir | Out-Null
|
|
||||||
docker cp $JunitExpectedContFilePath "$bundlesDir"
|
|
||||||
if (-not($LastExitCode -eq 0)) {
|
|
||||||
Throw "ERROR: Failed to docker cp the unit tests report ($JunitExpectedContFilePath) to $bundlesDir"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-not($TestRunExitCode -eq 0)) {
|
if (-not($TestRunExitCode -eq 0)) {
|
||||||
|
@ -855,8 +848,7 @@ Try {
|
||||||
#https://blogs.technet.microsoft.com/heyscriptingguy/2011/09/20/solve-problems-with-external-command-lines-in-powershell/ is useful to see tokenising
|
#https://blogs.technet.microsoft.com/heyscriptingguy/2011/09/20/solve-problems-with-external-command-lines-in-powershell/ is useful to see tokenising
|
||||||
$jsonFilePath = "..\\bundles\\go-test-report-intcli-tests.json"
|
$jsonFilePath = "..\\bundles\\go-test-report-intcli-tests.json"
|
||||||
$xmlFilePath = "..\\bundles\\junit-report-intcli-tests.xml"
|
$xmlFilePath = "..\\bundles\\junit-report-intcli-tests.xml"
|
||||||
$c = "gotestsum --format=standard-quiet --jsonfile=$jsonFilePath --junitfile=$xmlFilePath -- "
|
$c = "gotestsum --format=standard-verbose --jsonfile=$jsonFilePath --junitfile=$xmlFilePath -- "
|
||||||
$c += "`"-test.v`" "
|
|
||||||
if ($null -ne $env:INTEGRATION_TEST_NAME) { # Makes is quicker for debugging to be able to run only a subset of the integration tests
|
if ($null -ne $env:INTEGRATION_TEST_NAME) { # Makes is quicker for debugging to be able to run only a subset of the integration tests
|
||||||
$c += "`"-test.run`" "
|
$c += "`"-test.run`" "
|
||||||
$c += "`"$env:INTEGRATION_TEST_NAME`" "
|
$c += "`"$env:INTEGRATION_TEST_NAME`" "
|
||||||
|
@ -886,14 +878,9 @@ Try {
|
||||||
|
|
||||||
$ErrorActionPreference = "SilentlyContinue"
|
$ErrorActionPreference = "SilentlyContinue"
|
||||||
Write-Host -ForegroundColor Cyan "INFO: Integration API tests being run from the host:"
|
Write-Host -ForegroundColor Cyan "INFO: Integration API tests being run from the host:"
|
||||||
if (!($env:INTEGRATION_TESTFLAGS)) {
|
|
||||||
$env:INTEGRATION_TESTFLAGS = "-test.v"
|
|
||||||
}
|
|
||||||
$start=(Get-Date); Invoke-Expression ".\hack\make.ps1 -TestIntegration"; $Duration=New-Timespan -Start $start -End (Get-Date)
|
$start=(Get-Date); Invoke-Expression ".\hack\make.ps1 -TestIntegration"; $Duration=New-Timespan -Start $start -End (Get-Date)
|
||||||
$IntTestsRunResult = $LastExitCode
|
$IntTestsRunResult = $LastExitCode
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
# Copy all the test results to TEMPORIG for archival
|
|
||||||
Copy-Item -Path "$env:SOURCES_DRIVE`:\$env:SOURCES_SUBDIR\src\github.com\docker\docker\bundles\junit-report*xml" -Destination $TEMPORIG
|
|
||||||
if (-not($IntTestsRunResult -eq 0)) {
|
if (-not($IntTestsRunResult -eq 0)) {
|
||||||
Throw "ERROR: Integration API tests failed at $(Get-Date). Duration`:$Duration"
|
Throw "ERROR: Integration API tests failed at $(Get-Date). Duration`:$Duration"
|
||||||
}
|
}
|
||||||
|
@ -904,7 +891,6 @@ Try {
|
||||||
Set-Location "$env:SOURCES_DRIVE`:\$env:SOURCES_SUBDIR\src\github.com\docker\docker\integration-cli"
|
Set-Location "$env:SOURCES_DRIVE`:\$env:SOURCES_SUBDIR\src\github.com\docker\docker\integration-cli"
|
||||||
# Explicit to not use measure-command otherwise don't get output as it goes
|
# Explicit to not use measure-command otherwise don't get output as it goes
|
||||||
$start=(Get-Date); Invoke-Expression $c; $Duration=New-Timespan -Start $start -End (Get-Date)
|
$start=(Get-Date); Invoke-Expression $c; $Duration=New-Timespan -Start $start -End (Get-Date)
|
||||||
Copy-Item -Path $xmlFilePath -Destination $TEMPORIG
|
|
||||||
}
|
}
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
if (-not($LastExitCode -eq 0)) {
|
if (-not($LastExitCode -eq 0)) {
|
||||||
|
@ -1052,10 +1038,10 @@ Finally {
|
||||||
|
|
||||||
# Save the daemon under test log
|
# Save the daemon under test log
|
||||||
if ($daemonStarted -eq 1) {
|
if ($daemonStarted -eq 1) {
|
||||||
Write-Host -ForegroundColor Green "INFO: Saving daemon under test log ($env:TEMP\dut.out) to $TEMPORIG\CIDUT.out"
|
Write-Host -ForegroundColor Green "INFO: Saving daemon under test log ($env:TEMP\dut.out) to bundles\CIDUT.out"
|
||||||
Copy-Item "$env:TEMP\dut.out" "$TEMPORIG\CIDUT.out" -Force -ErrorAction SilentlyContinue
|
Copy-Item "$env:TEMP\dut.out" "bundles\CIDUT.out" -Force -ErrorAction SilentlyContinue
|
||||||
Write-Host -ForegroundColor Green "INFO: Saving daemon under test log ($env:TEMP\dut.err) to $TEMPORIG\CIDUT.err"
|
Write-Host -ForegroundColor Green "INFO: Saving daemon under test log ($env:TEMP\dut.err) to bundles\CIDUT.err"
|
||||||
Copy-Item "$env:TEMP\dut.err" "$TEMPORIG\CIDUT.err" -Force -ErrorAction SilentlyContinue
|
Copy-Item "$env:TEMP\dut.err" "bundles\CIDUT.err" -Force -ErrorAction SilentlyContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
Set-Location "$env:SOURCES_DRIVE\$env:SOURCES_SUBDIR" -ErrorAction SilentlyContinue
|
Set-Location "$env:SOURCES_DRIVE\$env:SOURCES_SUBDIR" -ErrorAction SilentlyContinue
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
: ${GOTESTSUM_COMMIT:=v0.3.5}
|
: ${GOTESTSUM_COMMIT:=v0.5.3}
|
||||||
|
|
||||||
install_gotestsum() (
|
install_gotestsum() (
|
||||||
set -e
|
set -e
|
||||||
|
|
|
@ -320,10 +320,19 @@ Function Run-UnitTests() {
|
||||||
$pkgList = $pkgList | Select-String -NotMatch "github.com/docker/docker/man"
|
$pkgList = $pkgList | Select-String -NotMatch "github.com/docker/docker/man"
|
||||||
$pkgList = $pkgList | Select-String -NotMatch "github.com/docker/docker/integration"
|
$pkgList = $pkgList | Select-String -NotMatch "github.com/docker/docker/integration"
|
||||||
$pkgList = $pkgList -replace "`r`n", " "
|
$pkgList = $pkgList -replace "`r`n", " "
|
||||||
$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"
|
|
||||||
Write-Host "INFO: Invoking unit tests run with $goTestCommand"
|
$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"
|
||||||
Invoke-Expression $goTestCommand
|
Write-Host "INFO: Invoking unit tests run with $GOTESTSUM_LOCATION\gotestsum.exe $goTestArg"
|
||||||
if ($LASTEXITCODE -ne 0) { Throw "Unit tests failed" }
|
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
|
||||||
|
$pinfo.FileName = "$GOTESTSUM_LOCATION\gotestsum.exe"
|
||||||
|
$pinfo.WorkingDirectory = "$($PWD.Path)"
|
||||||
|
$pinfo.UseShellExecute = $false
|
||||||
|
$pinfo.Arguments = $goTestArg
|
||||||
|
$p = New-Object System.Diagnostics.Process
|
||||||
|
$p.StartInfo = $pinfo
|
||||||
|
$p.Start() | Out-Null
|
||||||
|
$p.WaitForExit()
|
||||||
|
if ($p.ExitCode -ne 0) { Throw "Unit tests failed" }
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run the integration tests
|
# Run the integration tests
|
||||||
|
@ -353,19 +362,13 @@ Function Run-IntegrationTests() {
|
||||||
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
|
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
|
||||||
$pinfo.FileName = "gotestsum.exe"
|
$pinfo.FileName = "gotestsum.exe"
|
||||||
$pinfo.WorkingDirectory = "$($PWD.Path)"
|
$pinfo.WorkingDirectory = "$($PWD.Path)"
|
||||||
$pinfo.RedirectStandardError = $true
|
|
||||||
$pinfo.UseShellExecute = $false
|
$pinfo.UseShellExecute = $false
|
||||||
$pinfo.Arguments = "--format=standard-quiet --jsonfile=$jsonFilePath --junitfile=$xmlFilePath -- $env:INTEGRATION_TESTFLAGS"
|
$pinfo.Arguments = "--format=standard-verbose --jsonfile=$jsonFilePath --junitfile=$xmlFilePath -- $env:INTEGRATION_TESTFLAGS"
|
||||||
$p = New-Object System.Diagnostics.Process
|
$p = New-Object System.Diagnostics.Process
|
||||||
$p.StartInfo = $pinfo
|
$p.StartInfo = $pinfo
|
||||||
$p.Start() | Out-Null
|
$p.Start() | Out-Null
|
||||||
$p.WaitForExit()
|
$p.WaitForExit()
|
||||||
$err = $p.StandardError.ReadToEnd()
|
if ($p.ExitCode -ne 0) { Throw "Integration tests failed" }
|
||||||
if (($LASTEXITCODE -ne 0) -and ($err -notlike "*warning: no tests to run*")) {
|
|
||||||
Throw "Integration tests failed: $err"
|
|
||||||
} else {
|
|
||||||
Write-Host "$err"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -506,7 +509,7 @@ Catch [Exception] {
|
||||||
Write-Host -ForegroundColor Red " \/ \/ \/ \/ "
|
Write-Host -ForegroundColor Red " \/ \/ \/ \/ "
|
||||||
Write-Host
|
Write-Host
|
||||||
|
|
||||||
Throw $_
|
exit 1
|
||||||
}
|
}
|
||||||
Finally {
|
Finally {
|
||||||
Pop-Location # As we pushed to the root of the repo as the very first thing
|
Pop-Location # As we pushed to the root of the repo as the very first thing
|
||||||
|
|
Loading…
Reference in a new issue