Enabling Windows integration tests
Signed-off-by: Salahuddin Khan <salah@docker.com>
This commit is contained in:
parent
d3cc071bb9
commit
4c8b1fd5a2
|
@ -1,9 +1,19 @@
|
|||
# WARNING WARNING WARNING - DO NOT EDIT THIS FILE IN JENKINS DIRECTLY.
|
||||
# SUBMIT A PR TO https://github.com/jhowardmsft/docker-w2wCIScripts/blob/master/runCI/executeCI.ps1,
|
||||
# AND MAKE SURE https://github.com/jhowardmsft/docker-w2wCIScripts/blob/master/runCI/Invoke-DockerCI.ps1
|
||||
# ISN'T BROKEN!!!!!!! VALIDATE USING A TEST CONTEXT IN JENKINS. THEN COPY/PASTE INTO JENKINS PRODUCTION.
|
||||
#
|
||||
# Jenkins CI scripts for Windows to Windows CI (Powershell Version)
|
||||
# By John Howard (@jhowardmsft) January 2016 - bash version; July 2016 Ported to PowerShell
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$StartTime=Get-Date
|
||||
#$env:DOCKER_DUT_DEBUG="yes" # Comment out to not be in debug mode
|
||||
|
||||
# Put up top to be blindingly obvious. The production jenkins.dockerproject.org Linux-container
|
||||
# CI job is "Docker-PRs-LoW-RS3". Force into LCOW mode for this run, or not.
|
||||
if ($env:BUILD_TAG -match "-LoW") { $env:LCOW_MODE=1 }
|
||||
if ($env:BUILD_TAG -match "-WoW") { $env:LCOW_MODE="" }
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------
|
||||
# When executed, we rely on four variables being set in the environment:
|
||||
|
@ -67,6 +77,12 @@ $StartTime=Get-Date
|
|||
# WINDOWS_BASE_IMAGE if defined, uses that as the base image. Note that the
|
||||
# docker integration tests are also coded to use the same
|
||||
# environment variable, and if no set, defaults to microsoft/windowsservercore
|
||||
#
|
||||
# LCOW_BASIC_MODE if defined, does very basic LCOW verification. Ultimately we
|
||||
# want to run the entire CI suite from docker, but that's a way off.
|
||||
#
|
||||
# LCOW_MODE if defined, runs the entire CI suite
|
||||
#
|
||||
# -------------------------------------------------------------------------------------------
|
||||
#
|
||||
# Jenkins Integration. Add a Windows Powershell build step as follows:
|
||||
|
@ -88,9 +104,11 @@ $StartTime=Get-Date
|
|||
# & $CISCRIPT_LOCAL_LOCATION
|
||||
# -------------------------------------------------------------------------------------------
|
||||
|
||||
$SCRIPT_VER="10-May-2017 12:16 PDT"
|
||||
|
||||
$SCRIPT_VER="28-Aug-2018 09:33 PDT"
|
||||
$FinallyColour="Cyan"
|
||||
|
||||
#$env:DOCKER_DUT_DEBUG="yes" # Comment out to not be in debug mode
|
||||
#$env:SKIP_UNIT_TESTS="yes"
|
||||
#$env:SKIP_VALIDATION_TESTS="yes"
|
||||
#$env:SKIP_ZAP_DUT=""
|
||||
|
@ -104,12 +122,10 @@ $FinallyColour="Cyan"
|
|||
|
||||
Function Nuke-Everything {
|
||||
$ErrorActionPreference = 'SilentlyContinue'
|
||||
if ($env:SKIP_ALL_CLEANUP -ne $null) {
|
||||
Write-Host -ForegroundColor Magenta "WARN: Skipping all cleanup"
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
if ($env:SKIP_ALL_CLEANUP -eq $null) {
|
||||
Write-Host -ForegroundColor green "INFO: Nuke-Everything..."
|
||||
$containerCount = ($(docker ps -aq | Measure-Object -line).Lines)
|
||||
if (-not $LastExitCode -eq 0) {
|
||||
|
@ -133,6 +149,9 @@ Function Nuke-Everything {
|
|||
select-string -NotMatch "nanoserver" | `
|
||||
select-string -NotMatch "docker").ToString().Split(":")[1]
|
||||
}
|
||||
} else {
|
||||
Write-Host -ForegroundColor Magenta "WARN: Skipping cleanup of images and containers"
|
||||
}
|
||||
|
||||
# Kill any spurious daemons. The '-' is IMPORTANT otherwise will kill the control daemon!
|
||||
$pids=$(get-process | where-object {$_.ProcessName -like 'dockerd-*'}).id
|
||||
|
@ -141,6 +160,18 @@ Function Nuke-Everything {
|
|||
Stop-Process -Id $p -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
if ($pidFile -ne $Null) {
|
||||
Write-Host "INFO: Tidying pidfile $pidfile"
|
||||
if (Test-Path $pidFile) {
|
||||
$p=Get-Content $pidFile -raw
|
||||
if ($p -ne $null){
|
||||
Write-Host -ForegroundColor green "INFO: Stopping possible daemon pid $p"
|
||||
taskkill -f -t -pid $p
|
||||
}
|
||||
Remove-Item "$env:TEMP\docker.pid" -force -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
|
||||
Stop-Process -name "cc1" -Force -ErrorAction SilentlyContinue 2>&1 | Out-Null
|
||||
Stop-Process -name "link" -Force -ErrorAction SilentlyContinue 2>&1 | Out-Null
|
||||
Stop-Process -name "compile" -Force -ErrorAction SilentlyContinue 2>&1 | Out-Null
|
||||
|
@ -159,7 +190,7 @@ Function Nuke-Everything {
|
|||
|
||||
# Delete the directory using our dangerous utility unless told not to
|
||||
if (Test-Path "$env:TESTRUN_DRIVE`:\$env:TESTRUN_SUBDIR") {
|
||||
if ($env:SKIP_ZAP_DUT -eq $null) {
|
||||
if (($env:SKIP_ZAP_DUT -ne $null) -or ($env:SKIP_ALL_CLEANUP -eq $null)) {
|
||||
Write-Host -ForegroundColor Green "INFO: Nuking $env:TESTRUN_DRIVE`:\$env:TESTRUN_SUBDIR"
|
||||
docker-ci-zap "-folder=$env:TESTRUN_DRIVE`:\$env:TESTRUN_SUBDIR"
|
||||
} else {
|
||||
|
@ -167,7 +198,7 @@ Function Nuke-Everything {
|
|||
}
|
||||
}
|
||||
|
||||
# RS1 Production Server workaround - Psched
|
||||
# TODO: This should be able to be removed in August 2017 update. Only needed for RS1 Production Server workaround - Psched
|
||||
$reg = "HKLM:\System\CurrentControlSet\Services\Psched\Parameters\NdisAdapters"
|
||||
$count=(Get-ChildItem $reg | Measure-Object).Count
|
||||
if ($count -gt 0) {
|
||||
|
@ -180,7 +211,7 @@ Function Nuke-Everything {
|
|||
}
|
||||
}
|
||||
|
||||
# RS1 Production Server workaround - WFPLWFS
|
||||
# TODO: This should be able to be removed in August 2017 update. Only needed for RS1
|
||||
$reg = "HKLM:\System\CurrentControlSet\Services\WFPLWFS\Parameters\NdisAdapters"
|
||||
$count=(Get-ChildItem $reg | Measure-Object).Count
|
||||
if ($count -gt 0) {
|
||||
|
@ -248,7 +279,6 @@ Try {
|
|||
# SOURCES_DRIVE\SOURCES_SUBDIR must be a directory and exist
|
||||
if (-not (Test-Path -PathType Container "$env:SOURCES_DRIVE`:\$env:SOURCES_SUBDIR")) { Throw "ERROR: $env:SOURCES_DRIVE`:\$env:SOURCES_SUBDIR must be an existing directory" }
|
||||
|
||||
|
||||
# Create the TESTRUN_DRIVE\TESTRUN_SUBDIR if it does not already exist
|
||||
New-Item -ItemType Directory -Force -Path "$env:TESTRUN_DRIVE`:\$env:TESTRUN_SUBDIR" -ErrorAction SilentlyContinue | Out-Null
|
||||
|
||||
|
@ -266,7 +296,7 @@ Try {
|
|||
|
||||
# Make sure we are in repo
|
||||
if (-not (Test-Path -PathType Leaf -Path ".\Dockerfile.windows")) {
|
||||
Throw "$(pwd) does not container Dockerfile.Windows!"
|
||||
Throw "$(pwd) does not contain Dockerfile.windows!"
|
||||
}
|
||||
Write-Host -ForegroundColor Green "INFO: docker/docker repository was found"
|
||||
|
||||
|
@ -349,8 +379,8 @@ Try {
|
|||
Write-Host
|
||||
Write-Host -ForegroundColor Green "---------------------------------------------------------------------------"
|
||||
Write-Host -ForegroundColor Green " Failed to get a response from the control daemon. It may be down."
|
||||
Write-Host -ForegroundColor Green " Try re-running this CI job, or ask on #docker-dev or #docker-maintainers"
|
||||
Write-Host -ForegroundColor Green " to see if the the daemon is running. Also check the nssm configuration."
|
||||
Write-Host -ForegroundColor Green " Try re-running this CI job, or ask on #docker-maintainers on docker slack"
|
||||
Write-Host -ForegroundColor Green " to see if the the daemon is running. Also check the service configuration."
|
||||
Write-Host -ForegroundColor Green " DOCKER_HOST is set to $DOCKER_HOST."
|
||||
Write-Host -ForegroundColor Green "---------------------------------------------------------------------------"
|
||||
Write-Host
|
||||
|
@ -401,8 +431,23 @@ Try {
|
|||
Write-Host -ForegroundColor Green "INFO: Location for testing is $env:TEMP"
|
||||
|
||||
# CI Integrity check - ensure Dockerfile.windows and Dockerfile go versions match
|
||||
$goVersionDockerfileWindows=$(Get-Content ".\Dockerfile.windows" | Select-String "ENV GO_VERSION").ToString().Replace("ENV GO_VERSION=","").Replace("\","").Replace("``","").Trim()
|
||||
$goVersionDockerfile=$(Get-Content ".\Dockerfile" | Select-String "ENV GO_VERSION").ToString().Split(" ")[2]
|
||||
$goVersionDockerfileWindows=$(Get-Content ".\Dockerfile.windows" | Select-String "^ENV GO_VERSION").ToString().Replace("ENV GO_VERSION=","").Replace("\","").Replace("``","").Trim()
|
||||
$goVersionDockerfile=$(Get-Content ".\Dockerfile" | Select-String "^ENV GO_VERSION")
|
||||
|
||||
# As of go 1.11, Dockerfile changed to be in the format like "FROM golang:1.11.0 AS base".
|
||||
# If a version number ends with .0 (as in 1.11.0, a convention used in golang docker
|
||||
# image versions), it needs to be removed (i.e. "1.11.0" becomes "1.11").
|
||||
if ($goVersionDockerfile -eq $Null) {
|
||||
$goVersionDockerfile=$(Get-Content ".\Dockerfile" | Select-String "^FROM golang:")
|
||||
if ($goVersionDockerfile -ne $Null) {
|
||||
$goVersionDockerfile = $goVersionDockerfile.ToString().Split(" ")[1].Split(":")[1] -replace '\.0$',''
|
||||
}
|
||||
} else {
|
||||
$goVersionDockerfile = $goVersionDockerfile.ToString().Split(" ")[2]
|
||||
}
|
||||
if ($goVersionDockerfile -eq $Null) {
|
||||
Throw "ERROR: Failed to extract golang version from Dockerfile"
|
||||
}
|
||||
Write-Host -ForegroundColor Green "INFO: Validating GOLang consistency in Dockerfile.windows..."
|
||||
if (-not ($goVersionDockerfile -eq $goVersionDockerfileWindows)) {
|
||||
Throw "ERROR: Mismatched GO versions between Dockerfile and Dockerfile.windows. Update your PR to ensure that both files are updated and in sync. $goVersionDockerfile $goVersionDockerfileWindows"
|
||||
|
@ -423,7 +468,7 @@ Try {
|
|||
Write-Host -ForegroundColor Magenta "WARN: Skipping building the docker image"
|
||||
}
|
||||
|
||||
# DON'T THINK THIS IS USED ANYMORE.... $v=$(Get-Content ".\VERSION" -raw).ToString().Replace("`n","").Trim()
|
||||
# Following at the moment must be docker\docker as it's dictated by dockerfile.Windows
|
||||
$contPath="$COMMITHASH`:c`:\go\src\github.com\docker\docker\bundles"
|
||||
|
||||
# After https://github.com/docker/docker/pull/30290, .git was added to .dockerignore. Therefore
|
||||
|
@ -446,7 +491,7 @@ Try {
|
|||
git status --porcelain --untracked-files=no | Write-Warning
|
||||
Write-Host ""
|
||||
}
|
||||
$Duration=$(Measure-Command {docker run --name $COMMITHASH -e DOCKER_GITCOMMIT=$COMMITHASH$CommitUnsupported docker hack\make.ps1 -Binary | Out-Host })
|
||||
$Duration=$(Measure-Command {docker run --name $COMMITHASH -e DOCKER_GITCOMMIT=$COMMITHASH$CommitUnsupported docker hack\make.ps1 -Daemon -Client | Out-Host })
|
||||
$ErrorActionPreference = "Stop"
|
||||
if (-not($LastExitCode -eq 0)) {
|
||||
Throw "ERROR: Failed to build binary"
|
||||
|
@ -524,9 +569,12 @@ Try {
|
|||
# Arguments for the daemon under test
|
||||
$dutArgs=@()
|
||||
$dutArgs += "-H $DASHH_DUT"
|
||||
$dutArgs += "--graph $env:TEMP\daemon"
|
||||
$dutArgs += "--data-root $env:TEMP\daemon"
|
||||
$dutArgs += "--pidfile $env:TEMP\docker.pid"
|
||||
|
||||
# Save the PID file so we can nuke it if set
|
||||
$pidFile="$env:TEMP\docker.pid"
|
||||
|
||||
# Arguments: Are we starting the daemon under test in debug mode?
|
||||
if (-not ("$env:DOCKER_DUT_DEBUG" -eq "")) {
|
||||
Write-Host -ForegroundColor Green "INFO: Running the daemon under test in debug mode"
|
||||
|
@ -546,6 +594,11 @@ Try {
|
|||
Write-Host -ForegroundColor Green "INFO: Args: $dutArgs"
|
||||
New-Item -ItemType Directory $env:TEMP\daemon -ErrorAction SilentlyContinue | Out-Null
|
||||
|
||||
# In LCOW mode, for now we need to set an environment variable before starting the daemon under test
|
||||
if (($env:LCOW_MODE -ne $Null) -or ($env:LCOW_BASIC_MODE -ne $Null)) {
|
||||
$env:LCOW_SUPPORTED=1
|
||||
}
|
||||
|
||||
# Cannot fathom why, but always writes to stderr....
|
||||
Start-Process "$env:TEMP\binary\dockerd-$COMMITHASH" `
|
||||
-ArgumentList $dutArgs `
|
||||
|
@ -554,6 +607,12 @@ Try {
|
|||
Write-Host -ForegroundColor Green "INFO: Process started successfully."
|
||||
$daemonStarted=1
|
||||
|
||||
# In LCOW mode, turn off that variable
|
||||
if (($env:LCOW_MODE -ne $Null) -or ($env:LCOW_BASIC_MODE -ne $Null)) {
|
||||
$env:LCOW_SUPPORTED=""
|
||||
}
|
||||
|
||||
|
||||
# Start tailing the daemon under test if the command is installed
|
||||
if ((Get-Command "tail" -ErrorAction SilentlyContinue) -ne $null) {
|
||||
$tail = start-process "tail" -ArgumentList "-f $env:TEMP\dut.out" -ErrorAction SilentlyContinue
|
||||
|
@ -616,6 +675,9 @@ Try {
|
|||
}
|
||||
Write-Host
|
||||
|
||||
# Don't need Windows images when in LCOW mode.
|
||||
if (($env:LCOW_MODE -eq $Null) -and ($env:LCOW_BASIC_MODE -eq $Null)) {
|
||||
|
||||
# Default to windowsservercore for the base image used for the tests. The "docker" image
|
||||
# and the control daemon use microsoft/windowsservercore regardless. This is *JUST* for the tests.
|
||||
if ($env:WINDOWS_BASE_IMAGE -eq $Null) {
|
||||
|
@ -658,11 +720,13 @@ Try {
|
|||
Write-Host -ForegroundColor Green "INFO: Image"$($env:WINDOWS_BASE_IMAGE+":latest")"is already loaded in the daemon under test"
|
||||
}
|
||||
|
||||
|
||||
# Inspect the pulled or loaded image to get the version directly
|
||||
$ErrorActionPreference = "SilentlyContinue"
|
||||
$dutimgVersion = $(&"$env:TEMP\binary\docker-$COMMITHASH" "-H=$($DASHH_CUT)" inspect $($env:WINDOWS_BASE_IMAGE) --format "{{.OsVersion}}")
|
||||
$ErrorActionPreference = "Stop"
|
||||
Write-Host -ForegroundColor Green $("INFO: Version of "+$env:WINDOWS_BASE_IMAGE+":latest is '"+$dutimgVersion+"'")
|
||||
}
|
||||
|
||||
# Run the validation tests unless SKIP_VALIDATION_TESTS is defined.
|
||||
if ($env:SKIP_VALIDATION_TESTS -eq $null) {
|
||||
|
@ -678,7 +742,9 @@ Try {
|
|||
Write-Host -ForegroundColor Magenta "WARN: Skipping validation tests"
|
||||
}
|
||||
|
||||
# Note the unit tests won't work in LCOW mode as I turned off loading the base images above.
|
||||
# Run the unit tests inside a container unless SKIP_UNIT_TESTS is defined
|
||||
if (($env:LCOW_MODE -eq $Null) -and ($env:LCOW_BASIC_MODE -eq $Null)) {
|
||||
if ($env:SKIP_UNIT_TESTS -eq $null) {
|
||||
Write-Host -ForegroundColor Cyan "INFO: Running unit tests at $(Get-Date)..."
|
||||
$ErrorActionPreference = "SilentlyContinue"
|
||||
|
@ -691,8 +757,10 @@ Try {
|
|||
} else {
|
||||
Write-Host -ForegroundColor Magenta "WARN: Skipping unit tests"
|
||||
}
|
||||
}
|
||||
|
||||
# Add the busybox image. Needed for integration tests
|
||||
# Add the Windows busybox image. Needed for WCOW integration tests
|
||||
if (($env:LCOW_MODE -eq $Null) -and ($env:LCOW_BASIC_MODE -eq $Null)) {
|
||||
if ($env:SKIP_INTEGRATION_TESTS -eq $null) {
|
||||
$ErrorActionPreference = "SilentlyContinue"
|
||||
# Build it regardless while switching between nanoserver and windowsservercore
|
||||
|
@ -730,8 +798,10 @@ Try {
|
|||
}
|
||||
Write-Host
|
||||
}
|
||||
}
|
||||
|
||||
# Run the integration tests unless SKIP_INTEGRATION_TESTS is defined
|
||||
# Run the WCOW integration tests unless SKIP_INTEGRATION_TESTS is defined
|
||||
if (($env:LCOW_MODE -eq $Null) -and ($env:LCOW_BASIC_MODE -eq $Null)) {
|
||||
if ($env:SKIP_INTEGRATION_TESTS -eq $null) {
|
||||
Write-Host -ForegroundColor Cyan "INFO: Running integration tests at $(Get-Date)..."
|
||||
$ErrorActionPreference = "SilentlyContinue"
|
||||
|
@ -739,52 +809,6 @@ Try {
|
|||
# Location of the daemon under test.
|
||||
$env:OrigDOCKER_HOST="$env:DOCKER_HOST"
|
||||
|
||||
#https://blogs.technet.microsoft.com/heyscriptingguy/2011/09/20/solve-problems-with-external-command-lines-in-powershell/ is useful to see tokenising
|
||||
$c = "go test "
|
||||
$c += "`"-tags`" " + "`"autogen`" "
|
||||
$c += "./integration/..."
|
||||
|
||||
if ($env:INTEGRATION_IN_CONTAINER -ne $null) {
|
||||
Write-Host -ForegroundColor Green "INFO: Integration tests being run inside a container"
|
||||
# Note we talk back through the containers gateway address
|
||||
# And the ridiculous lengths we have to go to to get the default gateway address... (GetNetIPConfiguration doesn't work in nanoserver)
|
||||
# I just could not get the escaping to work in a single command, so output $c to a file and run that in the container instead...
|
||||
# Not the prettiest, but it works.
|
||||
$c | Out-File -Force "$env:TEMP\binary\runIntegration.ps1"
|
||||
$Duration= $(Measure-Command { & docker run `
|
||||
--rm `
|
||||
-e c=$c `
|
||||
--workdir "c`:\go\src\github.com\docker\docker\" `
|
||||
-v "$env:TEMP\binary`:c:\target" `
|
||||
docker `
|
||||
"`$env`:PATH`='c`:\target;'+`$env:PATH`; `$env:DOCKER_HOST`='tcp`://'+(ipconfig | select -last 1).Substring(39)+'`:2357'; c:\target\runIntegrationCLI.ps1" | Out-Host } )
|
||||
} else {
|
||||
Write-Host -ForegroundColor Green "INFO: Integration tests being run from the host:"
|
||||
#cd "$env:SOURCES_DRIVE`:\$env:SOURCES_SUBDIR\src\github.com\docker\docker\integration"
|
||||
$env:DOCKER_HOST=$DASHH_CUT
|
||||
$env:PATH="$env:TEMP\binary;$env:PATH;" # Force to use the test binaries, not the host ones.
|
||||
Write-Host -ForegroundColor Green "INFO: $c"
|
||||
Write-Host -ForegroundColor Green "INFO: DOCKER_HOST at $DASHH_CUT"
|
||||
# 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)
|
||||
}
|
||||
$ErrorActionPreference = "Stop"
|
||||
if (-not($LastExitCode -eq 0)) {
|
||||
Throw "ERROR: Integration tests failed at $(Get-Date). Duration`:$Duration"
|
||||
}
|
||||
Write-Host -ForegroundColor Green "INFO: Integration tests ended at $(Get-Date). Duration`:$Duration"
|
||||
}else {
|
||||
Write-Host -ForegroundColor Magenta "WARN: Skipping integration tests"
|
||||
}
|
||||
|
||||
# Run the integration tests unless SKIP_INTEGRATION_TESTS is defined
|
||||
if ($env:SKIP_INTEGRATION_TESTS -eq $null) {
|
||||
Write-Host -ForegroundColor Cyan "INFO: Running integration cli tests at $(Get-Date)..."
|
||||
$ErrorActionPreference = "SilentlyContinue"
|
||||
|
||||
# Location of the daemon under test.
|
||||
$env:OrigDOCKER_HOST="$env:DOCKER_HOST"
|
||||
|
||||
#https://blogs.technet.microsoft.com/heyscriptingguy/2011/09/20/solve-problems-with-external-command-lines-in-powershell/ is useful to see tokenising
|
||||
$c = "go test "
|
||||
$c += "`"-check.v`" "
|
||||
|
@ -826,9 +850,75 @@ Try {
|
|||
Throw "ERROR: Integration tests failed at $(Get-Date). Duration`:$Duration"
|
||||
}
|
||||
Write-Host -ForegroundColor Green "INFO: Integration tests ended at $(Get-Date). Duration`:$Duration"
|
||||
}else {
|
||||
} else {
|
||||
Write-Host -ForegroundColor Magenta "WARN: Skipping integration tests"
|
||||
}
|
||||
} else {
|
||||
# The LCOW version of the tests here
|
||||
if ($env:SKIP_INTEGRATION_TESTS -eq $null) {
|
||||
Write-Host -ForegroundColor Cyan "INFO: Running LCOW tests at $(Get-Date)..."
|
||||
|
||||
$ErrorActionPreference = "SilentlyContinue"
|
||||
|
||||
# Location of the daemon under test.
|
||||
$env:OrigDOCKER_HOST="$env:DOCKER_HOST"
|
||||
|
||||
# Make sure we are pointing at the DUT
|
||||
$env:DOCKER_HOST=$DASHH_CUT
|
||||
Write-Host -ForegroundColor Green "INFO: DOCKER_HOST at $DASHH_CUT"
|
||||
|
||||
# Force to use the test binaries, not the host ones.
|
||||
$env:PATH="$env:TEMP\binary;$env:PATH;"
|
||||
|
||||
if ($env:LCOW_BASIC_MODE -ne $null) {
|
||||
$wc = New-Object net.webclient
|
||||
try {
|
||||
Write-Host -ForegroundColor green "INFO: Downloading latest execution script..."
|
||||
$wc.Downloadfile("https://raw.githubusercontent.com/jhowardmsft/docker-w2wCIScripts/master/runCI/lcowbasicvalidation.ps1", "$env:TEMP\binary\lcowbasicvalidation.ps1")
|
||||
}
|
||||
catch [System.Net.WebException]
|
||||
{
|
||||
Throw ("Failed to download: $_")
|
||||
}
|
||||
|
||||
# Explicit to not use measure-command otherwise don't get output as it goes
|
||||
$ErrorActionPreference = "Stop"
|
||||
$start=(Get-Date); Invoke-Expression "powershell $env:TEMP\binary\lcowbasicvalidation.ps1"; $lec=$lastExitCode; $Duration=New-Timespan -Start $start -End (Get-Date)
|
||||
$Duration=New-Timespan -Start $start -End (Get-Date)
|
||||
Write-Host -ForegroundColor Green "INFO: LCOW tests ended at $(Get-Date). Duration`:$Duration"
|
||||
if ($lec -ne 0) {
|
||||
Throw "LCOW validation tests failed"
|
||||
}
|
||||
} else {
|
||||
#https://blogs.technet.microsoft.com/heyscriptingguy/2011/09/20/solve-problems-with-external-command-lines-in-powershell/ is useful to see tokenising
|
||||
$c = "go test "
|
||||
$c += "`"-check.v`" "
|
||||
if ($env:INTEGRATION_TEST_NAME -ne $null) { # Makes is quicker for debugging to be able to run only a subset of the integration tests
|
||||
$c += "`"-check.f`" "
|
||||
$c += "`"$env:INTEGRATION_TEST_NAME`" "
|
||||
Write-Host -ForegroundColor Magenta "WARN: Only running LCOW integration tests matching $env:INTEGRATION_TEST_NAME"
|
||||
}
|
||||
$c += "`"-tags`" " + "`"autogen`" "
|
||||
$c += "`"-check.timeout`" " + "`"10m`" "
|
||||
$c += "`"-test.timeout`" " + "`"200m`" "
|
||||
|
||||
Write-Host -ForegroundColor Green "INFO: LCOW Integration tests being run from the host:"
|
||||
cd "$env:SOURCES_DRIVE`:\$env:SOURCES_SUBDIR\src\github.com\docker\docker\integration-cli"
|
||||
Write-Host -ForegroundColor Green "INFO: $c"
|
||||
Write-Host -ForegroundColor Green "INFO: DOCKER_HOST at $DASHH_CUT"
|
||||
# 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)
|
||||
|
||||
}
|
||||
$ErrorActionPreference = "Stop"
|
||||
if (-not($LastExitCode -eq 0)) {
|
||||
Throw "ERROR: Integration tests failed at $(Get-Date). Duration`:$Duration"
|
||||
}
|
||||
Write-Host -ForegroundColor Green "INFO: Integration tests ended at $(Get-Date). Duration`:$Duration"
|
||||
} else {
|
||||
Write-Host -ForegroundColor Magenta "WARN: Skipping LCOW tests"
|
||||
}
|
||||
}
|
||||
|
||||
# Docker info now to get counts (after or if jjh/containercounts is merged)
|
||||
if ($daemonStarted -eq 1) {
|
||||
|
@ -845,16 +935,14 @@ Try {
|
|||
}
|
||||
|
||||
# Stop the daemon under test
|
||||
if ($daemonStarted -eq 1) {
|
||||
if (Test-Path "$env:TEMP\docker.pid") {
|
||||
$p=Get-Content "$env:TEMP\docker.pid" -raw
|
||||
if ($p -ne $null) {
|
||||
if (($p -ne $null) -and ($daemonStarted -eq 1)) {
|
||||
Write-Host -ForegroundColor green "INFO: Stopping daemon under test"
|
||||
taskkill -f -t -pid $p
|
||||
Remove-Item "$env:TEMP\docker.pid" -force -ErrorAction SilentlyContinue
|
||||
#sleep 5
|
||||
}
|
||||
}
|
||||
Remove-Item "$env:TEMP\docker.pid" -force -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
Write-Host -ForegroundColor Green "INFO: executeCI.ps1 Completed successfully at $(Get-Date)."
|
||||
|
@ -862,6 +950,7 @@ Try {
|
|||
Catch [Exception] {
|
||||
$FinallyColour="Red"
|
||||
Write-Host -ForegroundColor Red ("`r`n`r`nERROR: Failed '$_' at $(Get-Date)")
|
||||
Write-Host -ForegroundColor Red ($_.InvocationInfo.PositionMessage)
|
||||
Write-Host "`n`n"
|
||||
|
||||
# Exit to ensure Jenkins captures it. Don't do this in the ISE or interactive Powershell - they will catch the Throw onwards.
|
||||
|
@ -906,4 +995,3 @@ Finally {
|
|||
$Dur=New-TimeSpan -Start $StartTime -End $(Get-Date)
|
||||
Write-Host -ForegroundColor $FinallyColour "`nINFO: executeCI.ps1 exiting at $(date). Duration $dur`n"
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
|
||||
func TestBuildSquashParent(t *testing.T) {
|
||||
skip.If(t, testEnv.DaemonInfo.OSType == "windows")
|
||||
skip.If(t, !testEnv.DaemonInfo.ExperimentalBuild)
|
||||
skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon")
|
||||
d := daemon.New(t, daemon.WithExperimental)
|
||||
d.StartWithBusybox(t)
|
||||
|
|
|
@ -189,6 +189,7 @@ func TestBuildMultiStageParentConfig(t *testing.T) {
|
|||
// Test cases in #36996
|
||||
func TestBuildLabelWithTargets(t *testing.T) {
|
||||
skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.38"), "test added after 1.38")
|
||||
skip.If(t, testEnv.DaemonInfo.OSType == "windows", "FIXME")
|
||||
bldName := "build-a"
|
||||
testLabels := map[string]string{
|
||||
"foo": "bar",
|
||||
|
@ -443,6 +444,7 @@ RUN [ ! -f foo ]
|
|||
|
||||
// #37581
|
||||
func TestBuildWithHugeFile(t *testing.T) {
|
||||
skip.If(t, testEnv.OSType == "windows")
|
||||
ctx := context.TODO()
|
||||
defer setupTest(t)()
|
||||
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
package container // import "github.com/docker/docker/integration/container"
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/integration/internal/container"
|
||||
"github.com/docker/docker/internal/test/request"
|
||||
"gotest.tools/assert"
|
||||
"gotest.tools/icmd"
|
||||
"gotest.tools/poll"
|
||||
"gotest.tools/skip"
|
||||
)
|
||||
|
||||
// TestStopContainerWithTimeout checks that ContainerStop with
|
||||
// a timeout works as documented, i.e. in case of negative timeout
|
||||
// waiting is not limited (issue #35311).
|
||||
func TestStopContainerWithTimeout(t *testing.T) {
|
||||
defer setupTest(t)()
|
||||
client := request.NewAPIClient(t)
|
||||
ctx := context.Background()
|
||||
|
||||
testCmd := container.WithCmd("sh", "-c", "sleep 2 && exit 42")
|
||||
testData := []struct {
|
||||
doc string
|
||||
timeout int
|
||||
expectedExitCode int
|
||||
}{
|
||||
// In case container is forcefully killed, 137 is returned,
|
||||
// otherwise the exit code from the above script
|
||||
{
|
||||
"zero timeout: expect forceful container kill",
|
||||
0, 137,
|
||||
},
|
||||
{
|
||||
"too small timeout: expect forceful container kill",
|
||||
1, 137,
|
||||
},
|
||||
{
|
||||
"big enough timeout: expect graceful container stop",
|
||||
3, 42,
|
||||
},
|
||||
{
|
||||
"unlimited timeout: expect graceful container stop",
|
||||
-1, 42,
|
||||
},
|
||||
}
|
||||
|
||||
for _, d := range testData {
|
||||
d := d
|
||||
t.Run(strconv.Itoa(d.timeout), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
id := container.Run(t, ctx, client, testCmd)
|
||||
|
||||
timeout := time.Duration(d.timeout) * time.Second
|
||||
err := client.ContainerStop(ctx, id, &timeout)
|
||||
assert.NilError(t, err)
|
||||
|
||||
poll.WaitOn(t, container.IsStopped(ctx, client, id),
|
||||
poll.WithDelay(100*time.Millisecond))
|
||||
|
||||
inspect, err := client.ContainerInspect(ctx, id)
|
||||
assert.NilError(t, err)
|
||||
assert.Equal(t, inspect.State.ExitCode, d.expectedExitCode)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeleteDevicemapper(t *testing.T) {
|
||||
skip.If(t, testEnv.DaemonInfo.Driver != "devicemapper")
|
||||
skip.If(t, testEnv.IsRemoteDaemon, "cannot start daemon on remote test run")
|
||||
|
||||
defer setupTest(t)()
|
||||
client := request.NewAPIClient(t)
|
||||
ctx := context.Background()
|
||||
|
||||
id := container.Run(t, ctx, client, container.WithName("foo-"+t.Name()), container.WithCmd("echo"))
|
||||
|
||||
poll.WaitOn(t, container.IsStopped(ctx, client, id), poll.WithDelay(100*time.Millisecond))
|
||||
|
||||
inspect, err := client.ContainerInspect(ctx, id)
|
||||
assert.NilError(t, err)
|
||||
|
||||
deviceID := inspect.GraphDriver.Data["DeviceId"]
|
||||
|
||||
// Find pool name from device name
|
||||
deviceName := inspect.GraphDriver.Data["DeviceName"]
|
||||
devicePrefix := deviceName[:strings.LastIndex(deviceName, "-")]
|
||||
devicePool := fmt.Sprintf("/dev/mapper/%s-pool", devicePrefix)
|
||||
|
||||
result := icmd.RunCommand("dmsetup", "message", devicePool, "0", fmt.Sprintf("delete %s", deviceID))
|
||||
result.Assert(t, icmd.Success)
|
||||
|
||||
err = client.ContainerRemove(ctx, id, types.ContainerRemoveOptions{})
|
||||
assert.NilError(t, err)
|
||||
}
|
|
@ -2,19 +2,13 @@ package container // import "github.com/docker/docker/integration/container"
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/integration/internal/container"
|
||||
"github.com/docker/docker/internal/test/request"
|
||||
"gotest.tools/assert"
|
||||
"gotest.tools/icmd"
|
||||
"gotest.tools/poll"
|
||||
"gotest.tools/skip"
|
||||
)
|
||||
|
||||
func TestStopContainerWithRestartPolicyAlways(t *testing.T) {
|
||||
|
@ -42,86 +36,3 @@ func TestStopContainerWithRestartPolicyAlways(t *testing.T) {
|
|||
poll.WaitOn(t, container.IsStopped(ctx, client, name), poll.WithDelay(100*time.Millisecond))
|
||||
}
|
||||
}
|
||||
|
||||
// TestStopContainerWithTimeout checks that ContainerStop with
|
||||
// a timeout works as documented, i.e. in case of negative timeout
|
||||
// waiting is not limited (issue #35311).
|
||||
func TestStopContainerWithTimeout(t *testing.T) {
|
||||
defer setupTest(t)()
|
||||
client := request.NewAPIClient(t)
|
||||
ctx := context.Background()
|
||||
|
||||
testCmd := container.WithCmd("sh", "-c", "sleep 2 && exit 42")
|
||||
testData := []struct {
|
||||
doc string
|
||||
timeout int
|
||||
expectedExitCode int
|
||||
}{
|
||||
// In case container is forcefully killed, 137 is returned,
|
||||
// otherwise the exit code from the above script
|
||||
{
|
||||
"zero timeout: expect forceful container kill",
|
||||
0, 137,
|
||||
},
|
||||
{
|
||||
"too small timeout: expect forceful container kill",
|
||||
1, 137,
|
||||
},
|
||||
{
|
||||
"big enough timeout: expect graceful container stop",
|
||||
3, 42,
|
||||
},
|
||||
{
|
||||
"unlimited timeout: expect graceful container stop",
|
||||
-1, 42,
|
||||
},
|
||||
}
|
||||
|
||||
for _, d := range testData {
|
||||
d := d
|
||||
t.Run(strconv.Itoa(d.timeout), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
id := container.Run(t, ctx, client, testCmd)
|
||||
|
||||
timeout := time.Duration(d.timeout) * time.Second
|
||||
err := client.ContainerStop(ctx, id, &timeout)
|
||||
assert.NilError(t, err)
|
||||
|
||||
poll.WaitOn(t, container.IsStopped(ctx, client, id),
|
||||
poll.WithDelay(100*time.Millisecond))
|
||||
|
||||
inspect, err := client.ContainerInspect(ctx, id)
|
||||
assert.NilError(t, err)
|
||||
assert.Equal(t, inspect.State.ExitCode, d.expectedExitCode)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeleteDevicemapper(t *testing.T) {
|
||||
skip.If(t, testEnv.DaemonInfo.Driver != "devicemapper")
|
||||
skip.If(t, testEnv.IsRemoteDaemon, "cannot start daemon on remote test run")
|
||||
|
||||
defer setupTest(t)()
|
||||
client := request.NewAPIClient(t)
|
||||
ctx := context.Background()
|
||||
|
||||
id := container.Run(t, ctx, client, container.WithName("foo-"+t.Name()), container.WithCmd("echo"))
|
||||
|
||||
poll.WaitOn(t, container.IsStopped(ctx, client, id), poll.WithDelay(100*time.Millisecond))
|
||||
|
||||
inspect, err := client.ContainerInspect(ctx, id)
|
||||
assert.NilError(t, err)
|
||||
|
||||
deviceID := inspect.GraphDriver.Data["DeviceId"]
|
||||
|
||||
// Find pool name from device name
|
||||
deviceName := inspect.GraphDriver.Data["DeviceName"]
|
||||
devicePrefix := deviceName[:strings.LastIndex(deviceName, "-")]
|
||||
devicePool := fmt.Sprintf("/dev/mapper/%s-pool", devicePrefix)
|
||||
|
||||
result := icmd.RunCommand("dmsetup", "message", devicePool, "0", fmt.Sprintf("delete %s", deviceID))
|
||||
result.Assert(t, icmd.Success)
|
||||
|
||||
err = client.ContainerRemove(ctx, id, types.ContainerRemoveOptions{})
|
||||
assert.NilError(t, err)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
package container // import "github.com/docker/docker/integration/container"
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/integration/internal/container"
|
||||
"github.com/docker/docker/internal/test/request"
|
||||
"gotest.tools/assert"
|
||||
"gotest.tools/poll"
|
||||
"gotest.tools/skip"
|
||||
)
|
||||
|
||||
// TestStopContainerWithTimeout checks that ContainerStop with
|
||||
// a timeout works as documented, i.e. in case of negative timeout
|
||||
// waiting is not limited (issue #35311).
|
||||
func TestStopContainerWithTimeout(t *testing.T) {
|
||||
skip.If(t, testEnv.OSType == "windows")
|
||||
defer setupTest(t)()
|
||||
client := request.NewAPIClient(t)
|
||||
ctx := context.Background()
|
||||
|
||||
testCmd := container.WithCmd("sh", "-c", "sleep 2 && exit 42")
|
||||
testData := []struct {
|
||||
doc string
|
||||
timeout int
|
||||
expectedExitCode int
|
||||
}{
|
||||
// In case container is forcefully killed, 137 is returned,
|
||||
// otherwise the exit code from the above script
|
||||
{
|
||||
"zero timeout: expect forceful container kill",
|
||||
1, 0x40010004,
|
||||
},
|
||||
{
|
||||
"too small timeout: expect forceful container kill",
|
||||
2, 0x40010004,
|
||||
},
|
||||
{
|
||||
"big enough timeout: expect graceful container stop",
|
||||
120, 42,
|
||||
},
|
||||
{
|
||||
"unlimited timeout: expect graceful container stop",
|
||||
-1, 42,
|
||||
},
|
||||
}
|
||||
|
||||
for _, d := range testData {
|
||||
d := d
|
||||
t.Run(strconv.Itoa(d.timeout), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
id := container.Run(t, ctx, client, testCmd)
|
||||
|
||||
timeout := time.Duration(d.timeout) * time.Second
|
||||
err := client.ContainerStop(ctx, id, &timeout)
|
||||
assert.NilError(t, err)
|
||||
|
||||
poll.WaitOn(t, container.IsStopped(ctx, client, id),
|
||||
poll.WithDelay(100*time.Millisecond))
|
||||
|
||||
inspect, err := client.ContainerInspect(ctx, id)
|
||||
assert.NilError(t, err)
|
||||
assert.Equal(t, inspect.State.ExitCode, d.expectedExitCode)
|
||||
})
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@ import (
|
|||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/internal/test/request"
|
||||
"github.com/docker/docker/internal/testutil"
|
||||
"github.com/gotestyourself/gotestyourself/skip"
|
||||
"gotest.tools/skip"
|
||||
)
|
||||
|
||||
// Ensure we don't regress on CVE-2017-14992.
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/docker/docker/internal/testutil"
|
||||
"gotest.tools/assert"
|
||||
is "gotest.tools/assert/cmp"
|
||||
"gotest.tools/skip"
|
||||
)
|
||||
|
||||
// tagging a named image in a new unprefixed repo should work
|
||||
|
@ -95,6 +96,7 @@ func TestTagExistedNameWithoutForce(t *testing.T) {
|
|||
// ensure tagging using official names works
|
||||
// ensure all tags result in the same name
|
||||
func TestTagOfficialNames(t *testing.T) {
|
||||
skip.If(t, testEnv.OSType == "windows")
|
||||
defer setupTest(t)()
|
||||
client := request.NewAPIClient(t)
|
||||
ctx := context.Background()
|
||||
|
|
|
@ -5,9 +5,6 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/pkg/parsers/kernel"
|
||||
"gotest.tools/icmd"
|
||||
)
|
||||
|
||||
// HasHubConnectivity checks to see if https://hub.docker.com is
|
||||
|
@ -28,26 +25,3 @@ func HasHubConnectivity(t *testing.T) bool {
|
|||
}
|
||||
return err == nil
|
||||
}
|
||||
|
||||
func overlayFSSupported() bool {
|
||||
result := icmd.RunCommand("/bin/sh", "-c", "cat /proc/filesystems")
|
||||
if result.Error != nil {
|
||||
return false
|
||||
}
|
||||
return strings.Contains(result.Combined(), "overlay\n")
|
||||
}
|
||||
|
||||
// Overlay2Supported returns true if the current system supports overlay2 as graphdriver
|
||||
func Overlay2Supported(kernelVersion string) bool {
|
||||
if !overlayFSSupported() {
|
||||
return false
|
||||
}
|
||||
|
||||
daemonV, err := kernel.ParseRelease(kernelVersion)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
requiredV := kernel.VersionInfo{Kernel: 4}
|
||||
return kernel.CompareKernelVersion(*daemonV, requiredV) > -1
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
package requirement // import "github.com/docker/docker/integration/internal/requirement"
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/docker/docker/pkg/parsers/kernel"
|
||||
"gotest.tools/icmd"
|
||||
)
|
||||
|
||||
func overlayFSSupported() bool {
|
||||
result := icmd.RunCommand("/bin/sh", "-c", "cat /proc/filesystems")
|
||||
if result.Error != nil {
|
||||
return false
|
||||
}
|
||||
return strings.Contains(result.Combined(), "overlay\n")
|
||||
}
|
||||
|
||||
// Overlay2Supported returns true if the current system supports overlay2 as graphdriver
|
||||
func Overlay2Supported(kernelVersion string) bool {
|
||||
if !overlayFSSupported() {
|
||||
return false
|
||||
}
|
||||
|
||||
daemonV, err := kernel.ParseRelease(kernelVersion)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
requiredV := kernel.VersionInfo{Kernel: 4}
|
||||
return kernel.CompareKernelVersion(*daemonV, requiredV) > -1
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
// +build windows
|
||||
|
||||
package requirement // import "github.com/docker/docker/integration/internal/requirement"
|
||||
|
||||
func overlayFSSupported() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Overlay2Supported returns true if the current system supports overlay2 as graphdriver
|
||||
func Overlay2Supported(kernelVersion string) bool {
|
||||
return false
|
||||
}
|
|
@ -44,6 +44,7 @@ func createAmbiguousNetworks(t *testing.T) (string, string, string) {
|
|||
return testNet, idPrefixNet, fullIDNet
|
||||
}
|
||||
|
||||
// TestNetworkCreateDelete tests creation and deletion of a network.
|
||||
func TestNetworkCreateDelete(t *testing.T) {
|
||||
skip.If(t, testEnv.DaemonInfo.OSType != "linux")
|
||||
defer setupTest(t)()
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package network
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/client"
|
||||
"gotest.tools/assert/cmp"
|
||||
)
|
||||
|
||||
// IsNetworkAvailable provides a comparison to check if a docker network is available
|
||||
func IsNetworkAvailable(c client.NetworkAPIClient, name string) cmp.Comparison {
|
||||
return func() cmp.Result {
|
||||
networks, err := c.NetworkList(context.Background(), types.NetworkListOptions{})
|
||||
if err != nil {
|
||||
return cmp.ResultFromError(err)
|
||||
}
|
||||
for _, network := range networks {
|
||||
if network.Name == name {
|
||||
return cmp.ResultSuccess
|
||||
}
|
||||
}
|
||||
return cmp.ResultFailure(fmt.Sprintf("could not find network %s", name))
|
||||
}
|
||||
}
|
||||
|
||||
// IsNetworkNotAvailable provides a comparison to check if a docker network is not available
|
||||
func IsNetworkNotAvailable(c client.NetworkAPIClient, name string) cmp.Comparison {
|
||||
return func() cmp.Result {
|
||||
networks, err := c.NetworkList(context.Background(), types.NetworkListOptions{})
|
||||
if err != nil {
|
||||
return cmp.ResultFromError(err)
|
||||
}
|
||||
for _, network := range networks {
|
||||
if network.Name == name {
|
||||
return cmp.ResultFailure(fmt.Sprintf("network %s is still present", name))
|
||||
}
|
||||
}
|
||||
return cmp.ResultSuccess
|
||||
}
|
||||
}
|
||||
|
||||
// IsUserNamespace returns whether the user namespace remapping is enabled
|
||||
func IsUserNamespace() bool {
|
||||
root := os.Getenv("DOCKER_REMAP_ROOT")
|
||||
return root != ""
|
||||
}
|
|
@ -19,7 +19,6 @@ import (
|
|||
|
||||
func TestDockerNetworkMacvlanPersistance(t *testing.T) {
|
||||
// verify the driver automatically provisions the 802.1q link (dm-dummy0.60)
|
||||
skip.If(t, testEnv.DaemonInfo.OSType == "windows")
|
||||
skip.If(t, testEnv.IsRemoteDaemon())
|
||||
skip.If(t, !macvlanKernelSupport(), "Kernel doesn't support macvlan")
|
||||
|
||||
|
@ -44,7 +43,6 @@ func TestDockerNetworkMacvlanPersistance(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDockerNetworkMacvlan(t *testing.T) {
|
||||
skip.If(t, testEnv.DaemonInfo.OSType == "windows")
|
||||
skip.If(t, testEnv.IsRemoteDaemon())
|
||||
skip.If(t, !macvlanKernelSupport(), "Kernel doesn't support macvlan")
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ func delInterface(t *testing.T, ifName string) {
|
|||
}
|
||||
|
||||
func TestDaemonRestartWithLiveRestore(t *testing.T) {
|
||||
skip.If(t, testEnv.OSType == "windows")
|
||||
skip.If(t, testEnv.IsRemoteDaemon())
|
||||
skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.38"), "skip test from new feature")
|
||||
d := daemon.New(t)
|
||||
|
@ -46,6 +47,7 @@ func TestDaemonRestartWithLiveRestore(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDaemonDefaultNetworkPools(t *testing.T) {
|
||||
skip.If(t, testEnv.OSType == "windows")
|
||||
// Remove docker0 bridge and the start daemon defining the predefined address pools
|
||||
skip.If(t, testEnv.IsRemoteDaemon())
|
||||
skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.38"), "skip test from new feature")
|
||||
|
@ -87,6 +89,7 @@ func TestDaemonDefaultNetworkPools(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDaemonRestartWithExistingNetwork(t *testing.T) {
|
||||
skip.If(t, testEnv.OSType == "windows")
|
||||
skip.If(t, testEnv.IsRemoteDaemon())
|
||||
skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.38"), "skip test from new feature")
|
||||
defaultNetworkBridge := "docker0"
|
||||
|
@ -119,6 +122,7 @@ func TestDaemonRestartWithExistingNetwork(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDaemonRestartWithExistingNetworkWithDefaultPoolRange(t *testing.T) {
|
||||
skip.If(t, testEnv.OSType == "windows")
|
||||
skip.If(t, testEnv.IsRemoteDaemon())
|
||||
skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.38"), "skip test from new feature")
|
||||
defaultNetworkBridge := "docker0"
|
||||
|
@ -167,6 +171,7 @@ func TestDaemonRestartWithExistingNetworkWithDefaultPoolRange(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDaemonWithBipAndDefaultNetworkPool(t *testing.T) {
|
||||
skip.If(t, testEnv.OSType == "windows")
|
||||
skip.If(t, testEnv.IsRemoteDaemon())
|
||||
skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.38"), "skip test from new feature")
|
||||
defaultNetworkBridge := "docker0"
|
||||
|
@ -317,6 +322,7 @@ func noServices(client client.ServiceAPIClient) func(log poll.LogT) poll.Result
|
|||
}
|
||||
|
||||
func TestServiceWithDefaultAddressPoolInit(t *testing.T) {
|
||||
skip.If(t, testEnv.OSType == "windows")
|
||||
defer setupTest(t)()
|
||||
var ops = []func(*daemon.Daemon){}
|
||||
ipAddr := []string{"20.20.0.0/16"}
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/docker/docker/internal/test/request"
|
||||
"gotest.tools/assert"
|
||||
is "gotest.tools/assert/cmp"
|
||||
"gotest.tools/skip"
|
||||
)
|
||||
|
||||
func TestInfoAPI(t *testing.T) {
|
||||
|
@ -43,6 +44,7 @@ func TestInfoAPI(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestInfoAPIWarnings(t *testing.T) {
|
||||
skip.If(t, testEnv.DaemonInfo.OSType == "windows", "FIXME")
|
||||
d := daemon.New(t)
|
||||
|
||||
client, err := d.NewClient()
|
||||
|
|
Loading…
Reference in New Issue