mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Enable integrations API tests for Windows CI
Signed-off-by: Olli Janatuinen <olli.janatuinen@gmail.com>
(cherry picked from commit 2f22247cad
)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
ceb773e1ff
commit
de45ce73eb
4 changed files with 71 additions and 7 deletions
|
@ -119,6 +119,7 @@ $FinallyColour="Cyan"
|
||||||
#$env:INTEGRATION_IN_CONTAINER="yes"
|
#$env:INTEGRATION_IN_CONTAINER="yes"
|
||||||
#$env:WINDOWS_BASE_IMAGE=""
|
#$env:WINDOWS_BASE_IMAGE=""
|
||||||
#$env:SKIP_COPY_GO="yes"
|
#$env:SKIP_COPY_GO="yes"
|
||||||
|
#$env:INTEGRATION_TESTFLAGS="-test.v"
|
||||||
|
|
||||||
Function Nuke-Everything {
|
Function Nuke-Everything {
|
||||||
$ErrorActionPreference = 'SilentlyContinue'
|
$ErrorActionPreference = 'SilentlyContinue'
|
||||||
|
@ -825,18 +826,32 @@ Try {
|
||||||
docker `
|
docker `
|
||||||
"`$env`:PATH`='c`:\target;'+`$env:PATH`; `$env:DOCKER_HOST`='tcp`://'+(ipconfig | select -last 1).Substring(39)+'`:2357'; c:\target\runIntegrationCLI.ps1" | Out-Host } )
|
"`$env`:PATH`='c`:\target;'+`$env:PATH`; `$env:DOCKER_HOST`='tcp`://'+(ipconfig | select -last 1).Substring(39)+'`:2357'; c:\target\runIntegrationCLI.ps1" | Out-Host } )
|
||||||
} else {
|
} else {
|
||||||
Write-Host -ForegroundColor Green "INFO: Integration tests being run from the host:"
|
|
||||||
Set-Location "$env:SOURCES_DRIVE`:\$env:SOURCES_SUBDIR\src\github.com\docker\docker\integration-cli"
|
|
||||||
$env:DOCKER_HOST=$DASHH_CUT
|
$env:DOCKER_HOST=$DASHH_CUT
|
||||||
$env:PATH="$env:TEMP\binary;$env:PATH;" # Force to use the test binaries, not the host ones.
|
$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"
|
Write-Host -ForegroundColor Green "INFO: DOCKER_HOST at $DASHH_CUT"
|
||||||
|
|
||||||
|
$ErrorActionPreference = "SilentlyContinue"
|
||||||
|
Write-Host -ForegroundColor Cyan "INFO: Integration API tests being run from the host:"
|
||||||
|
if (!($env:INTEGRATION_TESTFLAGS)) {
|
||||||
|
$env:INTEGRATION_TESTFLAGS = "-test.v"
|
||||||
|
}
|
||||||
|
Set-Location "$env:SOURCES_DRIVE`:\$env:SOURCES_SUBDIR\src\github.com\docker\docker"
|
||||||
|
$start=(Get-Date); Invoke-Expression ".\hack\make.ps1 -TestIntegration"; $Duration=New-Timespan -Start $start -End (Get-Date)
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
if (-not($LastExitCode -eq 0)) {
|
||||||
|
Throw "ERROR: Integration API tests failed at $(Get-Date). Duration`:$Duration"
|
||||||
|
}
|
||||||
|
|
||||||
|
$ErrorActionPreference = "SilentlyContinue"
|
||||||
|
Write-Host -ForegroundColor Green "INFO: Integration CLI tests being run from the host:"
|
||||||
|
Write-Host -ForegroundColor Green "INFO: $c"
|
||||||
|
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)
|
||||||
}
|
}
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
if (-not($LastExitCode -eq 0)) {
|
if (-not($LastExitCode -eq 0)) {
|
||||||
Throw "ERROR: Integration tests failed at $(Get-Date). Duration`:$Duration"
|
Throw "ERROR: Integration CLI tests failed at $(Get-Date). Duration`:$Duration"
|
||||||
}
|
}
|
||||||
Write-Host -ForegroundColor Green "INFO: Integration tests ended at $(Get-Date). Duration`:$Duration"
|
Write-Host -ForegroundColor Green "INFO: Integration tests ended at $(Get-Date). Duration`:$Duration"
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -60,6 +60,9 @@
|
||||||
.PARAMETER TestUnit
|
.PARAMETER TestUnit
|
||||||
Runs unit tests.
|
Runs unit tests.
|
||||||
|
|
||||||
|
.PARAMETER TestIntegration
|
||||||
|
Runs integration tests.
|
||||||
|
|
||||||
.PARAMETER All
|
.PARAMETER All
|
||||||
Runs everything this script knows about that can run in a container.
|
Runs everything this script knows about that can run in a container.
|
||||||
|
|
||||||
|
@ -84,6 +87,7 @@ param(
|
||||||
[Parameter(Mandatory=$False)][switch]$PkgImports,
|
[Parameter(Mandatory=$False)][switch]$PkgImports,
|
||||||
[Parameter(Mandatory=$False)][switch]$GoFormat,
|
[Parameter(Mandatory=$False)][switch]$GoFormat,
|
||||||
[Parameter(Mandatory=$False)][switch]$TestUnit,
|
[Parameter(Mandatory=$False)][switch]$TestUnit,
|
||||||
|
[Parameter(Mandatory=$False)][switch]$TestIntegration,
|
||||||
[Parameter(Mandatory=$False)][switch]$All
|
[Parameter(Mandatory=$False)][switch]$All
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -320,6 +324,39 @@ Function Run-UnitTests() {
|
||||||
if ($LASTEXITCODE -ne 0) { Throw "Unit tests failed" }
|
if ($LASTEXITCODE -ne 0) { Throw "Unit tests failed" }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Run the integration tests
|
||||||
|
Function Run-IntegrationTests() {
|
||||||
|
$env:DOCKER_INTEGRATION_DAEMON_DEST = $root + "\bundles\tmp"
|
||||||
|
$dirs = Get-ChildItem -Path integration -Directory -Recurse
|
||||||
|
$integration_api_dirs = @()
|
||||||
|
ForEach($dir in $dirs) {
|
||||||
|
$RelativePath = "." + $dir.FullName -replace "$($PWD.Path -replace "\\","\\")",""
|
||||||
|
If ($RelativePath -notmatch '(^.\\integration($|\\internal)|\\testdata)') {
|
||||||
|
$integration_api_dirs += $dir
|
||||||
|
Write-Host "Building test suite binary $RelativePath"
|
||||||
|
go test -c -o "$RelativePath\test.exe" $RelativePath
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ForEach($dir in $integration_api_dirs) {
|
||||||
|
Set-Location $dir.FullName
|
||||||
|
Write-Host "Running $($PWD.Path)"
|
||||||
|
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
|
||||||
|
$pinfo.FileName = "$($PWD.Path)\test.exe"
|
||||||
|
$pinfo.RedirectStandardError = $true
|
||||||
|
$pinfo.UseShellExecute = $false
|
||||||
|
$pinfo.Arguments = $env:INTEGRATION_TESTFLAGS
|
||||||
|
$p = New-Object System.Diagnostics.Process
|
||||||
|
$p.StartInfo = $pinfo
|
||||||
|
$p.Start() | Out-Null
|
||||||
|
$p.WaitForExit()
|
||||||
|
$err = $p.StandardError.ReadToEnd()
|
||||||
|
if (($LASTEXITCODE -ne 0) -and ($err -notlike "*warning: no tests to run*")) {
|
||||||
|
Throw "Integration tests failed: $err"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Start of main code.
|
# Start of main code.
|
||||||
Try {
|
Try {
|
||||||
Write-Host -ForegroundColor Cyan "INFO: make.ps1 starting at $(Get-Date)"
|
Write-Host -ForegroundColor Cyan "INFO: make.ps1 starting at $(Get-Date)"
|
||||||
|
@ -331,13 +368,13 @@ Try {
|
||||||
# Handle the "-All" shortcut to turn on all things we can handle.
|
# Handle the "-All" shortcut to turn on all things we can handle.
|
||||||
# Note we expressly only include the items which can run in a container - the validations tests cannot
|
# Note we expressly only include the items which can run in a container - the validations tests cannot
|
||||||
# as they require the .git directory which is excluded from the image by .dockerignore
|
# as they require the .git directory which is excluded from the image by .dockerignore
|
||||||
if ($All) { $Client=$True; $Daemon=$True; $TestUnit=$True }
|
if ($All) { $Client=$True; $Daemon=$True; $TestUnit=$True; }
|
||||||
|
|
||||||
# Handle the "-Binary" shortcut to build both client and daemon.
|
# Handle the "-Binary" shortcut to build both client and daemon.
|
||||||
if ($Binary) { $Client = $True; $Daemon = $True }
|
if ($Binary) { $Client = $True; $Daemon = $True }
|
||||||
|
|
||||||
# Default to building the daemon if not asked for anything explicitly.
|
# Default to building the daemon if not asked for anything explicitly.
|
||||||
if (-not($Client) -and -not($Daemon) -and -not($DCO) -and -not($PkgImports) -and -not($GoFormat) -and -not($TestUnit)) { $Daemon=$True }
|
if (-not($Client) -and -not($Daemon) -and -not($DCO) -and -not($PkgImports) -and -not($GoFormat) -and -not($TestUnit) -and -not($TestIntegration)) { $Daemon=$True }
|
||||||
|
|
||||||
# Verify git is installed
|
# Verify git is installed
|
||||||
if ($(Get-Command git -ErrorAction SilentlyContinue) -eq $nil) { Throw "Git does not appear to be installed" }
|
if ($(Get-Command git -ErrorAction SilentlyContinue) -eq $nil) { Throw "Git does not appear to be installed" }
|
||||||
|
@ -425,6 +462,9 @@ Try {
|
||||||
# Run unit tests
|
# Run unit tests
|
||||||
if ($TestUnit) { Run-UnitTests }
|
if ($TestUnit) { Run-UnitTests }
|
||||||
|
|
||||||
|
# Run integration tests
|
||||||
|
if ($TestIntegration) { Run-IntegrationTests }
|
||||||
|
|
||||||
# Gratuitous ASCII art.
|
# Gratuitous ASCII art.
|
||||||
if ($Daemon -or $Client) {
|
if ($Daemon -or $Client) {
|
||||||
Write-Host
|
Write-Host
|
||||||
|
|
|
@ -2,6 +2,7 @@ package container
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
|
@ -24,10 +25,14 @@ type TestContainerConfig struct {
|
||||||
// nolint: golint
|
// nolint: golint
|
||||||
func Create(t *testing.T, ctx context.Context, client client.APIClient, ops ...func(*TestContainerConfig)) string { // nolint: golint
|
func Create(t *testing.T, ctx context.Context, client client.APIClient, ops ...func(*TestContainerConfig)) string { // nolint: golint
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
cmd := []string{"top"}
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
cmd = []string{"sleep", "240"}
|
||||||
|
}
|
||||||
config := &TestContainerConfig{
|
config := &TestContainerConfig{
|
||||||
Config: &container.Config{
|
Config: &container.Config{
|
||||||
Image: "busybox",
|
Image: "busybox",
|
||||||
Cmd: []string{"top"},
|
Cmd: cmd,
|
||||||
},
|
},
|
||||||
HostConfig: &container.HostConfig{},
|
HostConfig: &container.HostConfig{},
|
||||||
NetworkingConfig: &network.NetworkingConfig{},
|
NetworkingConfig: &network.NetworkingConfig{},
|
||||||
|
|
|
@ -25,6 +25,10 @@ func TestVolumesCreateAndList(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
name := t.Name()
|
name := t.Name()
|
||||||
|
// Windows file system is case insensitive
|
||||||
|
if testEnv.OSType == "windows" {
|
||||||
|
name = strings.ToLower(name)
|
||||||
|
}
|
||||||
vol, err := client.VolumeCreate(ctx, volumetypes.VolumeCreateBody{
|
vol, err := client.VolumeCreate(ctx, volumetypes.VolumeCreateBody{
|
||||||
Name: name,
|
Name: name,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue