Merge pull request #198 from thaJeztah/18.09_backport_test_updates
[18.09 backport] test-fixes and updates, and fix images filter when use multi reference filter
diff --git a/client/client.go b/client/client.go
index 3714dc5..dcdf393 100644
--- a/client/client.go
+++ b/client/client.go
@@ -90,7 +90,7 @@
// If the request is non-GET return `ErrRedirect`. Otherwise use the last response.
//
// Go 1.8 changes behavior for HTTP redirects (specifically 301, 307, and 308) in the client .
-// The Docker client (and by extension docker API client) can be made to to send a request
+// The Docker client (and by extension docker API client) can be made to send a request
// like POST /containers//start where what would normally be in the name section of the URL is empty.
// This triggers an HTTP 301 from the daemon.
// In go 1.8 this 301 will be converted to a GET request, and ends up getting a 404 from the daemon.
diff --git a/hack/ci/windows.ps1 b/hack/ci/windows.ps1
index b0e64d3..c2c937f 100644
--- a/hack/ci/windows.ps1
+++ b/hack/ci/windows.ps1
@@ -105,7 +105,7 @@
# -------------------------------------------------------------------------------------------
-$SCRIPT_VER="28-Aug-2018 09:33 PDT"
+$SCRIPT_VER="05-Feb-2019 09:03 PDT"
$FinallyColour="Cyan"
#$env:DOCKER_DUT_DEBUG="yes" # Comment out to not be in debug mode
@@ -125,7 +125,7 @@
try {
- if ($env:SKIP_ALL_CLEANUP -eq $null) {
+ if ($null -eq $env:SKIP_ALL_CLEANUP) {
Write-Host -ForegroundColor green "INFO: Nuke-Everything..."
$containerCount = ($(docker ps -aq | Measure-Object -line).Lines)
if (-not $LastExitCode -eq 0) {
@@ -136,18 +136,14 @@
if ($(docker ps -aq | Measure-Object -line).Lines -gt 0) {
docker rm -f $(docker ps -aq)
}
- $imageCount=($(docker images --format "{{.Repository}}:{{.ID}}" | `
- select-string -NotMatch "windowsservercore" | `
- select-string -NotMatch "nanoserver" | `
- select-string -NotMatch "docker" | `
- Measure-Object -line).Lines)
+
+ $allImages = $(docker images --format "{{.Repository}}#{{.ID}}")
+ $toRemove = ($allImages | Select-String -NotMatch "windowsservercore","nanoserver","docker")
+ $imageCount = ($toRemove | Measure-Object -line).Lines
+
if ($imageCount -gt 0) {
Write-Host -Foregroundcolor green "INFO: Non-base image count on control daemon to delete is $imageCount"
- docker rmi -f `
- $(docker images --format "{{.Repository}}:{{.ID}}" | `
- select-string -NotMatch "windowsservercore" | `
- select-string -NotMatch "nanoserver" | `
- select-string -NotMatch "docker").ToString().Split(":")[1]
+ docker rmi -f ($toRemove | Foreach-Object { $_.ToString().Split("#")[1] })
}
} else {
Write-Host -ForegroundColor Magenta "WARN: Skipping cleanup of images and containers"
@@ -160,11 +156,11 @@
Stop-Process -Id $p -Force -ErrorAction SilentlyContinue
}
- if ($pidFile -ne $Null) {
+ if ($null -ne $pidFile) {
Write-Host "INFO: Tidying pidfile $pidfile"
if (Test-Path $pidFile) {
$p=Get-Content $pidFile -raw
- if ($p -ne $null){
+ if ($null -ne $p){
Write-Host -ForegroundColor green "INFO: Stopping possible daemon pid $p"
taskkill -f -t -pid $p
}
@@ -190,7 +186,7 @@
# 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 -ne $null) -or ($env:SKIP_ALL_CLEANUP -eq $null)) {
+ if (($null -ne $env:SKIP_ZAP_DUT) -or ($null -eq $env:SKIP_ALL_CLEANUP)) {
Write-Host -ForegroundColor Green "INFO: Nuking $env:TESTRUN_DRIVE`:\$env:TESTRUN_SUBDIR"
docker-ci-zap "-folder=$env:TESTRUN_DRIVE`:\$env:TESTRUN_SUBDIR"
} else {
@@ -256,25 +252,25 @@
Get-ChildItem Env: | Out-String
# PR
- if (-not ($env:PR -eq $Null)) { echo "INFO: PR#$env:PR (https://github.com/docker/docker/pull/$env:PR)" }
+ if (-not ($null -eq $env:PR)) { Write-Output "INFO: PR#$env:PR (https://github.com/docker/docker/pull/$env:PR)" }
# Make sure docker is installed
- if ((Get-Command "docker" -ErrorAction SilentlyContinue) -eq $null) { Throw "ERROR: docker is not installed or not found on path" }
+ if ($null -eq (Get-Command "docker" -ErrorAction SilentlyContinue)) { Throw "ERROR: docker is not installed or not found on path" }
# Make sure docker-ci-zap is installed
- if ((Get-Command "docker-ci-zap" -ErrorAction SilentlyContinue) -eq $null) { Throw "ERROR: docker-ci-zap is not installed or not found on path" }
+ if ($null -eq (Get-Command "docker-ci-zap" -ErrorAction SilentlyContinue)) { Throw "ERROR: docker-ci-zap is not installed or not found on path" }
# Make sure SOURCES_DRIVE is set
- if ($env:SOURCES_DRIVE -eq $Null) { Throw "ERROR: Environment variable SOURCES_DRIVE is not set" }
+ if ($null -eq $env:SOURCES_DRIVE) { Throw "ERROR: Environment variable SOURCES_DRIVE is not set" }
# Make sure TESTRUN_DRIVE is set
- if ($env:TESTRUN_DRIVE -eq $Null) { Throw "ERROR: Environment variable TESTRUN_DRIVE is not set" }
+ if ($null -eq $env:TESTRUN_DRIVE) { Throw "ERROR: Environment variable TESTRUN_DRIVE is not set" }
# Make sure SOURCES_SUBDIR is set
- if ($env:SOURCES_SUBDIR -eq $Null) { Throw "ERROR: Environment variable SOURCES_SUBDIR is not set" }
+ if ($null -eq $env:SOURCES_SUBDIR) { Throw "ERROR: Environment variable SOURCES_SUBDIR is not set" }
# Make sure TESTRUN_SUBDIR is set
- if ($env:TESTRUN_SUBDIR -eq $Null) { Throw "ERROR: Environment variable TESTRUN_SUBDIR is not set" }
+ if ($null -eq $env:TESTRUN_SUBDIR) { Throw "ERROR: Environment variable TESTRUN_SUBDIR is not set" }
# 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" }
@@ -291,12 +287,12 @@
}
# Make sure we start at the root of the sources
- cd "$env:SOURCES_DRIVE`:\$env:SOURCES_SUBDIR\src\github.com\docker\docker"
- Write-Host -ForegroundColor Green "INFO: Running in $(pwd)"
+ Set-Location "$env:SOURCES_DRIVE`:\$env:SOURCES_SUBDIR\src\github.com\docker\docker"
+ Write-Host -ForegroundColor Green "INFO: Running in $(Get-Location)"
# Make sure we are in repo
if (-not (Test-Path -PathType Leaf -Path ".\Dockerfile.windows")) {
- Throw "$(pwd) does not contain Dockerfile.windows!"
+ Throw "$(Get-Location) does not contain Dockerfile.windows!"
}
Write-Host -ForegroundColor Green "INFO: docker/docker repository was found"
@@ -318,28 +314,26 @@
# Try the internal azure CI image version or Microsoft internal corpnet where the base image is already pre-prepared on the disk,
# either through Invoke-DockerCI or, in the case of Azure CI servers, baked into the VHD at the same location.
if (Test-Path $("$env:SOURCES_DRIVE`:\baseimages\"+$ControlDaemonBaseImage+".tar")) {
-
- # An optimization for CI servers to copy it to the D: drive which is an SSD.
- if ($env:SOURCES_DRIVE -ne $env:TESTRUN_DRIVE) {
- $readBaseFrom=$env:TESTRUN_DRIVE
- if (!(Test-Path "$env:TESTRUN_DRIVE`:\baseimages")) {
- New-Item "$env:TESTRUN_DRIVE`:\baseimages" -type directory | Out-Null
- }
- if (!(Test-Path "$env:TESTRUN_DRIVE`:\baseimages\windowsservercore.tar")) {
- if (Test-Path "$env:SOURCES_DRIVE`:\baseimages\windowsservercore.tar") {
- Write-Host -ForegroundColor Green "INFO: Optimisation - copying $env:SOURCES_DRIVE`:\baseimages\windowsservercore.tar to $env:TESTRUN_DRIVE`:\baseimages"
- Copy-Item "$env:SOURCES_DRIVE`:\baseimages\windowsservercore.tar" "$env:TESTRUN_DRIVE`:\baseimages"
- }
- }
- if (!(Test-Path "$env:TESTRUN_DRIVE`:\baseimages\nanoserver.tar")) {
- if (Test-Path "$env:SOURCES_DRIVE`:\baseimages\nanoserver.tar") {
- Write-Host -ForegroundColor Green "INFO: Optimisation - copying $env:SOURCES_DRIVE`:\baseimages\nanoserver.tar to $env:TESTRUN_DRIVE`:\baseimages"
- Copy-Item "$env:SOURCES_DRIVE`:\baseimages\nanoserver.tar" "$env:TESTRUN_DRIVE`:\baseimages"
- }
- }
- $readBaseFrom=$env:TESTRUN_DRIVE
- }
-
+ # An optimization for CI servers to copy it to the D: drive which is an SSD.
+ if ($env:SOURCES_DRIVE -ne $env:TESTRUN_DRIVE) {
+ $readBaseFrom=$env:TESTRUN_DRIVE
+ if (!(Test-Path "$env:TESTRUN_DRIVE`:\baseimages")) {
+ New-Item "$env:TESTRUN_DRIVE`:\baseimages" -type directory | Out-Null
+ }
+ if (!(Test-Path "$env:TESTRUN_DRIVE`:\baseimages\windowsservercore.tar")) {
+ if (Test-Path "$env:SOURCES_DRIVE`:\baseimages\windowsservercore.tar") {
+ Write-Host -ForegroundColor Green "INFO: Optimisation - copying $env:SOURCES_DRIVE`:\baseimages\windowsservercore.tar to $env:TESTRUN_DRIVE`:\baseimages"
+ Copy-Item "$env:SOURCES_DRIVE`:\baseimages\windowsservercore.tar" "$env:TESTRUN_DRIVE`:\baseimages"
+ }
+ }
+ if (!(Test-Path "$env:TESTRUN_DRIVE`:\baseimages\nanoserver.tar")) {
+ if (Test-Path "$env:SOURCES_DRIVE`:\baseimages\nanoserver.tar") {
+ Write-Host -ForegroundColor Green "INFO: Optimisation - copying $env:SOURCES_DRIVE`:\baseimages\nanoserver.tar to $env:TESTRUN_DRIVE`:\baseimages"
+ Copy-Item "$env:SOURCES_DRIVE`:\baseimages\nanoserver.tar" "$env:TESTRUN_DRIVE`:\baseimages"
+ }
+ }
+ $readBaseFrom=$env:TESTRUN_DRIVE
+ }
Write-Host -ForegroundColor Green "INFO: Loading"$ControlDaemonBaseImage".tar from disk. This may take some time..."
$ErrorActionPreference = "SilentlyContinue"
docker load -i $("$readBaseFrom`:\baseimages\"+$ControlDaemonBaseImage+".tar")
@@ -380,7 +374,7 @@
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-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 " to see if 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
@@ -422,7 +416,7 @@
New-Item -ItemType Directory "$env:TEMP\localappdata" -ErrorAction SilentlyContinue | Out-Null
New-Item -ItemType Directory "$env:TEMP\binary" -ErrorAction SilentlyContinue | Out-Null
New-Item -ItemType Directory "$env:TEMP\installer" -ErrorAction SilentlyContinue | Out-Null
- if ($env:SKIP_COPY_GO -eq $null) {
+ if ($null -eq $env:SKIP_COPY_GO) {
# Wipe the previous version of GO - we're going to get it out of the image
if (Test-Path "$env:TEMP\go") { Remove-Item "$env:TEMP\go" -Recurse -Force -ErrorAction SilentlyContinue | Out-Null }
New-Item -ItemType Directory "$env:TEMP\go" -ErrorAction SilentlyContinue | Out-Null
@@ -431,21 +425,21 @@
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")
+ $goVersionDockerfileWindows=$(Get-Content ".\Dockerfile.windows" | Select-String "^ENV GO_VERSION" | Select-object -First 1).ToString().Replace("ENV GO_VERSION=","").Replace("\","").Replace("``","").Trim()
+ $goVersionDockerfile=$(Get-Content ".\Dockerfile" | Select-String "^ENV GO_VERSION" | Select-object -First 1)
# 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) {
+ if ($null -eq $goVersionDockerfile) {
+ $goVersionDockerfile=$(Get-Content ".\Dockerfile" | Select-String "^FROM golang:" | Select-object -First 1)
+ if ($null -ne $goVersionDockerfile) {
$goVersionDockerfile = $goVersionDockerfile.ToString().Split(" ")[1].Split(":")[1] -replace '\.0$',''
}
} else {
$goVersionDockerfile = $goVersionDockerfile.ToString().Split(" ")[2]
}
- if ($goVersionDockerfile -eq $Null) {
+ if ($null -eq $goVersionDockerfile) {
Throw "ERROR: Failed to extract golang version from Dockerfile"
}
Write-Host -ForegroundColor Green "INFO: Validating GOLang consistency in Dockerfile.windows..."
@@ -454,7 +448,7 @@
}
# Build the image
- if ($env:SKIP_IMAGE_BUILD -eq $null) {
+ if ($null -eq $env:SKIP_IMAGE_BUILD) {
Write-Host -ForegroundColor Cyan "`n`nINFO: Building the image from Dockerfile.windows at $(Get-Date)..."
Write-Host
$ErrorActionPreference = "SilentlyContinue"
@@ -480,7 +474,7 @@
}
# Build the binary in a container unless asked to skip it.
- if ($env:SKIP_BINARY_BUILD -eq $null) {
+ if ($null -eq $env:SKIP_BINARY_BUILD) {
Write-Host -ForegroundColor Cyan "`n`nINFO: Building the test binaries at $(Get-Date)..."
$ErrorActionPreference = "SilentlyContinue"
docker rm -f $COMMITHASH 2>&1 | Out-Null
@@ -532,7 +526,7 @@
# Grab the golang installer out of the built image. That way, we know we are consistent once extracted and paths set,
# so there's no need to re-deploy on account of an upgrade to the version of GO being used in docker.
- if ($env:SKIP_COPY_GO -eq $null) {
+ if ($null -eq $env:SKIP_COPY_GO) {
Write-Host -ForegroundColor Green "INFO: Copying the golang package from the container to $env:TEMP\installer\go.zip..."
docker cp "$COMMITHASH`:c`:\go.zip" $env:TEMP\installer\
if (-not($LastExitCode -eq 0)) {
@@ -560,7 +554,7 @@
$env:GOROOT="$env:TEMP\go"
Write-Host -ForegroundColor Green "INFO: $(go version)"
- # Work out the the -H parameter for the daemon under test (DASHH_DUT) and client under test (DASHH_CUT)
+ # Work out the -H parameter for the daemon under test (DASHH_DUT) and client under test (DASHH_CUT)
#$DASHH_DUT="npipe:////./pipe/$COMMITHASH" # Can't do remote named pipe
#$ip = (resolve-dnsname $env:COMPUTERNAME -type A -NoHostsFile -LlmnrNetbiosOnly).IPAddress # Useful to tie down
$DASHH_CUT="tcp://127.0.0.1`:2357" # Not a typo for 2375!
@@ -595,7 +589,7 @@
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)) {
+ if (($null -ne $env:LCOW_MODE) -or ($null -ne $env:LCOW_BASIC_MODE)) {
$env:LCOW_SUPPORTED=1
}
@@ -608,13 +602,13 @@
$daemonStarted=1
# In LCOW mode, turn off that variable
- if (($env:LCOW_MODE -ne $Null) -or ($env:LCOW_BASIC_MODE -ne $Null)) {
+ if (($null -ne $env:LCOW_MODE) -or ($null -ne $env:LCOW_BASIC_MODE)) {
$env:LCOW_SUPPORTED=""
}
# Start tailing the daemon under test if the command is installed
- if ((Get-Command "tail" -ErrorAction SilentlyContinue) -ne $null) {
+ if ($null -ne (Get-Command "tail" -ErrorAction SilentlyContinue)) {
$tail = start-process "tail" -ArgumentList "-f $env:TEMP\dut.out" -ErrorAction SilentlyContinue
}
@@ -631,7 +625,6 @@
$tries--
if ($tries -le 0) {
- $DumpDaemonLog=1
Throw "ERROR: Failed to get a response from the daemon under test"
}
Write-Host -NoNewline "."
@@ -647,7 +640,6 @@
$ErrorActionPreference = "Stop"
if ($LastExitCode -ne 0) {
Throw "ERROR: The daemon under test does not appear to be running."
- $DumpDaemonLog=1
}
Write-Host
@@ -659,7 +651,6 @@
$ErrorActionPreference = "Stop"
if ($LastExitCode -ne 0) {
Throw "ERROR: The daemon under test does not appear to be running."
- $DumpDaemonLog=1
}
Write-Host
@@ -671,16 +662,15 @@
$ErrorActionPreference = "Stop"
if ($LastExitCode -ne 0) {
Throw "ERROR: The daemon under test does not appear to be running."
- $DumpDaemonLog=1
}
Write-Host
# Don't need Windows images when in LCOW mode.
- if (($env:LCOW_MODE -eq $Null) -and ($env:LCOW_BASIC_MODE -eq $Null)) {
+ if (($null -eq $env:LCOW_MODE) -and ($null -eq $env:LCOW_BASIC_MODE)) {
# 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) {
+ if ($null -eq $env:WINDOWS_BASE_IMAGE) {
$env:WINDOWS_BASE_IMAGE="microsoft/windowsservercore"
}
@@ -729,7 +719,7 @@
}
# Run the validation tests unless SKIP_VALIDATION_TESTS is defined.
- if ($env:SKIP_VALIDATION_TESTS -eq $null) {
+ if ($null -eq $env:SKIP_VALIDATION_TESTS) {
Write-Host -ForegroundColor Cyan "INFO: Running validation tests at $(Get-Date)..."
$ErrorActionPreference = "SilentlyContinue"
$Duration=$(Measure-Command { hack\make.ps1 -DCO -GoFormat -PkgImports | Out-Host })
@@ -744,8 +734,8 @@
# 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) {
+ if (($null -eq $env:LCOW_MODE) -and ($null -eq $env:LCOW_BASIC_MODE)) {
+ if ($null -eq $env:SKIP_UNIT_TESTS) {
Write-Host -ForegroundColor Cyan "INFO: Running unit tests at $(Get-Date)..."
$ErrorActionPreference = "SilentlyContinue"
$Duration=$(Measure-Command {docker run -e DOCKER_GITCOMMIT=$COMMITHASH$CommitUnsupported docker hack\make.ps1 -TestUnit | Out-Host })
@@ -760,8 +750,8 @@
}
# 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) {
+ if (($null -eq $env:LCOW_MODE) -and ($null -eq $env:LCOW_BASIC_MODE)) {
+ if ($null -eq $env:SKIP_INTEGRATION_TESTS) {
$ErrorActionPreference = "SilentlyContinue"
# Build it regardless while switching between nanoserver and windowsservercore
#$bbCount = $(& "$env:TEMP\binary\docker-$COMMITHASH" "-H=$($DASHH_CUT)" images | Select-String "busybox" | Measure-Object -line).Lines
@@ -794,15 +784,14 @@
$ErrorActionPreference = "Stop"
if ($LastExitCode -ne 0) {
Throw "ERROR: The daemon under test does not appear to be running."
- $DumpDaemonLog=1
}
Write-Host
}
}
# 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) {
+ if (($null -eq $env:LCOW_MODE) -and ($null -eq $env:LCOW_BASIC_MODE)) {
+ if ($null -eq $env:SKIP_INTEGRATION_TESTS) {
Write-Host -ForegroundColor Cyan "INFO: Running integration tests at $(Get-Date)..."
$ErrorActionPreference = "SilentlyContinue"
@@ -812,7 +801,7 @@
#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
+ 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 += "`"-check.f`" "
$c += "`"$env:INTEGRATION_TEST_NAME`" "
Write-Host -ForegroundColor Magenta "WARN: Only running integration tests matching $env:INTEGRATION_TEST_NAME"
@@ -821,10 +810,10 @@
$c += "`"-check.timeout`" " + "`"10m`" "
$c += "`"-test.timeout`" " + "`"200m`" "
- if ($env:INTEGRATION_IN_CONTAINER -ne $null) {
+ if ($null -ne $env:INTEGRATION_IN_CONTAINER) {
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)
+ # And the ridiculous lengths we have to go 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\runIntegrationCLI.ps1"
@@ -837,7 +826,7 @@
"`$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-cli"
+ Set-Location "$env:SOURCES_DRIVE`:\$env:SOURCES_SUBDIR\src\github.com\docker\docker\integration-cli"
$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"
@@ -855,7 +844,7 @@
}
} else {
# The LCOW version of the tests here
- if ($env:SKIP_INTEGRATION_TESTS -eq $null) {
+ if ($null -eq $env:SKIP_INTEGRATION_TESTS) {
Write-Host -ForegroundColor Cyan "INFO: Running LCOW tests at $(Get-Date)..."
$ErrorActionPreference = "SilentlyContinue"
@@ -870,7 +859,7 @@
# Force to use the test binaries, not the host ones.
$env:PATH="$env:TEMP\binary;$env:PATH;"
- if ($env:LCOW_BASIC_MODE -ne $null) {
+ if ($null -ne $env:LCOW_BASIC_MODE) {
$wc = New-Object net.webclient
try {
Write-Host -ForegroundColor green "INFO: Downloading latest execution script..."
@@ -893,7 +882,7 @@
#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
+ 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 += "`"-check.f`" "
$c += "`"$env:INTEGRATION_TEST_NAME`" "
Write-Host -ForegroundColor Magenta "WARN: Only running LCOW integration tests matching $env:INTEGRATION_TEST_NAME"
@@ -903,7 +892,7 @@
$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"
+ Set-Location "$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
@@ -929,7 +918,6 @@
$ErrorActionPreference = "Stop"
if ($LastExitCode -ne 0) {
Throw "ERROR: The daemon under test does not appear to be running."
- $DumpDaemonLog=1
}
Write-Host
}
@@ -937,7 +925,7 @@
# Stop the daemon under test
if (Test-Path "$env:TEMP\docker.pid") {
$p=Get-Content "$env:TEMP\docker.pid" -raw
- if (($p -ne $null) -and ($daemonStarted -eq 1)) {
+ if (($null -ne $p) -and ($daemonStarted -eq 1)) {
Write-Host -ForegroundColor green "INFO: Stopping daemon under test"
taskkill -f -t -pid $p
#sleep 5
@@ -962,35 +950,35 @@
}
Finally {
$ErrorActionPreference="SilentlyContinue"
- $global:ProgressPreference=$origProgressPreference
+ $global:ProgressPreference=$origProgressPreference
Write-Host -ForegroundColor Green "INFO: Tidying up at end of run"
# Restore the path
- if ($origPath -ne $null) { $env:PATH=$origPath }
+ if ($null -ne $origPath) { $env:PATH=$origPath }
# Restore the DOCKER_HOST
- if ($origDOCKER_HOST -ne $null) { $env:DOCKER_HOST=$origDOCKER_HOST }
+ if ($null -ne $origDOCKER_HOST) { $env:DOCKER_HOST=$origDOCKER_HOST }
# Restore the GOROOT and GOPATH variables
- if ($origGOROOT -ne $null) { $env:GOROOT=$origGOROOT }
- if ($origGOPATH -ne $null) { $env:GOPATH=$origGOPATH }
+ if ($null -ne $origGOROOT) { $env:GOROOT=$origGOROOT }
+ if ($null -ne $origGOPATH) { $env:GOPATH=$origGOPATH }
- # Dump the daemon log if asked to
- if ($daemonStarted -eq 1) {
- if ($dumpDaemonLog -eq 1) {
- Write-Host -ForegroundColor Cyan "----------- DAEMON LOG ------------"
- Get-Content "$env:TEMP\dut.err" -ErrorAction SilentlyContinue | Write-Host -ForegroundColor Cyan
- Write-Host -ForegroundColor Cyan "----------- END DAEMON LOG --------"
- }
+ # Dump the daemon log. This will include any possible panic stack in the .err.
+ if (($daemonStarted -eq 1) -and ($(Get-Item "$env:TEMP\dut.err").Length -gt 0)) {
+ Write-Host -ForegroundColor Cyan "----------- DAEMON LOG ------------"
+ Get-Content "$env:TEMP\dut.err" -ErrorAction SilentlyContinue | Write-Host -ForegroundColor Cyan
+ Write-Host -ForegroundColor Cyan "----------- END DAEMON LOG --------"
}
# Save the daemon under test log
if ($daemonStarted -eq 1) {
- Write-Host -ForegroundColor Green "INFO: Saving daemon under test log ($env:TEMP\dut.err) to $TEMPORIG\CIDUT.log"
- Copy-Item "$env:TEMP\dut.err" "$TEMPORIG\CIDUT.log" -Force -ErrorAction SilentlyContinue
+ Write-Host -ForegroundColor Green "INFO: Saving daemon under test log ($env:TEMP\dut.out) to $TEMPORIG\CIDUT.out"
+ Copy-Item "$env:TEMP\dut.out" "$TEMPORIG\CIDUT.out" -Force -ErrorAction SilentlyContinue
+ Write-Host -ForegroundColor Green "INFO: Saving daemon under test log ($env:TEMP\dut.err) to $TEMPORIG\CIDUT.err"
+ Copy-Item "$env:TEMP\dut.err" "$TEMPORIG\CIDUT.err" -Force -ErrorAction SilentlyContinue
}
- cd "$env:SOURCES_DRIVE\$env:SOURCES_SUBDIR" -ErrorAction SilentlyContinue
+ Set-Location "$env:SOURCES_DRIVE\$env:SOURCES_SUBDIR" -ErrorAction SilentlyContinue
Nuke-Everything
$Dur=New-TimeSpan -Start $StartTime -End $(Get-Date)
Write-Host -ForegroundColor $FinallyColour "`nINFO: executeCI.ps1 exiting at $(date). Duration $dur`n"
diff --git a/hack/make.ps1 b/hack/make.ps1
index f15f8ef..6221e36 100644
--- a/hack/make.ps1
+++ b/hack/make.ps1
@@ -218,7 +218,7 @@
if ($LASTEXITCODE -ne 0) { Throw "Failed git log --format" }
$commits = $($commits -split '\s+' -match '\S')
$badCommits=@()
- $commits | %{
+ $commits | ForEach-Object{
# Skip commits with no content such as merge commits etc
if ($(git log -1 --format=format: --name-status $_).Length -gt 0) {
# Ignore exit code on next call - always process regardless
@@ -244,7 +244,7 @@
# Get a list of go source-code files which have changed under pkg\. Ignore exit code on next call - always process regardless
$files=@(); $files = Invoke-Expression "git diff $upstreamCommit...$headCommit --diff-filter=ACMR --name-only -- `'pkg\*.go`'"
- $badFiles=@(); $files | %{
+ $badFiles=@(); $files | ForEach-Object{
$file=$_
# For the current changed file, get its list of dependencies, sorted and uniqued.
$imports = Invoke-Expression "go list -e -f `'{{ .Deps }}`' $file"
@@ -255,13 +255,13 @@
-NotMatch "^github.com/docker/docker/vendor" `
-Match "^github.com/docker/docker" `
-Replace "`n", ""
- $imports | % { $badFiles+="$file imports $_`n" }
+ $imports | ForEach-Object{ $badFiles+="$file imports $_`n" }
}
if ($badFiles.Length -eq 0) {
Write-Host 'Congratulations! ".\pkg\*.go" is safely isolated from internal code.'
} else {
$e = "`nThese files import internal code: (either directly or indirectly)`n"
- $badFiles | %{ $e+=" - $_"}
+ $badFiles | ForEach-Object{ $e+=" - $_"}
Throw $e
}
}
@@ -297,7 +297,7 @@
Write-Host 'Congratulations! All Go source files are properly formatted.'
} else {
$e = "`nThese files are not properly gofmt`'d:`n"
- $badFiles | %{ $e+=" - $_`n"}
+ $badFiles | ForEach-Object{ $e+=" - $_`n"}
$e+= "`nPlease reformat the above files using `"gofmt -s -w`" and commit the result."
Throw $e
}
diff --git a/hack/make/.go-autogen.ps1 b/hack/make/.go-autogen.ps1
index cd4d87c..8334b11 100644
--- a/hack/make/.go-autogen.ps1
+++ b/hack/make/.go-autogen.ps1
@@ -43,19 +43,19 @@
// Default build-time variable for library-import.
// This file is overridden on build with build-time informations.
const (
- GitCommit string = "'+$CommitString+'"
- Version string = "'+$DockerVersion+'"
- BuildTime string = "'+$buildDateTime+'"
- PlatformName string = "'+$Platform+'"
- ProductName string = "'+$Product+'"
- DefaultProductLicense string = "'+$DefaultProductLicense+'"
+ GitCommit string = "'+$CommitString+'"
+ Version string = "'+$DockerVersion+'"
+ BuildTime string = "'+$buildDateTime+'"
+ PlatformName string = "'+$Platform+'"
+ ProductName string = "'+$Product+'"
+ DefaultProductLicense string = "'+$DefaultProductLicense+'"
)
// AUTOGENERATED FILE; see hack\make\.go-autogen.ps1
'
# Write the file without BOM
- $outputFile="$(pwd)\dockerversion\version_autogen.go"
+ $outputFile="$(Get-Location)\dockerversion\version_autogen.go"
if (Test-Path $outputFile) { Remove-Item $outputFile }
[System.IO.File]::WriteAllText($outputFile, $fileContents, (New-Object System.Text.UTF8Encoding($False)))