Signed-off-by: Olli Janatuinen <olli.janatuinen@gmail.com>
(cherry picked from commit 2f22247cad9237d255a4b541a974705802abdad8)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -119,6 +119,7 @@ $FinallyColour="Cyan" |
| 119 | 119 |
#$env:INTEGRATION_IN_CONTAINER="yes" |
| 120 | 120 |
#$env:WINDOWS_BASE_IMAGE="" |
| 121 | 121 |
#$env:SKIP_COPY_GO="yes" |
| 122 |
+#$env:INTEGRATION_TESTFLAGS="-test.v" |
|
| 122 | 123 |
|
| 123 | 124 |
Function Nuke-Everything {
|
| 124 | 125 |
$ErrorActionPreference = 'SilentlyContinue' |
| ... | ... |
@@ -825,18 +826,32 @@ Try {
|
| 825 | 825 |
docker ` |
| 826 | 826 |
"`$env`:PATH`='c`:\target;'+`$env:PATH`; `$env:DOCKER_HOST`='tcp`://'+(ipconfig | select -last 1).Substring(39)+'`:2357'; c:\target\runIntegrationCLI.ps1" | Out-Host } ) |
| 827 | 827 |
} else {
|
| 828 |
- Write-Host -ForegroundColor Green "INFO: Integration tests being run from the host:" |
|
| 829 |
- Set-Location "$env:SOURCES_DRIVE`:\$env:SOURCES_SUBDIR\src\github.com\docker\docker\integration-cli" |
|
| 830 | 828 |
$env:DOCKER_HOST=$DASHH_CUT |
| 831 | 829 |
$env:PATH="$env:TEMP\binary;$env:PATH;" # Force to use the test binaries, not the host ones. |
| 832 |
- Write-Host -ForegroundColor Green "INFO: $c" |
|
| 833 | 830 |
Write-Host -ForegroundColor Green "INFO: DOCKER_HOST at $DASHH_CUT" |
| 831 |
+ |
|
| 832 |
+ $ErrorActionPreference = "SilentlyContinue" |
|
| 833 |
+ Write-Host -ForegroundColor Cyan "INFO: Integration API tests being run from the host:" |
|
| 834 |
+ if (!($env:INTEGRATION_TESTFLAGS)) {
|
|
| 835 |
+ $env:INTEGRATION_TESTFLAGS = "-test.v" |
|
| 836 |
+ } |
|
| 837 |
+ Set-Location "$env:SOURCES_DRIVE`:\$env:SOURCES_SUBDIR\src\github.com\docker\docker" |
|
| 838 |
+ $start=(Get-Date); Invoke-Expression ".\hack\make.ps1 -TestIntegration"; $Duration=New-Timespan -Start $start -End (Get-Date) |
|
| 839 |
+ $ErrorActionPreference = "Stop" |
|
| 840 |
+ if (-not($LastExitCode -eq 0)) {
|
|
| 841 |
+ Throw "ERROR: Integration API tests failed at $(Get-Date). Duration`:$Duration" |
|
| 842 |
+ } |
|
| 843 |
+ |
|
| 844 |
+ $ErrorActionPreference = "SilentlyContinue" |
|
| 845 |
+ Write-Host -ForegroundColor Green "INFO: Integration CLI tests being run from the host:" |
|
| 846 |
+ Write-Host -ForegroundColor Green "INFO: $c" |
|
| 847 |
+ Set-Location "$env:SOURCES_DRIVE`:\$env:SOURCES_SUBDIR\src\github.com\docker\docker\integration-cli" |
|
| 834 | 848 |
# Explicit to not use measure-command otherwise don't get output as it goes |
| 835 | 849 |
$start=(Get-Date); Invoke-Expression $c; $Duration=New-Timespan -Start $start -End (Get-Date) |
| 836 | 850 |
} |
| 837 | 851 |
$ErrorActionPreference = "Stop" |
| 838 | 852 |
if (-not($LastExitCode -eq 0)) {
|
| 839 |
- Throw "ERROR: Integration tests failed at $(Get-Date). Duration`:$Duration" |
|
| 853 |
+ Throw "ERROR: Integration CLI tests failed at $(Get-Date). Duration`:$Duration" |
|
| 840 | 854 |
} |
| 841 | 855 |
Write-Host -ForegroundColor Green "INFO: Integration tests ended at $(Get-Date). Duration`:$Duration" |
| 842 | 856 |
} else {
|
| ... | ... |
@@ -60,6 +60,9 @@ |
| 60 | 60 |
.PARAMETER TestUnit |
| 61 | 61 |
Runs unit tests. |
| 62 | 62 |
|
| 63 |
+.PARAMETER TestIntegration |
|
| 64 |
+ Runs integration tests. |
|
| 65 |
+ |
|
| 63 | 66 |
.PARAMETER All |
| 64 | 67 |
Runs everything this script knows about that can run in a container. |
| 65 | 68 |
|
| ... | ... |
@@ -84,6 +87,7 @@ param( |
| 84 | 84 |
[Parameter(Mandatory=$False)][switch]$PkgImports, |
| 85 | 85 |
[Parameter(Mandatory=$False)][switch]$GoFormat, |
| 86 | 86 |
[Parameter(Mandatory=$False)][switch]$TestUnit, |
| 87 |
+ [Parameter(Mandatory=$False)][switch]$TestIntegration, |
|
| 87 | 88 |
[Parameter(Mandatory=$False)][switch]$All |
| 88 | 89 |
) |
| 89 | 90 |
|
| ... | ... |
@@ -320,6 +324,39 @@ Function Run-UnitTests() {
|
| 320 | 320 |
if ($LASTEXITCODE -ne 0) { Throw "Unit tests failed" }
|
| 321 | 321 |
} |
| 322 | 322 |
|
| 323 |
+# Run the integration tests |
|
| 324 |
+Function Run-IntegrationTests() {
|
|
| 325 |
+ $env:DOCKER_INTEGRATION_DAEMON_DEST = $root + "\bundles\tmp" |
|
| 326 |
+ $dirs = Get-ChildItem -Path integration -Directory -Recurse |
|
| 327 |
+ $integration_api_dirs = @() |
|
| 328 |
+ ForEach($dir in $dirs) {
|
|
| 329 |
+ $RelativePath = "." + $dir.FullName -replace "$($PWD.Path -replace "\\","\\")","" |
|
| 330 |
+ If ($RelativePath -notmatch '(^.\\integration($|\\internal)|\\testdata)') {
|
|
| 331 |
+ $integration_api_dirs += $dir |
|
| 332 |
+ Write-Host "Building test suite binary $RelativePath" |
|
| 333 |
+ go test -c -o "$RelativePath\test.exe" $RelativePath |
|
| 334 |
+ } |
|
| 335 |
+ } |
|
| 336 |
+ |
|
| 337 |
+ ForEach($dir in $integration_api_dirs) {
|
|
| 338 |
+ Set-Location $dir.FullName |
|
| 339 |
+ Write-Host "Running $($PWD.Path)" |
|
| 340 |
+ $pinfo = New-Object System.Diagnostics.ProcessStartInfo |
|
| 341 |
+ $pinfo.FileName = "$($PWD.Path)\test.exe" |
|
| 342 |
+ $pinfo.RedirectStandardError = $true |
|
| 343 |
+ $pinfo.UseShellExecute = $false |
|
| 344 |
+ $pinfo.Arguments = $env:INTEGRATION_TESTFLAGS |
|
| 345 |
+ $p = New-Object System.Diagnostics.Process |
|
| 346 |
+ $p.StartInfo = $pinfo |
|
| 347 |
+ $p.Start() | Out-Null |
|
| 348 |
+ $p.WaitForExit() |
|
| 349 |
+ $err = $p.StandardError.ReadToEnd() |
|
| 350 |
+ if (($LASTEXITCODE -ne 0) -and ($err -notlike "*warning: no tests to run*")) {
|
|
| 351 |
+ Throw "Integration tests failed: $err" |
|
| 352 |
+ } |
|
| 353 |
+ } |
|
| 354 |
+} |
|
| 355 |
+ |
|
| 323 | 356 |
# Start of main code. |
| 324 | 357 |
Try {
|
| 325 | 358 |
Write-Host -ForegroundColor Cyan "INFO: make.ps1 starting at $(Get-Date)" |
| ... | ... |
@@ -331,13 +368,13 @@ Try {
|
| 331 | 331 |
# Handle the "-All" shortcut to turn on all things we can handle. |
| 332 | 332 |
# Note we expressly only include the items which can run in a container - the validations tests cannot |
| 333 | 333 |
# as they require the .git directory which is excluded from the image by .dockerignore |
| 334 |
- if ($All) { $Client=$True; $Daemon=$True; $TestUnit=$True }
|
|
| 334 |
+ if ($All) { $Client=$True; $Daemon=$True; $TestUnit=$True; }
|
|
| 335 | 335 |
|
| 336 | 336 |
# Handle the "-Binary" shortcut to build both client and daemon. |
| 337 | 337 |
if ($Binary) { $Client = $True; $Daemon = $True }
|
| 338 | 338 |
|
| 339 | 339 |
# Default to building the daemon if not asked for anything explicitly. |
| 340 |
- if (-not($Client) -and -not($Daemon) -and -not($DCO) -and -not($PkgImports) -and -not($GoFormat) -and -not($TestUnit)) { $Daemon=$True }
|
|
| 340 |
+ if (-not($Client) -and -not($Daemon) -and -not($DCO) -and -not($PkgImports) -and -not($GoFormat) -and -not($TestUnit) -and -not($TestIntegration)) { $Daemon=$True }
|
|
| 341 | 341 |
|
| 342 | 342 |
# Verify git is installed |
| 343 | 343 |
if ($(Get-Command git -ErrorAction SilentlyContinue) -eq $nil) { Throw "Git does not appear to be installed" }
|
| ... | ... |
@@ -425,6 +462,9 @@ Try {
|
| 425 | 425 |
# Run unit tests |
| 426 | 426 |
if ($TestUnit) { Run-UnitTests }
|
| 427 | 427 |
|
| 428 |
+ # Run integration tests |
|
| 429 |
+ if ($TestIntegration) { Run-IntegrationTests }
|
|
| 430 |
+ |
|
| 428 | 431 |
# Gratuitous ASCII art. |
| 429 | 432 |
if ($Daemon -or $Client) {
|
| 430 | 433 |
Write-Host |
| ... | ... |
@@ -2,6 +2,7 @@ package container |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"context" |
| 5 |
+ "runtime" |
|
| 5 | 6 |
"testing" |
| 6 | 7 |
|
| 7 | 8 |
"github.com/docker/docker/api/types" |
| ... | ... |
@@ -24,10 +25,14 @@ type TestContainerConfig struct {
|
| 24 | 24 |
// nolint: golint |
| 25 | 25 |
func Create(t *testing.T, ctx context.Context, client client.APIClient, ops ...func(*TestContainerConfig)) string { // nolint: golint
|
| 26 | 26 |
t.Helper() |
| 27 |
+ cmd := []string{"top"}
|
|
| 28 |
+ if runtime.GOOS == "windows" {
|
|
| 29 |
+ cmd = []string{"sleep", "240"}
|
|
| 30 |
+ } |
|
| 27 | 31 |
config := &TestContainerConfig{
|
| 28 | 32 |
Config: &container.Config{
|
| 29 | 33 |
Image: "busybox", |
| 30 |
- Cmd: []string{"top"},
|
|
| 34 |
+ Cmd: cmd, |
|
| 31 | 35 |
}, |
| 32 | 36 |
HostConfig: &container.HostConfig{},
|
| 33 | 37 |
NetworkingConfig: &network.NetworkingConfig{},
|
| ... | ... |
@@ -25,6 +25,10 @@ func TestVolumesCreateAndList(t *testing.T) {
|
| 25 | 25 |
ctx := context.Background() |
| 26 | 26 |
|
| 27 | 27 |
name := t.Name() |
| 28 |
+ // Windows file system is case insensitive |
|
| 29 |
+ if testEnv.OSType == "windows" {
|
|
| 30 |
+ name = strings.ToLower(name) |
|
| 31 |
+ } |
|
| 28 | 32 |
vol, err := client.VolumeCreate(ctx, volumetypes.VolumeCreateBody{
|
| 29 | 33 |
Name: name, |
| 30 | 34 |
}) |