diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index f6592b5277..626a51555e 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -16,6 +16,8 @@ on: env: GO_VERSION: 1.18.3 + GOTESTLIST_VERSION: v0.2.0 + TESTSTAT_VERSION: v0.1.3 WINDOWS_BASE_IMAGE: mcr.microsoft.com/windows/servercore WINDOWS_BASE_TAG_2019: ltsc2019 WINDOWS_BASE_TAG_2022: ltsc2022 @@ -188,10 +190,75 @@ jobs: name: ${{ matrix.os }}-unit-reports path: ${{ env.GOPATH }}\src\github.com\docker\docker\bundles\* + unit-test-report: + runs-on: ubuntu-latest + if: always() + needs: + - unit-test + strategy: + fail-fast: false + matrix: + os: + - windows-2019 + - windows-2022 + steps: + - + name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: ${{ env.GO_VERSION }} + - + name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: ${{ matrix.os }}-unit-reports + path: /tmp/artifacts + - + name: Install teststat + run: | + go install github.com/vearutop/teststat@${{ env.TESTSTAT_VERSION }} + - + name: Create summary + run: | + teststat -markdown $(find /tmp/artifacts -type f -name '*.json' -print0 | xargs -0) >> $GITHUB_STEP_SUMMARY + + integration-test-prepare: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.tests.outputs.matrix }} + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: ${{ env.GO_VERSION }} + - + name: Install gotestlist + run: + go install github.com/crazy-max/gotestlist/cmd/gotestlist@${{ env.GOTESTLIST_VERSION }} + - + name: Create matrix + id: tests + working-directory: ./integration-cli + run: | + # Distribute integration-cli tests for the matrix in integration-test job. + # Also prepend ./... to the matrix. This is a special case to run "Test integration" step exclusively. + matrix="$(gotestlist -d 4 ./...)" + matrix="$(echo "$matrix" | jq -c '. |= ["./..."] + .')" + echo "::set-output name=matrix::$matrix" + - + name: Show matrix + run: | + echo ${{ steps.tests.outputs.matrix }} + integration-test: runs-on: ${{ matrix.os }} needs: - build + - integration-test-prepare strategy: fail-fast: false matrix: @@ -201,6 +268,7 @@ jobs: runtime: - builtin - containerd + test: ${{ fromJson(needs.integration-test-prepare.outputs.matrix) }} env: GOPATH: ${{ github.workspace }}\go GOBIN: ${{ github.workspace }}\go\bin @@ -343,7 +411,8 @@ jobs: with: go-version: ${{ env.GO_VERSION }} - - name: Test API + name: Test integration + if: matrix.test == './...' run: | .\hack\make.ps1 -TestIntegration env: @@ -351,22 +420,15 @@ jobs: GO111MODULE: "off" TEST_CLIENT_BINARY: ${{ env.BIN_OUT }}\docker - - name: Test CLI + name: Test integration-cli + if: matrix.test != './...' run: | - & gotestsum ` - --format=standard-verbose ` - --jsonfile="./bundles/go-test-report-int-cli-tests.json" ` - --junitfile="./bundles/junit-report-int-cli-tests.xml" ` - --packages="./integration-cli/..." ` - -- ` - "-coverprofile" "./bundles/coverage-report-int-cli-tests.txt" ` - "-covermode" "atomic" ` - "-tags" "autogen" ` - "-test.timeout" "200m" + .\hack\make.ps1 -TestIntegrationCli env: DOCKER_HOST: npipe:////./pipe/docker_engine GO111MODULE: "off" TEST_CLIENT_BINARY: ${{ env.BIN_OUT }}\docker + INTEGRATION_TESTRUN: ${{ matrix.test }} - name: Send to Codecov if: matrix.os == 'windows-2022' @@ -420,3 +482,38 @@ jobs: with: name: ${{ matrix.os }}-integration-reports-${{ matrix.runtime }} path: ${{ env.GOPATH }}\src\github.com\docker\docker\bundles\* + + integration-test-report: + runs-on: ubuntu-latest + if: always() + needs: + - integration-test + strategy: + fail-fast: false + matrix: + os: + - windows-2019 + - windows-2022 + runtime: + - builtin + - containerd + steps: + - + name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: ${{ env.GO_VERSION }} + - + name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: ${{ matrix.os }}-integration-reports-${{ matrix.runtime }} + path: /tmp/artifacts + - + name: Install teststat + run: | + go install github.com/vearutop/teststat@${{ env.TESTSTAT_VERSION }} + - + name: Create summary + run: | + teststat -markdown $(find /tmp/artifacts -type f -name '*.json' -print0 | xargs -0) >> $GITHUB_STEP_SUMMARY diff --git a/Dockerfile.e2e b/Dockerfile.e2e index 8db21210bb..898196d547 100644 --- a/Dockerfile.e2e +++ b/Dockerfile.e2e @@ -31,7 +31,7 @@ COPY hack/dockerfile/install/install.sh ./install.sh COPY hack/dockerfile/install/$INSTALL_BINARY_NAME.installer ./ RUN PREFIX=/build ./install.sh $INSTALL_BINARY_NAME -# Build DockerSuite.TestBuild* dependency +# TestDockerCLIBuildSuite dependency FROM base AS contrib COPY contrib/syscall-test /build/syscall-test COPY contrib/httpserver/Dockerfile /build/httpserver/Dockerfile diff --git a/docs/contributing/test.md b/docs/contributing/test.md index 3bbec68071..099b92c7d8 100644 --- a/docs/contributing/test.md +++ b/docs/contributing/test.md @@ -171,16 +171,16 @@ $ TESTDIRS='github.com/docker/docker/opts' TESTFLAGS='-test.run ^TestValidateIPA We use [gocheck](https://labix.org/gocheck) for our integration-cli tests. You can use the `TESTFLAGS` environment variable to run a single test. The flag's value is passed as arguments to the `go test` command. For example, from -your local host you can run the `TestBuild` test with this command: +your local host you can run the `TestDockerCLIBuildSuite` test with this command: ```bash -$ TESTFLAGS='-test.run TestDockerSuite/TestBuild*' make test-integration +$ TESTFLAGS='-test.run TestDockerCLIBuildSuite' make test-integration ``` To run the same test inside your Docker development container, you do this: ```bash -# TESTFLAGS='-test.run TestDockerSuite/TestBuild*' hack/make.sh binary test-integration +# TESTFLAGS='-test.run TestDockerCLIBuildSuite' hack/make.sh binary test-integration ``` ## Test the Windows binary against a Linux daemon diff --git a/hack/make.ps1 b/hack/make.ps1 index 8d1f7177a7..9359d8f52d 100644 --- a/hack/make.ps1 +++ b/hack/make.ps1 @@ -63,6 +63,9 @@ .PARAMETER TestIntegration Runs integration tests. +.PARAMETER TestIntegrationCli + Runs integration-cli tests. + .PARAMETER All Runs everything this script knows about that can run in a container. @@ -88,6 +91,7 @@ param( [Parameter(Mandatory=$False)][switch]$GoFormat, [Parameter(Mandatory=$False)][switch]$TestUnit, [Parameter(Mandatory=$False)][switch]$TestIntegration, + [Parameter(Mandatory=$False)][switch]$TestIntegrationCli, [Parameter(Mandatory=$False)][switch]$All ) @@ -383,6 +387,36 @@ Function Run-IntegrationTests() { } } +# Run the integration-cli tests +Function Run-IntegrationCliTests() { + Write-Host "INFO: Running integration-cli tests..." + + $goTestRun = "" + $reportSuffix = "" + if ($env:INTEGRATION_TESTRUN.Length -ne 0) + { + $goTestRun = "-test.run=($env:INTEGRATION_TESTRUN)/" + $reportSuffixStream = [IO.MemoryStream]::new([byte[]][char[]]$env:INTEGRATION_TESTRUN) + $reportSuffix = "-" + (Get-FileHash -InputStream $reportSuffixStream -Algorithm SHA256).Hash + } + + $jsonFilePath = $bundlesDir + "\go-test-report-int-cli-tests$reportSuffix.json" + $xmlFilePath = $bundlesDir + "\junit-report-int-cli-tests$reportSuffix.xml" + $coverageFilePath = $bundlesDir + "\coverage-report-int-cli-tests$reportSuffix.txt" + $goTestArg = "--format=standard-verbose --packages=./integration-cli/... --jsonfile=$jsonFilePath --junitfile=$xmlFilePath -- -coverprofile=$coverageFilePath -covermode=atomic -tags=autogen -test.timeout=200m $goTestRun $env:INTEGRATION_TESTFLAGS" + Write-Host "INFO: Invoking integration-cli tests run with gotestsum.exe $goTestArg" + $pinfo = New-Object System.Diagnostics.ProcessStartInfo + $pinfo.FileName = "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 "integration-cli tests failed" } +} + # Start of main code. Try { Write-Host -ForegroundColor Cyan "INFO: make.ps1 starting at $(Get-Date)" @@ -405,7 +439,7 @@ Try { if ($Binary) { $Client = $True; $Daemon = $True } # 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) -and -not($TestIntegration)) { $Daemon=$True } + if (-not($Client) -and -not($Daemon) -and -not($DCO) -and -not($PkgImports) -and -not($GoFormat) -and -not($TestUnit) -and -not($TestIntegration) -and -not($TestIntegrationCli)) { $Daemon=$True } # Verify git is installed if ($(Get-Command git -ErrorAction SilentlyContinue) -eq $nil) { Throw "Git does not appear to be installed" } @@ -501,6 +535,9 @@ Try { # Run integration tests if ($TestIntegration) { Run-IntegrationTests } + # Run integration-cli tests + if ($TestIntegrationCli) { Run-IntegrationCliTests } + # Gratuitous ASCII art. if ($Daemon -or $Client) { Write-Host diff --git a/hack/make/.integration-test-helpers b/hack/make/.integration-test-helpers index cd17e6354d..b8b4896ef4 100644 --- a/hack/make/.integration-test-helpers +++ b/hack/make/.integration-test-helpers @@ -3,7 +3,7 @@ # For integration-cli test, we use [gocheck](https://labix.org/gocheck), if you want # to run certain tests on your local host, you should run with command: # -# TESTFLAGS='-test.run TestDockerSuite/TestBuild*' ./hack/make.sh binary test-integration +# TESTFLAGS='-test.run TestDockerCLIBuildSuite' ./hack/make.sh binary test-integration # if [ -z "${MAKEDIR}" ]; then diff --git a/hack/validate/default b/hack/validate/default index cb85489190..88a4b95680 100755 --- a/hack/validate/default +++ b/hack/validate/default @@ -13,6 +13,6 @@ export SCRIPTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" . "${SCRIPTDIR}"/toml . "${SCRIPTDIR}"/changelog-well-formed . "${SCRIPTDIR}"/changelog-date-descending -. "${SCRIPTDIR}"/deprecate-integration-cli +#. "${SCRIPTDIR}"/deprecate-integration-cli . "${SCRIPTDIR}"/golangci-lint . "${SCRIPTDIR}"/shfmt diff --git a/integration-cli/benchmark_test.go b/integration-cli/benchmark_test.go index 8ab87b22d9..ae93cf30de 100644 --- a/integration-cli/benchmark_test.go +++ b/integration-cli/benchmark_test.go @@ -7,11 +7,24 @@ import ( "strings" "sync" "testing" + "time" "gotest.tools/v3/assert" ) -func (s *DockerSuite) BenchmarkConcurrentContainerActions(c *testing.B) { +type DockerBenchmarkSuite struct { + ds *DockerSuite +} + +func (s *DockerBenchmarkSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerBenchmarkSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + +func (s *DockerBenchmarkSuite) BenchmarkConcurrentContainerActions(c *testing.B) { maxConcurrency := runtime.GOMAXPROCS(0) numIterations := c.N outerGroup := &sync.WaitGroup{} @@ -92,3 +105,26 @@ func (s *DockerSuite) BenchmarkConcurrentContainerActions(c *testing.B) { assert.NilError(c, err) } } + +func (s *DockerBenchmarkSuite) BenchmarkLogsCLIRotateFollow(c *testing.B) { + out, _ := dockerCmd(c, "run", "-d", "--log-opt", "max-size=1b", "--log-opt", "max-file=10", "busybox", "sh", "-c", "while true; do usleep 50000; echo hello; done") + id := strings.TrimSpace(out) + ch := make(chan error, 1) + go func() { + ch <- nil + out, _, _ := dockerCmdWithError("logs", "-f", id) + // if this returns at all, it's an error + ch <- fmt.Errorf(out) + }() + + <-ch + select { + case <-time.After(30 * time.Second): + // ran for 30 seconds with no problem + return + case err := <-ch: + if err != nil { + c.Fatal(err) + } + } +} diff --git a/integration-cli/check_test.go b/integration-cli/check_test.go index 0001d081f3..36f58c43ed 100644 --- a/integration-cli/check_test.go +++ b/integration-cli/check_test.go @@ -83,7 +83,240 @@ func ensureTestEnvSetup(t *testing.T) { func TestDockerSuite(t *testing.T) { ensureTestEnvSetup(t) - suite.Run(t, &DockerSuite{}) + suite.Run(t, &DockerAPISuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerBenchmarkSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLIAttachSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLIBuildSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLICommitSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLICpSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLICreateSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLIEventSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLIExecSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLIHealthSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLIHistorySuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLIImagesSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLIImportSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLIInfoSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLIInspectSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLILinksSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLILoginSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLILogsSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLINetmodeSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLINetworkSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLIPluginLogDriverSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLIPluginsSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLIPortSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLIProxySuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLIPruneSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLIPsSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLIPullSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLIPushSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLIRestartSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLIRmiSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLIRunSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLISaveLoadSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLISearchSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLISNISuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLIStartSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLIStatsSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLITopSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLIUpdateSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerCLIVolumeSuite{ds: &DockerSuite{}}) +} + +func TestDockerAPISuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerAPISuite{ds: &DockerSuite{}}) +} + +func TestDockerBenchmarkSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerBenchmarkSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLIAttachSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLIAttachSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLIBuildSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLIBuildSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLICommitSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLICommitSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLICpSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLICpSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLICreateSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLICreateSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLIEventSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLIEventSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLIExecSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLIExecSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLIHealthSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLIHealthSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLIHistorySuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLIHistorySuite{ds: &DockerSuite{}}) +} + +func TestDockerCLIImagesSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLIImagesSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLIImportSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLIImportSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLIInfoSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLIInfoSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLIInspectSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLIInspectSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLILinksSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLILinksSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLILoginSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLILoginSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLILogsSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLILogsSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLINetmodeSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLINetmodeSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLINetworkSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLINetworkSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLIPluginLogDriverSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLIPluginLogDriverSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLIPluginsSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLIPluginsSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLIPortSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLIPortSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLIProxySuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLIProxySuite{ds: &DockerSuite{}}) +} + +func TestDockerCLIPruneSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLIPruneSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLIPsSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLIPsSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLIPullSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLIPullSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLIPushSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLIPushSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLIRestartSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLIRestartSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLIRmiSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLIRmiSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLIRunSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLIRunSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLISaveLoadSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLISaveLoadSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLISearchSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLISearchSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLISNISuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLISNISuite{ds: &DockerSuite{}}) +} + +func TestDockerCLIStartSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLIStartSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLIStatsSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLIStatsSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLITopSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLITopSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLIUpdateSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLIUpdateSuite{ds: &DockerSuite{}}) +} + +func TestDockerCLIVolumeSuite(t *testing.T) { + ensureTestEnvSetup(t) + suite.Run(t, &DockerCLIVolumeSuite{ds: &DockerSuite{}}) } func TestDockerRegistrySuite(t *testing.T) { diff --git a/integration-cli/docker_api_attach_test.go b/integration-cli/docker_api_attach_test.go index 7b4a1fe746..5e009f7617 100644 --- a/integration-cli/docker_api_attach_test.go +++ b/integration-cli/docker_api_attach_test.go @@ -22,7 +22,7 @@ import ( is "gotest.tools/v3/assert/cmp" ) -func (s *DockerSuite) TestGetContainersAttachWebsocket(c *testing.T) { +func (s *DockerAPISuite) TestGetContainersAttachWebsocket(c *testing.T) { testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "-dit", "busybox", "cat") @@ -75,7 +75,7 @@ func (s *DockerSuite) TestGetContainersAttachWebsocket(c *testing.T) { } // regression gh14320 -func (s *DockerSuite) TestPostContainersAttachContainerNotFound(c *testing.T) { +func (s *DockerAPISuite) TestPostContainersAttachContainerNotFound(c *testing.T) { resp, _, err := request.Post("/containers/doesnotexist/attach") assert.NilError(c, err) // connection will shutdown, err should be "persistent connection closed" @@ -86,7 +86,7 @@ func (s *DockerSuite) TestPostContainersAttachContainerNotFound(c *testing.T) { assert.Equal(c, string(content), expected) } -func (s *DockerSuite) TestGetContainersWsAttachContainerNotFound(c *testing.T) { +func (s *DockerAPISuite) TestGetContainersWsAttachContainerNotFound(c *testing.T) { res, body, err := request.Get("/containers/doesnotexist/attach/ws") assert.Equal(c, res.StatusCode, http.StatusNotFound) assert.NilError(c, err) @@ -96,7 +96,7 @@ func (s *DockerSuite) TestGetContainersWsAttachContainerNotFound(c *testing.T) { assert.Assert(c, strings.Contains(getErrorMessage(c, b), expected)) } -func (s *DockerSuite) TestPostContainersAttach(c *testing.T) { +func (s *DockerAPISuite) TestPostContainersAttach(c *testing.T) { testRequires(c, DaemonIsLinux) expectSuccess := func(wc io.WriteCloser, br *bufio.Reader, stream string, tty bool) { diff --git a/integration-cli/docker_api_build_test.go b/integration-cli/docker_api_build_test.go index 507ebe624c..21eecab56f 100644 --- a/integration-cli/docker_api_build_test.go +++ b/integration-cli/docker_api_build_test.go @@ -21,7 +21,7 @@ import ( is "gotest.tools/v3/assert/cmp" ) -func (s *DockerSuite) TestBuildAPIDockerFileRemote(c *testing.T) { +func (s *DockerAPISuite) TestBuildAPIDockerFileRemote(c *testing.T) { testRequires(c, NotUserNamespace) var testD string @@ -52,7 +52,7 @@ RUN find /tmp/` assert.Assert(c, !strings.Contains(out, "baz")) } -func (s *DockerSuite) TestBuildAPIRemoteTarballContext(c *testing.T) { +func (s *DockerAPISuite) TestBuildAPIRemoteTarballContext(c *testing.T) { buffer := new(bytes.Buffer) tw := tar.NewWriter(buffer) defer tw.Close() @@ -79,7 +79,7 @@ func (s *DockerSuite) TestBuildAPIRemoteTarballContext(c *testing.T) { b.Close() } -func (s *DockerSuite) TestBuildAPIRemoteTarballContextWithCustomDockerfile(c *testing.T) { +func (s *DockerAPISuite) TestBuildAPIRemoteTarballContextWithCustomDockerfile(c *testing.T) { buffer := new(bytes.Buffer) tw := tar.NewWriter(buffer) defer tw.Close() @@ -133,7 +133,7 @@ RUN echo 'right' assert.Assert(c, !strings.Contains(string(content), "wrong")) } -func (s *DockerSuite) TestBuildAPILowerDockerfile(c *testing.T) { +func (s *DockerAPISuite) TestBuildAPILowerDockerfile(c *testing.T) { git := fakegit.New(c, "repo", map[string]string{ "dockerfile": `FROM busybox RUN echo from dockerfile`, @@ -151,7 +151,7 @@ RUN echo from dockerfile`, assert.Assert(c, is.Contains(out, "from dockerfile")) } -func (s *DockerSuite) TestBuildAPIBuildGitWithF(c *testing.T) { +func (s *DockerAPISuite) TestBuildAPIBuildGitWithF(c *testing.T) { git := fakegit.New(c, "repo", map[string]string{ "baz": `FROM busybox RUN echo from baz`, @@ -172,7 +172,7 @@ RUN echo from Dockerfile`, assert.Assert(c, is.Contains(out, "from baz")) } -func (s *DockerSuite) TestBuildAPIDoubleDockerfile(c *testing.T) { +func (s *DockerAPISuite) TestBuildAPIDoubleDockerfile(c *testing.T) { testRequires(c, UnixCli) // dockerfile overwrites Dockerfile on Windows git := fakegit.New(c, "repo", map[string]string{ "Dockerfile": `FROM busybox @@ -194,7 +194,7 @@ RUN echo from dockerfile`, assert.Assert(c, is.Contains(out, "from Dockerfile")) } -func (s *DockerSuite) TestBuildAPIUnnormalizedTarPaths(c *testing.T) { +func (s *DockerAPISuite) TestBuildAPIUnnormalizedTarPaths(c *testing.T) { // Make sure that build context tars with entries of the form // x/./y don't cause caching false positives. @@ -248,7 +248,7 @@ func (s *DockerSuite) TestBuildAPIUnnormalizedTarPaths(c *testing.T) { assert.Assert(c, imageA != imageB) } -func (s *DockerSuite) TestBuildOnBuildWithCopy(c *testing.T) { +func (s *DockerAPISuite) TestBuildOnBuildWithCopy(c *testing.T) { dockerfile := ` FROM ` + minimalBaseImage() + ` as onbuildbase ONBUILD COPY file /file @@ -273,7 +273,7 @@ func (s *DockerSuite) TestBuildOnBuildWithCopy(c *testing.T) { assert.Assert(c, is.Contains(string(out), "Successfully built")) } -func (s *DockerSuite) TestBuildOnBuildCache(c *testing.T) { +func (s *DockerAPISuite) TestBuildOnBuildCache(c *testing.T) { build := func(dockerfile string) []byte { ctx := fakecontext.New(c, "", fakecontext.WithDockerfile(dockerfile), @@ -352,7 +352,7 @@ func (s *DockerRegistrySuite) TestBuildCopyFromForcePull(c *testing.T) { assert.Check(c, is.Contains(string(out), "Successfully built")) } -func (s *DockerSuite) TestBuildAddRemoteNoDecompress(c *testing.T) { +func (s *DockerAPISuite) TestBuildAddRemoteNoDecompress(c *testing.T) { buffer := new(bytes.Buffer) tw := tar.NewWriter(buffer) dt := []byte("contents") @@ -396,7 +396,7 @@ func (s *DockerSuite) TestBuildAddRemoteNoDecompress(c *testing.T) { assert.Check(c, is.Contains(string(out), "Successfully built")) } -func (s *DockerSuite) TestBuildChownOnCopy(c *testing.T) { +func (s *DockerAPISuite) TestBuildChownOnCopy(c *testing.T) { // new feature added in 1.31 - https://github.com/moby/moby/pull/34263 testRequires(c, DaemonIsLinux, MinimumAPIVersion("1.31")) dockerfile := `FROM busybox @@ -426,7 +426,7 @@ func (s *DockerSuite) TestBuildChownOnCopy(c *testing.T) { assert.Check(c, is.Contains(string(out), "Successfully built")) } -func (s *DockerSuite) TestBuildCopyCacheOnFileChange(c *testing.T) { +func (s *DockerAPISuite) TestBuildCopyCacheOnFileChange(c *testing.T) { dockerfile := `FROM busybox COPY file /file` @@ -467,7 +467,7 @@ COPY file /file` } } -func (s *DockerSuite) TestBuildAddCacheOnFileChange(c *testing.T) { +func (s *DockerAPISuite) TestBuildAddCacheOnFileChange(c *testing.T) { dockerfile := `FROM busybox ADD file /file` @@ -508,7 +508,7 @@ ADD file /file` } } -func (s *DockerSuite) TestBuildScratchCopy(c *testing.T) { +func (s *DockerAPISuite) TestBuildScratchCopy(c *testing.T) { testRequires(c, DaemonIsLinux) dockerfile := `FROM scratch ADD Dockerfile / diff --git a/integration-cli/docker_api_build_windows_test.go b/integration-cli/docker_api_build_windows_test.go index 68e19ca036..e69586e8fd 100644 --- a/integration-cli/docker_api_build_windows_test.go +++ b/integration-cli/docker_api_build_windows_test.go @@ -13,7 +13,7 @@ import ( is "gotest.tools/v3/assert/cmp" ) -func (s *DockerSuite) TestBuildWithRecycleBin(c *testing.T) { +func (s *DockerAPISuite) TestBuildWithRecycleBin(c *testing.T) { testRequires(c, DaemonIsWindows) dockerfile := "" + diff --git a/integration-cli/docker_api_containers_test.go b/integration-cli/docker_api_containers_test.go index b5e6b18e67..b929818594 100644 --- a/integration-cli/docker_api_containers_test.go +++ b/integration-cli/docker_api_containers_test.go @@ -36,7 +36,7 @@ import ( "gotest.tools/v3/poll" ) -func (s *DockerSuite) TestContainerAPIGetAll(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIGetAll(c *testing.T) { startCount := getContainerCount(c) name := "getall" dockerCmd(c, "run", "--name", name, "busybox", "true") @@ -56,7 +56,7 @@ func (s *DockerSuite) TestContainerAPIGetAll(c *testing.T) { } // regression test for empty json field being omitted #13691 -func (s *DockerSuite) TestContainerAPIGetJSONNoFieldsOmitted(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIGetJSONNoFieldsOmitted(c *testing.T) { startCount := getContainerCount(c) dockerCmd(c, "run", "busybox", "true") @@ -96,7 +96,7 @@ func (s *DockerSuite) TestContainerAPIGetJSONNoFieldsOmitted(c *testing.T) { } } -func (s *DockerSuite) TestContainerAPIGetExport(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIGetExport(c *testing.T) { // Not supported on Windows as Windows does not support docker export testRequires(c, DaemonIsLinux) name := "exportcontainer" @@ -123,7 +123,7 @@ func (s *DockerSuite) TestContainerAPIGetExport(c *testing.T) { assert.Assert(c, found, "The created test file has not been found in the exported image") } -func (s *DockerSuite) TestContainerAPIGetChanges(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIGetChanges(c *testing.T) { // Not supported on Windows as Windows does not support docker diff (/containers/name/changes) testRequires(c, DaemonIsLinux) name := "changescontainer" @@ -146,7 +146,7 @@ func (s *DockerSuite) TestContainerAPIGetChanges(c *testing.T) { assert.Assert(c, success, "/etc/passwd has been removed but is not present in the diff") } -func (s *DockerSuite) TestGetContainerStats(c *testing.T) { +func (s *DockerAPISuite) TestGetContainerStats(c *testing.T) { var ( name = "statscontainer" ) @@ -186,7 +186,7 @@ func (s *DockerSuite) TestGetContainerStats(c *testing.T) { } } -func (s *DockerSuite) TestGetContainerStatsRmRunning(c *testing.T) { +func (s *DockerAPISuite) TestGetContainerStatsRmRunning(c *testing.T) { out := runSleepingContainer(c) id := strings.TrimSpace(out) @@ -253,7 +253,7 @@ func (c *ChannelBuffer) ReadTimeout(p []byte, n time.Duration) (int, error) { // regression test for gh13421 // previous test was just checking one stat entry so it didn't fail (stats with // stream false always return one stat) -func (s *DockerSuite) TestGetContainerStatsStream(c *testing.T) { +func (s *DockerAPISuite) TestGetContainerStatsStream(c *testing.T) { name := "statscontainer" runSleepingContainer(c, "--name", name) @@ -294,7 +294,7 @@ func (s *DockerSuite) TestGetContainerStatsStream(c *testing.T) { } } -func (s *DockerSuite) TestGetContainerStatsNoStream(c *testing.T) { +func (s *DockerAPISuite) TestGetContainerStatsNoStream(c *testing.T) { name := "statscontainer" runSleepingContainer(c, "--name", name) @@ -334,7 +334,7 @@ func (s *DockerSuite) TestGetContainerStatsNoStream(c *testing.T) { } } -func (s *DockerSuite) TestGetStoppedContainerStats(c *testing.T) { +func (s *DockerAPISuite) TestGetStoppedContainerStats(c *testing.T) { name := "statscontainer" dockerCmd(c, "create", "--name", name, "busybox", "ps") @@ -361,7 +361,7 @@ func (s *DockerSuite) TestGetStoppedContainerStats(c *testing.T) { } } -func (s *DockerSuite) TestContainerAPIPause(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIPause(c *testing.T) { // Problematic on Windows as Windows does not support pause testRequires(c, DaemonIsLinux) @@ -392,7 +392,7 @@ func (s *DockerSuite) TestContainerAPIPause(c *testing.T) { assert.Equal(c, len(pausedContainers), 0, "There should be no paused container.") } -func (s *DockerSuite) TestContainerAPITop(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPITop(c *testing.T) { testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "top && true") id := strings.TrimSpace(out) @@ -415,7 +415,7 @@ func (s *DockerSuite) TestContainerAPITop(c *testing.T) { assert.Equal(c, top.Processes[1][10], "top") } -func (s *DockerSuite) TestContainerAPITopWindows(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPITopWindows(c *testing.T) { testRequires(c, DaemonIsWindows) out := runSleepingContainer(c, "-d") id := strings.TrimSpace(out) @@ -446,7 +446,7 @@ func (s *DockerSuite) TestContainerAPITopWindows(c *testing.T) { assert.Assert(c, foundProcess, "expected to find %s: %v", expectedProcess, top.Processes) } -func (s *DockerSuite) TestContainerAPICommit(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPICommit(c *testing.T) { cName := "testapicommit" dockerCmd(c, "run", "--name="+cName, "busybox", "/bin/sh", "-c", "touch /test") @@ -468,7 +468,7 @@ func (s *DockerSuite) TestContainerAPICommit(c *testing.T) { dockerCmd(c, "run", img.ID, "ls", "/test") } -func (s *DockerSuite) TestContainerAPICommitWithLabelInConfig(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPICommitWithLabelInConfig(c *testing.T) { cName := "testapicommitwithconfig" dockerCmd(c, "run", "--name="+cName, "busybox", "/bin/sh", "-c", "touch /test") @@ -500,7 +500,7 @@ func (s *DockerSuite) TestContainerAPICommitWithLabelInConfig(c *testing.T) { dockerCmd(c, "run", img.ID, "ls", "/test") } -func (s *DockerSuite) TestContainerAPIBadPort(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIBadPort(c *testing.T) { // TODO Windows to Windows CI - Port this test testRequires(c, DaemonIsLinux) @@ -527,7 +527,7 @@ func (s *DockerSuite) TestContainerAPIBadPort(c *testing.T) { assert.ErrorContains(c, err, `invalid port specification: "aa80"`) } -func (s *DockerSuite) TestContainerAPICreate(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPICreate(c *testing.T) { config := container.Config{ Image: "busybox", Cmd: []string{"/bin/sh", "-c", "touch /test && ls /test"}, @@ -544,7 +544,7 @@ func (s *DockerSuite) TestContainerAPICreate(c *testing.T) { assert.Equal(c, strings.TrimSpace(out), "/test") } -func (s *DockerSuite) TestContainerAPICreateEmptyConfig(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPICreateEmptyConfig(c *testing.T) { cli, err := client.NewClientWithOpts(client.FromEnv) assert.NilError(c, err) @@ -556,7 +556,7 @@ func (s *DockerSuite) TestContainerAPICreateEmptyConfig(c *testing.T) { assert.ErrorContains(c, err, expected) } -func (s *DockerSuite) TestContainerAPICreateMultipleNetworksConfig(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPICreateMultipleNetworksConfig(c *testing.T) { // Container creation must fail if client specified configurations for more than one network config := container.Config{ Image: "busybox", @@ -583,13 +583,13 @@ func (s *DockerSuite) TestContainerAPICreateMultipleNetworksConfig(c *testing.T) assert.Assert(c, strings.Contains(msg, "net3")) } -func (s *DockerSuite) TestContainerAPICreateBridgeNetworkMode(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPICreateBridgeNetworkMode(c *testing.T) { // Windows does not support bridge testRequires(c, DaemonIsLinux) UtilCreateNetworkMode(c, "bridge") } -func (s *DockerSuite) TestContainerAPICreateOtherNetworkModes(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPICreateOtherNetworkModes(c *testing.T) { // Windows does not support these network modes testRequires(c, DaemonIsLinux, NotUserNamespace) UtilCreateNetworkMode(c, "host") @@ -618,7 +618,7 @@ func UtilCreateNetworkMode(c *testing.T, networkMode container.NetworkMode) { assert.Equal(c, containerJSON.HostConfig.NetworkMode, networkMode, "Mismatched NetworkMode") } -func (s *DockerSuite) TestContainerAPICreateWithCpuSharesCpuset(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPICreateWithCpuSharesCpuset(c *testing.T) { // TODO Windows to Windows CI. The CpuShares part could be ported. testRequires(c, DaemonIsLinux) config := container.Config{ @@ -649,7 +649,7 @@ func (s *DockerSuite) TestContainerAPICreateWithCpuSharesCpuset(c *testing.T) { assert.Equal(c, outCpuset, "0") } -func (s *DockerSuite) TestContainerAPIVerifyHeader(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIVerifyHeader(c *testing.T) { config := map[string]interface{}{ "Image": "busybox", } @@ -690,7 +690,7 @@ func (s *DockerSuite) TestContainerAPIVerifyHeader(c *testing.T) { } // Issue 14230. daemon should return 500 for invalid port syntax -func (s *DockerSuite) TestContainerAPIInvalidPortSyntax(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIInvalidPortSyntax(c *testing.T) { config := `{ "Image": "busybox", "HostConfig": { @@ -716,7 +716,7 @@ func (s *DockerSuite) TestContainerAPIInvalidPortSyntax(c *testing.T) { assert.Assert(c, strings.Contains(string(b[:]), "invalid port")) } -func (s *DockerSuite) TestContainerAPIRestartPolicyInvalidPolicyName(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIRestartPolicyInvalidPolicyName(c *testing.T) { config := `{ "Image": "busybox", "HostConfig": { @@ -740,7 +740,7 @@ func (s *DockerSuite) TestContainerAPIRestartPolicyInvalidPolicyName(c *testing. assert.Assert(c, strings.Contains(string(b[:]), "invalid restart policy")) } -func (s *DockerSuite) TestContainerAPIRestartPolicyRetryMismatch(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIRestartPolicyRetryMismatch(c *testing.T) { config := `{ "Image": "busybox", "HostConfig": { @@ -764,7 +764,7 @@ func (s *DockerSuite) TestContainerAPIRestartPolicyRetryMismatch(c *testing.T) { assert.Assert(c, strings.Contains(string(b[:]), "maximum retry count cannot be used with restart policy")) } -func (s *DockerSuite) TestContainerAPIRestartPolicyNegativeRetryCount(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIRestartPolicyNegativeRetryCount(c *testing.T) { config := `{ "Image": "busybox", "HostConfig": { @@ -788,7 +788,7 @@ func (s *DockerSuite) TestContainerAPIRestartPolicyNegativeRetryCount(c *testing assert.Assert(c, strings.Contains(string(b[:]), "maximum retry count cannot be negative")) } -func (s *DockerSuite) TestContainerAPIRestartPolicyDefaultRetryCount(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIRestartPolicyDefaultRetryCount(c *testing.T) { config := `{ "Image": "busybox", "HostConfig": { @@ -806,7 +806,7 @@ func (s *DockerSuite) TestContainerAPIRestartPolicyDefaultRetryCount(c *testing. // Issue 7941 - test to make sure a "null" in JSON is just ignored. // W/o this fix a null in JSON would be parsed into a string var as "null" -func (s *DockerSuite) TestContainerAPIPostCreateNull(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIPostCreateNull(c *testing.T) { config := `{ "Hostname":"", "Domainname":"", @@ -850,7 +850,7 @@ func (s *DockerSuite) TestContainerAPIPostCreateNull(c *testing.T) { assert.Equal(c, outMemorySwap, "0") } -func (s *DockerSuite) TestCreateWithTooLowMemoryLimit(c *testing.T) { +func (s *DockerAPISuite) TestCreateWithTooLowMemoryLimit(c *testing.T) { // TODO Windows: Port once memory is supported testRequires(c, DaemonIsLinux) config := `{ @@ -874,7 +874,7 @@ func (s *DockerSuite) TestCreateWithTooLowMemoryLimit(c *testing.T) { assert.Assert(c, strings.Contains(string(b), "Minimum memory limit allowed is 6MB")) } -func (s *DockerSuite) TestContainerAPIRename(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIRename(c *testing.T) { out, _ := dockerCmd(c, "run", "--name", "TestContainerAPIRename", "-d", "busybox", "sh") containerID := strings.TrimSpace(out) @@ -891,7 +891,7 @@ func (s *DockerSuite) TestContainerAPIRename(c *testing.T) { assert.Equal(c, name, "/"+newName, "Failed to rename container") } -func (s *DockerSuite) TestContainerAPIKill(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIKill(c *testing.T) { name := "test-api-kill" runSleepingContainer(c, "-i", "--name", name) @@ -906,7 +906,7 @@ func (s *DockerSuite) TestContainerAPIKill(c *testing.T) { assert.Equal(c, state, "false", fmt.Sprintf("got wrong State from container %s: %q", name, state)) } -func (s *DockerSuite) TestContainerAPIRestart(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIRestart(c *testing.T) { name := "test-api-restart" runSleepingContainer(c, "-di", "--name", name) cli, err := client.NewClientWithOpts(client.FromEnv) @@ -920,7 +920,7 @@ func (s *DockerSuite) TestContainerAPIRestart(c *testing.T) { assert.Assert(c, waitInspect(name, "{{ .State.Restarting }} {{ .State.Running }}", "false true", 15*time.Second) == nil) } -func (s *DockerSuite) TestContainerAPIRestartNotimeoutParam(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIRestartNotimeoutParam(c *testing.T) { name := "test-api-restart-no-timeout-param" out := runSleepingContainer(c, "-di", "--name", name) id := strings.TrimSpace(out) @@ -936,7 +936,7 @@ func (s *DockerSuite) TestContainerAPIRestartNotimeoutParam(c *testing.T) { assert.Assert(c, waitInspect(name, "{{ .State.Restarting }} {{ .State.Running }}", "false true", 15*time.Second) == nil) } -func (s *DockerSuite) TestContainerAPIStart(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIStart(c *testing.T) { name := "testing-start" config := container.Config{ Image: "busybox", @@ -962,7 +962,7 @@ func (s *DockerSuite) TestContainerAPIStart(c *testing.T) { // TODO(tibor): figure out why this doesn't work on windows } -func (s *DockerSuite) TestContainerAPIStop(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIStop(c *testing.T) { name := "test-api-stop" runSleepingContainer(c, "-i", "--name", name) timeout := 30 @@ -985,7 +985,7 @@ func (s *DockerSuite) TestContainerAPIStop(c *testing.T) { assert.NilError(c, err) } -func (s *DockerSuite) TestContainerAPIWait(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIWait(c *testing.T) { name := "test-api-wait" sleepCmd := "/bin/sleep" @@ -1008,7 +1008,7 @@ func (s *DockerSuite) TestContainerAPIWait(c *testing.T) { } } -func (s *DockerSuite) TestContainerAPICopyNotExistsAnyMore(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPICopyNotExistsAnyMore(c *testing.T) { name := "test-container-api-copy" dockerCmd(c, "run", "--name", name, "busybox", "touch", "/test.txt") @@ -1021,7 +1021,7 @@ func (s *DockerSuite) TestContainerAPICopyNotExistsAnyMore(c *testing.T) { assert.Equal(c, res.StatusCode, http.StatusNotFound) } -func (s *DockerSuite) TestContainerAPICopyPre124(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPICopyPre124(c *testing.T) { testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later name := "test-container-api-copy" dockerCmd(c, "run", "--name", name, "busybox", "touch", "/test.txt") @@ -1051,7 +1051,7 @@ func (s *DockerSuite) TestContainerAPICopyPre124(c *testing.T) { assert.Assert(c, found) } -func (s *DockerSuite) TestContainerAPICopyResourcePathEmptyPre124(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPICopyResourcePathEmptyPre124(c *testing.T) { testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later name := "test-container-api-copy-resource-empty" dockerCmd(c, "run", "--name", name, "busybox", "touch", "/test.txt") @@ -1073,7 +1073,7 @@ func (s *DockerSuite) TestContainerAPICopyResourcePathEmptyPre124(c *testing.T) } -func (s *DockerSuite) TestContainerAPICopyResourcePathNotFoundPre124(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPICopyResourcePathNotFoundPre124(c *testing.T) { testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later name := "test-container-api-copy-resource-not-found" dockerCmd(c, "run", "--name", name, "busybox") @@ -1095,7 +1095,7 @@ func (s *DockerSuite) TestContainerAPICopyResourcePathNotFoundPre124(c *testing. } -func (s *DockerSuite) TestContainerAPICopyContainerNotFoundPr124(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPICopyContainerNotFoundPr124(c *testing.T) { testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later postData := types.CopyConfig{ Resource: "/something", @@ -1106,7 +1106,7 @@ func (s *DockerSuite) TestContainerAPICopyContainerNotFoundPr124(c *testing.T) { assert.Equal(c, res.StatusCode, http.StatusNotFound) } -func (s *DockerSuite) TestContainerAPIDelete(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIDelete(c *testing.T) { out := runSleepingContainer(c) id := strings.TrimSpace(out) @@ -1122,7 +1122,7 @@ func (s *DockerSuite) TestContainerAPIDelete(c *testing.T) { assert.NilError(c, err) } -func (s *DockerSuite) TestContainerAPIDeleteNotExist(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIDeleteNotExist(c *testing.T) { cli, err := client.NewClientWithOpts(client.FromEnv) assert.NilError(c, err) defer cli.Close() @@ -1131,7 +1131,7 @@ func (s *DockerSuite) TestContainerAPIDeleteNotExist(c *testing.T) { assert.ErrorContains(c, err, "No such container: doesnotexist") } -func (s *DockerSuite) TestContainerAPIDeleteForce(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIDeleteForce(c *testing.T) { out := runSleepingContainer(c) id := strings.TrimSpace(out) assert.NilError(c, waitRun(id)) @@ -1148,7 +1148,7 @@ func (s *DockerSuite) TestContainerAPIDeleteForce(c *testing.T) { assert.NilError(c, err) } -func (s *DockerSuite) TestContainerAPIDeleteRemoveLinks(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIDeleteRemoveLinks(c *testing.T) { // Windows does not support links testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "-d", "--name", "tlink1", "busybox", "top") @@ -1179,7 +1179,7 @@ func (s *DockerSuite) TestContainerAPIDeleteRemoveLinks(c *testing.T) { assert.Equal(c, linksPostRm, "null", "call to api deleteContainer links should have removed the specified links") } -func (s *DockerSuite) TestContainerAPIDeleteConflict(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIDeleteConflict(c *testing.T) { out := runSleepingContainer(c) id := strings.TrimSpace(out) @@ -1194,7 +1194,7 @@ func (s *DockerSuite) TestContainerAPIDeleteConflict(c *testing.T) { assert.ErrorContains(c, err, expected) } -func (s *DockerSuite) TestContainerAPIDeleteRemoveVolume(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIDeleteRemoveVolume(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon) vol := "/testvolume" @@ -1229,7 +1229,7 @@ func (s *DockerSuite) TestContainerAPIDeleteRemoveVolume(c *testing.T) { } // Regression test for https://github.com/docker/docker/issues/6231 -func (s *DockerSuite) TestContainerAPIChunkedEncoding(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIChunkedEncoding(c *testing.T) { config := map[string]interface{}{ "Image": "busybox", @@ -1249,7 +1249,7 @@ func (s *DockerSuite) TestContainerAPIChunkedEncoding(c *testing.T) { assert.Equal(c, resp.StatusCode, http.StatusCreated) } -func (s *DockerSuite) TestContainerAPIPostContainerStop(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIPostContainerStop(c *testing.T) { out := runSleepingContainer(c) containerID := strings.TrimSpace(out) @@ -1265,7 +1265,7 @@ func (s *DockerSuite) TestContainerAPIPostContainerStop(c *testing.T) { } // #14170 -func (s *DockerSuite) TestPostContainerAPICreateWithStringOrSliceEntrypoint(c *testing.T) { +func (s *DockerAPISuite) TestPostContainerAPICreateWithStringOrSliceEntrypoint(c *testing.T) { config := container.Config{ Image: "busybox", Entrypoint: []string{"echo"}, @@ -1293,7 +1293,7 @@ func (s *DockerSuite) TestPostContainerAPICreateWithStringOrSliceEntrypoint(c *t } // #14170 -func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCmd(c *testing.T) { +func (s *DockerAPISuite) TestPostContainersCreateWithStringOrSliceCmd(c *testing.T) { config := container.Config{ Image: "busybox", Cmd: []string{"echo", "hello", "world"}, @@ -1322,7 +1322,7 @@ func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCmd(c *testing.T) // regression #14318 // for backward compatibility testing with and without CAP_ prefix // and with upper and lowercase -func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCapAddDrop(c *testing.T) { +func (s *DockerAPISuite) TestPostContainersCreateWithStringOrSliceCapAddDrop(c *testing.T) { // Windows doesn't support CapAdd/CapDrop testRequires(c, DaemonIsLinux) config := struct { @@ -1351,7 +1351,7 @@ func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCapAddDrop(c *tes } // #14915 -func (s *DockerSuite) TestContainerAPICreateNoHostConfig118(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPICreateNoHostConfig118(c *testing.T) { testRequires(c, DaemonIsLinux) // Windows only support 1.25 or later config := container.Config{ Image: "busybox", @@ -1367,7 +1367,7 @@ func (s *DockerSuite) TestContainerAPICreateNoHostConfig118(c *testing.T) { // Ensure an error occurs when you have a container read-only rootfs but you // extract an archive to a symlink in a writable volume which points to a // directory outside of the volume. -func (s *DockerSuite) TestPutContainerArchiveErrSymlinkInVolumeToReadOnlyRootfs(c *testing.T) { +func (s *DockerAPISuite) TestPutContainerArchiveErrSymlinkInVolumeToReadOnlyRootfs(c *testing.T) { // Windows does not support read-only rootfs // Requires local volume mount bind. // --read-only + userns has remount issues @@ -1393,7 +1393,7 @@ func (s *DockerSuite) TestPutContainerArchiveErrSymlinkInVolumeToReadOnlyRootfs( assert.ErrorContains(c, err, "container rootfs is marked read-only") } -func (s *DockerSuite) TestPostContainersCreateWithWrongCpusetValues(c *testing.T) { +func (s *DockerAPISuite) TestPostContainersCreateWithWrongCpusetValues(c *testing.T) { // Not supported on Windows testRequires(c, DaemonIsLinux) @@ -1426,7 +1426,7 @@ func (s *DockerSuite) TestPostContainersCreateWithWrongCpusetValues(c *testing.T assert.ErrorContains(c, err, expected) } -func (s *DockerSuite) TestPostContainersCreateShmSizeNegative(c *testing.T) { +func (s *DockerAPISuite) TestPostContainersCreateShmSizeNegative(c *testing.T) { // ShmSize is not supported on Windows testRequires(c, DaemonIsLinux) config := container.Config{ @@ -1444,7 +1444,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeNegative(c *testing.T) { assert.ErrorContains(c, err, "SHM size can not be less than 0") } -func (s *DockerSuite) TestPostContainersCreateShmSizeHostConfigOmitted(c *testing.T) { +func (s *DockerAPISuite) TestPostContainersCreateShmSizeHostConfigOmitted(c *testing.T) { // ShmSize is not supported on Windows testRequires(c, DaemonIsLinux) @@ -1472,7 +1472,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeHostConfigOmitted(c *testin } } -func (s *DockerSuite) TestPostContainersCreateShmSizeOmitted(c *testing.T) { +func (s *DockerAPISuite) TestPostContainersCreateShmSizeOmitted(c *testing.T) { // ShmSize is not supported on Windows testRequires(c, DaemonIsLinux) config := container.Config{ @@ -1499,7 +1499,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeOmitted(c *testing.T) { } } -func (s *DockerSuite) TestPostContainersCreateWithShmSize(c *testing.T) { +func (s *DockerAPISuite) TestPostContainersCreateWithShmSize(c *testing.T) { // ShmSize is not supported on Windows testRequires(c, DaemonIsLinux) config := container.Config{ @@ -1530,7 +1530,7 @@ func (s *DockerSuite) TestPostContainersCreateWithShmSize(c *testing.T) { } } -func (s *DockerSuite) TestPostContainersCreateMemorySwappinessHostConfigOmitted(c *testing.T) { +func (s *DockerAPISuite) TestPostContainersCreateMemorySwappinessHostConfigOmitted(c *testing.T) { // Swappiness is not supported on Windows testRequires(c, DaemonIsLinux) config := container.Config{ @@ -1555,7 +1555,7 @@ func (s *DockerSuite) TestPostContainersCreateMemorySwappinessHostConfigOmitted( } // check validation is done daemon side and not only in cli -func (s *DockerSuite) TestPostContainersCreateWithOomScoreAdjInvalidRange(c *testing.T) { +func (s *DockerAPISuite) TestPostContainersCreateWithOomScoreAdjInvalidRange(c *testing.T) { // OomScoreAdj is not supported on Windows testRequires(c, DaemonIsLinux) @@ -1589,7 +1589,7 @@ func (s *DockerSuite) TestPostContainersCreateWithOomScoreAdjInvalidRange(c *tes } // test case for #22210 where an empty container name caused panic. -func (s *DockerSuite) TestContainerAPIDeleteWithEmptyName(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIDeleteWithEmptyName(c *testing.T) { cli, err := client.NewClientWithOpts(client.FromEnv) assert.NilError(c, err) defer cli.Close() @@ -1598,7 +1598,7 @@ func (s *DockerSuite) TestContainerAPIDeleteWithEmptyName(c *testing.T) { assert.Check(c, errdefs.IsNotFound(err)) } -func (s *DockerSuite) TestContainerAPIStatsWithNetworkDisabled(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPIStatsWithNetworkDisabled(c *testing.T) { // Problematic on Windows as Windows does not support stats testRequires(c, DaemonIsLinux) @@ -1647,7 +1647,7 @@ func (s *DockerSuite) TestContainerAPIStatsWithNetworkDisabled(c *testing.T) { } } -func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) { +func (s *DockerAPISuite) TestContainersAPICreateMountsValidation(c *testing.T) { type testCase struct { config container.Config hostConfig container.HostConfig @@ -1940,7 +1940,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) { } } -func (s *DockerSuite) TestContainerAPICreateMountsBindRead(c *testing.T) { +func (s *DockerAPISuite) TestContainerAPICreateMountsBindRead(c *testing.T) { testRequires(c, NotUserNamespace, testEnv.IsLocalDaemon) // also with data in the host side prefix, slash := getPrefixAndSlashFromDaemonPlatform() @@ -1971,7 +1971,7 @@ func (s *DockerSuite) TestContainerAPICreateMountsBindRead(c *testing.T) { } // Test Mounts comes out as expected for the MountPoint -func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *testing.T) { +func (s *DockerAPISuite) TestContainersAPICreateMountsCreate(c *testing.T) { prefix, slash := getPrefixAndSlashFromDaemonPlatform() destPath := prefix + slash + "foo" @@ -2180,7 +2180,7 @@ func containerExit(apiclient client.APIClient, name string) func(poll.LogT) poll } } -func (s *DockerSuite) TestContainersAPICreateMountsTmpfs(c *testing.T) { +func (s *DockerAPISuite) TestContainersAPICreateMountsTmpfs(c *testing.T) { testRequires(c, DaemonIsLinux) type testCase struct { cfg mount.Mount @@ -2230,7 +2230,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsTmpfs(c *testing.T) { // Regression test for #33334 // Makes sure that when a container which has a custom stop signal + restart=always // gets killed (with SIGKILL) by the kill API, that the restart policy is cancelled. -func (s *DockerSuite) TestContainerKillCustomStopSignal(c *testing.T) { +func (s *DockerAPISuite) TestContainerKillCustomStopSignal(c *testing.T) { id := strings.TrimSpace(runSleepingContainer(c, "--stop-signal=SIGTERM", "--restart=always")) res, _, err := request.Post("/containers/" + id + "/kill") assert.NilError(c, err) diff --git a/integration-cli/docker_api_containers_windows_test.go b/integration-cli/docker_api_containers_windows_test.go index 8d4d4e20e7..88c2303c62 100644 --- a/integration-cli/docker_api_containers_windows_test.go +++ b/integration-cli/docker_api_containers_windows_test.go @@ -20,7 +20,7 @@ import ( is "gotest.tools/v3/assert/cmp" ) -func (s *DockerSuite) TestContainersAPICreateMountsBindNamedPipe(c *testing.T) { +func (s *DockerAPISuite) TestContainersAPICreateMountsBindNamedPipe(c *testing.T) { // Create a host pipe to map into the container hostPipeName := fmt.Sprintf(`\\.\pipe\docker-cli-test-pipe-%x`, rand.Uint64()) pc := &winio.PipeConfig{ diff --git a/integration-cli/docker_api_exec_resize_test.go b/integration-cli/docker_api_exec_resize_test.go index beff0adff9..21eddc4e11 100644 --- a/integration-cli/docker_api_exec_resize_test.go +++ b/integration-cli/docker_api_exec_resize_test.go @@ -16,7 +16,7 @@ import ( "gotest.tools/v3/assert" ) -func (s *DockerSuite) TestExecResizeAPIHeightWidthNoInt(c *testing.T) { +func (s *DockerAPISuite) TestExecResizeAPIHeightWidthNoInt(c *testing.T) { testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "-d", "busybox", "top") cleanedContainerID := strings.TrimSpace(out) @@ -32,7 +32,7 @@ func (s *DockerSuite) TestExecResizeAPIHeightWidthNoInt(c *testing.T) { } // Part of #14845 -func (s *DockerSuite) TestExecResizeImmediatelyAfterExecStart(c *testing.T) { +func (s *DockerAPISuite) TestExecResizeImmediatelyAfterExecStart(c *testing.T) { name := "exec_resize_test" dockerCmd(c, "run", "-d", "-i", "-t", "--name", name, "--restart", "always", "busybox", "/bin/sh") diff --git a/integration-cli/docker_api_exec_test.go b/integration-cli/docker_api_exec_test.go index 5d4dd2d2ab..09cde5411a 100644 --- a/integration-cli/docker_api_exec_test.go +++ b/integration-cli/docker_api_exec_test.go @@ -23,7 +23,7 @@ import ( ) // Regression test for #9414 -func (s *DockerSuite) TestExecAPICreateNoCmd(c *testing.T) { +func (s *DockerAPISuite) TestExecAPICreateNoCmd(c *testing.T) { name := "exec_test" dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh") @@ -39,7 +39,7 @@ func (s *DockerSuite) TestExecAPICreateNoCmd(c *testing.T) { assert.Assert(c, strings.Contains(getErrorMessage(c, b), "No exec command specified"), "Expected message when creating exec command with no Cmd specified") } -func (s *DockerSuite) TestExecAPICreateNoValidContentType(c *testing.T) { +func (s *DockerAPISuite) TestExecAPICreateNoValidContentType(c *testing.T) { name := "exec_test" dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh") @@ -60,7 +60,7 @@ func (s *DockerSuite) TestExecAPICreateNoValidContentType(c *testing.T) { assert.Assert(c, is.Contains(getErrorMessage(c, b), "unsupported Content-Type header (test/plain): must be 'application/json'")) } -func (s *DockerSuite) TestExecAPICreateContainerPaused(c *testing.T) { +func (s *DockerAPISuite) TestExecAPICreateContainerPaused(c *testing.T) { // Not relevant on Windows as Windows containers cannot be paused testRequires(c, DaemonIsLinux) name := "exec_create_test" @@ -79,7 +79,7 @@ func (s *DockerSuite) TestExecAPICreateContainerPaused(c *testing.T) { assert.ErrorContains(c, err, "Container "+name+" is paused, unpause the container before exec", "Expected message when creating exec command with Container %s is paused", name) } -func (s *DockerSuite) TestExecAPIStart(c *testing.T) { +func (s *DockerAPISuite) TestExecAPIStart(c *testing.T) { testRequires(c, DaemonIsLinux) // Uses pause/unpause but bits may be salvageable to Windows to Windows CI dockerCmd(c, "run", "-d", "--name", "test", "busybox", "top") @@ -106,7 +106,7 @@ func (s *DockerSuite) TestExecAPIStart(c *testing.T) { startExec(c, id, http.StatusOK) } -func (s *DockerSuite) TestExecAPIStartEnsureHeaders(c *testing.T) { +func (s *DockerAPISuite) TestExecAPIStartEnsureHeaders(c *testing.T) { testRequires(c, DaemonIsLinux) dockerCmd(c, "run", "-d", "--name", "test", "busybox", "top") @@ -116,7 +116,7 @@ func (s *DockerSuite) TestExecAPIStartEnsureHeaders(c *testing.T) { assert.Assert(c, resp.Header.Get("Server") != "") } -func (s *DockerSuite) TestExecAPIStartBackwardsCompatible(c *testing.T) { +func (s *DockerAPISuite) TestExecAPIStartBackwardsCompatible(c *testing.T) { testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later runSleepingContainer(c, "-d", "--name", "test") id := createExec(c, "test") @@ -131,7 +131,7 @@ func (s *DockerSuite) TestExecAPIStartBackwardsCompatible(c *testing.T) { } // #19362 -func (s *DockerSuite) TestExecAPIStartMultipleTimesError(c *testing.T) { +func (s *DockerAPISuite) TestExecAPIStartMultipleTimesError(c *testing.T) { runSleepingContainer(c, "-d", "--name", "test") execID := createExec(c, "test") startExec(c, execID, http.StatusOK) @@ -141,7 +141,7 @@ func (s *DockerSuite) TestExecAPIStartMultipleTimesError(c *testing.T) { } // #20638 -func (s *DockerSuite) TestExecAPIStartWithDetach(c *testing.T) { +func (s *DockerAPISuite) TestExecAPIStartWithDetach(c *testing.T) { name := "foo" runSleepingContainer(c, "-d", "-t", "--name", name) @@ -172,7 +172,7 @@ func (s *DockerSuite) TestExecAPIStartWithDetach(c *testing.T) { } // #30311 -func (s *DockerSuite) TestExecAPIStartValidCommand(c *testing.T) { +func (s *DockerAPISuite) TestExecAPIStartValidCommand(c *testing.T) { name := "exec_test" dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh") @@ -188,7 +188,7 @@ func (s *DockerSuite) TestExecAPIStartValidCommand(c *testing.T) { } // #30311 -func (s *DockerSuite) TestExecAPIStartInvalidCommand(c *testing.T) { +func (s *DockerAPISuite) TestExecAPIStartInvalidCommand(c *testing.T) { name := "exec_test" dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh") @@ -206,7 +206,7 @@ func (s *DockerSuite) TestExecAPIStartInvalidCommand(c *testing.T) { assert.Assert(c, inspectJSON.ExecIDs == nil) } -func (s *DockerSuite) TestExecStateCleanup(c *testing.T) { +func (s *DockerAPISuite) TestExecStateCleanup(c *testing.T) { testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) // This test checks accidental regressions. Not part of stable API. diff --git a/integration-cli/docker_api_images_test.go b/integration-cli/docker_api_images_test.go index f6c2de77de..c4010e3777 100644 --- a/integration-cli/docker_api_images_test.go +++ b/integration-cli/docker_api_images_test.go @@ -16,7 +16,7 @@ import ( "gotest.tools/v3/assert" ) -func (s *DockerSuite) TestAPIImagesFilter(c *testing.T) { +func (s *DockerAPISuite) TestAPIImagesFilter(c *testing.T) { cli, err := client.NewClientWithOpts(client.FromEnv) assert.NilError(c, err) defer cli.Close() @@ -54,7 +54,7 @@ func (s *DockerSuite) TestAPIImagesFilter(c *testing.T) { assert.Equal(c, len(images[0].RepoTags), 1) } -func (s *DockerSuite) TestAPIImagesSaveAndLoad(c *testing.T) { +func (s *DockerAPISuite) TestAPIImagesSaveAndLoad(c *testing.T) { testRequires(c, Network) buildImageSuccessfully(c, "saveandload", build.WithDockerfile("FROM busybox\nENV FOO bar")) id := getIDByName(c, "saveandload") @@ -75,7 +75,7 @@ func (s *DockerSuite) TestAPIImagesSaveAndLoad(c *testing.T) { assert.Equal(c, strings.TrimSpace(inspectOut), id, "load did not work properly") } -func (s *DockerSuite) TestAPIImagesDelete(c *testing.T) { +func (s *DockerAPISuite) TestAPIImagesDelete(c *testing.T) { cli, err := client.NewClientWithOpts(client.FromEnv) assert.NilError(c, err) defer cli.Close() @@ -99,7 +99,7 @@ func (s *DockerSuite) TestAPIImagesDelete(c *testing.T) { assert.NilError(c, err) } -func (s *DockerSuite) TestAPIImagesHistory(c *testing.T) { +func (s *DockerAPISuite) TestAPIImagesHistory(c *testing.T) { cli, err := client.NewClientWithOpts(client.FromEnv) assert.NilError(c, err) defer cli.Close() @@ -125,7 +125,7 @@ func (s *DockerSuite) TestAPIImagesHistory(c *testing.T) { assert.Assert(c, found) } -func (s *DockerSuite) TestAPIImagesImportBadSrc(c *testing.T) { +func (s *DockerAPISuite) TestAPIImagesImportBadSrc(c *testing.T) { testRequires(c, Network, testEnv.IsLocalDaemon) server := httptest.NewServer(http.NewServeMux()) @@ -151,7 +151,7 @@ func (s *DockerSuite) TestAPIImagesImportBadSrc(c *testing.T) { } // #14846 -func (s *DockerSuite) TestAPIImagesSearchJSONContentType(c *testing.T) { +func (s *DockerAPISuite) TestAPIImagesSearchJSONContentType(c *testing.T) { testRequires(c, Network) res, b, err := request.Get("/images/search?term=test", request.JSON) @@ -163,7 +163,7 @@ func (s *DockerSuite) TestAPIImagesSearchJSONContentType(c *testing.T) { // Test case for 30027: image size reported as -1 in v1.12 client against v1.13 daemon. // This test checks to make sure both v1.12 and v1.13 client against v1.13 daemon get correct `Size` after the fix. -func (s *DockerSuite) TestAPIImagesSizeCompatibility(c *testing.T) { +func (s *DockerAPISuite) TestAPIImagesSizeCompatibility(c *testing.T) { apiclient := testEnv.APIClient() defer apiclient.Close() diff --git a/integration-cli/docker_api_inspect_test.go b/integration-cli/docker_api_inspect_test.go index 2334bcf60e..577836e22f 100644 --- a/integration-cli/docker_api_inspect_test.go +++ b/integration-cli/docker_api_inspect_test.go @@ -13,7 +13,7 @@ import ( is "gotest.tools/v3/assert/cmp" ) -func (s *DockerSuite) TestInspectAPIContainerResponse(c *testing.T) { +func (s *DockerAPISuite) TestInspectAPIContainerResponse(c *testing.T) { out, _ := dockerCmd(c, "run", "-d", "busybox", "true") cleanedContainerID := strings.TrimSpace(out) @@ -57,7 +57,7 @@ func (s *DockerSuite) TestInspectAPIContainerResponse(c *testing.T) { } } -func (s *DockerSuite) TestInspectAPIContainerVolumeDriverLegacy(c *testing.T) { +func (s *DockerAPISuite) TestInspectAPIContainerVolumeDriverLegacy(c *testing.T) { // No legacy implications for Windows testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "-d", "busybox", "true") @@ -80,7 +80,7 @@ func (s *DockerSuite) TestInspectAPIContainerVolumeDriverLegacy(c *testing.T) { } } -func (s *DockerSuite) TestInspectAPIContainerVolumeDriver(c *testing.T) { +func (s *DockerAPISuite) TestInspectAPIContainerVolumeDriver(c *testing.T) { out, _ := dockerCmd(c, "run", "-d", "--volume-driver", "local", "busybox", "true") cleanedContainerID := strings.TrimSpace(out) @@ -104,7 +104,7 @@ func (s *DockerSuite) TestInspectAPIContainerVolumeDriver(c *testing.T) { assert.Assert(c, ok, "API version 1.25 expected to include VolumeDriver in 'HostConfig'") } -func (s *DockerSuite) TestInspectAPIImageResponse(c *testing.T) { +func (s *DockerAPISuite) TestInspectAPIImageResponse(c *testing.T) { dockerCmd(c, "tag", "busybox:latest", "busybox:mytag") cli, err := client.NewClientWithOpts(client.FromEnv) assert.NilError(c, err) @@ -119,7 +119,7 @@ func (s *DockerSuite) TestInspectAPIImageResponse(c *testing.T) { } // #17131, #17139, #17173 -func (s *DockerSuite) TestInspectAPIEmptyFieldsInConfigPre121(c *testing.T) { +func (s *DockerAPISuite) TestInspectAPIEmptyFieldsInConfigPre121(c *testing.T) { // Not relevant on Windows testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "-d", "busybox", "true") @@ -143,7 +143,7 @@ func (s *DockerSuite) TestInspectAPIEmptyFieldsInConfigPre121(c *testing.T) { } } -func (s *DockerSuite) TestInspectAPIBridgeNetworkSettings120(c *testing.T) { +func (s *DockerAPISuite) TestInspectAPIBridgeNetworkSettings120(c *testing.T) { // Not relevant on Windows, and besides it doesn't have any bridge network settings testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "-d", "busybox", "top") @@ -160,7 +160,7 @@ func (s *DockerSuite) TestInspectAPIBridgeNetworkSettings120(c *testing.T) { assert.Assert(c, len(settings.IPAddress) != 0) } -func (s *DockerSuite) TestInspectAPIBridgeNetworkSettings121(c *testing.T) { +func (s *DockerAPISuite) TestInspectAPIBridgeNetworkSettings121(c *testing.T) { // Windows doesn't have any bridge network settings testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "-d", "busybox", "top") diff --git a/integration-cli/docker_api_logs_test.go b/integration-cli/docker_api_logs_test.go index e4a845e70f..737e00862a 100644 --- a/integration-cli/docker_api_logs_test.go +++ b/integration-cli/docker_api_logs_test.go @@ -19,7 +19,7 @@ import ( "gotest.tools/v3/assert" ) -func (s *DockerSuite) TestLogsAPIWithStdout(c *testing.T) { +func (s *DockerAPISuite) TestLogsAPIWithStdout(c *testing.T) { out, _ := dockerCmd(c, "run", "-d", "-t", "busybox", "/bin/sh", "-c", "while true; do echo hello; sleep 1; done") id := strings.TrimSpace(out) assert.NilError(c, waitRun(id)) @@ -55,7 +55,7 @@ func (s *DockerSuite) TestLogsAPIWithStdout(c *testing.T) { } } -func (s *DockerSuite) TestLogsAPINoStdoutNorStderr(c *testing.T) { +func (s *DockerAPISuite) TestLogsAPINoStdoutNorStderr(c *testing.T) { name := "logs_test" dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh") cli, err := client.NewClientWithOpts(client.FromEnv) @@ -67,7 +67,7 @@ func (s *DockerSuite) TestLogsAPINoStdoutNorStderr(c *testing.T) { } // Regression test for #12704 -func (s *DockerSuite) TestLogsAPIFollowEmptyOutput(c *testing.T) { +func (s *DockerAPISuite) TestLogsAPIFollowEmptyOutput(c *testing.T) { name := "logs_test" t0 := time.Now() dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "sleep", "10") @@ -82,14 +82,14 @@ func (s *DockerSuite) TestLogsAPIFollowEmptyOutput(c *testing.T) { } } -func (s *DockerSuite) TestLogsAPIContainerNotFound(c *testing.T) { +func (s *DockerAPISuite) TestLogsAPIContainerNotFound(c *testing.T) { name := "nonExistentContainer" resp, _, err := request.Get(fmt.Sprintf("/containers/%s/logs?follow=1&stdout=1&stderr=1&tail=all", name)) assert.NilError(c, err) assert.Equal(c, resp.StatusCode, http.StatusNotFound) } -func (s *DockerSuite) TestLogsAPIUntilFutureFollow(c *testing.T) { +func (s *DockerAPISuite) TestLogsAPIUntilFutureFollow(c *testing.T) { testRequires(c, DaemonIsLinux) name := "logsuntilfuturefollow" dockerCmd(c, "run", "-d", "--name", name, "busybox", "/bin/sh", "-c", "while true; do date +%s; sleep 1; done") @@ -157,7 +157,7 @@ func (s *DockerSuite) TestLogsAPIUntilFutureFollow(c *testing.T) { } } -func (s *DockerSuite) TestLogsAPIUntil(c *testing.T) { +func (s *DockerAPISuite) TestLogsAPIUntil(c *testing.T) { testRequires(c, MinimumAPIVersion("1.34")) name := "logsuntil" dockerCmd(c, "run", "--name", name, "busybox", "/bin/sh", "-c", "for i in $(seq 1 3); do echo log$i; sleep 1; done") @@ -195,7 +195,7 @@ func (s *DockerSuite) TestLogsAPIUntil(c *testing.T) { assert.Assert(c, !strings.Contains(logsString, "log3"), "unexpected log message returned, until=%v", until) } -func (s *DockerSuite) TestLogsAPIUntilDefaultValue(c *testing.T) { +func (s *DockerAPISuite) TestLogsAPIUntilDefaultValue(c *testing.T) { name := "logsuntildefaultval" dockerCmd(c, "run", "--name", name, "busybox", "/bin/sh", "-c", "for i in $(seq 1 3); do echo log$i; done") diff --git a/integration-cli/docker_api_network_test.go b/integration-cli/docker_api_network_test.go index 716901b8ad..383837c470 100644 --- a/integration-cli/docker_api_network_test.go +++ b/integration-cli/docker_api_network_test.go @@ -17,7 +17,7 @@ import ( "gotest.tools/v3/assert" ) -func (s *DockerSuite) TestAPINetworkGetDefaults(c *testing.T) { +func (s *DockerAPISuite) TestAPINetworkGetDefaults(c *testing.T) { testRequires(c, DaemonIsLinux) // By default docker daemon creates 3 networks. check if they are present defaults := []string{"bridge", "host", "none"} @@ -26,7 +26,7 @@ func (s *DockerSuite) TestAPINetworkGetDefaults(c *testing.T) { } } -func (s *DockerSuite) TestAPINetworkCreateCheckDuplicate(c *testing.T) { +func (s *DockerAPISuite) TestAPINetworkCreateCheckDuplicate(c *testing.T) { testRequires(c, DaemonIsLinux) name := "testcheckduplicate" configOnCheck := types.NetworkCreateRequest{ @@ -64,13 +64,13 @@ func (s *DockerSuite) TestAPINetworkCreateCheckDuplicate(c *testing.T) { createNetwork(c, configNotCheck, http.StatusCreated) } -func (s *DockerSuite) TestAPINetworkFilter(c *testing.T) { +func (s *DockerAPISuite) TestAPINetworkFilter(c *testing.T) { testRequires(c, DaemonIsLinux) nr := getNetworkResource(c, getNetworkIDByName(c, "bridge")) assert.Equal(c, nr.Name, "bridge") } -func (s *DockerSuite) TestAPINetworkInspectBridge(c *testing.T) { +func (s *DockerAPISuite) TestAPINetworkInspectBridge(c *testing.T) { testRequires(c, DaemonIsLinux) // Inspect default bridge network nr := getNetworkResource(c, "bridge") @@ -96,7 +96,7 @@ func (s *DockerSuite) TestAPINetworkInspectBridge(c *testing.T) { assert.Equal(c, ip.String(), containerIP) } -func (s *DockerSuite) TestAPINetworkInspectUserDefinedNetwork(c *testing.T) { +func (s *DockerAPISuite) TestAPINetworkInspectUserDefinedNetwork(c *testing.T) { testRequires(c, DaemonIsLinux) // IPAM configuration inspect ipam := &network.IPAM{ @@ -127,7 +127,7 @@ func (s *DockerSuite) TestAPINetworkInspectUserDefinedNetwork(c *testing.T) { assert.Assert(c, !isNetworkAvailable(c, "br0")) } -func (s *DockerSuite) TestAPINetworkConnectDisconnect(c *testing.T) { +func (s *DockerAPISuite) TestAPINetworkConnectDisconnect(c *testing.T) { testRequires(c, DaemonIsLinux) // Create test network name := "testnetwork" @@ -169,7 +169,7 @@ func (s *DockerSuite) TestAPINetworkConnectDisconnect(c *testing.T) { deleteNetwork(c, nr.ID, true) } -func (s *DockerSuite) TestAPINetworkIPAMMultipleBridgeNetworks(c *testing.T) { +func (s *DockerAPISuite) TestAPINetworkIPAMMultipleBridgeNetworks(c *testing.T) { testRequires(c, DaemonIsLinux) // test0 bridge network ipam0 := &network.IPAM{ @@ -238,7 +238,7 @@ func (s *DockerSuite) TestAPINetworkIPAMMultipleBridgeNetworks(c *testing.T) { } } -func (s *DockerSuite) TestAPICreateDeletePredefinedNetworks(c *testing.T) { +func (s *DockerAPISuite) TestAPICreateDeletePredefinedNetworks(c *testing.T) { testRequires(c, DaemonIsLinux, SwarmInactive) createDeletePredefinedNetwork(c, "bridge") createDeletePredefinedNetwork(c, "none") diff --git a/integration-cli/docker_api_stats_test.go b/integration-cli/docker_api_stats_test.go index bbb37bbd97..6f6f831d83 100644 --- a/integration-cli/docker_api_stats_test.go +++ b/integration-cli/docker_api_stats_test.go @@ -23,7 +23,7 @@ import ( var expectedNetworkInterfaceStats = strings.Split("rx_bytes rx_dropped rx_errors rx_packets tx_bytes tx_dropped tx_errors tx_packets", " ") -func (s *DockerSuite) TestAPIStatsNoStreamGetCpu(c *testing.T) { +func (s *DockerAPISuite) TestAPIStatsNoStreamGetCpu(c *testing.T) { skip.If(c, RuntimeIsWindowsContainerd(), "FIXME: Broken on Windows + containerd combination") out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "while true;usleep 100; do echo 'Hello'; done") @@ -64,7 +64,7 @@ func (s *DockerSuite) TestAPIStatsNoStreamGetCpu(c *testing.T) { assert.Assert(c, cpuPercent != 0.0, "docker stats with no-stream get cpu usage failed: was %v", cpuPercent) } -func (s *DockerSuite) TestAPIStatsStoppedContainerInGoroutines(c *testing.T) { +func (s *DockerAPISuite) TestAPIStatsStoppedContainerInGoroutines(c *testing.T) { out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "echo 1") id := strings.TrimSpace(out) @@ -99,7 +99,7 @@ func (s *DockerSuite) TestAPIStatsStoppedContainerInGoroutines(c *testing.T) { } } -func (s *DockerSuite) TestAPIStatsNetworkStats(c *testing.T) { +func (s *DockerAPISuite) TestAPIStatsNetworkStats(c *testing.T) { skip.If(c, RuntimeIsWindowsContainerd(), "FIXME: Broken on Windows + containerd combination") testRequires(c, testEnv.IsLocalDaemon) @@ -165,7 +165,7 @@ func (s *DockerSuite) TestAPIStatsNetworkStats(c *testing.T) { assert.Assert(c, postRxPackets >= expRxPkts, "Reported less RxPackets than expected. Expected >= %d. Found %d. %s", expRxPkts, postRxPackets, pingouts) } -func (s *DockerSuite) TestAPIStatsNetworkStatsVersioning(c *testing.T) { +func (s *DockerAPISuite) TestAPIStatsNetworkStatsVersioning(c *testing.T) { // Windows doesn't support API versions less than 1.25, so no point testing 1.17 .. 1.21 testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) @@ -260,7 +260,7 @@ func jsonBlobHasGTE121NetworkStats(blob map[string]interface{}) bool { return true } -func (s *DockerSuite) TestAPIStatsContainerNotFound(c *testing.T) { +func (s *DockerAPISuite) TestAPIStatsContainerNotFound(c *testing.T) { testRequires(c, DaemonIsLinux) cli, err := client.NewClientWithOpts(client.FromEnv) assert.NilError(c, err) @@ -274,7 +274,7 @@ func (s *DockerSuite) TestAPIStatsContainerNotFound(c *testing.T) { assert.ErrorContains(c, err, expected) } -func (s *DockerSuite) TestAPIStatsNoStreamConnectedContainers(c *testing.T) { +func (s *DockerAPISuite) TestAPIStatsNoStreamConnectedContainers(c *testing.T) { testRequires(c, DaemonIsLinux) out1 := runSleepingContainer(c) diff --git a/integration-cli/docker_api_test.go b/integration-cli/docker_api_test.go index 6a091bc8a4..36f574833c 100644 --- a/integration-cli/docker_api_test.go +++ b/integration-cli/docker_api_test.go @@ -15,13 +15,25 @@ import ( "gotest.tools/v3/assert" ) -func (s *DockerSuite) TestAPIOptionsRoute(c *testing.T) { +type DockerAPISuite struct { + ds *DockerSuite +} + +func (s *DockerAPISuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerAPISuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + +func (s *DockerAPISuite) TestAPIOptionsRoute(c *testing.T) { resp, _, err := request.Do("/", request.Method(http.MethodOptions)) assert.NilError(c, err) assert.Equal(c, resp.StatusCode, http.StatusOK) } -func (s *DockerSuite) TestAPIGetEnabledCORS(c *testing.T) { +func (s *DockerAPISuite) TestAPIGetEnabledCORS(c *testing.T) { res, body, err := request.Get("/version") assert.NilError(c, err) assert.Equal(c, res.StatusCode, http.StatusOK) @@ -33,7 +45,7 @@ func (s *DockerSuite) TestAPIGetEnabledCORS(c *testing.T) { //assert.Equal(c, res.Header.Get("Access-Control-Allow-Headers"), "Origin, X-Requested-With, Content-Type, Accept, X-Registry-Auth") } -func (s *DockerSuite) TestAPIClientVersionOldNotSupported(c *testing.T) { +func (s *DockerAPISuite) TestAPIClientVersionOldNotSupported(c *testing.T) { if testEnv.OSType != runtime.GOOS { c.Skip("Daemon platform doesn't match test platform") } @@ -57,7 +69,7 @@ func (s *DockerSuite) TestAPIClientVersionOldNotSupported(c *testing.T) { assert.Equal(c, strings.TrimSpace(string(content)), expected) } -func (s *DockerSuite) TestAPIErrorJSON(c *testing.T) { +func (s *DockerAPISuite) TestAPIErrorJSON(c *testing.T) { httpResp, body, err := request.Post("/containers/create", request.JSONBody(struct{}{})) assert.NilError(c, err) if versions.LessThan(testEnv.DaemonAPIVersion(), "1.32") { @@ -71,7 +83,7 @@ func (s *DockerSuite) TestAPIErrorJSON(c *testing.T) { assert.Equal(c, getErrorMessage(c, b), "Config cannot be empty in order to create a container") } -func (s *DockerSuite) TestAPIErrorPlainText(c *testing.T) { +func (s *DockerAPISuite) TestAPIErrorPlainText(c *testing.T) { // Windows requires API 1.25 or later. This test is validating a behaviour which was present // in v1.23, but changed in 1.24, hence not applicable on Windows. See apiVersionSupportsJSONErrors testRequires(c, DaemonIsLinux) @@ -88,7 +100,7 @@ func (s *DockerSuite) TestAPIErrorPlainText(c *testing.T) { assert.Equal(c, strings.TrimSpace(string(b)), "Config cannot be empty in order to create a container") } -func (s *DockerSuite) TestAPIErrorNotFoundJSON(c *testing.T) { +func (s *DockerAPISuite) TestAPIErrorNotFoundJSON(c *testing.T) { // 404 is a different code path to normal errors, so test separately httpResp, body, err := request.Get("/notfound", request.JSON) assert.NilError(c, err) @@ -99,7 +111,7 @@ func (s *DockerSuite) TestAPIErrorNotFoundJSON(c *testing.T) { assert.Equal(c, getErrorMessage(c, b), "page not found") } -func (s *DockerSuite) TestAPIErrorNotFoundPlainText(c *testing.T) { +func (s *DockerAPISuite) TestAPIErrorNotFoundPlainText(c *testing.T) { httpResp, body, err := request.Get("/v1.23/notfound", request.JSON) assert.NilError(c, err) assert.Equal(c, httpResp.StatusCode, http.StatusNotFound) diff --git a/integration-cli/docker_cli_attach_test.go b/integration-cli/docker_cli_attach_test.go index d82565c68e..bd33bb4ded 100644 --- a/integration-cli/docker_cli_attach_test.go +++ b/integration-cli/docker_cli_attach_test.go @@ -18,7 +18,19 @@ import ( const attachWait = 5 * time.Second -func (s *DockerSuite) TestAttachMultipleAndRestart(c *testing.T) { +type DockerCLIAttachSuite struct { + ds *DockerSuite +} + +func (s *DockerCLIAttachSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLIAttachSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + +func (s *DockerCLIAttachSuite) TestAttachMultipleAndRestart(c *testing.T) { endGroup := &sync.WaitGroup{} startGroup := &sync.WaitGroup{} endGroup.Add(3) @@ -88,7 +100,7 @@ func (s *DockerSuite) TestAttachMultipleAndRestart(c *testing.T) { } } -func (s *DockerSuite) TestAttachTTYWithoutStdin(c *testing.T) { +func (s *DockerCLIAttachSuite) TestAttachTTYWithoutStdin(c *testing.T) { // TODO: Figure out how to get this running again reliable on Windows. // It works by accident at the moment. Sometimes. I've gone back to v1.13.0 and see the same. // On Windows, docker run -d -ti busybox causes the container to exit immediately. @@ -133,7 +145,7 @@ func (s *DockerSuite) TestAttachTTYWithoutStdin(c *testing.T) { } } -func (s *DockerSuite) TestAttachDisconnect(c *testing.T) { +func (s *DockerCLIAttachSuite) TestAttachDisconnect(c *testing.T) { testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "-di", "busybox", "/bin/cat") id := strings.TrimSpace(out) @@ -166,7 +178,7 @@ func (s *DockerSuite) TestAttachDisconnect(c *testing.T) { assert.Equal(c, running, "true") } -func (s *DockerSuite) TestAttachPausedContainer(c *testing.T) { +func (s *DockerCLIAttachSuite) TestAttachPausedContainer(c *testing.T) { testRequires(c, IsPausable) runSleepingContainer(c, "-d", "--name=test") dockerCmd(c, "pause", "test") diff --git a/integration-cli/docker_cli_attach_unix_test.go b/integration-cli/docker_cli_attach_unix_test.go index 8dbb55e761..cd19d8a047 100644 --- a/integration-cli/docker_cli_attach_unix_test.go +++ b/integration-cli/docker_cli_attach_unix_test.go @@ -16,7 +16,7 @@ import ( ) // #9860 Make sure attach ends when container ends (with no errors) -func (s *DockerSuite) TestAttachClosedOnContainerStop(c *testing.T) { +func (s *DockerCLIAttachSuite) TestAttachClosedOnContainerStop(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon) out, _ := dockerCmd(c, "run", "-dti", "busybox", "/bin/sh", "-c", `trap 'exit 0' SIGTERM; while true; do sleep 1; done`) @@ -59,7 +59,7 @@ func (s *DockerSuite) TestAttachClosedOnContainerStop(c *testing.T) { } -func (s *DockerSuite) TestAttachAfterDetach(c *testing.T) { +func (s *DockerCLIAttachSuite) TestAttachAfterDetach(c *testing.T) { name := "detachtest" cpty, tty, err := pty.Open() @@ -124,7 +124,7 @@ func (s *DockerSuite) TestAttachAfterDetach(c *testing.T) { } // TestAttachDetach checks that attach in tty mode can be detached using the long container ID -func (s *DockerSuite) TestAttachDetach(c *testing.T) { +func (s *DockerCLIAttachSuite) TestAttachDetach(c *testing.T) { out, _ := dockerCmd(c, "run", "-itd", "busybox", "cat") id := strings.TrimSpace(out) assert.NilError(c, waitRun(id)) diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index e698441f2d..7f18a1d451 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -31,14 +31,26 @@ import ( "gotest.tools/v3/icmd" ) -func (s *DockerSuite) TestBuildJSONEmptyRun(c *testing.T) { +type DockerCLIBuildSuite struct { + ds *DockerSuite +} + +func (s *DockerCLIBuildSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLIBuildSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + +func (s *DockerCLIBuildSuite) TestBuildJSONEmptyRun(c *testing.T) { cli.BuildCmd(c, "testbuildjsonemptyrun", build.WithDockerfile(` FROM busybox RUN [] `)) } -func (s *DockerSuite) TestBuildShCmdJSONEntrypoint(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildShCmdJSONEntrypoint(c *testing.T) { name := "testbuildshcmdjsonentrypoint" expected := "/bin/sh -c echo test" if testEnv.OSType == "windows" { @@ -57,7 +69,7 @@ func (s *DockerSuite) TestBuildShCmdJSONEntrypoint(c *testing.T) { } } -func (s *DockerSuite) TestBuildEnvironmentReplacementUser(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildEnvironmentReplacementUser(c *testing.T) { // Windows does not support FROM scratch or the USER command testRequires(c, DaemonIsLinux) name := "testbuildenvironmentreplacement" @@ -74,7 +86,7 @@ func (s *DockerSuite) TestBuildEnvironmentReplacementUser(c *testing.T) { } } -func (s *DockerSuite) TestBuildEnvironmentReplacementVolume(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildEnvironmentReplacementVolume(c *testing.T) { name := "testbuildenvironmentreplacement" var volumePath string @@ -99,7 +111,7 @@ func (s *DockerSuite) TestBuildEnvironmentReplacementVolume(c *testing.T) { } -func (s *DockerSuite) TestBuildEnvironmentReplacementExpose(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildEnvironmentReplacementExpose(c *testing.T) { // Windows does not support FROM scratch or the EXPOSE command testRequires(c, DaemonIsLinux) name := "testbuildenvironmentreplacement" @@ -124,7 +136,7 @@ func (s *DockerSuite) TestBuildEnvironmentReplacementExpose(c *testing.T) { } -func (s *DockerSuite) TestBuildEnvironmentReplacementWorkdir(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildEnvironmentReplacementWorkdir(c *testing.T) { name := "testbuildenvironmentreplacement" buildImageSuccessfully(c, name, build.WithDockerfile(` @@ -144,7 +156,7 @@ func (s *DockerSuite) TestBuildEnvironmentReplacementWorkdir(c *testing.T) { } } -func (s *DockerSuite) TestBuildEnvironmentReplacementAddCopy(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildEnvironmentReplacementAddCopy(c *testing.T) { name := "testbuildenvironmentreplacement" buildImageSuccessfully(c, name, build.WithBuildContext(c, @@ -168,7 +180,7 @@ func (s *DockerSuite) TestBuildEnvironmentReplacementAddCopy(c *testing.T) { )) } -func (s *DockerSuite) TestBuildEnvironmentReplacementEnv(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildEnvironmentReplacementEnv(c *testing.T) { // ENV expansions work differently in Windows testRequires(c, DaemonIsLinux) name := "testbuildenvironmentreplacement" @@ -231,7 +243,7 @@ func (s *DockerSuite) TestBuildEnvironmentReplacementEnv(c *testing.T) { } -func (s *DockerSuite) TestBuildHandleEscapesInVolume(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildHandleEscapesInVolume(c *testing.T) { // The volume paths used in this test are invalid on Windows testRequires(c, DaemonIsLinux) name := "testbuildhandleescapes" @@ -275,7 +287,7 @@ func (s *DockerSuite) TestBuildHandleEscapesInVolume(c *testing.T) { } } -func (s *DockerSuite) TestBuildOnBuildLowercase(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildOnBuildLowercase(c *testing.T) { name := "testbuildonbuildlowercase" name2 := "testbuildonbuildlowercase2" @@ -299,7 +311,7 @@ func (s *DockerSuite) TestBuildOnBuildLowercase(c *testing.T) { } -func (s *DockerSuite) TestBuildEnvEscapes(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildEnvEscapes(c *testing.T) { // ENV expansions work differently in Windows testRequires(c, DaemonIsLinux) name := "testbuildenvescapes" @@ -316,7 +328,7 @@ func (s *DockerSuite) TestBuildEnvEscapes(c *testing.T) { } -func (s *DockerSuite) TestBuildEnvOverwrite(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildEnvOverwrite(c *testing.T) { // ENV expansions work differently in Windows testRequires(c, DaemonIsLinux) name := "testbuildenvoverwrite" @@ -334,7 +346,7 @@ func (s *DockerSuite) TestBuildEnvOverwrite(c *testing.T) { } // FIXME(vdemeester) why we disabled cache here ? -func (s *DockerSuite) TestBuildOnBuildCmdEntrypointJSON(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildOnBuildCmdEntrypointJSON(c *testing.T) { name1 := "onbuildcmd" name2 := "onbuildgenerated" @@ -351,7 +363,7 @@ ONBUILD RUN ["true"]`)) } // FIXME(vdemeester) why we disabled cache here ? -func (s *DockerSuite) TestBuildOnBuildEntrypointJSON(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildOnBuildEntrypointJSON(c *testing.T) { name1 := "onbuildcmd" name2 := "onbuildgenerated" @@ -368,7 +380,7 @@ ONBUILD ENTRYPOINT ["echo"]`)) } -func (s *DockerSuite) TestBuildCacheAdd(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCacheAdd(c *testing.T) { testRequires(c, DaemonIsLinux) // Windows doesn't have httpserver image yet name := "testbuildtwoimageswithadd" server := fakestorage.New(c, "", fakecontext.WithFiles(map[string]string{ @@ -388,7 +400,7 @@ func (s *DockerSuite) TestBuildCacheAdd(c *testing.T) { } } -func (s *DockerSuite) TestBuildLastModified(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildLastModified(c *testing.T) { // Temporary fix for #30890. TODO: figure out what // has changed in the master busybox image. testRequires(c, DaemonIsLinux) @@ -441,7 +453,7 @@ ADD %s/file /` // Regression for https://github.com/docker/docker/pull/27805 // Makes sure that we don't use the cache if the contents of // a file in a subfolder of the context is modified and we re-build. -func (s *DockerSuite) TestBuildModifyFileInFolder(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildModifyFileInFolder(c *testing.T) { name := "testbuildmodifyfileinfolder" ctx := fakecontext.New(c, "", fakecontext.WithDockerfile(`FROM busybox @@ -463,7 +475,7 @@ ADD folder/file /test/changetarget`)) } } -func (s *DockerSuite) TestBuildAddSingleFileToRoot(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildAddSingleFileToRoot(c *testing.T) { testRequires(c, DaemonIsLinux) // Linux specific test buildImageSuccessfully(c, "testaddimg", build.WithBuildContext(c, build.WithFile("Dockerfile", fmt.Sprintf(`FROM busybox @@ -479,7 +491,7 @@ RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]`, expecte } // Issue #3960: "ADD src ." hangs -func (s *DockerSuite) TestBuildAddSingleFileToWorkdir(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildAddSingleFileToWorkdir(c *testing.T) { name := "testaddsinglefiletoworkdir" ctx := fakecontext.New(c, "", fakecontext.WithDockerfile( `FROM busybox @@ -502,7 +514,7 @@ func (s *DockerSuite) TestBuildAddSingleFileToWorkdir(c *testing.T) { } } -func (s *DockerSuite) TestBuildAddSingleFileToExistDir(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildAddSingleFileToExistDir(c *testing.T) { testRequires(c, DaemonIsLinux) // Linux specific test cli.BuildCmd(c, "testaddsinglefiletoexistdir", build.WithBuildContext(c, build.WithFile("Dockerfile", `FROM busybox @@ -518,7 +530,7 @@ RUN [ $(ls -l /exists/exists_file | awk '{print $3":"$4}') = 'dockerio:dockerio' build.WithFile("test_file", "test1"))) } -func (s *DockerSuite) TestBuildCopyAddMultipleFiles(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCopyAddMultipleFiles(c *testing.T) { testRequires(c, DaemonIsLinux) // Linux specific test server := fakestorage.New(c, "", fakecontext.WithFiles(map[string]string{ "robots.txt": "hello", @@ -551,7 +563,7 @@ RUN [ $(ls -l /exists/exists_file | awk '{print $3":"$4}') = 'dockerio:dockerio' // These tests are mainly for user namespaces to verify that new directories // are created as the remapped root uid/gid pair -func (s *DockerSuite) TestBuildUsernamespaceValidateRemappedRoot(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildUsernamespaceValidateRemappedRoot(c *testing.T) { testRequires(c, DaemonIsLinux) testCases := []string{ "ADD . /new_dir", @@ -570,7 +582,7 @@ RUN [ $(ls -l / | grep new_dir | awk '{print $3":"$4}') = 'root:root' ]`, tc)), } } -func (s *DockerSuite) TestBuildAddAndCopyFileWithWhitespace(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildAddAndCopyFileWithWhitespace(c *testing.T) { testRequires(c, DaemonIsLinux) // Not currently passing on Windows name := "testaddfilewithwhitespace" @@ -603,7 +615,7 @@ RUN [ $(cat "/test dir/test_file6") = 'test6' ]`, command, command, command, com } } -func (s *DockerSuite) TestBuildCopyFileWithWhitespaceOnWindows(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCopyFileWithWhitespaceOnWindows(c *testing.T) { testRequires(c, DaemonIsWindows) dockerfile := `FROM ` + testEnv.PlatformDefaults.BaseImage + ` RUN mkdir "C:/test dir" @@ -633,7 +645,7 @@ RUN find "test6" "C:/test dir/test_file6"` )) } -func (s *DockerSuite) TestBuildCopyWildcard(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCopyWildcard(c *testing.T) { name := "testcopywildcard" server := fakestorage.New(c, "", fakecontext.WithFiles(map[string]string{ "robots.txt": "hello", @@ -673,7 +685,7 @@ func (s *DockerSuite) TestBuildCopyWildcard(c *testing.T) { } -func (s *DockerSuite) TestBuildCopyWildcardInName(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCopyWildcardInName(c *testing.T) { // Run this only on Linux // Below is the original comment (that I don't agree with — vdemeester) // Normally we would do c.Fatal(err) here but given that @@ -693,7 +705,7 @@ func (s *DockerSuite) TestBuildCopyWildcardInName(c *testing.T) { )) } -func (s *DockerSuite) TestBuildCopyWildcardCache(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCopyWildcardCache(c *testing.T) { name := "testcopywildcardcache" ctx := fakecontext.New(c, "", fakecontext.WithDockerfile(`FROM busybox COPY file1.txt /tmp/`), @@ -719,7 +731,7 @@ func (s *DockerSuite) TestBuildCopyWildcardCache(c *testing.T) { } -func (s *DockerSuite) TestBuildAddSingleFileToNonExistingDir(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildAddSingleFileToNonExistingDir(c *testing.T) { testRequires(c, DaemonIsLinux) // Linux specific test buildImageSuccessfully(c, "testaddsinglefiletononexistingdir", build.WithBuildContext(c, build.WithFile("Dockerfile", `FROM busybox @@ -734,7 +746,7 @@ RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]`), build.WithFile("test_file", "test1"))) } -func (s *DockerSuite) TestBuildAddDirContentToRoot(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildAddDirContentToRoot(c *testing.T) { testRequires(c, DaemonIsLinux) // Linux specific test buildImageSuccessfully(c, "testadddircontenttoroot", build.WithBuildContext(c, build.WithFile("Dockerfile", `FROM busybox @@ -748,7 +760,7 @@ RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]`), build.WithFile("test_dir/test_file", "test1"))) } -func (s *DockerSuite) TestBuildAddDirContentToExistingDir(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildAddDirContentToExistingDir(c *testing.T) { testRequires(c, DaemonIsLinux) // Linux specific test buildImageSuccessfully(c, "testadddircontenttoexistingdir", build.WithBuildContext(c, build.WithFile("Dockerfile", `FROM busybox @@ -764,7 +776,7 @@ RUN [ $(ls -l /exists/test_file | awk '{print $3":"$4}') = 'root:root' ]`), build.WithFile("test_dir/test_file", "test1"))) } -func (s *DockerSuite) TestBuildAddWholeDirToRoot(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildAddWholeDirToRoot(c *testing.T) { testRequires(c, DaemonIsLinux) // Linux specific test buildImageSuccessfully(c, "testaddwholedirtoroot", build.WithBuildContext(c, build.WithFile("Dockerfile", fmt.Sprintf(`FROM busybox @@ -782,7 +794,7 @@ RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]`, expecte } // Testing #5941 : Having an etc directory in context conflicts with the /etc/mtab -func (s *DockerSuite) TestBuildAddOrCopyEtcToRootShouldNotConflict(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildAddOrCopyEtcToRootShouldNotConflict(c *testing.T) { buildImageSuccessfully(c, "testaddetctoroot", build.WithBuildContext(c, build.WithFile("Dockerfile", `FROM `+minimalBaseImage()+` ADD . /`), @@ -794,7 +806,7 @@ COPY . /`), } // Testing #9401 : Losing setuid flag after a ADD -func (s *DockerSuite) TestBuildAddPreservesFilesSpecialBits(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildAddPreservesFilesSpecialBits(c *testing.T) { testRequires(c, DaemonIsLinux) // Linux specific test buildImageSuccessfully(c, "testaddetctoroot", build.WithBuildContext(c, build.WithFile("Dockerfile", `FROM busybox @@ -807,7 +819,7 @@ RUN [ $(ls -l /usr/bin/suidbin | awk '{print $1}') = '-rwsr-xr-x' ]`), build.WithFile("/data/usr/test_file", "test1"))) } -func (s *DockerSuite) TestBuildCopySingleFileToRoot(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCopySingleFileToRoot(c *testing.T) { testRequires(c, DaemonIsLinux) // Linux specific test buildImageSuccessfully(c, "testcopysinglefiletoroot", build.WithBuildContext(c, build.WithFile("Dockerfile", fmt.Sprintf(`FROM busybox @@ -823,7 +835,7 @@ RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]`, expecte } // Issue #3960: "ADD src ." hangs - adapted for COPY -func (s *DockerSuite) TestBuildCopySingleFileToWorkdir(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCopySingleFileToWorkdir(c *testing.T) { name := "testcopysinglefiletoworkdir" ctx := fakecontext.New(c, "", fakecontext.WithDockerfile(`FROM busybox COPY test_file .`), @@ -845,7 +857,7 @@ COPY test_file .`), } } -func (s *DockerSuite) TestBuildCopySingleFileToExistDir(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCopySingleFileToExistDir(c *testing.T) { testRequires(c, DaemonIsLinux) // Linux specific test buildImageSuccessfully(c, "testcopysinglefiletoexistdir", build.WithBuildContext(c, build.WithFile("Dockerfile", `FROM busybox @@ -861,7 +873,7 @@ RUN [ $(ls -l /exists/exists_file | awk '{print $3":"$4}') = 'dockerio:dockerio' build.WithFile("test_file", "test1"))) } -func (s *DockerSuite) TestBuildCopySingleFileToNonExistDir(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCopySingleFileToNonExistDir(c *testing.T) { testRequires(c, DaemonIsLinux) // Linux specific buildImageSuccessfully(c, "testcopysinglefiletononexistdir", build.WithBuildContext(c, build.WithFile("Dockerfile", `FROM busybox @@ -876,7 +888,7 @@ RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]`), build.WithFile("test_file", "test1"))) } -func (s *DockerSuite) TestBuildCopyDirContentToRoot(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCopyDirContentToRoot(c *testing.T) { testRequires(c, DaemonIsLinux) // Linux specific test buildImageSuccessfully(c, "testcopydircontenttoroot", build.WithBuildContext(c, build.WithFile("Dockerfile", `FROM busybox @@ -890,7 +902,7 @@ RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]`), build.WithFile("test_dir/test_file", "test1"))) } -func (s *DockerSuite) TestBuildCopyDirContentToExistDir(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCopyDirContentToExistDir(c *testing.T) { testRequires(c, DaemonIsLinux) // Linux specific test buildImageSuccessfully(c, "testcopydircontenttoexistdir", build.WithBuildContext(c, build.WithFile("Dockerfile", `FROM busybox @@ -906,7 +918,7 @@ RUN [ $(ls -l /exists/test_file | awk '{print $3":"$4}') = 'root:root' ]`), build.WithFile("test_dir/test_file", "test1"))) } -func (s *DockerSuite) TestBuildCopyWholeDirToRoot(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCopyWholeDirToRoot(c *testing.T) { testRequires(c, DaemonIsLinux) // Linux specific test buildImageSuccessfully(c, "testcopywholedirtoroot", build.WithBuildContext(c, build.WithFile("Dockerfile", fmt.Sprintf(`FROM busybox @@ -923,7 +935,7 @@ RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]`, expecte build.WithFile("test_dir/test_file", "test1"))) } -func (s *DockerSuite) TestBuildAddBadLinks(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildAddBadLinks(c *testing.T) { testRequires(c, DaemonIsLinux) // Not currently working on Windows dockerfile := ` @@ -1003,7 +1015,7 @@ func (s *DockerSuite) TestBuildAddBadLinks(c *testing.T) { } -func (s *DockerSuite) TestBuildAddBadLinksVolume(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildAddBadLinksVolume(c *testing.T) { testRequires(c, DaemonIsLinux) // ln not implemented on Windows busybox const ( dockerfileTemplate = ` @@ -1046,7 +1058,7 @@ func (s *DockerSuite) TestBuildAddBadLinksVolume(c *testing.T) { // Issue #5270 - ensure we throw a better error than "unexpected EOF" // when we can't access files in the context. -func (s *DockerSuite) TestBuildWithInaccessibleFilesInContext(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildWithInaccessibleFilesInContext(c *testing.T) { testRequires(c, DaemonIsLinux, UnixCli, testEnv.IsLocalDaemon) // test uses chown/chmod: not available on windows { @@ -1167,7 +1179,7 @@ func (s *DockerSuite) TestBuildWithInaccessibleFilesInContext(c *testing.T) { } } -func (s *DockerSuite) TestBuildForceRm(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildForceRm(c *testing.T) { containerCountBefore := getContainerCount(c) name := "testbuildforcerm" @@ -1186,7 +1198,7 @@ func (s *DockerSuite) TestBuildForceRm(c *testing.T) { } -func (s *DockerSuite) TestBuildRm(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildRm(c *testing.T) { name := "testbuildrm" testCases := []struct { @@ -1229,7 +1241,7 @@ func (s *DockerSuite) TestBuildRm(c *testing.T) { } } -func (s *DockerSuite) TestBuildWithVolumes(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildWithVolumes(c *testing.T) { testRequires(c, DaemonIsLinux) // Invalid volume paths on Windows var ( result map[string]map[string]struct{} @@ -1264,7 +1276,7 @@ func (s *DockerSuite) TestBuildWithVolumes(c *testing.T) { } -func (s *DockerSuite) TestBuildMaintainer(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildMaintainer(c *testing.T) { name := "testbuildmaintainer" buildImageSuccessfully(c, name, build.WithDockerfile(`FROM `+minimalBaseImage()+` @@ -1277,7 +1289,7 @@ func (s *DockerSuite) TestBuildMaintainer(c *testing.T) { } } -func (s *DockerSuite) TestBuildUser(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildUser(c *testing.T) { testRequires(c, DaemonIsLinux) name := "testbuilduser" expected := "dockerio" @@ -1291,7 +1303,7 @@ func (s *DockerSuite) TestBuildUser(c *testing.T) { } } -func (s *DockerSuite) TestBuildRelativeWorkdir(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildRelativeWorkdir(c *testing.T) { name := "testbuildrelativeworkdir" var ( @@ -1333,7 +1345,7 @@ func (s *DockerSuite) TestBuildRelativeWorkdir(c *testing.T) { // #22181 Regression test. Single end-to-end test of using // Windows semantics. Most path handling verifications are in unit tests -func (s *DockerSuite) TestBuildWindowsWorkdirProcessing(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildWindowsWorkdirProcessing(c *testing.T) { testRequires(c, DaemonIsWindows) buildImageSuccessfully(c, "testbuildwindowsworkdirprocessing", build.WithDockerfile(`FROM busybox WORKDIR C:\\foo @@ -1344,7 +1356,7 @@ func (s *DockerSuite) TestBuildWindowsWorkdirProcessing(c *testing.T) { // #22181 Regression test. Most paths handling verifications are in unit test. // One functional test for end-to-end -func (s *DockerSuite) TestBuildWindowsAddCopyPathProcessing(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildWindowsAddCopyPathProcessing(c *testing.T) { testRequires(c, DaemonIsWindows) // TODO Windows. Needs a follow-up PR to 22181 to // support backslash such as .\\ being equivalent to ./ and c:\\ being @@ -1377,7 +1389,7 @@ func (s *DockerSuite) TestBuildWindowsAddCopyPathProcessing(c *testing.T) { )) } -func (s *DockerSuite) TestBuildWorkdirWithEnvVariables(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildWorkdirWithEnvVariables(c *testing.T) { name := "testbuildworkdirwithenvvariables" var expected string @@ -1398,7 +1410,7 @@ func (s *DockerSuite) TestBuildWorkdirWithEnvVariables(c *testing.T) { } } -func (s *DockerSuite) TestBuildRelativeCopy(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildRelativeCopy(c *testing.T) { // cat /test1/test2/foo gets permission denied for the user testRequires(c, NotUserNamespace) @@ -1437,7 +1449,7 @@ func (s *DockerSuite) TestBuildRelativeCopy(c *testing.T) { } // FIXME(vdemeester) should be unit test -func (s *DockerSuite) TestBuildBlankName(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildBlankName(c *testing.T) { name := "testbuildblankname" testCases := []struct { expression string @@ -1466,7 +1478,7 @@ func (s *DockerSuite) TestBuildBlankName(c *testing.T) { } } -func (s *DockerSuite) TestBuildEnv(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildEnv(c *testing.T) { testRequires(c, DaemonIsLinux) // ENV expansion is different in Windows name := "testbuildenv" expected := "[PATH=/test:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PORT=2375]" @@ -1480,7 +1492,7 @@ func (s *DockerSuite) TestBuildEnv(c *testing.T) { } } -func (s *DockerSuite) TestBuildPATH(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildPATH(c *testing.T) { testRequires(c, DaemonIsLinux) // ENV expansion is different in Windows defPath := "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" @@ -1509,7 +1521,7 @@ func (s *DockerSuite) TestBuildPATH(c *testing.T) { } } -func (s *DockerSuite) TestBuildContextCleanup(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildContextCleanup(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon) name := "testbuildcontextcleanup" @@ -1531,7 +1543,7 @@ func (s *DockerSuite) TestBuildContextCleanup(c *testing.T) { } -func (s *DockerSuite) TestBuildContextCleanupFailedBuild(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildContextCleanupFailedBuild(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon) name := "testbuildcontextcleanup" @@ -1574,7 +1586,7 @@ func compareDirectoryEntries(e1 []os.DirEntry, e2 []os.DirEntry) error { return nil } -func (s *DockerSuite) TestBuildCmd(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCmd(c *testing.T) { name := "testbuildcmd" expected := "[/bin/echo Hello World]" @@ -1587,7 +1599,7 @@ func (s *DockerSuite) TestBuildCmd(c *testing.T) { } } -func (s *DockerSuite) TestBuildExpose(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildExpose(c *testing.T) { testRequires(c, DaemonIsLinux) // Expose not implemented on Windows name := "testbuildexpose" expected := "map[2375/tcp:{}]" @@ -1601,7 +1613,7 @@ func (s *DockerSuite) TestBuildExpose(c *testing.T) { } } -func (s *DockerSuite) TestBuildExposeMorePorts(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildExposeMorePorts(c *testing.T) { testRequires(c, DaemonIsLinux) // Expose not implemented on Windows // start building docker file with a large number of ports portList := make([]string, 50) @@ -1650,7 +1662,7 @@ func (s *DockerSuite) TestBuildExposeMorePorts(c *testing.T) { } } -func (s *DockerSuite) TestBuildExposeOrder(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildExposeOrder(c *testing.T) { testRequires(c, DaemonIsLinux) // Expose not implemented on Windows buildID := func(name, exposed string) string { buildImageSuccessfully(c, name, build.WithDockerfile(fmt.Sprintf(`FROM scratch @@ -1666,7 +1678,7 @@ func (s *DockerSuite) TestBuildExposeOrder(c *testing.T) { } } -func (s *DockerSuite) TestBuildExposeUpperCaseProto(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildExposeUpperCaseProto(c *testing.T) { testRequires(c, DaemonIsLinux) // Expose not implemented on Windows name := "testbuildexposeuppercaseproto" expected := "map[5678/udp:{}]" @@ -1678,7 +1690,7 @@ func (s *DockerSuite) TestBuildExposeUpperCaseProto(c *testing.T) { } } -func (s *DockerSuite) TestBuildEmptyEntrypointInheritance(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildEmptyEntrypointInheritance(c *testing.T) { name := "testbuildentrypointinheritance" name2 := "testbuildentrypointinheritance2" @@ -1701,7 +1713,7 @@ func (s *DockerSuite) TestBuildEmptyEntrypointInheritance(c *testing.T) { } } -func (s *DockerSuite) TestBuildEmptyEntrypoint(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildEmptyEntrypoint(c *testing.T) { name := "testbuildentrypoint" expected := "[]" @@ -1715,7 +1727,7 @@ func (s *DockerSuite) TestBuildEmptyEntrypoint(c *testing.T) { } -func (s *DockerSuite) TestBuildEntrypoint(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildEntrypoint(c *testing.T) { name := "testbuildentrypoint" expected := "[/bin/echo]" @@ -1730,7 +1742,7 @@ func (s *DockerSuite) TestBuildEntrypoint(c *testing.T) { } // #6445 ensure ONBUILD triggers aren't committed to grandchildren -func (s *DockerSuite) TestBuildOnBuildLimitedInheritance(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildOnBuildLimitedInheritance(c *testing.T) { buildImageSuccessfully(c, "testonbuildtrigger1", build.WithDockerfile(` FROM busybox RUN echo "GRANDPARENT" @@ -1748,7 +1760,7 @@ func (s *DockerSuite) TestBuildOnBuildLimitedInheritance(c *testing.T) { } } -func (s *DockerSuite) TestBuildSameDockerfileWithAndWithoutCache(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildSameDockerfileWithAndWithoutCache(c *testing.T) { testRequires(c, DaemonIsLinux) // Expose not implemented on Windows name := "testbuildwithcache" dockerfile := `FROM scratch @@ -1770,7 +1782,7 @@ func (s *DockerSuite) TestBuildSameDockerfileWithAndWithoutCache(c *testing.T) { } // Make sure that ADD/COPY still populate the cache even if they don't use it -func (s *DockerSuite) TestBuildConditionalCache(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildConditionalCache(c *testing.T) { name := "testbuildconditionalcache" dockerfile := ` @@ -1804,7 +1816,7 @@ func (s *DockerSuite) TestBuildConditionalCache(c *testing.T) { } } -func (s *DockerSuite) TestBuildAddMultipleLocalFileWithAndWithoutCache(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildAddMultipleLocalFileWithAndWithoutCache(c *testing.T) { name := "testbuildaddmultiplelocalfilewithcache" baseName := name + "-base" @@ -1836,7 +1848,7 @@ func (s *DockerSuite) TestBuildAddMultipleLocalFileWithAndWithoutCache(c *testin } } -func (s *DockerSuite) TestBuildCopyDirButNotFile(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCopyDirButNotFile(c *testing.T) { name := "testbuildcopydirbutnotfile" name2 := "testbuildcopydirbutnotfile2" @@ -1860,7 +1872,7 @@ func (s *DockerSuite) TestBuildCopyDirButNotFile(c *testing.T) { } } -func (s *DockerSuite) TestBuildAddCurrentDirWithCache(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildAddCurrentDirWithCache(c *testing.T) { name := "testbuildaddcurrentdirwithcache" name2 := name + "2" name3 := name + "3" @@ -1907,7 +1919,7 @@ func (s *DockerSuite) TestBuildAddCurrentDirWithCache(c *testing.T) { } // FIXME(vdemeester) this really seems to test the same thing as before (TestBuildAddMultipleLocalFileWithAndWithoutCache) -func (s *DockerSuite) TestBuildAddCurrentDirWithoutCache(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildAddCurrentDirWithoutCache(c *testing.T) { name := "testbuildaddcurrentdirwithoutcache" dockerfile := ` FROM ` + minimalBaseImage() + ` @@ -1926,7 +1938,7 @@ func (s *DockerSuite) TestBuildAddCurrentDirWithoutCache(c *testing.T) { } } -func (s *DockerSuite) TestBuildAddRemoteFileWithAndWithoutCache(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildAddRemoteFileWithAndWithoutCache(c *testing.T) { name := "testbuildaddremotefilewithcache" server := fakestorage.New(c, "", fakecontext.WithFiles(map[string]string{ "baz": "hello", @@ -1951,7 +1963,7 @@ func (s *DockerSuite) TestBuildAddRemoteFileWithAndWithoutCache(c *testing.T) { } } -func (s *DockerSuite) TestBuildAddRemoteFileMTime(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildAddRemoteFileMTime(c *testing.T) { name := "testbuildaddremotefilemtime" name2 := name + "2" name3 := name + "3" @@ -1994,7 +2006,7 @@ func (s *DockerSuite) TestBuildAddRemoteFileMTime(c *testing.T) { } // FIXME(vdemeester) this really seems to test the same thing as before (combined) -func (s *DockerSuite) TestBuildAddLocalAndRemoteFilesWithAndWithoutCache(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildAddLocalAndRemoteFilesWithAndWithoutCache(c *testing.T) { name := "testbuildaddlocalandremotefilewithcache" server := fakestorage.New(c, "", fakecontext.WithFiles(map[string]string{ "baz": "hello", @@ -2042,15 +2054,15 @@ CMD ["cat", "/foo"]`), cli.BuildCmd(c, name, build.WithStdinContext(context)) } -func (s *DockerSuite) TestBuildContextTarGzip(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildContextTarGzip(c *testing.T) { testContextTar(c, archive.Gzip) } -func (s *DockerSuite) TestBuildContextTarNoCompression(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildContextTarNoCompression(c *testing.T) { testContextTar(c, archive.Uncompressed) } -func (s *DockerSuite) TestBuildNoContext(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildNoContext(c *testing.T) { name := "nocontext" icmd.RunCmd(icmd.Cmd{ Command: []string{dockerBinary, "build", "-t", name, "-"}, @@ -2065,7 +2077,7 @@ func (s *DockerSuite) TestBuildNoContext(c *testing.T) { } // FIXME(vdemeester) migrate to docker/cli e2e -func (s *DockerSuite) TestBuildDockerfileStdin(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildDockerfileStdin(c *testing.T) { name := "stdindockerfile" tmpDir, err := os.MkdirTemp("", "fake-context") assert.NilError(c, err) @@ -2085,7 +2097,7 @@ CMD ["cat", "/foo"]`), } // FIXME(vdemeester) migrate to docker/cli tests (unit or e2e) -func (s *DockerSuite) TestBuildDockerfileStdinConflict(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildDockerfileStdinConflict(c *testing.T) { name := "stdindockerfiletarcontext" icmd.RunCmd(icmd.Cmd{ Command: []string{dockerBinary, "build", "-t", name, "-f", "-", "-"}, @@ -2095,19 +2107,19 @@ func (s *DockerSuite) TestBuildDockerfileStdinConflict(c *testing.T) { }) } -func (s *DockerSuite) TestBuildDockerfileStdinNoExtraFiles(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildDockerfileStdinNoExtraFiles(c *testing.T) { s.testBuildDockerfileStdinNoExtraFiles(c, false, false) } -func (s *DockerSuite) TestBuildDockerfileStdinDockerignore(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildDockerfileStdinDockerignore(c *testing.T) { s.testBuildDockerfileStdinNoExtraFiles(c, true, false) } -func (s *DockerSuite) TestBuildDockerfileStdinDockerignoreIgnored(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildDockerfileStdinDockerignoreIgnored(c *testing.T) { s.testBuildDockerfileStdinNoExtraFiles(c, true, true) } -func (s *DockerSuite) testBuildDockerfileStdinNoExtraFiles(c *testing.T, hasDockerignore, ignoreDockerignore bool) { +func (s *DockerCLIBuildSuite) testBuildDockerfileStdinNoExtraFiles(c *testing.T, hasDockerignore, ignoreDockerignore bool) { name := "stdindockerfilenoextra" tmpDir, err := os.MkdirTemp("", "fake-context") assert.NilError(c, err) @@ -2147,7 +2159,7 @@ COPY . /baz`), } } -func (s *DockerSuite) TestBuildWithVolumeOwnership(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildWithVolumeOwnership(c *testing.T) { testRequires(c, DaemonIsLinux) name := "testbuildimg" @@ -2167,7 +2179,7 @@ func (s *DockerSuite) TestBuildWithVolumeOwnership(c *testing.T) { // testing #1405 - config.Cmd does not get cleaned up if // utilizing cache -func (s *DockerSuite) TestBuildEntrypointRunCleanup(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildEntrypointRunCleanup(c *testing.T) { name := "testbuildcmdcleanup" buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox RUN echo "hello"`)) @@ -2186,7 +2198,7 @@ func (s *DockerSuite) TestBuildEntrypointRunCleanup(c *testing.T) { } } -func (s *DockerSuite) TestBuildAddFileNotFound(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildAddFileNotFound(c *testing.T) { name := "testbuildaddnotfound" buildImage(name, build.WithBuildContext(c, @@ -2198,7 +2210,7 @@ func (s *DockerSuite) TestBuildAddFileNotFound(c *testing.T) { }) } -func (s *DockerSuite) TestBuildInheritance(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildInheritance(c *testing.T) { testRequires(c, DaemonIsLinux) name := "testbuildinheritance" @@ -2219,7 +2231,7 @@ func (s *DockerSuite) TestBuildInheritance(c *testing.T) { } } -func (s *DockerSuite) TestBuildFails(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildFails(c *testing.T) { name := "testbuildfails" buildImage(name, build.WithDockerfile(`FROM busybox RUN sh -c "exit 23"`)).Assert(c, icmd.Expected{ @@ -2228,7 +2240,7 @@ func (s *DockerSuite) TestBuildFails(c *testing.T) { }) } -func (s *DockerSuite) TestBuildOnBuild(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildOnBuild(c *testing.T) { name := "testbuildonbuild" buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox ONBUILD RUN touch foobar`)) @@ -2237,7 +2249,7 @@ func (s *DockerSuite) TestBuildOnBuild(c *testing.T) { } // gh #2446 -func (s *DockerSuite) TestBuildAddToSymlinkDest(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildAddToSymlinkDest(c *testing.T) { makeLink := `ln -s /foo /bar` if testEnv.OSType == "windows" { makeLink = `mklink /D C:\bar C:\foo` @@ -2255,7 +2267,7 @@ func (s *DockerSuite) TestBuildAddToSymlinkDest(c *testing.T) { )) } -func (s *DockerSuite) TestBuildEscapeWhitespace(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildEscapeWhitespace(c *testing.T) { name := "testbuildescapewhitespace" buildImageSuccessfully(c, name, build.WithDockerfile(` @@ -2273,7 +2285,7 @@ docker.com>" } -func (s *DockerSuite) TestBuildVerifyIntString(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildVerifyIntString(c *testing.T) { // Verify that strings that look like ints are still passed as strings name := "testbuildstringing" @@ -2288,7 +2300,7 @@ func (s *DockerSuite) TestBuildVerifyIntString(c *testing.T) { } -func (s *DockerSuite) TestBuildDockerignore(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildDockerignore(c *testing.T) { name := "testbuilddockerignore" buildImageSuccessfully(c, name, build.WithBuildContext(c, build.WithFile("Dockerfile", ` @@ -2326,7 +2338,7 @@ dir`), )) } -func (s *DockerSuite) TestBuildDockerignoreCleanPaths(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildDockerignoreCleanPaths(c *testing.T) { name := "testbuilddockerignorecleanpaths" buildImageSuccessfully(c, name, build.WithBuildContext(c, build.WithFile("Dockerfile", ` @@ -2340,7 +2352,7 @@ func (s *DockerSuite) TestBuildDockerignoreCleanPaths(c *testing.T) { )) } -func (s *DockerSuite) TestBuildDockerignoreExceptions(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildDockerignoreExceptions(c *testing.T) { name := "testbuilddockerignoreexceptions" buildImageSuccessfully(c, name, build.WithBuildContext(c, build.WithFile("Dockerfile", ` @@ -2385,7 +2397,7 @@ dir )) } -func (s *DockerSuite) TestBuildDockerignoringDockerfile(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildDockerignoringDockerfile(c *testing.T) { name := "testbuilddockerignoredockerfile" dockerfile := ` FROM busybox @@ -2403,7 +2415,7 @@ func (s *DockerSuite) TestBuildDockerignoringDockerfile(c *testing.T) { )) } -func (s *DockerSuite) TestBuildDockerignoringRenamedDockerfile(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildDockerignoringRenamedDockerfile(c *testing.T) { name := "testbuilddockerignoredockerfile" dockerfile := ` FROM busybox @@ -2424,7 +2436,7 @@ func (s *DockerSuite) TestBuildDockerignoringRenamedDockerfile(c *testing.T) { )) } -func (s *DockerSuite) TestBuildDockerignoringDockerignore(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildDockerignoringDockerignore(c *testing.T) { name := "testbuilddockerignoredockerignore" dockerfile := ` FROM busybox @@ -2437,7 +2449,7 @@ func (s *DockerSuite) TestBuildDockerignoringDockerignore(c *testing.T) { )) } -func (s *DockerSuite) TestBuildDockerignoreTouchDockerfile(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildDockerignoreTouchDockerfile(c *testing.T) { name := "testbuilddockerignoretouchdockerfile" dockerfile := ` FROM busybox @@ -2479,7 +2491,7 @@ func (s *DockerSuite) TestBuildDockerignoreTouchDockerfile(c *testing.T) { } } -func (s *DockerSuite) TestBuildDockerignoringWholeDir(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildDockerignoringWholeDir(c *testing.T) { name := "testbuilddockerignorewholedir" dockerfile := ` @@ -2496,7 +2508,7 @@ func (s *DockerSuite) TestBuildDockerignoringWholeDir(c *testing.T) { )) } -func (s *DockerSuite) TestBuildDockerignoringOnlyDotfiles(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildDockerignoringOnlyDotfiles(c *testing.T) { name := "testbuilddockerignorewholedir" dockerfile := ` @@ -2513,7 +2525,7 @@ func (s *DockerSuite) TestBuildDockerignoringOnlyDotfiles(c *testing.T) { )) } -func (s *DockerSuite) TestBuildDockerignoringBadExclusion(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildDockerignoringBadExclusion(c *testing.T) { name := "testbuilddockerignorebadexclusion" buildImage(name, build.WithBuildContext(c, build.WithFile("Dockerfile", ` @@ -2530,7 +2542,7 @@ func (s *DockerSuite) TestBuildDockerignoringBadExclusion(c *testing.T) { }) } -func (s *DockerSuite) TestBuildDockerignoringWildTopDir(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildDockerignoringWildTopDir(c *testing.T) { dockerfile := ` FROM busybox COPY . / @@ -2552,7 +2564,7 @@ func (s *DockerSuite) TestBuildDockerignoringWildTopDir(c *testing.T) { } } -func (s *DockerSuite) TestBuildDockerignoringWildDirs(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildDockerignoringWildDirs(c *testing.T) { dockerfile := ` FROM busybox COPY . / @@ -2615,7 +2627,7 @@ dir1/dir3/** )) } -func (s *DockerSuite) TestBuildLineBreak(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildLineBreak(c *testing.T) { testRequires(c, DaemonIsLinux) name := "testbuildlinebreak" buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox @@ -2626,7 +2638,7 @@ RUN sh -c "[ "$(cat /tmp/passwd)" = "root:testpass" ]" RUN sh -c "[ "$(ls -d /var/run/sshd)" = "/var/run/sshd" ]"`)) } -func (s *DockerSuite) TestBuildEOLInLine(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildEOLInLine(c *testing.T) { testRequires(c, DaemonIsLinux) name := "testbuildeolinline" buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox @@ -2637,7 +2649,7 @@ RUN sh -c "[ "$(cat /tmp/passwd)" = "root:testpass" ]" RUN sh -c "[ "$(ls -d /var/run/sshd)" = "/var/run/sshd" ]"`)) } -func (s *DockerSuite) TestBuildCommentsShebangs(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCommentsShebangs(c *testing.T) { testRequires(c, DaemonIsLinux) name := "testbuildcomments" buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox @@ -2651,7 +2663,7 @@ RUN [ "$(cat /hello.sh)" = $'#!/bin/sh\necho hello world' ] RUN [ "$(/hello.sh)" = "hello world" ]`)) } -func (s *DockerSuite) TestBuildUsersAndGroups(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildUsersAndGroups(c *testing.T) { testRequires(c, DaemonIsLinux) name := "testbuildusers" buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox @@ -2707,7 +2719,7 @@ RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)/$(id -G):$(id -Gn)" = '1042:1043/10 } // FIXME(vdemeester) rename this test (and probably "merge" it with the one below TestBuildEnvUsage2) -func (s *DockerSuite) TestBuildEnvUsage(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildEnvUsage(c *testing.T) { // /docker/world/hello is not owned by the correct user testRequires(c, NotUserNamespace) testRequires(c, DaemonIsLinux) @@ -2738,7 +2750,7 @@ RUN [ "$ghi" = "def" ] } // FIXME(vdemeester) rename this test (and probably "merge" it with the one above TestBuildEnvUsage) -func (s *DockerSuite) TestBuildEnvUsage2(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildEnvUsage2(c *testing.T) { // /docker/world/hello is not owned by the correct user testRequires(c, NotUserNamespace) testRequires(c, DaemonIsLinux) @@ -2807,7 +2819,7 @@ RUN [ "$eee1,$eee2,$eee3,$eee4" = 'foo,foo,foo,foo' ] )) } -func (s *DockerSuite) TestBuildAddScript(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildAddScript(c *testing.T) { testRequires(c, DaemonIsLinux) name := "testbuildaddscript" dockerfile := ` @@ -2823,7 +2835,7 @@ RUN [ "$(cat /testfile)" = 'test!' ]` )) } -func (s *DockerSuite) TestBuildAddTar(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildAddTar(c *testing.T) { // /test/foo is not owned by the correct user testRequires(c, NotUserNamespace) name := "testbuildaddtar" @@ -2877,7 +2889,7 @@ RUN cat /existing-directory-trailing-slash/test/foo | grep Hi` buildImageSuccessfully(c, name, build.WithExternalBuildContext(ctx)) } -func (s *DockerSuite) TestBuildAddBrokenTar(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildAddBrokenTar(c *testing.T) { name := "testbuildaddbrokentar" ctx := func() *fakecontext.Fake { @@ -2928,7 +2940,7 @@ ADD test.tar /` }) } -func (s *DockerSuite) TestBuildAddNonTar(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildAddNonTar(c *testing.T) { name := "testbuildaddnontar" // Should not try to extract test.tar @@ -2941,7 +2953,7 @@ func (s *DockerSuite) TestBuildAddNonTar(c *testing.T) { )) } -func (s *DockerSuite) TestBuildAddTarXz(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildAddTarXz(c *testing.T) { // /test/foo is not owned by the correct user testRequires(c, NotUserNamespace) testRequires(c, DaemonIsLinux) @@ -2990,7 +3002,7 @@ func (s *DockerSuite) TestBuildAddTarXz(c *testing.T) { buildImageSuccessfully(c, name, build.WithExternalBuildContext(ctx)) } -func (s *DockerSuite) TestBuildAddTarXzGz(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildAddTarXzGz(c *testing.T) { testRequires(c, DaemonIsLinux) name := "testbuildaddtarxzgz" @@ -3043,7 +3055,7 @@ func (s *DockerSuite) TestBuildAddTarXzGz(c *testing.T) { } // FIXME(vdemeester) most of the from git tests could be moved to `docker/cli` e2e tests -func (s *DockerSuite) TestBuildFromGit(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildFromGit(c *testing.T) { name := "testbuildfromgit" git := fakegit.New(c, "repo", map[string]string{ "Dockerfile": `FROM busybox @@ -3062,7 +3074,7 @@ func (s *DockerSuite) TestBuildFromGit(c *testing.T) { } } -func (s *DockerSuite) TestBuildFromGitWithContext(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildFromGitWithContext(c *testing.T) { name := "testbuildfromgit" git := fakegit.New(c, "repo", map[string]string{ "docker/Dockerfile": `FROM busybox @@ -3081,7 +3093,7 @@ func (s *DockerSuite) TestBuildFromGitWithContext(c *testing.T) { } } -func (s *DockerSuite) TestBuildFromGitWithF(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildFromGitWithF(c *testing.T) { name := "testbuildfromgitwithf" git := fakegit.New(c, "repo", map[string]string{ "myApp/myDockerfile": `FROM busybox @@ -3094,7 +3106,7 @@ func (s *DockerSuite) TestBuildFromGitWithF(c *testing.T) { }) } -func (s *DockerSuite) TestBuildFromRemoteTarball(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildFromRemoteTarball(c *testing.T) { name := "testbuildfromremotetarball" buffer := new(bytes.Buffer) @@ -3129,7 +3141,7 @@ func (s *DockerSuite) TestBuildFromRemoteTarball(c *testing.T) { } } -func (s *DockerSuite) TestBuildCleanupCmdOnEntrypoint(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCleanupCmdOnEntrypoint(c *testing.T) { name := "testbuildcmdcleanuponentrypoint" buildImageSuccessfully(c, name, build.WithDockerfile(`FROM `+minimalBaseImage()+` @@ -3148,7 +3160,7 @@ func (s *DockerSuite) TestBuildCleanupCmdOnEntrypoint(c *testing.T) { } } -func (s *DockerSuite) TestBuildClearCmd(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildClearCmd(c *testing.T) { name := "testbuildclearcmd" buildImageSuccessfully(c, name, build.WithDockerfile(`FROM `+minimalBaseImage()+` ENTRYPOINT ["/bin/bash"] @@ -3160,7 +3172,7 @@ func (s *DockerSuite) TestBuildClearCmd(c *testing.T) { } } -func (s *DockerSuite) TestBuildEmptyCmd(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildEmptyCmd(c *testing.T) { // Skip on Windows. Base image on Windows has a CMD set in the image. testRequires(c, DaemonIsLinux) @@ -3173,7 +3185,7 @@ func (s *DockerSuite) TestBuildEmptyCmd(c *testing.T) { } } -func (s *DockerSuite) TestBuildOnBuildOutput(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildOnBuildOutput(c *testing.T) { name := "testbuildonbuildparent" buildImageSuccessfully(c, name, build.WithDockerfile("FROM busybox\nONBUILD RUN echo foo\n")) @@ -3183,7 +3195,7 @@ func (s *DockerSuite) TestBuildOnBuildOutput(c *testing.T) { } // FIXME(vdemeester) should be a unit test -func (s *DockerSuite) TestBuildInvalidTag(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildInvalidTag(c *testing.T) { name := "abcd:" + testutil.GenerateRandomAlphaOnlyString(200) buildImage(name, build.WithDockerfile("FROM "+minimalBaseImage()+"\nMAINTAINER quux\n")).Assert(c, icmd.Expected{ ExitCode: 125, @@ -3191,7 +3203,7 @@ func (s *DockerSuite) TestBuildInvalidTag(c *testing.T) { }) } -func (s *DockerSuite) TestBuildCmdShDashC(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCmdShDashC(c *testing.T) { name := "testbuildcmdshc" buildImageSuccessfully(c, name, build.WithDockerfile("FROM busybox\nCMD echo cmd\n")) @@ -3206,7 +3218,7 @@ func (s *DockerSuite) TestBuildCmdShDashC(c *testing.T) { } -func (s *DockerSuite) TestBuildCmdSpaces(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCmdSpaces(c *testing.T) { // Test to make sure that when we strcat arrays we take into account // the arg separator to make sure ["echo","hi"] and ["echo hi"] don't // look the same @@ -3232,7 +3244,7 @@ func (s *DockerSuite) TestBuildCmdSpaces(c *testing.T) { } } -func (s *DockerSuite) TestBuildCmdJSONNoShDashC(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCmdJSONNoShDashC(c *testing.T) { name := "testbuildcmdjson" buildImageSuccessfully(c, name, build.WithDockerfile("FROM busybox\nCMD [\"echo\", \"cmd\"]")) @@ -3243,7 +3255,7 @@ func (s *DockerSuite) TestBuildCmdJSONNoShDashC(c *testing.T) { } } -func (s *DockerSuite) TestBuildEntrypointCanBeOverriddenByChild(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildEntrypointCanBeOverriddenByChild(c *testing.T) { buildImageSuccessfully(c, "parent", build.WithDockerfile(` FROM busybox ENTRYPOINT exit 130 @@ -3263,7 +3275,7 @@ func (s *DockerSuite) TestBuildEntrypointCanBeOverriddenByChild(c *testing.T) { }) } -func (s *DockerSuite) TestBuildEntrypointCanBeOverriddenByChildInspect(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildEntrypointCanBeOverriddenByChildInspect(c *testing.T) { var ( name = "testbuildepinherit" name2 = "testbuildepinherit2" @@ -3287,14 +3299,14 @@ func (s *DockerSuite) TestBuildEntrypointCanBeOverriddenByChildInspect(c *testin }) } -func (s *DockerSuite) TestBuildRunShEntrypoint(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildRunShEntrypoint(c *testing.T) { name := "testbuildentrypoint" buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox ENTRYPOINT echo`)) dockerCmd(c, "run", "--rm", name) } -func (s *DockerSuite) TestBuildExoticShellInterpolation(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildExoticShellInterpolation(c *testing.T) { testRequires(c, DaemonIsLinux) name := "testbuildexoticshellinterpolation" @@ -3319,7 +3331,7 @@ func (s *DockerSuite) TestBuildExoticShellInterpolation(c *testing.T) { `)) } -func (s *DockerSuite) TestBuildVerifySingleQuoteFails(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildVerifySingleQuoteFails(c *testing.T) { // This testcase is supposed to generate an error because the // JSON array we're passing in on the CMD uses single quotes instead // of double quotes (per the JSON spec). This means we interpret it @@ -3336,7 +3348,7 @@ func (s *DockerSuite) TestBuildVerifySingleQuoteFails(c *testing.T) { }) } -func (s *DockerSuite) TestBuildVerboseOut(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildVerboseOut(c *testing.T) { name := "testbuildverboseout" expected := "\n123\n" @@ -3350,7 +3362,7 @@ RUN echo 123`)).Assert(c, icmd.Expected{ }) } -func (s *DockerSuite) TestBuildWithTabs(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildWithTabs(c *testing.T) { name := "testbuildwithtabs" buildImageSuccessfully(c, name, build.WithDockerfile("FROM busybox\nRUN echo\tone\t\ttwo")) res := inspectFieldJSON(c, name, "ContainerConfig.Cmd") @@ -3365,7 +3377,7 @@ func (s *DockerSuite) TestBuildWithTabs(c *testing.T) { } } -func (s *DockerSuite) TestBuildLabels(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildLabels(c *testing.T) { name := "testbuildlabel" expected := `{"License":"GPL","Vendor":"Acme"}` buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox @@ -3377,7 +3389,7 @@ func (s *DockerSuite) TestBuildLabels(c *testing.T) { } } -func (s *DockerSuite) TestBuildLabelsCache(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildLabelsCache(c *testing.T) { name := "testbuildlabelcache" buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox @@ -3418,7 +3430,7 @@ func (s *DockerSuite) TestBuildLabelsCache(c *testing.T) { } // FIXME(vdemeester) port to docker/cli e2e tests (api tests should test suppressOutput option though) -func (s *DockerSuite) TestBuildNotVerboseSuccess(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildNotVerboseSuccess(c *testing.T) { // This test makes sure that -q works correctly when build is successful: // stdout has only the image ID (long image ID) and stderr is empty. outRegexp := regexp.MustCompile(`^(sha256:|)[a-z0-9]{64}\n$`) @@ -3469,7 +3481,7 @@ func (s *DockerSuite) TestBuildNotVerboseSuccess(c *testing.T) { } // FIXME(vdemeester) migrate to docker/cli tests -func (s *DockerSuite) TestBuildNotVerboseFailureWithNonExistImage(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildNotVerboseFailureWithNonExistImage(c *testing.T) { // This test makes sure that -q works correctly when build fails by // comparing between the stderr output in quiet mode and in stdout // and stderr output in verbose mode @@ -3490,7 +3502,7 @@ func (s *DockerSuite) TestBuildNotVerboseFailureWithNonExistImage(c *testing.T) } // FIXME(vdemeester) migrate to docker/cli tests -func (s *DockerSuite) TestBuildNotVerboseFailure(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildNotVerboseFailure(c *testing.T) { // This test makes sure that -q works correctly when build fails by // comparing between the stderr output in quiet mode and in stdout // and stderr output in verbose mode @@ -3518,7 +3530,7 @@ func (s *DockerSuite) TestBuildNotVerboseFailure(c *testing.T) { } // FIXME(vdemeester) migrate to docker/cli tests -func (s *DockerSuite) TestBuildNotVerboseFailureRemote(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildNotVerboseFailureRemote(c *testing.T) { // This test ensures that when given a wrong URL, stderr in quiet mode and // stderr in verbose mode are identical. // TODO(vdemeester) with cobra, stdout has a carriage return too much so this test should not check stdout @@ -3548,7 +3560,7 @@ func (s *DockerSuite) TestBuildNotVerboseFailureRemote(c *testing.T) { } // FIXME(vdemeester) migrate to docker/cli tests -func (s *DockerSuite) TestBuildStderr(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildStderr(c *testing.T) { // This test just makes sure that no non-error output goes // to stderr name := "testbuildstderr" @@ -3566,7 +3578,7 @@ func (s *DockerSuite) TestBuildStderr(c *testing.T) { } } -func (s *DockerSuite) TestBuildChownSingleFile(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildChownSingleFile(c *testing.T) { testRequires(c, UnixCli, DaemonIsLinux) // test uses chown: not available on windows name := "testbuildchownsinglefile" @@ -3590,7 +3602,7 @@ RUN [ $(ls -l /test | awk '{print $3":"$4}') = 'root:root' ] cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx)) } -func (s *DockerSuite) TestBuildSymlinkBreakout(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildSymlinkBreakout(c *testing.T) { name := "testbuildsymlinkbreakout" tmpdir, err := os.MkdirTemp("", name) assert.NilError(c, err) @@ -3645,7 +3657,7 @@ func (s *DockerSuite) TestBuildSymlinkBreakout(c *testing.T) { } } -func (s *DockerSuite) TestBuildXZHost(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildXZHost(c *testing.T) { // /usr/local/sbin/xz gets permission denied for the user testRequires(c, NotUserNamespace) testRequires(c, DaemonIsLinux) @@ -3663,7 +3675,7 @@ RUN [ ! -e /injected ]`), )) } -func (s *DockerSuite) TestBuildVolumesRetainContents(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildVolumesRetainContents(c *testing.T) { // /foo/file gets permission denied for the user testRequires(c, NotUserNamespace) testRequires(c, DaemonIsLinux) // TODO Windows: Issue #20127 @@ -3693,7 +3705,7 @@ CMD cat /foo/file`), } -func (s *DockerSuite) TestBuildFromMixedcaseDockerfile(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildFromMixedcaseDockerfile(c *testing.T) { testRequires(c, UnixCli) // Dockerfile overwrites dockerfile on windows testRequires(c, DaemonIsLinux) @@ -3717,7 +3729,7 @@ func (s *DockerSuite) TestBuildFromMixedcaseDockerfile(c *testing.T) { } // FIXME(vdemeester) should migrate to docker/cli tests -func (s *DockerSuite) TestBuildFromURLWithF(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildFromURLWithF(c *testing.T) { server := fakestorage.New(c, "", fakecontext.WithFiles(map[string]string{"baz": `FROM busybox RUN echo from baz COPY * /tmp/ @@ -3744,7 +3756,7 @@ RUN find /tmp/`})) } // FIXME(vdemeester) should migrate to docker/cli tests -func (s *DockerSuite) TestBuildFromStdinWithF(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildFromStdinWithF(c *testing.T) { testRequires(c, DaemonIsLinux) // TODO Windows: This test is flaky; no idea why ctx := fakecontext.New(c, "", fakecontext.WithDockerfile(`FROM busybox RUN echo "from Dockerfile"`)) @@ -3769,7 +3781,7 @@ RUN sh -c "find /tmp/" # sh -c is needed on Windows to use the correct find`) } -func (s *DockerSuite) TestBuildFromOfficialNames(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildFromOfficialNames(c *testing.T) { name := "testbuildfromofficial" fromNames := []string{ "busybox", @@ -3787,7 +3799,7 @@ func (s *DockerSuite) TestBuildFromOfficialNames(c *testing.T) { } // FIXME(vdemeester) should be a unit test -func (s *DockerSuite) TestBuildSpaces(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildSpaces(c *testing.T) { // Test to make sure that leading/trailing spaces on a command // doesn't change the error msg we get name := "testspaces" @@ -3850,7 +3862,7 @@ func (s *DockerSuite) TestBuildSpaces(c *testing.T) { } -func (s *DockerSuite) TestBuildSpacesWithQuotes(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildSpacesWithQuotes(c *testing.T) { // Test to make sure that spaces in quotes aren't lost name := "testspacesquotes" @@ -3870,7 +3882,7 @@ RUN echo " \ } // #4393 -func (s *DockerSuite) TestBuildVolumeFileExistsinContainer(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildVolumeFileExistsinContainer(c *testing.T) { testRequires(c, DaemonIsLinux) // TODO Windows: This should error out buildImage("docker-test-errcreatevolumewithfile", build.WithDockerfile(` FROM busybox @@ -3883,7 +3895,7 @@ func (s *DockerSuite) TestBuildVolumeFileExistsinContainer(c *testing.T) { } // FIXME(vdemeester) should be a unit test -func (s *DockerSuite) TestBuildMissingArgs(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildMissingArgs(c *testing.T) { // Test to make sure that all Dockerfile commands (except the ones listed // in skipCmds) will generate an error if no args are provided. // Note: INSERT is deprecated so we exclude it because of that. @@ -3928,7 +3940,7 @@ func (s *DockerSuite) TestBuildMissingArgs(c *testing.T) { } -func (s *DockerSuite) TestBuildEmptyScratch(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildEmptyScratch(c *testing.T) { testRequires(c, DaemonIsLinux) buildImage("sc", build.WithDockerfile("FROM scratch")).Assert(c, icmd.Expected{ ExitCode: 1, @@ -3936,14 +3948,14 @@ func (s *DockerSuite) TestBuildEmptyScratch(c *testing.T) { }) } -func (s *DockerSuite) TestBuildDotDotFile(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildDotDotFile(c *testing.T) { buildImageSuccessfully(c, "sc", build.WithBuildContext(c, build.WithFile("Dockerfile", "FROM busybox\n"), build.WithFile("..gitme", ""), )) } -func (s *DockerSuite) TestBuildRUNoneJSON(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildRUNoneJSON(c *testing.T) { testRequires(c, DaemonIsLinux) // No hello-world Windows image name := "testbuildrunonejson" @@ -3953,7 +3965,7 @@ RUN [ "/hello" ]`)).Assert(c, icmd.Expected{ }) } -func (s *DockerSuite) TestBuildEmptyStringVolume(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildEmptyStringVolume(c *testing.T) { name := "testbuildemptystringvolume" buildImage(name, build.WithDockerfile(` @@ -3965,7 +3977,7 @@ func (s *DockerSuite) TestBuildEmptyStringVolume(c *testing.T) { }) } -func (s *DockerSuite) TestBuildContainerWithCgroupParent(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildContainerWithCgroupParent(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) cgroupParent := "test" @@ -3993,7 +4005,7 @@ RUN cat /proc/self/cgroup } // FIXME(vdemeester) could be a unit test -func (s *DockerSuite) TestBuildNoDupOutput(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildNoDupOutput(c *testing.T) { // Check to make sure our build output prints the Dockerfile cmd // property - there was a bug that caused it to be duplicated on the // Step X line @@ -4010,7 +4022,7 @@ func (s *DockerSuite) TestBuildNoDupOutput(c *testing.T) { // GH15826 // FIXME(vdemeester) could be a unit test -func (s *DockerSuite) TestBuildStartsFromOne(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildStartsFromOne(c *testing.T) { // Explicit check to ensure that build starts from step 1 rather than 0 name := "testbuildstartsfromone" result := buildImage(name, build.WithDockerfile(`FROM busybox`)) @@ -4021,7 +4033,7 @@ func (s *DockerSuite) TestBuildStartsFromOne(c *testing.T) { } } -func (s *DockerSuite) TestBuildRUNErrMsg(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildRUNErrMsg(c *testing.T) { // Test to make sure the bad command is quoted with just "s and // not as a Go []string name := "testbuildbadrunerrmsg" @@ -4043,7 +4055,7 @@ func (s *DockerSuite) TestBuildRUNErrMsg(c *testing.T) { } // Issue #15634: COPY fails when path starts with "null" -func (s *DockerSuite) TestBuildNullStringInAddCopyVolume(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildNullStringInAddCopyVolume(c *testing.T) { name := "testbuildnullstringinaddcopyvolume" volName := "nullvolume" if testEnv.OSType == "windows" { @@ -4063,7 +4075,7 @@ func (s *DockerSuite) TestBuildNullStringInAddCopyVolume(c *testing.T) { )) } -func (s *DockerSuite) TestBuildStopSignal(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildStopSignal(c *testing.T) { testRequires(c, DaemonIsLinux) // Windows does not support STOPSIGNAL yet imgName := "test_build_stop_signal" buildImageSuccessfully(c, imgName, build.WithDockerfile(`FROM busybox @@ -4081,7 +4093,7 @@ func (s *DockerSuite) TestBuildStopSignal(c *testing.T) { } } -func (s *DockerSuite) TestBuildBuildTimeArg(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildBuildTimeArg(c *testing.T) { imgName := "bldargtest" envKey := "foo" envVal := "bar" @@ -4114,7 +4126,7 @@ func (s *DockerSuite) TestBuildBuildTimeArg(c *testing.T) { } } -func (s *DockerSuite) TestBuildBuildTimeArgHistory(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildBuildTimeArgHistory(c *testing.T) { imgName := "bldargtest" envKey := "foo" envVal := "bar" @@ -4135,7 +4147,7 @@ func (s *DockerSuite) TestBuildBuildTimeArgHistory(c *testing.T) { } } -func (s *DockerSuite) TestBuildTimeArgHistoryExclusions(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildTimeArgHistoryExclusions(c *testing.T) { imgName := "bldargtest" envKey := "foo" envVal := "bar" @@ -4175,7 +4187,7 @@ func (s *DockerSuite) TestBuildTimeArgHistoryExclusions(c *testing.T) { assert.Equal(c, origID, cacheID) } -func (s *DockerSuite) TestBuildBuildTimeArgCacheHit(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildBuildTimeArgCacheHit(c *testing.T) { imgName := "bldargtest" envKey := "foo" envVal := "bar" @@ -4199,7 +4211,7 @@ func (s *DockerSuite) TestBuildBuildTimeArgCacheHit(c *testing.T) { } } -func (s *DockerSuite) TestBuildBuildTimeArgCacheMissExtraArg(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildBuildTimeArgCacheMissExtraArg(c *testing.T) { imgName := "bldargtest" envKey := "foo" envVal := "bar" @@ -4230,7 +4242,7 @@ func (s *DockerSuite) TestBuildBuildTimeArgCacheMissExtraArg(c *testing.T) { } } -func (s *DockerSuite) TestBuildBuildTimeArgCacheMissSameArgDiffVal(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildBuildTimeArgCacheMissSameArgDiffVal(c *testing.T) { imgName := "bldargtest" envKey := "foo" envVal := "bar" @@ -4255,7 +4267,7 @@ func (s *DockerSuite) TestBuildBuildTimeArgCacheMissSameArgDiffVal(c *testing.T) } } -func (s *DockerSuite) TestBuildBuildTimeArgOverrideArgDefinedBeforeEnv(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildBuildTimeArgOverrideArgDefinedBeforeEnv(c *testing.T) { testRequires(c, DaemonIsLinux) // Windows does not support ARG imgName := "bldargtest" envKey := "foo" @@ -4284,7 +4296,7 @@ func (s *DockerSuite) TestBuildBuildTimeArgOverrideArgDefinedBeforeEnv(c *testin } // FIXME(vdemeester) might be useful to merge with the one above ? -func (s *DockerSuite) TestBuildBuildTimeArgOverrideEnvDefinedBeforeArg(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildBuildTimeArgOverrideEnvDefinedBeforeArg(c *testing.T) { testRequires(c, DaemonIsLinux) // Windows does not support ARG imgName := "bldargtest" envKey := "foo" @@ -4311,7 +4323,7 @@ func (s *DockerSuite) TestBuildBuildTimeArgOverrideEnvDefinedBeforeArg(c *testin } } -func (s *DockerSuite) TestBuildBuildTimeArgExpansion(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildBuildTimeArgExpansion(c *testing.T) { imgName := "bldvarstest" wdVar := "WDIR" @@ -4401,7 +4413,7 @@ func (s *DockerSuite) TestBuildBuildTimeArgExpansion(c *testing.T) { } } -func (s *DockerSuite) TestBuildBuildTimeArgExpansionOverride(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildBuildTimeArgExpansionOverride(c *testing.T) { testRequires(c, DaemonIsLinux) // Windows does not support ARG imgName := "bldvarstest" envKey := "foo" @@ -4429,7 +4441,7 @@ func (s *DockerSuite) TestBuildBuildTimeArgExpansionOverride(c *testing.T) { } } -func (s *DockerSuite) TestBuildBuildTimeArgUntrustedDefinedAfterUse(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildBuildTimeArgUntrustedDefinedAfterUse(c *testing.T) { testRequires(c, DaemonIsLinux) // Windows does not support ARG imgName := "bldargtest" envKey := "foo" @@ -4453,7 +4465,7 @@ func (s *DockerSuite) TestBuildBuildTimeArgUntrustedDefinedAfterUse(c *testing.T } } -func (s *DockerSuite) TestBuildBuildTimeArgBuiltinArg(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildBuildTimeArgBuiltinArg(c *testing.T) { testRequires(c, DaemonIsLinux) // Windows does not support --build-arg imgName := "bldargtest" envKey := "HTTP_PROXY" @@ -4476,7 +4488,7 @@ func (s *DockerSuite) TestBuildBuildTimeArgBuiltinArg(c *testing.T) { } } -func (s *DockerSuite) TestBuildBuildTimeArgDefaultOverride(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildBuildTimeArgDefaultOverride(c *testing.T) { testRequires(c, DaemonIsLinux) // Windows does not support ARG imgName := "bldargtest" envKey := "foo" @@ -4502,7 +4514,7 @@ func (s *DockerSuite) TestBuildBuildTimeArgDefaultOverride(c *testing.T) { } } -func (s *DockerSuite) TestBuildBuildTimeArgUnconsumedArg(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildBuildTimeArgUnconsumedArg(c *testing.T) { imgName := "bldargtest" envKey := "foo" envVal := "bar" @@ -4518,7 +4530,7 @@ func (s *DockerSuite) TestBuildBuildTimeArgUnconsumedArg(c *testing.T) { }) } -func (s *DockerSuite) TestBuildBuildTimeArgEnv(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildBuildTimeArgEnv(c *testing.T) { testRequires(c, DaemonIsLinux) // Windows does not support ARG dockerfile := `FROM busybox ARG FOO1=fromfile @@ -4578,7 +4590,7 @@ func (s *DockerSuite) TestBuildBuildTimeArgEnv(c *testing.T) { assert.Assert(c, strings.Contains(out, "FOO9")) } -func (s *DockerSuite) TestBuildBuildTimeArgQuotedValVariants(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildBuildTimeArgQuotedValVariants(c *testing.T) { imgName := "bldargtest" envKey := "foo" envKey1 := "foo1" @@ -4599,7 +4611,7 @@ func (s *DockerSuite) TestBuildBuildTimeArgQuotedValVariants(c *testing.T) { buildImageSuccessfully(c, imgName, build.WithDockerfile(dockerfile)) } -func (s *DockerSuite) TestBuildBuildTimeArgEmptyValVariants(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildBuildTimeArgEmptyValVariants(c *testing.T) { testRequires(c, DaemonIsLinux) // Windows does not support ARG imgName := "bldargtest" envKey := "foo" @@ -4615,7 +4627,7 @@ func (s *DockerSuite) TestBuildBuildTimeArgEmptyValVariants(c *testing.T) { buildImageSuccessfully(c, imgName, build.WithDockerfile(dockerfile)) } -func (s *DockerSuite) TestBuildBuildTimeArgDefinitionWithNoEnvInjection(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildBuildTimeArgDefinitionWithNoEnvInjection(c *testing.T) { imgName := "bldargtest" envKey := "foo" dockerfile := fmt.Sprintf(`FROM busybox @@ -4629,7 +4641,7 @@ func (s *DockerSuite) TestBuildBuildTimeArgDefinitionWithNoEnvInjection(c *testi } } -func (s *DockerSuite) TestBuildMultiStageArg(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildMultiStageArg(c *testing.T) { imgName := "multifrombldargtest" dockerfile := `FROM busybox ARG foo=abc @@ -4652,7 +4664,7 @@ func (s *DockerSuite) TestBuildMultiStageArg(c *testing.T) { assert.Assert(c, strings.Contains(result.Stdout(), "bar=def")) } -func (s *DockerSuite) TestBuildMultiStageGlobalArg(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildMultiStageGlobalArg(c *testing.T) { imgName := "multifrombldargtest" dockerfile := `ARG tag=nosuchtag FROM busybox:${tag} @@ -4676,7 +4688,7 @@ func (s *DockerSuite) TestBuildMultiStageGlobalArg(c *testing.T) { assert.Assert(c, strings.Contains(result.Stdout(), "tag=latest")) } -func (s *DockerSuite) TestBuildMultiStageUnusedArg(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildMultiStageUnusedArg(c *testing.T) { imgName := "multifromunusedarg" dockerfile := `FROM busybox ARG foo @@ -4695,7 +4707,7 @@ func (s *DockerSuite) TestBuildMultiStageUnusedArg(c *testing.T) { assert.Assert(c, !strings.Contains(result.Stdout(), "baz")) } -func (s *DockerSuite) TestBuildNoNamedVolume(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildNoNamedVolume(c *testing.T) { volName := "testname:/foo" if testEnv.OSType == "windows" { @@ -4712,7 +4724,7 @@ func (s *DockerSuite) TestBuildNoNamedVolume(c *testing.T) { }) } -func (s *DockerSuite) TestBuildTagEvent(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildTagEvent(c *testing.T) { since := daemonUnixTime(c) dockerFile := `FROM busybox @@ -4736,7 +4748,7 @@ func (s *DockerSuite) TestBuildTagEvent(c *testing.T) { } // #15780 -func (s *DockerSuite) TestBuildMultipleTags(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildMultipleTags(c *testing.T) { dockerfile := ` FROM busybox MAINTAINER test-15780 @@ -4749,7 +4761,7 @@ func (s *DockerSuite) TestBuildMultipleTags(c *testing.T) { } // #17290 -func (s *DockerSuite) TestBuildCacheBrokenSymlink(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCacheBrokenSymlink(c *testing.T) { name := "testbuildbrokensymlink" ctx := fakecontext.New(c, "", fakecontext.WithDockerfile(` @@ -4776,7 +4788,7 @@ func (s *DockerSuite) TestBuildCacheBrokenSymlink(c *testing.T) { } } -func (s *DockerSuite) TestBuildFollowSymlinkToFile(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildFollowSymlinkToFile(c *testing.T) { name := "testbuildbrokensymlink" ctx := fakecontext.New(c, "", fakecontext.WithDockerfile(` @@ -4806,7 +4818,7 @@ func (s *DockerSuite) TestBuildFollowSymlinkToFile(c *testing.T) { } -func (s *DockerSuite) TestBuildFollowSymlinkToDir(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildFollowSymlinkToDir(c *testing.T) { name := "testbuildbrokensymlink" ctx := fakecontext.New(c, "", fakecontext.WithDockerfile(` @@ -4839,7 +4851,7 @@ func (s *DockerSuite) TestBuildFollowSymlinkToDir(c *testing.T) { // TestBuildSymlinkBasename tests that target file gets basename from symlink, // not from the target file. -func (s *DockerSuite) TestBuildSymlinkBasename(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildSymlinkBasename(c *testing.T) { name := "testbuildbrokensymlink" ctx := fakecontext.New(c, "", fakecontext.WithDockerfile(` @@ -4861,7 +4873,7 @@ func (s *DockerSuite) TestBuildSymlinkBasename(c *testing.T) { } // #17827 -func (s *DockerSuite) TestBuildCacheRootSource(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCacheRootSource(c *testing.T) { name := "testbuildrootsource" ctx := fakecontext.New(c, "", fakecontext.WithDockerfile(` @@ -4886,7 +4898,7 @@ func (s *DockerSuite) TestBuildCacheRootSource(c *testing.T) { // #19375 // FIXME(vdemeester) should migrate to docker/cli tests -func (s *DockerSuite) TestBuildFailsGitNotCallable(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildFailsGitNotCallable(c *testing.T) { buildImage("gitnotcallable", cli.WithEnvironmentVariables("PATH="), build.WithContextPath("github.com/docker/v1.10-migrator.git")).Assert(c, icmd.Expected{ ExitCode: 1, @@ -4901,7 +4913,7 @@ func (s *DockerSuite) TestBuildFailsGitNotCallable(c *testing.T) { } // TestBuildWorkdirWindowsPath tests that a Windows style path works as a workdir -func (s *DockerSuite) TestBuildWorkdirWindowsPath(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildWorkdirWindowsPath(c *testing.T) { testRequires(c, DaemonIsWindows) name := "testbuildworkdirwindowspath" buildImageSuccessfully(c, name, build.WithDockerfile(` @@ -4912,7 +4924,7 @@ func (s *DockerSuite) TestBuildWorkdirWindowsPath(c *testing.T) { `)) } -func (s *DockerSuite) TestBuildLabel(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildLabel(c *testing.T) { name := "testbuildlabel" testLabel := "foo" @@ -4929,7 +4941,7 @@ func (s *DockerSuite) TestBuildLabel(c *testing.T) { } } -func (s *DockerSuite) TestBuildLabelOneNode(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildLabelOneNode(c *testing.T) { name := "testbuildlabel" buildImageSuccessfully(c, name, cli.WithFlags("--label", "foo=bar"), build.WithDockerfile("FROM busybox")) @@ -4943,7 +4955,7 @@ func (s *DockerSuite) TestBuildLabelOneNode(c *testing.T) { assert.Equal(c, v, "bar") } -func (s *DockerSuite) TestBuildLabelCacheCommit(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildLabelCacheCommit(c *testing.T) { name := "testbuildlabelcachecommit" testLabel := "foo" @@ -4964,7 +4976,7 @@ func (s *DockerSuite) TestBuildLabelCacheCommit(c *testing.T) { } } -func (s *DockerSuite) TestBuildLabelMultiple(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildLabelMultiple(c *testing.T) { name := "testbuildlabelmultiple" testLabels := map[string]string{ "foo": "bar", @@ -5047,7 +5059,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestBuildWithExternalAuth(c *testing.T } // Test cases in #22036 -func (s *DockerSuite) TestBuildLabelsOverride(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildLabelsOverride(c *testing.T) { // Command line option labels will always override name := "scratchy" expected := `{"bar":"from-flag","foo":"from-flag"}` @@ -5126,7 +5138,7 @@ func (s *DockerSuite) TestBuildLabelsOverride(c *testing.T) { } // Test case for #22855 -func (s *DockerSuite) TestBuildDeleteCommittedFile(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildDeleteCommittedFile(c *testing.T) { name := "test-delete-committed-file" buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox RUN echo test > file @@ -5136,7 +5148,7 @@ func (s *DockerSuite) TestBuildDeleteCommittedFile(c *testing.T) { } // #20083 -func (s *DockerSuite) TestBuildDockerignoreComment(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildDockerignoreComment(c *testing.T) { // TODO Windows: Figure out why this test is flakey on TP5. If you add // something like RUN sleep 5, or even RUN ls /tmp after the ADD line, // it is more reliable, but that's not a good fix. @@ -5170,7 +5182,7 @@ foo2 } // Test case for #23221 -func (s *DockerSuite) TestBuildWithUTF8BOM(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildWithUTF8BOM(c *testing.T) { name := "test-with-utf8-bom" dockerfile := []byte(`FROM busybox`) bomDockerfile := append([]byte{0xEF, 0xBB, 0xBF}, dockerfile...) @@ -5180,7 +5192,7 @@ func (s *DockerSuite) TestBuildWithUTF8BOM(c *testing.T) { } // Test case for UTF-8 BOM in .dockerignore, related to #23221 -func (s *DockerSuite) TestBuildWithUTF8BOMDockerignore(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildWithUTF8BOMDockerignore(c *testing.T) { name := "test-with-utf8-bom-dockerignore" dockerfile := ` FROM busybox @@ -5197,7 +5209,7 @@ func (s *DockerSuite) TestBuildWithUTF8BOMDockerignore(c *testing.T) { } // #22489 Shell test to confirm config gets updated correctly -func (s *DockerSuite) TestBuildShellUpdatesConfig(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildShellUpdatesConfig(c *testing.T) { name := "testbuildshellupdatesconfig" buildImageSuccessfully(c, name, build.WithDockerfile(`FROM `+minimalBaseImage()+` @@ -5214,7 +5226,7 @@ func (s *DockerSuite) TestBuildShellUpdatesConfig(c *testing.T) { } // #22489 Changing the shell multiple times and CMD after. -func (s *DockerSuite) TestBuildShellMultiple(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildShellMultiple(c *testing.T) { name := "testbuildshellmultiple" result := buildImage(name, build.WithDockerfile(`FROM busybox @@ -5250,7 +5262,7 @@ func (s *DockerSuite) TestBuildShellMultiple(c *testing.T) { } // #22489. Changed SHELL with ENTRYPOINT -func (s *DockerSuite) TestBuildShellEntrypoint(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildShellEntrypoint(c *testing.T) { name := "testbuildshellentrypoint" buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox @@ -5265,7 +5277,7 @@ func (s *DockerSuite) TestBuildShellEntrypoint(c *testing.T) { } // #22489 Shell test to confirm shell is inherited in a subsequent build -func (s *DockerSuite) TestBuildShellInherited(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildShellInherited(c *testing.T) { name1 := "testbuildshellinherited1" buildImageSuccessfully(c, name1, build.WithDockerfile(`FROM busybox SHELL ["ls"]`)) @@ -5278,7 +5290,7 @@ func (s *DockerSuite) TestBuildShellInherited(c *testing.T) { } // #22489 Shell test to confirm non-JSON doesn't work -func (s *DockerSuite) TestBuildShellNotJSON(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildShellNotJSON(c *testing.T) { name := "testbuildshellnotjson" buildImage(name, build.WithDockerfile(`FROM `+minimalBaseImage()+` @@ -5291,7 +5303,7 @@ func (s *DockerSuite) TestBuildShellNotJSON(c *testing.T) { // #22489 Windows shell test to confirm native is powershell if executing a PS command // This would error if the default shell were still cmd. -func (s *DockerSuite) TestBuildShellWindowsPowershell(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildShellWindowsPowershell(c *testing.T) { testRequires(c, DaemonIsWindows) name := "testbuildshellpowershell" buildImage(name, build.WithDockerfile(`FROM `+minimalBaseImage()+` @@ -5303,7 +5315,7 @@ func (s *DockerSuite) TestBuildShellWindowsPowershell(c *testing.T) { // Verify that escape is being correctly applied to words when escape directive is not \. // Tests WORKDIR, ADD -func (s *DockerSuite) TestBuildEscapeNotBackslashWordTest(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildEscapeNotBackslashWordTest(c *testing.T) { testRequires(c, DaemonIsWindows) name := "testbuildescapenotbackslashwordtesta" buildImage(name, build.WithDockerfile(`# escape= `+"`"+` @@ -5326,7 +5338,7 @@ func (s *DockerSuite) TestBuildEscapeNotBackslashWordTest(c *testing.T) { // #22868. Make sure shell-form CMD is not marked as escaped in the config of the image, // but an exec-form CMD is marked. -func (s *DockerSuite) TestBuildCmdShellArgsEscaped(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCmdShellArgsEscaped(c *testing.T) { testRequires(c, DaemonIsWindows) name1 := "testbuildcmdshellescapedshellform" buildImageSuccessfully(c, name1, build.WithDockerfile(` @@ -5366,7 +5378,7 @@ func (s *DockerSuite) TestBuildCmdShellArgsEscaped(c *testing.T) { } // Test case for #24912. -func (s *DockerSuite) TestBuildStepsWithProgress(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildStepsWithProgress(c *testing.T) { name := "testbuildstepswithprogress" totalRun := 5 result := buildImage(name, build.WithDockerfile("FROM busybox\n"+strings.Repeat("RUN echo foo\n", totalRun))) @@ -5377,7 +5389,7 @@ func (s *DockerSuite) TestBuildStepsWithProgress(c *testing.T) { } } -func (s *DockerSuite) TestBuildWithFailure(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildWithFailure(c *testing.T) { name := "testbuildwithfailure" // First test case can only detect `nobody` in runtime so all steps will show up @@ -5394,7 +5406,7 @@ func (s *DockerSuite) TestBuildWithFailure(c *testing.T) { assert.Assert(c, !strings.Contains(result.Stdout(), "Step 2/2 : RUN nobody")) } -func (s *DockerSuite) TestBuildCacheFromEqualDiffIDsLength(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCacheFromEqualDiffIDsLength(c *testing.T) { dockerfile := ` FROM busybox RUN echo "test" @@ -5416,7 +5428,7 @@ func (s *DockerSuite) TestBuildCacheFromEqualDiffIDsLength(c *testing.T) { assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 2) } -func (s *DockerSuite) TestBuildCacheFrom(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCacheFrom(c *testing.T) { testRequires(c, DaemonIsLinux) // All tests that do save are skipped in windows dockerfile := ` FROM busybox @@ -5510,7 +5522,7 @@ func (s *DockerSuite) TestBuildCacheFrom(c *testing.T) { assert.Assert(c, layers1[len(layers1)-1] != layers2[len(layers1)-1]) } -func (s *DockerSuite) TestBuildMultiStageCache(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildMultiStageCache(c *testing.T) { testRequires(c, DaemonIsLinux) // All tests that do save are skipped in windows dockerfile := ` FROM busybox @@ -5534,7 +5546,7 @@ func (s *DockerSuite) TestBuildMultiStageCache(c *testing.T) { assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 2) } -func (s *DockerSuite) TestBuildNetNone(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildNetNone(c *testing.T) { testRequires(c, DaemonIsLinux) name := "testbuildnetnone" buildImage(name, cli.WithFlags("--network=none"), build.WithDockerfile(` @@ -5546,7 +5558,7 @@ func (s *DockerSuite) TestBuildNetNone(c *testing.T) { }) } -func (s *DockerSuite) TestBuildNetContainer(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildNetContainer(c *testing.T) { testRequires(c, DaemonIsLinux) id, _ := dockerCmd(c, "run", "--hostname", "foobar", "-d", "busybox", "nc", "-ll", "-p", "1234", "-e", "hostname") @@ -5562,7 +5574,7 @@ func (s *DockerSuite) TestBuildNetContainer(c *testing.T) { assert.Equal(c, strings.TrimSpace(host), "foobar") } -func (s *DockerSuite) TestBuildWithExtraHost(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildWithExtraHost(c *testing.T) { testRequires(c, DaemonIsLinux) name := "testbuildwithextrahost" @@ -5578,7 +5590,7 @@ func (s *DockerSuite) TestBuildWithExtraHost(c *testing.T) { `)) } -func (s *DockerSuite) TestBuildWithExtraHostInvalidFormat(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildWithExtraHostInvalidFormat(c *testing.T) { testRequires(c, DaemonIsLinux) dockerfile := ` FROM busybox @@ -5605,7 +5617,7 @@ func (s *DockerSuite) TestBuildWithExtraHostInvalidFormat(c *testing.T) { } -func (s *DockerSuite) TestBuildMultiStageCopyFromSyntax(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildMultiStageCopyFromSyntax(c *testing.T) { dockerfile := ` FROM busybox AS first COPY foo bar @@ -5663,7 +5675,7 @@ func (s *DockerSuite) TestBuildMultiStageCopyFromSyntax(c *testing.T) { cli.DockerCmd(c, "run", "build4", "cat", "baz").Assert(c, icmd.Expected{Out: "pqr"}) } -func (s *DockerSuite) TestBuildMultiStageCopyFromErrors(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildMultiStageCopyFromErrors(c *testing.T) { testCases := []struct { dockerfile string expectedError string @@ -5710,7 +5722,7 @@ func (s *DockerSuite) TestBuildMultiStageCopyFromErrors(c *testing.T) { } } -func (s *DockerSuite) TestBuildMultiStageMultipleBuilds(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildMultiStageMultipleBuilds(c *testing.T) { dockerfile := ` FROM busybox COPY foo bar` @@ -5743,7 +5755,7 @@ func (s *DockerSuite) TestBuildMultiStageMultipleBuilds(c *testing.T) { assert.Equal(c, strings.TrimSpace(out), "def") } -func (s *DockerSuite) TestBuildMultiStageImplicitFrom(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildMultiStageImplicitFrom(c *testing.T) { dockerfile := ` FROM busybox COPY --from=busybox /etc/passwd /mypasswd @@ -5800,7 +5812,7 @@ func (s *DockerRegistrySuite) TestBuildMultiStageImplicitPull(c *testing.T) { cli.Docker(cli.Args("run", "build1", "cat", "baz")).Assert(c, icmd.Expected{Out: "abc"}) } -func (s *DockerSuite) TestBuildMultiStageNameVariants(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildMultiStageNameVariants(c *testing.T) { dockerfile := ` FROM busybox as foo COPY foo / @@ -5825,7 +5837,7 @@ func (s *DockerSuite) TestBuildMultiStageNameVariants(c *testing.T) { cli.Docker(cli.Args("run", "build1", "cat", "f2")).Assert(c, icmd.Expected{Out: "bar2"}) } -func (s *DockerSuite) TestBuildMultiStageMultipleBuildsWindows(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildMultiStageMultipleBuildsWindows(c *testing.T) { testRequires(c, DaemonIsWindows) dockerfile := ` FROM ` + testEnv.PlatformDefaults.BaseImage + ` @@ -5859,7 +5871,7 @@ func (s *DockerSuite) TestBuildMultiStageMultipleBuildsWindows(c *testing.T) { assert.Equal(c, strings.TrimSpace(out), "def") } -func (s *DockerSuite) TestBuildCopyFromForbidWindowsSystemPaths(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCopyFromForbidWindowsSystemPaths(c *testing.T) { testRequires(c, DaemonIsWindows) dockerfile := ` FROM ` + testEnv.PlatformDefaults.BaseImage + ` @@ -5876,7 +5888,7 @@ func (s *DockerSuite) TestBuildCopyFromForbidWindowsSystemPaths(c *testing.T) { buildImage("testforbidsystempaths4", build.WithDockerfile(fmt.Sprintf(dockerfile, "c:\\\\wInDows"))).Assert(c, exp) } -func (s *DockerSuite) TestBuildCopyFromForbidWindowsRelativePaths(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCopyFromForbidWindowsRelativePaths(c *testing.T) { testRequires(c, DaemonIsWindows) dockerfile := ` FROM ` + testEnv.PlatformDefaults.BaseImage + ` @@ -5894,7 +5906,7 @@ func (s *DockerSuite) TestBuildCopyFromForbidWindowsRelativePaths(c *testing.T) buildImage("testforbidsystempaths5", build.WithDockerfile(fmt.Sprintf(dockerfile, "\\\\windows"))).Assert(c, exp) } -func (s *DockerSuite) TestBuildCopyFromWindowsIsCaseInsensitive(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCopyFromWindowsIsCaseInsensitive(c *testing.T) { testRequires(c, DaemonIsWindows) dockerfile := ` FROM ` + testEnv.PlatformDefaults.BaseImage + ` @@ -5913,7 +5925,7 @@ func (s *DockerSuite) TestBuildCopyFromWindowsIsCaseInsensitive(c *testing.T) { } // #33176 -func (s *DockerSuite) TestBuildMultiStageResetScratch(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildMultiStageResetScratch(c *testing.T) { testRequires(c, DaemonIsLinux) dockerfile := ` @@ -5933,7 +5945,7 @@ func (s *DockerSuite) TestBuildMultiStageResetScratch(c *testing.T) { assert.Equal(c, strings.TrimSpace(res), "") } -func (s *DockerSuite) TestBuildIntermediateTarget(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildIntermediateTarget(c *testing.T) { //todo: need to be removed after 18.06 release if strings.Contains(testEnv.DaemonInfo.ServerVersion, "18.05.0") { c.Skip(fmt.Sprintf("Bug fixed in 18.06 or higher.Skipping it for %s", testEnv.DaemonInfo.ServerVersion)) @@ -5971,7 +5983,7 @@ func (s *DockerSuite) TestBuildIntermediateTarget(c *testing.T) { // TestBuildOpaqueDirectory tests that a build succeeds which // creates opaque directories. // See https://github.com/docker/docker/issues/25244 -func (s *DockerSuite) TestBuildOpaqueDirectory(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildOpaqueDirectory(c *testing.T) { testRequires(c, DaemonIsLinux) dockerFile := ` FROM busybox @@ -5986,7 +5998,7 @@ func (s *DockerSuite) TestBuildOpaqueDirectory(c *testing.T) { } // Windows test for USER in dockerfile -func (s *DockerSuite) TestBuildWindowsUser(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildWindowsUser(c *testing.T) { testRequires(c, DaemonIsWindows) name := "testbuildwindowsuser" buildImage(name, build.WithDockerfile(`FROM `+testEnv.PlatformDefaults.BaseImage+` @@ -6003,7 +6015,7 @@ func (s *DockerSuite) TestBuildWindowsUser(c *testing.T) { // as opposed to the file being copied as a file with the name of the // directory. Fix for 27545 (found on Windows, but regression good for Linux too). // Note 27545 was reverted in 28505, but a new fix was added subsequently in 28514. -func (s *DockerSuite) TestBuildCopyFileDotWithWorkdir(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCopyFileDotWithWorkdir(c *testing.T) { name := "testbuildcopyfiledotwithworkdir" buildImageSuccessfully(c, name, build.WithBuildContext(c, build.WithFile("Dockerfile", `FROM busybox @@ -6016,7 +6028,7 @@ RUN ["cat", "/foo/file"] } // Case-insensitive environment variables on Windows -func (s *DockerSuite) TestBuildWindowsEnvCaseInsensitive(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildWindowsEnvCaseInsensitive(c *testing.T) { testRequires(c, DaemonIsWindows) name := "testbuildwindowsenvcaseinsensitive" buildImageSuccessfully(c, name, build.WithDockerfile(` @@ -6030,7 +6042,7 @@ func (s *DockerSuite) TestBuildWindowsEnvCaseInsensitive(c *testing.T) { } // Test case for 29667 -func (s *DockerSuite) TestBuildWorkdirImageCmd(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildWorkdirImageCmd(c *testing.T) { image := "testworkdirimagecmd" buildImageSuccessfully(c, image, build.WithDockerfile(` FROM busybox @@ -6051,7 +6063,7 @@ LABEL a=b } // Test case for 28902/28909 -func (s *DockerSuite) TestBuildWorkdirCmd(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildWorkdirCmd(c *testing.T) { testRequires(c, DaemonIsLinux) name := "testbuildworkdircmd" dockerFile := ` @@ -6065,7 +6077,7 @@ func (s *DockerSuite) TestBuildWorkdirCmd(c *testing.T) { } // FIXME(vdemeester) should be a unit test -func (s *DockerSuite) TestBuildLineErrorOnBuild(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildLineErrorOnBuild(c *testing.T) { name := "test_build_line_error_onbuild" buildImage(name, build.WithDockerfile(`FROM busybox ONBUILD @@ -6076,7 +6088,7 @@ func (s *DockerSuite) TestBuildLineErrorOnBuild(c *testing.T) { } // FIXME(vdemeester) should be a unit test -func (s *DockerSuite) TestBuildLineErrorUnknownInstruction(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildLineErrorUnknownInstruction(c *testing.T) { name := "test_build_line_error_unknown_instruction" cli.Docker(cli.Build(name), build.WithDockerfile(`FROM busybox RUN echo hello world @@ -6090,7 +6102,7 @@ func (s *DockerSuite) TestBuildLineErrorUnknownInstruction(c *testing.T) { } // FIXME(vdemeester) should be a unit test -func (s *DockerSuite) TestBuildLineErrorWithEmptyLines(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildLineErrorWithEmptyLines(c *testing.T) { name := "test_build_line_error_with_empty_lines" cli.Docker(cli.Build(name), build.WithDockerfile(` FROM busybox @@ -6107,7 +6119,7 @@ func (s *DockerSuite) TestBuildLineErrorWithEmptyLines(c *testing.T) { } // FIXME(vdemeester) should be a unit test -func (s *DockerSuite) TestBuildLineErrorWithComments(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildLineErrorWithComments(c *testing.T) { name := "test_build_line_error_with_comments" cli.Docker(cli.Build(name), build.WithDockerfile(`FROM busybox # This will print hello world @@ -6121,7 +6133,7 @@ func (s *DockerSuite) TestBuildLineErrorWithComments(c *testing.T) { } // #31957 -func (s *DockerSuite) TestBuildSetCommandWithDefinedShell(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildSetCommandWithDefinedShell(c *testing.T) { buildImageSuccessfully(c, "build1", build.WithDockerfile(` FROM busybox SHELL ["/bin/sh", "-c"] @@ -6140,7 +6152,7 @@ CMD echo foo } // FIXME(vdemeester) should migrate to docker/cli tests -func (s *DockerSuite) TestBuildIidFile(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildIidFile(c *testing.T) { tmpDir, err := os.MkdirTemp("", "TestBuildIidFile") if err != nil { c.Fatal(err) @@ -6165,7 +6177,7 @@ ENV BAR BAZ`), } // FIXME(vdemeester) should migrate to docker/cli tests -func (s *DockerSuite) TestBuildIidFileCleanupOnFail(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildIidFileCleanupOnFail(c *testing.T) { tmpDir, err := os.MkdirTemp("", "TestBuildIidFileCleanupOnFail") if err != nil { c.Fatal(err) diff --git a/integration-cli/docker_cli_build_unix_test.go b/integration-cli/docker_cli_build_unix_test.go index 92e51b611a..3d59d62fcb 100644 --- a/integration-cli/docker_cli_build_unix_test.go +++ b/integration-cli/docker_cli_build_unix_test.go @@ -24,10 +24,10 @@ import ( "gotest.tools/v3/icmd" ) -func (s *DockerSuite) TestBuildResourceConstraintsAreUsed(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildResourceConstraintsAreUsed(c *testing.T) { testRequires(c, cpuCfsQuota) name := "testbuildresourceconstraints" - buildLabel := "DockerSuite.TestBuildResourceConstraintsAreUsed" + buildLabel := "DockerCLIBuildSuite.TestBuildResourceConstraintsAreUsed" ctx := fakecontext.New(c, "", fakecontext.WithDockerfile(` FROM hello-world:frozen @@ -84,7 +84,7 @@ func (s *DockerSuite) TestBuildResourceConstraintsAreUsed(c *testing.T) { assert.Assert(c, c2.Ulimits == nil, "resource leaked from build for Ulimits") } -func (s *DockerSuite) TestBuildAddChangeOwnership(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildAddChangeOwnership(c *testing.T) { testRequires(c, DaemonIsLinux) name := "testbuildaddown" @@ -130,7 +130,7 @@ func (s *DockerSuite) TestBuildAddChangeOwnership(c *testing.T) { // TODO(buildkit): this test needs to be rewritten for buildkit. // It has been manually tested positive. Confirmed issue: docker build output parsing. // Potential issue: newEventObserver uses docker events, which is not hooked up to buildkit. -func (s *DockerSuite) TestBuildCancellationKillsSleep(c *testing.T) { +func (s *DockerCLIBuildSuite) TestBuildCancellationKillsSleep(c *testing.T) { testRequires(c, DaemonIsLinux, TODOBuildkit) name := "testbuildcancellation" diff --git a/integration-cli/docker_cli_commit_test.go b/integration-cli/docker_cli_commit_test.go index d5c4b8ca59..c562430527 100644 --- a/integration-cli/docker_cli_commit_test.go +++ b/integration-cli/docker_cli_commit_test.go @@ -10,7 +10,19 @@ import ( "gotest.tools/v3/skip" ) -func (s *DockerSuite) TestCommitAfterContainerIsDone(c *testing.T) { +type DockerCLICommitSuite struct { + ds *DockerSuite +} + +func (s *DockerCLICommitSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLICommitSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + +func (s *DockerCLICommitSuite) TestCommitAfterContainerIsDone(c *testing.T) { skip.If(c, RuntimeIsWindowsContainerd(), "FIXME: Broken on Windows + containerd combination") out := cli.DockerCmd(c, "run", "-i", "-a", "stdin", "busybox", "echo", "foo").Combined() @@ -25,7 +37,7 @@ func (s *DockerSuite) TestCommitAfterContainerIsDone(c *testing.T) { cli.DockerCmd(c, "inspect", cleanedImageID) } -func (s *DockerSuite) TestCommitWithoutPause(c *testing.T) { +func (s *DockerCLICommitSuite) TestCommitWithoutPause(c *testing.T) { testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "-i", "-a", "stdin", "busybox", "echo", "foo") @@ -41,7 +53,7 @@ func (s *DockerSuite) TestCommitWithoutPause(c *testing.T) { } // TestCommitPausedContainer tests that a paused container is not unpaused after being committed -func (s *DockerSuite) TestCommitPausedContainer(c *testing.T) { +func (s *DockerCLICommitSuite) TestCommitPausedContainer(c *testing.T) { testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "-i", "-d", "busybox") @@ -55,7 +67,7 @@ func (s *DockerSuite) TestCommitPausedContainer(c *testing.T) { assert.Assert(c, strings.Contains(out, "true")) } -func (s *DockerSuite) TestCommitNewFile(c *testing.T) { +func (s *DockerCLICommitSuite) TestCommitNewFile(c *testing.T) { dockerCmd(c, "run", "--name", "committer", "busybox", "/bin/sh", "-c", "echo koye > /foo") imageID, _ := dockerCmd(c, "commit", "committer") @@ -66,7 +78,7 @@ func (s *DockerSuite) TestCommitNewFile(c *testing.T) { assert.Equal(c, actual, "koye") } -func (s *DockerSuite) TestCommitHardlink(c *testing.T) { +func (s *DockerCLICommitSuite) TestCommitHardlink(c *testing.T) { testRequires(c, DaemonIsLinux) firstOutput, _ := dockerCmd(c, "run", "-t", "--name", "hardlinks", "busybox", "sh", "-c", "touch file1 && ln file1 file2 && ls -di file1 file2") @@ -85,7 +97,7 @@ func (s *DockerSuite) TestCommitHardlink(c *testing.T) { assert.Assert(c, strings.Contains(chunks[1], chunks[0]), "Failed to create hardlink in a container. Expected to find %q in %q", inode, chunks[1:]) } -func (s *DockerSuite) TestCommitTTY(c *testing.T) { +func (s *DockerCLICommitSuite) TestCommitTTY(c *testing.T) { dockerCmd(c, "run", "-t", "--name", "tty", "busybox", "/bin/ls") imageID, _ := dockerCmd(c, "commit", "tty", "ttytest") @@ -94,7 +106,7 @@ func (s *DockerSuite) TestCommitTTY(c *testing.T) { dockerCmd(c, "run", imageID, "/bin/ls") } -func (s *DockerSuite) TestCommitWithHostBindMount(c *testing.T) { +func (s *DockerCLICommitSuite) TestCommitWithHostBindMount(c *testing.T) { testRequires(c, DaemonIsLinux) dockerCmd(c, "run", "--name", "bind-commit", "-v", "/dev/null:/winning", "busybox", "true") @@ -104,7 +116,7 @@ func (s *DockerSuite) TestCommitWithHostBindMount(c *testing.T) { dockerCmd(c, "run", imageID, "true") } -func (s *DockerSuite) TestCommitChange(c *testing.T) { +func (s *DockerCLICommitSuite) TestCommitChange(c *testing.T) { dockerCmd(c, "run", "--name", "test", "busybox", "true") imageID, _ := dockerCmd(c, "commit", @@ -154,7 +166,7 @@ func (s *DockerSuite) TestCommitChange(c *testing.T) { } } -func (s *DockerSuite) TestCommitChangeLabels(c *testing.T) { +func (s *DockerCLICommitSuite) TestCommitChangeLabels(c *testing.T) { dockerCmd(c, "run", "--name", "test", "--label", "some=label", "busybox", "true") imageID, _ := dockerCmd(c, "commit", diff --git a/integration-cli/docker_cli_cp_from_container_test.go b/integration-cli/docker_cli_cp_from_container_test.go index a357489280..3b309ee7f6 100644 --- a/integration-cli/docker_cli_cp_from_container_test.go +++ b/integration-cli/docker_cli_cp_from_container_test.go @@ -21,7 +21,7 @@ import ( // Check that copying from a container to a local symlink copies to the symlink // target and does not overwrite the local symlink itself. // TODO: move to docker/cli and/or integration/container/copy_test.go -func (s *DockerSuite) TestCpFromSymlinkDestination(c *testing.T) { +func (s *DockerCLICpSuite) TestCpFromSymlinkDestination(c *testing.T) { testRequires(c, DaemonIsLinux) containerID := makeTestContainer(c, testContainerOptions{addContent: true}) @@ -96,7 +96,7 @@ func (s *DockerSuite) TestCpFromSymlinkDestination(c *testing.T) { // A. SRC specifies a file and DST (no trailing path separator) doesn't // exist. This should create a file with the name DST and copy the // contents of the source file into it. -func (s *DockerSuite) TestCpFromCaseA(c *testing.T) { +func (s *DockerCLICpSuite) TestCpFromCaseA(c *testing.T) { testRequires(c, DaemonIsLinux) containerID := makeTestContainer(c, testContainerOptions{ addContent: true, workDir: "/root", @@ -115,7 +115,7 @@ func (s *DockerSuite) TestCpFromCaseA(c *testing.T) { // B. SRC specifies a file and DST (with trailing path separator) doesn't // exist. This should cause an error because the copy operation cannot // create a directory when copying a single file. -func (s *DockerSuite) TestCpFromCaseB(c *testing.T) { +func (s *DockerCLICpSuite) TestCpFromCaseB(c *testing.T) { testRequires(c, DaemonIsLinux) containerID := makeTestContainer(c, testContainerOptions{addContent: true}) @@ -132,7 +132,7 @@ func (s *DockerSuite) TestCpFromCaseB(c *testing.T) { // C. SRC specifies a file and DST exists as a file. This should overwrite // the file at DST with the contents of the source file. -func (s *DockerSuite) TestCpFromCaseC(c *testing.T) { +func (s *DockerCLICpSuite) TestCpFromCaseC(c *testing.T) { testRequires(c, DaemonIsLinux) containerID := makeTestContainer(c, testContainerOptions{ addContent: true, workDir: "/root", @@ -155,7 +155,7 @@ func (s *DockerSuite) TestCpFromCaseC(c *testing.T) { // D. SRC specifies a file and DST exists as a directory. This should place // a copy of the source file inside it using the basename from SRC. Ensure // this works whether DST has a trailing path separator or not. -func (s *DockerSuite) TestCpFromCaseD(c *testing.T) { +func (s *DockerCLICpSuite) TestCpFromCaseD(c *testing.T) { testRequires(c, DaemonIsLinux) containerID := makeTestContainer(c, testContainerOptions{addContent: true}) @@ -190,7 +190,7 @@ func (s *DockerSuite) TestCpFromCaseD(c *testing.T) { // directory at DST and copy the contents of the SRC directory into the DST // directory. Ensure this works whether DST has a trailing path separator or // not. -func (s *DockerSuite) TestCpFromCaseE(c *testing.T) { +func (s *DockerCLICpSuite) TestCpFromCaseE(c *testing.T) { testRequires(c, DaemonIsLinux) containerID := makeTestContainer(c, testContainerOptions{addContent: true}) @@ -216,7 +216,7 @@ func (s *DockerSuite) TestCpFromCaseE(c *testing.T) { // F. SRC specifies a directory and DST exists as a file. This should cause an // error as it is not possible to overwrite a file with a directory. -func (s *DockerSuite) TestCpFromCaseF(c *testing.T) { +func (s *DockerCLICpSuite) TestCpFromCaseF(c *testing.T) { testRequires(c, DaemonIsLinux) containerID := makeTestContainer(c, testContainerOptions{ addContent: true, workDir: "/root", @@ -238,7 +238,7 @@ func (s *DockerSuite) TestCpFromCaseF(c *testing.T) { // G. SRC specifies a directory and DST exists as a directory. This should copy // the SRC directory and all its contents to the DST directory. Ensure this // works whether DST has a trailing path separator or not. -func (s *DockerSuite) TestCpFromCaseG(c *testing.T) { +func (s *DockerCLICpSuite) TestCpFromCaseG(c *testing.T) { testRequires(c, DaemonIsLinux) containerID := makeTestContainer(c, testContainerOptions{ addContent: true, workDir: "/root", @@ -272,7 +272,7 @@ func (s *DockerSuite) TestCpFromCaseG(c *testing.T) { // should create a directory at DST and copy the contents of the SRC // directory (but not the directory itself) into the DST directory. Ensure // this works whether DST has a trailing path separator or not. -func (s *DockerSuite) TestCpFromCaseH(c *testing.T) { +func (s *DockerCLICpSuite) TestCpFromCaseH(c *testing.T) { testRequires(c, DaemonIsLinux) containerID := makeTestContainer(c, testContainerOptions{addContent: true}) @@ -299,7 +299,7 @@ func (s *DockerSuite) TestCpFromCaseH(c *testing.T) { // I. SRC specifies a directory's contents only and DST exists as a file. This // should cause an error as it is not possible to overwrite a file with a // directory. -func (s *DockerSuite) TestCpFromCaseI(c *testing.T) { +func (s *DockerCLICpSuite) TestCpFromCaseI(c *testing.T) { testRequires(c, DaemonIsLinux) containerID := makeTestContainer(c, testContainerOptions{ addContent: true, workDir: "/root", @@ -322,7 +322,7 @@ func (s *DockerSuite) TestCpFromCaseI(c *testing.T) { // This should copy the contents of the SRC directory (but not the directory // itself) into the DST directory. Ensure this works whether DST has a // trailing path separator or not. -func (s *DockerSuite) TestCpFromCaseJ(c *testing.T) { +func (s *DockerCLICpSuite) TestCpFromCaseJ(c *testing.T) { testRequires(c, DaemonIsLinux) containerID := makeTestContainer(c, testContainerOptions{ addContent: true, workDir: "/root", diff --git a/integration-cli/docker_cli_cp_test.go b/integration-cli/docker_cli_cp_test.go index 173cf4eee5..47d40a9ac3 100644 --- a/integration-cli/docker_cli_cp_test.go +++ b/integration-cli/docker_cli_cp_test.go @@ -26,15 +26,27 @@ const ( cpHostContents = "hello, i am the host" ) +type DockerCLICpSuite struct { + ds *DockerSuite +} + +func (s *DockerCLICpSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLICpSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + // Ensure that an all-local path case returns an error. -func (s *DockerSuite) TestCpLocalOnly(c *testing.T) { +func (s *DockerCLICpSuite) TestCpLocalOnly(c *testing.T) { err := runDockerCp(c, "foo", "bar") assert.ErrorContains(c, err, "must specify at least one container source") } // Test for #5656 // Check that garbage paths don't escape the container's rootfs -func (s *DockerSuite) TestCpGarbagePath(c *testing.T) { +func (s *DockerCLICpSuite) TestCpGarbagePath(c *testing.T) { out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath) containerID := strings.TrimSpace(out) @@ -70,7 +82,7 @@ func (s *DockerSuite) TestCpGarbagePath(c *testing.T) { } // Check that relative paths are relative to the container's rootfs -func (s *DockerSuite) TestCpRelativePath(c *testing.T) { +func (s *DockerCLICpSuite) TestCpRelativePath(c *testing.T) { out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath) containerID := strings.TrimSpace(out) @@ -112,7 +124,7 @@ func (s *DockerSuite) TestCpRelativePath(c *testing.T) { } // Check that absolute paths are relative to the container's rootfs -func (s *DockerSuite) TestCpAbsolutePath(c *testing.T) { +func (s *DockerCLICpSuite) TestCpAbsolutePath(c *testing.T) { out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath) containerID := strings.TrimSpace(out) @@ -149,7 +161,7 @@ func (s *DockerSuite) TestCpAbsolutePath(c *testing.T) { // Test for #5619 // Check that absolute symlinks are still relative to the container's rootfs -func (s *DockerSuite) TestCpAbsoluteSymlink(c *testing.T) { +func (s *DockerCLICpSuite) TestCpAbsoluteSymlink(c *testing.T) { testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath+" && ln -s "+cpFullPath+" container_path") @@ -185,7 +197,7 @@ func (s *DockerSuite) TestCpAbsoluteSymlink(c *testing.T) { // Check that symlinks to a directory behave as expected when copying one from // a container. -func (s *DockerSuite) TestCpFromSymlinkToDirectory(c *testing.T) { +func (s *DockerCLICpSuite) TestCpFromSymlinkToDirectory(c *testing.T) { testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath+" && ln -s "+cpTestPathParent+" /dir_link") @@ -231,7 +243,7 @@ func (s *DockerSuite) TestCpFromSymlinkToDirectory(c *testing.T) { // Check that symlinks to a directory behave as expected when copying one to a // container. -func (s *DockerSuite) TestCpToSymlinkToDirectory(c *testing.T) { +func (s *DockerCLICpSuite) TestCpToSymlinkToDirectory(c *testing.T) { testRequires(c, DaemonIsLinux) testRequires(c, testEnv.IsLocalDaemon) // Requires local volume mount bind. @@ -308,7 +320,7 @@ func (s *DockerSuite) TestCpToSymlinkToDirectory(c *testing.T) { // Test for #5619 // Check that symlinks which are part of the resource path are still relative to the container's rootfs -func (s *DockerSuite) TestCpSymlinkComponent(c *testing.T) { +func (s *DockerCLICpSuite) TestCpSymlinkComponent(c *testing.T) { testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath+" && ln -s "+cpTestPath+" container_path") @@ -347,7 +359,7 @@ func (s *DockerSuite) TestCpSymlinkComponent(c *testing.T) { } // Check that cp with unprivileged user doesn't return any error -func (s *DockerSuite) TestCpUnprivilegedUser(c *testing.T) { +func (s *DockerCLICpSuite) TestCpUnprivilegedUser(c *testing.T) { testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) testRequires(c, UnixCli) // uses chmod/su: not available on windows @@ -371,7 +383,7 @@ func (s *DockerSuite) TestCpUnprivilegedUser(c *testing.T) { result.Assert(c, icmd.Expected{}) } -func (s *DockerSuite) TestCpSpecialFiles(c *testing.T) { +func (s *DockerCLICpSuite) TestCpSpecialFiles(c *testing.T) { testRequires(c, DaemonIsLinux) testRequires(c, testEnv.IsLocalDaemon) @@ -411,7 +423,7 @@ func (s *DockerSuite) TestCpSpecialFiles(c *testing.T) { assert.Assert(c, bytes.Equal(actual, expected), "Expected copied file to be duplicate of the container hostname") } -func (s *DockerSuite) TestCpVolumePath(c *testing.T) { +func (s *DockerCLICpSuite) TestCpVolumePath(c *testing.T) { // stat /tmp/cp-test-volumepath851508420/test gets permission denied for the user testRequires(c, NotUserNamespace) testRequires(c, DaemonIsLinux) @@ -474,7 +486,7 @@ func (s *DockerSuite) TestCpVolumePath(c *testing.T) { assert.Assert(c, bytes.Equal(fb, fb2), "Expected copied file to be duplicate of bind-mounted file") } -func (s *DockerSuite) TestCpToDot(c *testing.T) { +func (s *DockerCLICpSuite) TestCpToDot(c *testing.T) { out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "echo lololol > /test") containerID := strings.TrimSpace(out) @@ -497,7 +509,7 @@ func (s *DockerSuite) TestCpToDot(c *testing.T) { assert.Equal(c, string(content), "lololol\n") } -func (s *DockerSuite) TestCpToStdout(c *testing.T) { +func (s *DockerCLICpSuite) TestCpToStdout(c *testing.T) { out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "echo lololol > /test") containerID := strings.TrimSpace(out) @@ -514,7 +526,7 @@ func (s *DockerSuite) TestCpToStdout(c *testing.T) { assert.Check(c, is.Contains(out, "-rw")) } -func (s *DockerSuite) TestCpNameHasColon(c *testing.T) { +func (s *DockerCLICpSuite) TestCpNameHasColon(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "echo lololol > /te:s:t") @@ -533,7 +545,7 @@ func (s *DockerSuite) TestCpNameHasColon(c *testing.T) { assert.Equal(c, string(content), "lololol\n") } -func (s *DockerSuite) TestCopyAndRestart(c *testing.T) { +func (s *DockerCLICpSuite) TestCopyAndRestart(c *testing.T) { testRequires(c, DaemonIsLinux) expectedMsg := "hello" out, _ := dockerCmd(c, "run", "-d", "busybox", "echo", expectedMsg) @@ -552,7 +564,7 @@ func (s *DockerSuite) TestCopyAndRestart(c *testing.T) { assert.Equal(c, strings.TrimSpace(out), expectedMsg) } -func (s *DockerSuite) TestCopyCreatedContainer(c *testing.T) { +func (s *DockerCLICpSuite) TestCopyCreatedContainer(c *testing.T) { testRequires(c, DaemonIsLinux) dockerCmd(c, "create", "--name", "test_cp", "-v", "/test", "busybox") @@ -565,7 +577,7 @@ func (s *DockerSuite) TestCopyCreatedContainer(c *testing.T) { // test copy with option `-L`: following symbol link // Check that symlinks to a file behave as expected when copying one from // a container to host following symbol link -func (s *DockerSuite) TestCpSymlinkFromConToHostFollowSymlink(c *testing.T) { +func (s *DockerCLICpSuite) TestCpSymlinkFromConToHostFollowSymlink(c *testing.T) { testRequires(c, DaemonIsLinux) out, exitCode := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath+" && ln -s "+cpFullPath+" /dir_link") assert.Equal(c, exitCode, 0, "failed to set up container: %s", out) diff --git a/integration-cli/docker_cli_cp_to_container_test.go b/integration-cli/docker_cli_cp_to_container_test.go index 6f28077f92..c15a545f9a 100644 --- a/integration-cli/docker_cli_cp_to_container_test.go +++ b/integration-cli/docker_cli_cp_to_container_test.go @@ -19,7 +19,7 @@ import ( // Check that copying from a local path to a symlink in a container copies to // the symlink target and does not overwrite the container symlink itself. -func (s *DockerSuite) TestCpToSymlinkDestination(c *testing.T) { +func (s *DockerCLICpSuite) TestCpToSymlinkDestination(c *testing.T) { // stat /tmp/test-cp-to-symlink-destination-262430901/vol3 gets permission denied for the user testRequires(c, NotUserNamespace) testRequires(c, DaemonIsLinux) @@ -100,7 +100,7 @@ func (s *DockerSuite) TestCpToSymlinkDestination(c *testing.T) { // A. SRC specifies a file and DST (no trailing path separator) doesn't // exist. This should create a file with the name DST and copy the // contents of the source file into it. -func (s *DockerSuite) TestCpToCaseA(c *testing.T) { +func (s *DockerCLICpSuite) TestCpToCaseA(c *testing.T) { containerID := makeTestContainer(c, testContainerOptions{ workDir: "/root", command: makeCatFileCommand("itWorks.txt"), }) @@ -120,7 +120,7 @@ func (s *DockerSuite) TestCpToCaseA(c *testing.T) { // B. SRC specifies a file and DST (with trailing path separator) doesn't // exist. This should cause an error because the copy operation cannot // create a directory when copying a single file. -func (s *DockerSuite) TestCpToCaseB(c *testing.T) { +func (s *DockerCLICpSuite) TestCpToCaseB(c *testing.T) { containerID := makeTestContainer(c, testContainerOptions{ command: makeCatFileCommand("testDir/file1"), }) @@ -140,7 +140,7 @@ func (s *DockerSuite) TestCpToCaseB(c *testing.T) { // C. SRC specifies a file and DST exists as a file. This should overwrite // the file at DST with the contents of the source file. -func (s *DockerSuite) TestCpToCaseC(c *testing.T) { +func (s *DockerCLICpSuite) TestCpToCaseC(c *testing.T) { testRequires(c, DaemonIsLinux) containerID := makeTestContainer(c, testContainerOptions{ addContent: true, workDir: "/root", @@ -164,7 +164,7 @@ func (s *DockerSuite) TestCpToCaseC(c *testing.T) { // D. SRC specifies a file and DST exists as a directory. This should place // a copy of the source file inside it using the basename from SRC. Ensure // this works whether DST has a trailing path separator or not. -func (s *DockerSuite) TestCpToCaseD(c *testing.T) { +func (s *DockerCLICpSuite) TestCpToCaseD(c *testing.T) { testRequires(c, DaemonIsLinux) containerID := makeTestContainer(c, testContainerOptions{ addContent: true, @@ -202,7 +202,7 @@ func (s *DockerSuite) TestCpToCaseD(c *testing.T) { // directory at DST and copy the contents of the SRC directory into the DST // directory. Ensure this works whether DST has a trailing path separator or // not. -func (s *DockerSuite) TestCpToCaseE(c *testing.T) { +func (s *DockerCLICpSuite) TestCpToCaseE(c *testing.T) { containerID := makeTestContainer(c, testContainerOptions{ command: makeCatFileCommand("/testDir/file1-1"), }) @@ -233,7 +233,7 @@ func (s *DockerSuite) TestCpToCaseE(c *testing.T) { // F. SRC specifies a directory and DST exists as a file. This should cause an // error as it is not possible to overwrite a file with a directory. -func (s *DockerSuite) TestCpToCaseF(c *testing.T) { +func (s *DockerCLICpSuite) TestCpToCaseF(c *testing.T) { testRequires(c, DaemonIsLinux) containerID := makeTestContainer(c, testContainerOptions{ addContent: true, workDir: "/root", @@ -255,7 +255,7 @@ func (s *DockerSuite) TestCpToCaseF(c *testing.T) { // G. SRC specifies a directory and DST exists as a directory. This should copy // the SRC directory and all its contents to the DST directory. Ensure this // works whether DST has a trailing path separator or not. -func (s *DockerSuite) TestCpToCaseG(c *testing.T) { +func (s *DockerCLICpSuite) TestCpToCaseG(c *testing.T) { testRequires(c, DaemonIsLinux) containerID := makeTestContainer(c, testContainerOptions{ addContent: true, workDir: "/root", @@ -293,7 +293,7 @@ func (s *DockerSuite) TestCpToCaseG(c *testing.T) { // should create a directory at DST and copy the contents of the SRC // directory (but not the directory itself) into the DST directory. Ensure // this works whether DST has a trailing path separator or not. -func (s *DockerSuite) TestCpToCaseH(c *testing.T) { +func (s *DockerCLICpSuite) TestCpToCaseH(c *testing.T) { containerID := makeTestContainer(c, testContainerOptions{ command: makeCatFileCommand("/testDir/file1-1"), }) @@ -325,7 +325,7 @@ func (s *DockerSuite) TestCpToCaseH(c *testing.T) { // I. SRC specifies a directory's contents only and DST exists as a file. This // should cause an error as it is not possible to overwrite a file with a // directory. -func (s *DockerSuite) TestCpToCaseI(c *testing.T) { +func (s *DockerCLICpSuite) TestCpToCaseI(c *testing.T) { testRequires(c, DaemonIsLinux) containerID := makeTestContainer(c, testContainerOptions{ addContent: true, workDir: "/root", @@ -348,7 +348,7 @@ func (s *DockerSuite) TestCpToCaseI(c *testing.T) { // This should copy the contents of the SRC directory (but not the directory // itself) into the DST directory. Ensure this works whether DST has a // trailing path separator or not. -func (s *DockerSuite) TestCpToCaseJ(c *testing.T) { +func (s *DockerCLICpSuite) TestCpToCaseJ(c *testing.T) { testRequires(c, DaemonIsLinux) containerID := makeTestContainer(c, testContainerOptions{ addContent: true, workDir: "/root", @@ -383,7 +383,7 @@ func (s *DockerSuite) TestCpToCaseJ(c *testing.T) { // The `docker cp` command should also ensure that you cannot // write to a container rootfs that is marked as read-only. -func (s *DockerSuite) TestCpToErrReadOnlyRootfs(c *testing.T) { +func (s *DockerCLICpSuite) TestCpToErrReadOnlyRootfs(c *testing.T) { // --read-only + userns has remount issues testRequires(c, DaemonIsLinux, NotUserNamespace) tmpDir := getTestDir(c, "test-cp-to-err-read-only-rootfs") @@ -408,7 +408,7 @@ func (s *DockerSuite) TestCpToErrReadOnlyRootfs(c *testing.T) { // The `docker cp` command should also ensure that you // cannot write to a volume that is mounted as read-only. -func (s *DockerSuite) TestCpToErrReadOnlyVolume(c *testing.T) { +func (s *DockerCLICpSuite) TestCpToErrReadOnlyVolume(c *testing.T) { // --read-only + userns has remount issues testRequires(c, DaemonIsLinux, NotUserNamespace) tmpDir := getTestDir(c, "test-cp-to-err-read-only-volume") diff --git a/integration-cli/docker_cli_cp_to_container_unix_test.go b/integration-cli/docker_cli_cp_to_container_unix_test.go index 80e668c2ec..18e50e2c06 100644 --- a/integration-cli/docker_cli_cp_to_container_unix_test.go +++ b/integration-cli/docker_cli_cp_to_container_unix_test.go @@ -16,7 +16,7 @@ import ( "gotest.tools/v3/assert" ) -func (s *DockerSuite) TestCpToContainerWithPermissions(c *testing.T) { +func (s *DockerCLICpSuite) TestCpToContainerWithPermissions(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) tmpDir := getTestDir(c, "test-cp-to-host-with-permissions") @@ -43,7 +43,7 @@ func (s *DockerSuite) TestCpToContainerWithPermissions(c *testing.T) { } // Check ownership is root, both in non-userns and userns enabled modes -func (s *DockerSuite) TestCpCheckDestOwnership(c *testing.T) { +func (s *DockerCLICpSuite) TestCpCheckDestOwnership(c *testing.T) { testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) tmpVolDir := getTestDir(c, "test-cp-tmpvol") containerID := makeTestContainer(c, diff --git a/integration-cli/docker_cli_create_test.go b/integration-cli/docker_cli_create_test.go index 94c91c2c7c..5512032c6c 100644 --- a/integration-cli/docker_cli_create_test.go +++ b/integration-cli/docker_cli_create_test.go @@ -17,8 +17,20 @@ import ( is "gotest.tools/v3/assert/cmp" ) +type DockerCLICreateSuite struct { + ds *DockerSuite +} + +func (s *DockerCLICreateSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLICreateSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + // Make sure we can create a simple container with some args -func (s *DockerSuite) TestCreateArgs(c *testing.T) { +func (s *DockerCLICreateSuite) TestCreateArgs(c *testing.T) { // Intentionally clear entrypoint, as the Windows busybox image needs an entrypoint, which breaks this test out, _ := dockerCmd(c, "create", "--entrypoint=", "busybox", "command", "arg1", "arg2", "arg with space", "-c", "flags") @@ -53,7 +65,7 @@ func (s *DockerSuite) TestCreateArgs(c *testing.T) { } // Make sure we can grow the container's rootfs at creation time. -func (s *DockerSuite) TestCreateGrowRootfs(c *testing.T) { +func (s *DockerCLICreateSuite) TestCreateGrowRootfs(c *testing.T) { // Windows and Devicemapper support growing the rootfs if testEnv.OSType != "windows" { testRequires(c, Devicemapper) @@ -67,7 +79,7 @@ func (s *DockerSuite) TestCreateGrowRootfs(c *testing.T) { } // Make sure we cannot shrink the container's rootfs at creation time. -func (s *DockerSuite) TestCreateShrinkRootfs(c *testing.T) { +func (s *DockerCLICreateSuite) TestCreateShrinkRootfs(c *testing.T) { testRequires(c, Devicemapper) // Ensure this fails because of the defaultBaseFsSize is 10G @@ -77,7 +89,7 @@ func (s *DockerSuite) TestCreateShrinkRootfs(c *testing.T) { } // Make sure we can set hostconfig options too -func (s *DockerSuite) TestCreateHostConfig(c *testing.T) { +func (s *DockerCLICreateSuite) TestCreateHostConfig(c *testing.T) { out, _ := dockerCmd(c, "create", "-P", "busybox", "echo") cleanedContainerID := strings.TrimSpace(out) @@ -99,7 +111,7 @@ func (s *DockerSuite) TestCreateHostConfig(c *testing.T) { assert.Assert(c, cont.HostConfig.PublishAllPorts, "Expected PublishAllPorts, got false") } -func (s *DockerSuite) TestCreateWithPortRange(c *testing.T) { +func (s *DockerCLICreateSuite) TestCreateWithPortRange(c *testing.T) { out, _ := dockerCmd(c, "create", "-p", "3300-3303:3300-3303/tcp", "busybox", "echo") cleanedContainerID := strings.TrimSpace(out) @@ -128,7 +140,7 @@ func (s *DockerSuite) TestCreateWithPortRange(c *testing.T) { } -func (s *DockerSuite) TestCreateWithLargePortRange(c *testing.T) { +func (s *DockerCLICreateSuite) TestCreateWithLargePortRange(c *testing.T) { out, _ := dockerCmd(c, "create", "-p", "1-65535:1-65535/tcp", "busybox", "echo") cleanedContainerID := strings.TrimSpace(out) @@ -157,7 +169,7 @@ func (s *DockerSuite) TestCreateWithLargePortRange(c *testing.T) { } // "test123" should be printed by docker create + start -func (s *DockerSuite) TestCreateEchoStdout(c *testing.T) { +func (s *DockerCLICreateSuite) TestCreateEchoStdout(c *testing.T) { out, _ := dockerCmd(c, "create", "busybox", "echo", "test123") cleanedContainerID := strings.TrimSpace(out) @@ -166,7 +178,7 @@ func (s *DockerSuite) TestCreateEchoStdout(c *testing.T) { assert.Equal(c, out, "test123\n", "container should've printed 'test123', got %q", out) } -func (s *DockerSuite) TestCreateVolumesCreated(c *testing.T) { +func (s *DockerCLICreateSuite) TestCreateVolumesCreated(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon) prefix, slash := getPrefixAndSlashFromDaemonPlatform() @@ -185,7 +197,7 @@ func (s *DockerSuite) TestCreateVolumesCreated(c *testing.T) { } -func (s *DockerSuite) TestCreateLabels(c *testing.T) { +func (s *DockerCLICreateSuite) TestCreateLabels(c *testing.T) { name := "test_create_labels" expected := map[string]string{"k1": "v1", "k2": "v2"} dockerCmd(c, "create", "--name", name, "-l", "k1=v1", "--label", "k2=v2", "busybox") @@ -198,7 +210,7 @@ func (s *DockerSuite) TestCreateLabels(c *testing.T) { } } -func (s *DockerSuite) TestCreateLabelFromImage(c *testing.T) { +func (s *DockerCLICreateSuite) TestCreateLabelFromImage(c *testing.T) { imageName := "testcreatebuildlabel" buildImageSuccessfully(c, imageName, build.WithDockerfile(`FROM busybox LABEL k1=v1 k2=v2`)) @@ -215,7 +227,7 @@ func (s *DockerSuite) TestCreateLabelFromImage(c *testing.T) { } } -func (s *DockerSuite) TestCreateHostnameWithNumber(c *testing.T) { +func (s *DockerCLICreateSuite) TestCreateHostnameWithNumber(c *testing.T) { image := "busybox" // Busybox on Windows does not implement hostname command if testEnv.OSType == "windows" { @@ -225,7 +237,7 @@ func (s *DockerSuite) TestCreateHostnameWithNumber(c *testing.T) { assert.Equal(c, strings.TrimSpace(out), "web.0", "hostname not set, expected `web.0`, got: %s", out) } -func (s *DockerSuite) TestCreateRM(c *testing.T) { +func (s *DockerCLICreateSuite) TestCreateRM(c *testing.T) { // Test to make sure we can 'rm' a new container that is in // "Created" state, and has ever been run. Test "rm -f" too. @@ -242,7 +254,7 @@ func (s *DockerSuite) TestCreateRM(c *testing.T) { dockerCmd(c, "rm", "-f", cID) } -func (s *DockerSuite) TestCreateModeIpcContainer(c *testing.T) { +func (s *DockerCLICreateSuite) TestCreateModeIpcContainer(c *testing.T) { // Uses Linux specific functionality (--ipc) testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) @@ -252,7 +264,7 @@ func (s *DockerSuite) TestCreateModeIpcContainer(c *testing.T) { dockerCmd(c, "create", fmt.Sprintf("--ipc=container:%s", id), "busybox") } -func (s *DockerSuite) TestCreateByImageID(c *testing.T) { +func (s *DockerCLICreateSuite) TestCreateByImageID(c *testing.T) { imageName := "testcreatebyimageid" buildImageSuccessfully(c, imageName, build.WithDockerfile(`FROM busybox MAINTAINER dockerio`)) @@ -285,7 +297,7 @@ func (s *DockerSuite) TestCreateByImageID(c *testing.T) { } } -func (s *DockerSuite) TestCreateStopSignal(c *testing.T) { +func (s *DockerCLICreateSuite) TestCreateStopSignal(c *testing.T) { name := "test_create_stop_signal" dockerCmd(c, "create", "--name", name, "--stop-signal", "9", "busybox") @@ -293,7 +305,7 @@ func (s *DockerSuite) TestCreateStopSignal(c *testing.T) { assert.Assert(c, strings.Contains(res, "9")) } -func (s *DockerSuite) TestCreateWithWorkdir(c *testing.T) { +func (s *DockerCLICreateSuite) TestCreateWithWorkdir(c *testing.T) { name := "foo" prefix, slash := getPrefixAndSlashFromDaemonPlatform() @@ -315,7 +327,7 @@ func (s *DockerSuite) TestCreateWithWorkdir(c *testing.T) { dockerCmd(c, "cp", fmt.Sprintf("%s:%s", name, dir), prefix+slash+"tmp") } -func (s *DockerSuite) TestCreateWithInvalidLogOpts(c *testing.T) { +func (s *DockerCLICreateSuite) TestCreateWithInvalidLogOpts(c *testing.T) { name := "test-invalidate-log-opts" out, _, err := dockerCmdWithError("create", "--name", name, "--log-opt", "invalid=true", "busybox") assert.ErrorContains(c, err, "") @@ -327,7 +339,7 @@ func (s *DockerSuite) TestCreateWithInvalidLogOpts(c *testing.T) { } // #20972 -func (s *DockerSuite) TestCreate64ByteHexID(c *testing.T) { +func (s *DockerCLICreateSuite) TestCreate64ByteHexID(c *testing.T) { out := inspectField(c, "busybox", "Id") imageID := strings.TrimPrefix(strings.TrimSpace(out), "sha256:") @@ -335,7 +347,7 @@ func (s *DockerSuite) TestCreate64ByteHexID(c *testing.T) { } // Test case for #23498 -func (s *DockerSuite) TestCreateUnsetEntrypoint(c *testing.T) { +func (s *DockerCLICreateSuite) TestCreateUnsetEntrypoint(c *testing.T) { name := "test-entrypoint" dockerfile := `FROM busybox ADD entrypoint.sh /entrypoint.sh @@ -362,7 +374,7 @@ exec "$@"`, } // #22471 -func (s *DockerSuite) TestCreateStopTimeout(c *testing.T) { +func (s *DockerCLICreateSuite) TestCreateStopTimeout(c *testing.T) { name1 := "test_create_stop_timeout_1" dockerCmd(c, "create", "--name", name1, "--stop-timeout", "15", "busybox") diff --git a/integration-cli/docker_cli_events_test.go b/integration-cli/docker_cli_events_test.go index a84a2925be..4b8bf53b53 100644 --- a/integration-cli/docker_cli_events_test.go +++ b/integration-cli/docker_cli_events_test.go @@ -24,7 +24,19 @@ import ( "gotest.tools/v3/icmd" ) -func (s *DockerSuite) TestEventsTimestampFormats(c *testing.T) { +type DockerCLIEventSuite struct { + ds *DockerSuite +} + +func (s *DockerCLIEventSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLIEventSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + +func (s *DockerCLIEventSuite) TestEventsTimestampFormats(c *testing.T) { name := "events-time-format-test" // Start stopwatch, generate an event @@ -53,7 +65,7 @@ func (s *DockerSuite) TestEventsTimestampFormats(c *testing.T) { } } -func (s *DockerSuite) TestEventsUntag(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsUntag(c *testing.T) { image := "busybox" dockerCmd(c, "tag", image, "utest:tag1") dockerCmd(c, "tag", image, "utest:tag2") @@ -76,7 +88,7 @@ func (s *DockerSuite) TestEventsUntag(c *testing.T) { } } -func (s *DockerSuite) TestEventsContainerEvents(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsContainerEvents(c *testing.T) { dockerCmd(c, "run", "--rm", "--name", "container-events-test", "busybox", "true") out, _ := dockerCmd(c, "events", "--until", daemonUnixTime(c)) @@ -90,7 +102,7 @@ func (s *DockerSuite) TestEventsContainerEvents(c *testing.T) { assert.Assert(c, is.DeepEqual(containerEvents, []string{"create", "attach", "start", "die", "destroy"}), out) } -func (s *DockerSuite) TestEventsContainerEventsAttrSort(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsContainerEventsAttrSort(c *testing.T) { since := daemonUnixTime(c) dockerCmd(c, "run", "--rm", "--name", "container-events-test", "busybox", "true") @@ -114,7 +126,7 @@ func (s *DockerSuite) TestEventsContainerEventsAttrSort(c *testing.T) { assert.Equal(c, matchedEvents, 2, "missing events for container container-events-test:\n%s", out) } -func (s *DockerSuite) TestEventsContainerEventsSinceUnixEpoch(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsContainerEventsSinceUnixEpoch(c *testing.T) { dockerCmd(c, "run", "--rm", "--name", "since-epoch-test", "busybox", "true") timeBeginning := time.Unix(0, 0).Format(time.RFC3339Nano) timeBeginning = strings.ReplaceAll(timeBeginning, "Z", ".000000000Z") @@ -128,7 +140,7 @@ func (s *DockerSuite) TestEventsContainerEventsSinceUnixEpoch(c *testing.T) { assert.Assert(c, is.DeepEqual(containerEvents, []string{"create", "attach", "start", "die", "destroy"}), out) } -func (s *DockerSuite) TestEventsImageTag(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsImageTag(c *testing.T) { time.Sleep(1 * time.Second) // because API has seconds granularity since := daemonUnixTime(c) image := "testimageevents:tag" @@ -146,7 +158,7 @@ func (s *DockerSuite) TestEventsImageTag(c *testing.T) { assert.Equal(c, matches["action"], "tag") } -func (s *DockerSuite) TestEventsImagePull(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsImagePull(c *testing.T) { // TODO Windows: Enable this test once pull and reliable image names are available testRequires(c, DaemonIsLinux) since := daemonUnixTime(c) @@ -164,7 +176,7 @@ func (s *DockerSuite) TestEventsImagePull(c *testing.T) { assert.Equal(c, matches["action"], "pull") } -func (s *DockerSuite) TestEventsImageImport(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsImageImport(c *testing.T) { // TODO Windows CI. This should be portable once export/import are // more reliable (@swernli) testRequires(c, DaemonIsLinux) @@ -188,7 +200,7 @@ func (s *DockerSuite) TestEventsImageImport(c *testing.T) { assert.Equal(c, matches["action"], "import", "matches: %v\nout:\n%s\n", matches, out) } -func (s *DockerSuite) TestEventsImageLoad(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsImageLoad(c *testing.T) { testRequires(c, DaemonIsLinux) myImageName := "footest:v1" dockerCmd(c, "tag", "busybox", myImageName) @@ -227,7 +239,7 @@ func (s *DockerSuite) TestEventsImageLoad(c *testing.T) { assert.Equal(c, matches["action"], "save", "matches: %v\nout:\n%s\n", matches, out) } -func (s *DockerSuite) TestEventsPluginOps(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsPluginOps(c *testing.T) { testRequires(c, DaemonIsLinux, IsAmd64, Network) since := daemonUnixTime(c) @@ -246,7 +258,7 @@ func (s *DockerSuite) TestEventsPluginOps(c *testing.T) { assert.Assert(c, is.DeepEqual(pluginEvents, []string{"pull", "enable", "disable", "remove"}), out) } -func (s *DockerSuite) TestEventsFilters(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsFilters(c *testing.T) { since := daemonUnixTime(c) dockerCmd(c, "run", "--rm", "busybox", "true") dockerCmd(c, "run", "--rm", "busybox", "true") @@ -261,7 +273,7 @@ func (s *DockerSuite) TestEventsFilters(c *testing.T) { assert.Assert(c, count >= 2, "should have had 2 start events but had %d, out: %s", count, out) } -func (s *DockerSuite) TestEventsFilterImageName(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsFilterImageName(c *testing.T) { since := daemonUnixTime(c) out, _ := dockerCmd(c, "run", "--name", "container_1", "-d", "busybox:latest", "true") @@ -289,7 +301,7 @@ func (s *DockerSuite) TestEventsFilterImageName(c *testing.T) { assert.Assert(c, count2 != 0, "Expected event from container but got %d from %s", count2, container2) } -func (s *DockerSuite) TestEventsFilterLabels(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsFilterLabels(c *testing.T) { since := strconv.FormatUint(uint64(daemonTime(c).Unix()), 10) label := "io.docker.testing=foo" @@ -324,7 +336,7 @@ func (s *DockerSuite) TestEventsFilterLabels(c *testing.T) { assert.Assert(c, found) } -func (s *DockerSuite) TestEventsFilterImageLabels(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsFilterImageLabels(c *testing.T) { since := daemonUnixTime(c) name := "labelfiltertest" label := "io.docker.testing=image" @@ -354,7 +366,7 @@ func (s *DockerSuite) TestEventsFilterImageLabels(c *testing.T) { } } -func (s *DockerSuite) TestEventsFilterContainer(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsFilterContainer(c *testing.T) { since := daemonUnixTime(c) nameID := make(map[string]string) @@ -392,7 +404,7 @@ func (s *DockerSuite) TestEventsFilterContainer(c *testing.T) { } } -func (s *DockerSuite) TestEventsCommit(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsCommit(c *testing.T) { // Problematic on Windows as cannot commit a running container testRequires(c, DaemonIsLinux) @@ -409,7 +421,7 @@ func (s *DockerSuite) TestEventsCommit(c *testing.T) { assert.Assert(c, strings.Contains(out, "commit"), "Missing 'commit' log event") } -func (s *DockerSuite) TestEventsCopy(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsCopy(c *testing.T) { // Build a test image. buildImageSuccessfully(c, "cpimg", build.WithDockerfile(` FROM busybox @@ -438,7 +450,7 @@ func (s *DockerSuite) TestEventsCopy(c *testing.T) { assert.Assert(c, strings.Contains(out, "extract-to-dir"), "Missing 'extract-to-dir' log event") } -func (s *DockerSuite) TestEventsResize(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsResize(c *testing.T) { out := runSleepingContainer(c, "-d", "-t") cID := strings.TrimSpace(out) assert.NilError(c, waitRun(cID)) @@ -461,7 +473,7 @@ func (s *DockerSuite) TestEventsResize(c *testing.T) { assert.Assert(c, strings.Contains(out, "resize"), "Missing 'resize' log event") } -func (s *DockerSuite) TestEventsAttach(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsAttach(c *testing.T) { // TODO Windows CI: Figure out why this test fails intermittently (TP5). testRequires(c, DaemonIsLinux) @@ -499,7 +511,7 @@ func (s *DockerSuite) TestEventsAttach(c *testing.T) { assert.Assert(c, strings.Contains(out, "attach"), "Missing 'attach' log event") } -func (s *DockerSuite) TestEventsRename(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsRename(c *testing.T) { out, _ := dockerCmd(c, "run", "--name", "oldName", "busybox", "true") cID := strings.TrimSpace(out) dockerCmd(c, "rename", "oldName", "newName") @@ -510,7 +522,7 @@ func (s *DockerSuite) TestEventsRename(c *testing.T) { assert.Assert(c, strings.Contains(out, "rename"), "Missing 'rename' log event") } -func (s *DockerSuite) TestEventsTop(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsTop(c *testing.T) { // Problematic on Windows as Windows does not support top testRequires(c, DaemonIsLinux) @@ -547,7 +559,7 @@ func (s *DockerRegistrySuite) TestEventsImageFilterPush(c *testing.T) { assert.Assert(c, strings.Contains(out, repoName), "Missing 'push' log event for %s", repoName) } -func (s *DockerSuite) TestEventsFilterType(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsFilterType(c *testing.T) { // FIXME(vdemeester) fails on e2e run testRequires(c, testEnv.IsLocalDaemon) since := daemonUnixTime(c) @@ -601,7 +613,7 @@ func (s *DockerSuite) TestEventsFilterType(c *testing.T) { } // #25798 -func (s *DockerSuite) TestEventsSpecialFiltersWithExecCreate(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsSpecialFiltersWithExecCreate(c *testing.T) { since := daemonUnixTime(c) runSleepingContainer(c, "--name", "test-container", "-d") waitRun("test-container") @@ -631,7 +643,7 @@ func (s *DockerSuite) TestEventsSpecialFiltersWithExecCreate(c *testing.T) { assert.Equal(c, len(events), 1, out) } -func (s *DockerSuite) TestEventsFilterImageInContainerAction(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsFilterImageInContainerAction(c *testing.T) { since := daemonUnixTime(c) dockerCmd(c, "run", "--name", "test-container", "-d", "busybox", "true") waitRun("test-container") @@ -641,7 +653,7 @@ func (s *DockerSuite) TestEventsFilterImageInContainerAction(c *testing.T) { assert.Assert(c, len(events) > 1, out) } -func (s *DockerSuite) TestEventsContainerRestart(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsContainerRestart(c *testing.T) { dockerCmd(c, "run", "-d", "--name=testEvent", "--restart=on-failure:3", "busybox", "false") // wait until test2 is auto removed. @@ -681,7 +693,7 @@ func (s *DockerSuite) TestEventsContainerRestart(c *testing.T) { assert.Equal(c, dieCount, 4, "testEvent should die 4 times: %v", actions) } -func (s *DockerSuite) TestEventsSinceInTheFuture(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsSinceInTheFuture(c *testing.T) { dockerCmd(c, "run", "--name", "test-container", "-d", "busybox", "true") waitRun("test-container") @@ -693,7 +705,7 @@ func (s *DockerSuite) TestEventsSinceInTheFuture(c *testing.T) { assert.Assert(c, strings.Contains(out, "cannot be after `until`")) } -func (s *DockerSuite) TestEventsUntilInThePast(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsUntilInThePast(c *testing.T) { since := daemonUnixTime(c) dockerCmd(c, "run", "--name", "test-container", "-d", "busybox", "true") @@ -710,7 +722,7 @@ func (s *DockerSuite) TestEventsUntilInThePast(c *testing.T) { assert.Assert(c, strings.Contains(out, "test-container")) } -func (s *DockerSuite) TestEventsFormat(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsFormat(c *testing.T) { since := daemonUnixTime(c) dockerCmd(c, "run", "--rm", "busybox", "true") dockerCmd(c, "run", "--rm", "busybox", "true") @@ -733,7 +745,7 @@ func (s *DockerSuite) TestEventsFormat(c *testing.T) { assert.Equal(c, startCount, 2, "should have had 2 start events but had %d, out: %s", startCount, out) } -func (s *DockerSuite) TestEventsFormatBadFunc(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsFormatBadFunc(c *testing.T) { // make sure it fails immediately, without receiving any event result := dockerCmdWithResult("events", "--format", "{{badFuncString .}}") result.Assert(c, icmd.Expected{ @@ -743,7 +755,7 @@ func (s *DockerSuite) TestEventsFormatBadFunc(c *testing.T) { }) } -func (s *DockerSuite) TestEventsFormatBadField(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsFormatBadField(c *testing.T) { // make sure it fails immediately, without receiving any event result := dockerCmdWithResult("events", "--format", "{{.badFieldString}}") result.Assert(c, icmd.Expected{ diff --git a/integration-cli/docker_cli_events_unix_test.go b/integration-cli/docker_cli_events_unix_test.go index 87ef637e7d..81076845d1 100644 --- a/integration-cli/docker_cli_events_unix_test.go +++ b/integration-cli/docker_cli_events_unix_test.go @@ -22,7 +22,7 @@ import ( ) // #5979 -func (s *DockerSuite) TestEventsRedirectStdout(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsRedirectStdout(c *testing.T) { since := daemonUnixTime(c) dockerCmd(c, "run", "busybox", "true") @@ -48,7 +48,7 @@ func (s *DockerSuite) TestEventsRedirectStdout(c *testing.T) { assert.NilError(c, scanner.Err(), "Scan err for command %q", command) } -func (s *DockerSuite) TestEventsOOMDisableFalse(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsOOMDisableFalse(c *testing.T) { testRequires(c, DaemonIsLinux, oomControl, memoryLimitSupport, swapMemorySupport, NotPpc64le) errChan := make(chan error, 1) @@ -78,7 +78,7 @@ func (s *DockerSuite) TestEventsOOMDisableFalse(c *testing.T) { assert.Equal(c, parseEventAction(c, events[nEvents-1]), "die") } -func (s *DockerSuite) TestEventsOOMDisableTrue(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsOOMDisableTrue(c *testing.T) { testRequires(c, DaemonIsLinux, oomControl, memoryLimitSupport, NotArm, swapMemorySupport, NotPpc64le) errChan := make(chan error, 1) @@ -126,7 +126,7 @@ func (s *DockerSuite) TestEventsOOMDisableTrue(c *testing.T) { } // #18453 -func (s *DockerSuite) TestEventsContainerFilterByName(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsContainerFilterByName(c *testing.T) { testRequires(c, DaemonIsLinux) cOut, _ := dockerCmd(c, "run", "--name=foo", "-d", "busybox", "top") c1 := strings.TrimSpace(cOut) @@ -140,7 +140,7 @@ func (s *DockerSuite) TestEventsContainerFilterByName(c *testing.T) { } // #18453 -func (s *DockerSuite) TestEventsContainerFilterBeforeCreate(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsContainerFilterBeforeCreate(c *testing.T) { testRequires(c, DaemonIsLinux) buf := &bytes.Buffer{} cmd := exec.Command(dockerBinary, "events", "-f", "container=foo", "--since=0") @@ -165,7 +165,7 @@ func (s *DockerSuite) TestEventsContainerFilterBeforeCreate(c *testing.T) { } } -func (s *DockerSuite) TestVolumeEvents(c *testing.T) { +func (s *DockerCLIEventSuite) TestVolumeEvents(c *testing.T) { testRequires(c, DaemonIsLinux) since := daemonUnixTime(c) @@ -192,7 +192,7 @@ func (s *DockerSuite) TestVolumeEvents(c *testing.T) { assert.Equal(c, volumeEvents[3], "destroy") } -func (s *DockerSuite) TestNetworkEvents(c *testing.T) { +func (s *DockerCLIEventSuite) TestNetworkEvents(c *testing.T) { testRequires(c, DaemonIsLinux) since := daemonUnixTime(c) @@ -219,7 +219,7 @@ func (s *DockerSuite) TestNetworkEvents(c *testing.T) { assert.Equal(c, netEvents[3], "destroy") } -func (s *DockerSuite) TestEventsContainerWithMultiNetwork(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsContainerWithMultiNetwork(c *testing.T) { testRequires(c, DaemonIsLinux) // Observe create/connect network actions @@ -247,7 +247,7 @@ func (s *DockerSuite) TestEventsContainerWithMultiNetwork(c *testing.T) { assert.Assert(c, strings.Contains(out, "test-event-network-local-2")) } -func (s *DockerSuite) TestEventsStreaming(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsStreaming(c *testing.T) { testRequires(c, DaemonIsLinux) observer, err := newEventObserver(c) @@ -301,7 +301,7 @@ func (s *DockerSuite) TestEventsStreaming(c *testing.T) { } } -func (s *DockerSuite) TestEventsImageUntagDelete(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsImageUntagDelete(c *testing.T) { testRequires(c, DaemonIsLinux) observer, err := newEventObserver(c) @@ -340,7 +340,7 @@ func (s *DockerSuite) TestEventsImageUntagDelete(c *testing.T) { } } -func (s *DockerSuite) TestEventsFilterVolumeAndNetworkType(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsFilterVolumeAndNetworkType(c *testing.T) { testRequires(c, DaemonIsLinux) since := daemonUnixTime(c) @@ -359,7 +359,7 @@ func (s *DockerSuite) TestEventsFilterVolumeAndNetworkType(c *testing.T) { assert.Equal(c, networkActions[0], "create") } -func (s *DockerSuite) TestEventsFilterVolumeID(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsFilterVolumeID(c *testing.T) { testRequires(c, DaemonIsLinux) since := daemonUnixTime(c) @@ -374,7 +374,7 @@ func (s *DockerSuite) TestEventsFilterVolumeID(c *testing.T) { assert.Assert(c, strings.Contains(events[0], "driver=local")) } -func (s *DockerSuite) TestEventsFilterNetworkID(c *testing.T) { +func (s *DockerCLIEventSuite) TestEventsFilterNetworkID(c *testing.T) { testRequires(c, DaemonIsLinux) since := daemonUnixTime(c) diff --git a/integration-cli/docker_cli_exec_test.go b/integration-cli/docker_cli_exec_test.go index 1ef31cfc37..5c3043a038 100644 --- a/integration-cli/docker_cli_exec_test.go +++ b/integration-cli/docker_cli_exec_test.go @@ -22,7 +22,19 @@ import ( "gotest.tools/v3/icmd" ) -func (s *DockerSuite) TestExec(c *testing.T) { +type DockerCLIExecSuite struct { + ds *DockerSuite +} + +func (s *DockerCLIExecSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLIExecSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + +func (s *DockerCLIExecSuite) TestExec(c *testing.T) { testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "-d", "--name", "testing", "busybox", "sh", "-c", "echo test > /tmp/file && top") assert.NilError(c, waitRun(strings.TrimSpace(out))) @@ -31,7 +43,7 @@ func (s *DockerSuite) TestExec(c *testing.T) { assert.Equal(c, strings.Trim(out, "\r\n"), "test") } -func (s *DockerSuite) TestExecInteractive(c *testing.T) { +func (s *DockerCLIExecSuite) TestExecInteractive(c *testing.T) { testRequires(c, DaemonIsLinux) dockerCmd(c, "run", "-d", "--name", "testing", "busybox", "sh", "-c", "echo test > /tmp/file && top") @@ -67,7 +79,7 @@ func (s *DockerSuite) TestExecInteractive(c *testing.T) { } -func (s *DockerSuite) TestExecAfterContainerRestart(c *testing.T) { +func (s *DockerCLIExecSuite) TestExecAfterContainerRestart(c *testing.T) { out := runSleepingContainer(c) cleanedContainerID := strings.TrimSpace(out) assert.NilError(c, waitRun(cleanedContainerID)) @@ -96,7 +108,7 @@ func (s *DockerDaemonSuite) TestExecAfterDaemonRestart(c *testing.T) { } // Regression test for #9155, #9044 -func (s *DockerSuite) TestExecEnv(c *testing.T) { +func (s *DockerCLIExecSuite) TestExecEnv(c *testing.T) { // TODO Windows CI: This one is interesting and may just end up being a feature // difference between Windows and Linux. On Windows, the environment is passed // into the process that is launched, not into the machine environment. Hence @@ -111,7 +123,7 @@ func (s *DockerSuite) TestExecEnv(c *testing.T) { assert.Check(c, strings.Contains(out, "HOME=/root")) } -func (s *DockerSuite) TestExecSetEnv(c *testing.T) { +func (s *DockerCLIExecSuite) TestExecSetEnv(c *testing.T) { testRequires(c, DaemonIsLinux) runSleepingContainer(c, "-e", "HOME=/root", "-d", "--name", "testing") assert.NilError(c, waitRun("testing")) @@ -122,14 +134,14 @@ func (s *DockerSuite) TestExecSetEnv(c *testing.T) { assert.Check(c, strings.Contains(out, "ABC=xyz")) } -func (s *DockerSuite) TestExecExitStatus(c *testing.T) { +func (s *DockerCLIExecSuite) TestExecExitStatus(c *testing.T) { runSleepingContainer(c, "-d", "--name", "top") result := icmd.RunCommand(dockerBinary, "exec", "top", "sh", "-c", "exit 23") result.Assert(c, icmd.Expected{ExitCode: 23, Error: "exit status 23"}) } -func (s *DockerSuite) TestExecPausedContainer(c *testing.T) { +func (s *DockerCLIExecSuite) TestExecPausedContainer(c *testing.T) { testRequires(c, IsPausable) out := runSleepingContainer(c, "-d", "--name", "testing") @@ -144,7 +156,7 @@ func (s *DockerSuite) TestExecPausedContainer(c *testing.T) { } // regression test for #9476 -func (s *DockerSuite) TestExecTTYCloseStdin(c *testing.T) { +func (s *DockerCLIExecSuite) TestExecTTYCloseStdin(c *testing.T) { // TODO Windows CI: This requires some work to port to Windows. testRequires(c, DaemonIsLinux) dockerCmd(c, "run", "-d", "-it", "--name", "exec_tty_stdin", "busybox") @@ -165,7 +177,7 @@ func (s *DockerSuite) TestExecTTYCloseStdin(c *testing.T) { assert.Assert(c, !strings.Contains(out, "nsenter-exec")) } -func (s *DockerSuite) TestExecTTYWithoutStdin(c *testing.T) { +func (s *DockerCLIExecSuite) TestExecTTYWithoutStdin(c *testing.T) { out, _ := dockerCmd(c, "run", "-d", "-ti", "busybox") id := strings.TrimSpace(out) assert.NilError(c, waitRun(id)) @@ -202,7 +214,7 @@ func (s *DockerSuite) TestExecTTYWithoutStdin(c *testing.T) { } // FIXME(vdemeester) this should be a unit tests on cli/command/container package -func (s *DockerSuite) TestExecParseError(c *testing.T) { +func (s *DockerCLIExecSuite) TestExecParseError(c *testing.T) { // TODO Windows CI: Requires some extra work. Consider copying the // runSleepingContainer helper to have an exec version. testRequires(c, DaemonIsLinux) @@ -216,7 +228,7 @@ func (s *DockerSuite) TestExecParseError(c *testing.T) { }) } -func (s *DockerSuite) TestExecStopNotHanging(c *testing.T) { +func (s *DockerCLIExecSuite) TestExecStopNotHanging(c *testing.T) { // TODO Windows CI: Requires some extra work. Consider copying the // runSleepingContainer helper to have an exec version. testRequires(c, DaemonIsLinux) @@ -244,7 +256,7 @@ func (s *DockerSuite) TestExecStopNotHanging(c *testing.T) { } } -func (s *DockerSuite) TestExecCgroup(c *testing.T) { +func (s *DockerCLIExecSuite) TestExecCgroup(c *testing.T) { // Not applicable on Windows - using Linux specific functionality testRequires(c, NotUserNamespace) testRequires(c, DaemonIsLinux) @@ -297,7 +309,7 @@ func (s *DockerSuite) TestExecCgroup(c *testing.T) { } } -func (s *DockerSuite) TestExecInspectID(c *testing.T) { +func (s *DockerCLIExecSuite) TestExecInspectID(c *testing.T) { out := runSleepingContainer(c, "-d") id := strings.TrimSuffix(out, "\n") @@ -364,7 +376,7 @@ func (s *DockerSuite) TestExecInspectID(c *testing.T) { assert.ErrorContains(c, err, "No such exec instance") } -func (s *DockerSuite) TestLinksPingLinkedContainersOnRename(c *testing.T) { +func (s *DockerCLIExecSuite) TestLinksPingLinkedContainersOnRename(c *testing.T) { // Problematic on Windows as Windows does not support links testRequires(c, DaemonIsLinux) var out string @@ -380,7 +392,7 @@ func (s *DockerSuite) TestLinksPingLinkedContainersOnRename(c *testing.T) { dockerCmd(c, "exec", "container2", "ping", "-c", "1", "alias1", "-W", "1") } -func (s *DockerSuite) TestRunMutableNetworkFiles(c *testing.T) { +func (s *DockerCLIExecSuite) TestRunMutableNetworkFiles(c *testing.T) { // Not applicable on Windows to Windows CI. testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) for _, fn := range []string{"resolv.conf", "hosts"} { @@ -421,7 +433,7 @@ func (s *DockerSuite) TestRunMutableNetworkFiles(c *testing.T) { } } -func (s *DockerSuite) TestExecWithUser(c *testing.T) { +func (s *DockerCLIExecSuite) TestExecWithUser(c *testing.T) { // TODO Windows CI: This may be fixable in the future once Windows // supports users testRequires(c, DaemonIsLinux) @@ -434,7 +446,7 @@ func (s *DockerSuite) TestExecWithUser(c *testing.T) { assert.Assert(c, strings.Contains(out, "uid=0(root) gid=0(root)"), "exec with user by id expected daemon user got %s", out) } -func (s *DockerSuite) TestExecWithPrivileged(c *testing.T) { +func (s *DockerCLIExecSuite) TestExecWithPrivileged(c *testing.T) { // Not applicable on Windows testRequires(c, DaemonIsLinux, NotUserNamespace) // Start main loop which attempts mknod repeatedly @@ -464,7 +476,7 @@ func (s *DockerSuite) TestExecWithPrivileged(c *testing.T) { assert.Assert(c, !strings.Contains(result.Combined(), "Success")) } -func (s *DockerSuite) TestExecWithImageUser(c *testing.T) { +func (s *DockerCLIExecSuite) TestExecWithImageUser(c *testing.T) { // Not applicable on Windows testRequires(c, DaemonIsLinux) name := "testbuilduser" @@ -477,7 +489,7 @@ func (s *DockerSuite) TestExecWithImageUser(c *testing.T) { assert.Assert(c, strings.Contains(out, "dockerio"), "exec with user by id expected dockerio user got %s", out) } -func (s *DockerSuite) TestExecOnReadonlyContainer(c *testing.T) { +func (s *DockerCLIExecSuite) TestExecOnReadonlyContainer(c *testing.T) { // Windows does not support read-only // --read-only + userns has remount issues testRequires(c, DaemonIsLinux, NotUserNamespace) @@ -485,7 +497,7 @@ func (s *DockerSuite) TestExecOnReadonlyContainer(c *testing.T) { dockerCmd(c, "exec", "parent", "true") } -func (s *DockerSuite) TestExecUlimits(c *testing.T) { +func (s *DockerCLIExecSuite) TestExecUlimits(c *testing.T) { testRequires(c, DaemonIsLinux) name := "testexeculimits" runSleepingContainer(c, "-d", "--ulimit", "nofile=511:511", "--name", name) @@ -497,7 +509,7 @@ func (s *DockerSuite) TestExecUlimits(c *testing.T) { } // #15750 -func (s *DockerSuite) TestExecStartFails(c *testing.T) { +func (s *DockerCLIExecSuite) TestExecStartFails(c *testing.T) { // TODO Windows CI. This test should be portable. Figure out why it fails // currently. testRequires(c, DaemonIsLinux) @@ -511,7 +523,7 @@ func (s *DockerSuite) TestExecStartFails(c *testing.T) { } // Fix regression in https://github.com/docker/docker/pull/26461#issuecomment-250287297 -func (s *DockerSuite) TestExecWindowsPathNotWiped(c *testing.T) { +func (s *DockerCLIExecSuite) TestExecWindowsPathNotWiped(c *testing.T) { testRequires(c, DaemonIsWindows) out, _ := dockerCmd(c, "run", "-d", "--name", "testing", minimalBaseImage(), "powershell", "start-sleep", "60") assert.NilError(c, waitRun(strings.TrimSpace(out))) @@ -521,7 +533,7 @@ func (s *DockerSuite) TestExecWindowsPathNotWiped(c *testing.T) { assert.Assert(c, strings.Contains(out, `windowspowershell\v1.0`)) } -func (s *DockerSuite) TestExecEnvLinksHost(c *testing.T) { +func (s *DockerCLIExecSuite) TestExecEnvLinksHost(c *testing.T) { testRequires(c, DaemonIsLinux) runSleepingContainer(c, "-d", "--name", "foo") runSleepingContainer(c, "-d", "--link", "foo:db", "--hostname", "myhost", "--name", "bar") diff --git a/integration-cli/docker_cli_exec_unix_test.go b/integration-cli/docker_cli_exec_unix_test.go index f83b2aad1c..aea87e76a2 100644 --- a/integration-cli/docker_cli_exec_unix_test.go +++ b/integration-cli/docker_cli_exec_unix_test.go @@ -16,7 +16,7 @@ import ( ) // regression test for #12546 -func (s *DockerSuite) TestExecInteractiveStdinClose(c *testing.T) { +func (s *DockerCLIExecSuite) TestExecInteractiveStdinClose(c *testing.T) { testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "-itd", "busybox", "/bin/cat") contID := strings.TrimSpace(out) @@ -45,7 +45,7 @@ func (s *DockerSuite) TestExecInteractiveStdinClose(c *testing.T) { } } -func (s *DockerSuite) TestExecTTY(c *testing.T) { +func (s *DockerCLIExecSuite) TestExecTTY(c *testing.T) { testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) dockerCmd(c, "run", "-d", "--name=test", "busybox", "sh", "-c", "echo hello > /foo && top") @@ -75,7 +75,7 @@ func (s *DockerSuite) TestExecTTY(c *testing.T) { } // Test the TERM env var is set when -t is provided on exec -func (s *DockerSuite) TestExecWithTERM(c *testing.T) { +func (s *DockerCLIExecSuite) TestExecWithTERM(c *testing.T) { testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) out, _ := dockerCmd(c, "run", "-id", "busybox", "/bin/cat") contID := strings.TrimSpace(out) @@ -87,7 +87,7 @@ func (s *DockerSuite) TestExecWithTERM(c *testing.T) { // Test that the TERM env var is not set on exec when -t is not provided, even if it was set // on run -func (s *DockerSuite) TestExecWithNoTERM(c *testing.T) { +func (s *DockerCLIExecSuite) TestExecWithNoTERM(c *testing.T) { testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) out, _ := dockerCmd(c, "run", "-itd", "busybox", "/bin/cat") contID := strings.TrimSpace(out) diff --git a/integration-cli/docker_cli_health_test.go b/integration-cli/docker_cli_health_test.go index 5278e18d05..6adecb8c00 100644 --- a/integration-cli/docker_cli_health_test.go +++ b/integration-cli/docker_cli_health_test.go @@ -12,6 +12,18 @@ import ( "gotest.tools/v3/assert" ) +type DockerCLIHealthSuite struct { + ds *DockerSuite +} + +func (s *DockerCLIHealthSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLIHealthSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + func waitForHealthStatus(c *testing.T, name string, prev string, expected string) { prev = prev + "\n" expected = expected + "\n" @@ -36,7 +48,7 @@ func getHealth(c *testing.T, name string) *types.Health { return &health } -func (s *DockerSuite) TestHealth(c *testing.T) { +func (s *DockerCLIHealthSuite) TestHealth(c *testing.T) { testRequires(c, DaemonIsLinux) // busybox doesn't work on Windows existingContainers := ExistingContainerIDs(c) @@ -144,7 +156,7 @@ func (s *DockerSuite) TestHealth(c *testing.T) { } // GitHub #33021 -func (s *DockerSuite) TestUnsetEnvVarHealthCheck(c *testing.T) { +func (s *DockerCLIHealthSuite) TestUnsetEnvVarHealthCheck(c *testing.T) { testRequires(c, DaemonIsLinux) // busybox doesn't work on Windows imageName := "testhealth" diff --git a/integration-cli/docker_cli_history_test.go b/integration-cli/docker_cli_history_test.go index 8ae1d275ab..248b14c853 100644 --- a/integration-cli/docker_cli_history_test.go +++ b/integration-cli/docker_cli_history_test.go @@ -12,9 +12,21 @@ import ( "gotest.tools/v3/assert/cmp" ) +type DockerCLIHistorySuite struct { + ds *DockerSuite +} + +func (s *DockerCLIHistorySuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLIHistorySuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + // This is a heisen-test. Because the created timestamp of images and the behavior of // sort is not predictable it doesn't always fail. -func (s *DockerSuite) TestBuildHistory(c *testing.T) { +func (s *DockerCLIHistorySuite) TestBuildHistory(c *testing.T) { name := "testbuildhistory" buildImageSuccessfully(c, name, build.WithDockerfile(`FROM `+minimalBaseImage()+` LABEL label.A="A" @@ -56,16 +68,16 @@ LABEL label.Z="Z"`)) } -func (s *DockerSuite) TestHistoryExistentImage(c *testing.T) { +func (s *DockerCLIHistorySuite) TestHistoryExistentImage(c *testing.T) { dockerCmd(c, "history", "busybox") } -func (s *DockerSuite) TestHistoryNonExistentImage(c *testing.T) { +func (s *DockerCLIHistorySuite) TestHistoryNonExistentImage(c *testing.T) { _, _, err := dockerCmdWithError("history", "testHistoryNonExistentImage") assert.Assert(c, err != nil, "history on a non-existent image should fail.") } -func (s *DockerSuite) TestHistoryImageWithComment(c *testing.T) { +func (s *DockerCLIHistorySuite) TestHistoryImageWithComment(c *testing.T) { name := "testhistoryimagewithcomment" // make an image through docker commit [ -m messages ] @@ -84,7 +96,7 @@ func (s *DockerSuite) TestHistoryImageWithComment(c *testing.T) { assert.Assert(c, strings.Contains(actualValue, comment)) } -func (s *DockerSuite) TestHistoryHumanOptionFalse(c *testing.T) { +func (s *DockerCLIHistorySuite) TestHistoryHumanOptionFalse(c *testing.T) { out, _ := dockerCmd(c, "history", "--human=false", "busybox") lines := strings.Split(out, "\n") sizeColumnRegex, _ := regexp.Compile("SIZE +") @@ -102,7 +114,7 @@ func (s *DockerSuite) TestHistoryHumanOptionFalse(c *testing.T) { } } -func (s *DockerSuite) TestHistoryHumanOptionTrue(c *testing.T) { +func (s *DockerCLIHistorySuite) TestHistoryHumanOptionTrue(c *testing.T) { out, _ := dockerCmd(c, "history", "--human=true", "busybox") lines := strings.Split(out, "\n") sizeColumnRegex, _ := regexp.Compile("SIZE +") diff --git a/integration-cli/docker_cli_images_test.go b/integration-cli/docker_cli_images_test.go index dbb9f893a9..b77f62e2d2 100644 --- a/integration-cli/docker_cli_images_test.go +++ b/integration-cli/docker_cli_images_test.go @@ -17,12 +17,24 @@ import ( "gotest.tools/v3/icmd" ) -func (s *DockerSuite) TestImagesEnsureImageIsListed(c *testing.T) { +type DockerCLIImagesSuite struct { + ds *DockerSuite +} + +func (s *DockerCLIImagesSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLIImagesSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + +func (s *DockerCLIImagesSuite) TestImagesEnsureImageIsListed(c *testing.T) { imagesOut, _ := dockerCmd(c, "images") assert.Assert(c, strings.Contains(imagesOut, "busybox")) } -func (s *DockerSuite) TestImagesEnsureImageWithTagIsListed(c *testing.T) { +func (s *DockerCLIImagesSuite) TestImagesEnsureImageWithTagIsListed(c *testing.T) { name := "imagewithtag" dockerCmd(c, "tag", "busybox", name+":v1") dockerCmd(c, "tag", "busybox", name+":v1v1") @@ -40,12 +52,12 @@ func (s *DockerSuite) TestImagesEnsureImageWithTagIsListed(c *testing.T) { assert.Assert(c, strings.Contains(imagesOut, "v2")) } -func (s *DockerSuite) TestImagesEnsureImageWithBadTagIsNotListed(c *testing.T) { +func (s *DockerCLIImagesSuite) TestImagesEnsureImageWithBadTagIsNotListed(c *testing.T) { imagesOut, _ := dockerCmd(c, "images", "busybox:nonexistent") assert.Assert(c, !strings.Contains(imagesOut, "busybox")) } -func (s *DockerSuite) TestImagesOrderedByCreationDate(c *testing.T) { +func (s *DockerCLIImagesSuite) TestImagesOrderedByCreationDate(c *testing.T) { buildImageSuccessfully(c, "order:test_a", build.WithDockerfile(`FROM busybox MAINTAINER dockerio1`)) id1 := getIDByName(c, "order:test_a") @@ -65,13 +77,13 @@ func (s *DockerSuite) TestImagesOrderedByCreationDate(c *testing.T) { assert.Equal(c, imgs[2], id1, fmt.Sprintf("First image must be %s, got %s", id1, imgs[2])) } -func (s *DockerSuite) TestImagesErrorWithInvalidFilterNameTest(c *testing.T) { +func (s *DockerCLIImagesSuite) TestImagesErrorWithInvalidFilterNameTest(c *testing.T) { out, _, err := dockerCmdWithError("images", "-f", "FOO=123") assert.ErrorContains(c, err, "") assert.Assert(c, strings.Contains(out, "invalid filter")) } -func (s *DockerSuite) TestImagesFilterLabelMatch(c *testing.T) { +func (s *DockerCLIImagesSuite) TestImagesFilterLabelMatch(c *testing.T) { imageName1 := "images_filter_test1" imageName2 := "images_filter_test2" imageName3 := "images_filter_test3" @@ -101,7 +113,7 @@ func (s *DockerSuite) TestImagesFilterLabelMatch(c *testing.T) { } // Regression : #15659 -func (s *DockerSuite) TestCommitWithFilterLabel(c *testing.T) { +func (s *DockerCLIImagesSuite) TestCommitWithFilterLabel(c *testing.T) { // Create a container dockerCmd(c, "run", "--name", "bar", "busybox", "/bin/sh") // Commit with labels "using changes" @@ -113,7 +125,7 @@ func (s *DockerSuite) TestCommitWithFilterLabel(c *testing.T) { assert.Equal(c, out, imageID) } -func (s *DockerSuite) TestImagesFilterSinceAndBefore(c *testing.T) { +func (s *DockerCLIImagesSuite) TestImagesFilterSinceAndBefore(c *testing.T) { buildImageSuccessfully(c, "image:1", build.WithDockerfile(`FROM `+minimalBaseImage()+` LABEL number=1`)) imageID1 := getIDByName(c, "image:1") @@ -183,7 +195,7 @@ func assertImageList(out string, expected []string) bool { } // FIXME(vdemeester) should be a unit test on `docker image ls` -func (s *DockerSuite) TestImagesFilterSpaceTrimCase(c *testing.T) { +func (s *DockerCLIImagesSuite) TestImagesFilterSpaceTrimCase(c *testing.T) { imageName := "images_filter_test" // Build a image and fail to build so that we have dangling images ? buildImage(imageName, build.WithDockerfile(`FROM busybox @@ -223,7 +235,7 @@ func (s *DockerSuite) TestImagesFilterSpaceTrimCase(c *testing.T) { } } -func (s *DockerSuite) TestImagesEnsureDanglingImageOnlyListedOnce(c *testing.T) { +func (s *DockerCLIImagesSuite) TestImagesEnsureDanglingImageOnlyListedOnce(c *testing.T) { testRequires(c, DaemonIsLinux) // create container 1 out, _ := dockerCmd(c, "run", "-d", "busybox", "true") @@ -249,13 +261,13 @@ func (s *DockerSuite) TestImagesEnsureDanglingImageOnlyListedOnce(c *testing.T) } // FIXME(vdemeester) should be a unit test for `docker image ls` -func (s *DockerSuite) TestImagesWithIncorrectFilter(c *testing.T) { +func (s *DockerCLIImagesSuite) TestImagesWithIncorrectFilter(c *testing.T) { out, _, err := dockerCmdWithError("images", "-f", "dangling=invalid") assert.ErrorContains(c, err, "") assert.Assert(c, strings.Contains(out, "invalid filter")) } -func (s *DockerSuite) TestImagesEnsureOnlyHeadsImagesShown(c *testing.T) { +func (s *DockerCLIImagesSuite) TestImagesEnsureOnlyHeadsImagesShown(c *testing.T) { dockerfile := ` FROM busybox MAINTAINER docker @@ -278,7 +290,7 @@ func (s *DockerSuite) TestImagesEnsureOnlyHeadsImagesShown(c *testing.T) { assert.Assert(c, strings.Contains(out, stringid.TruncateID(id))) } -func (s *DockerSuite) TestImagesEnsureImagesFromScratchShown(c *testing.T) { +func (s *DockerCLIImagesSuite) TestImagesEnsureImagesFromScratchShown(c *testing.T) { testRequires(c, DaemonIsLinux) // Windows does not support FROM scratch dockerfile := ` FROM scratch @@ -295,7 +307,7 @@ func (s *DockerSuite) TestImagesEnsureImagesFromScratchShown(c *testing.T) { // For W2W - equivalent to TestImagesEnsureImagesFromScratchShown but Windows // doesn't support from scratch -func (s *DockerSuite) TestImagesEnsureImagesFromBusyboxShown(c *testing.T) { +func (s *DockerCLIImagesSuite) TestImagesEnsureImagesFromBusyboxShown(c *testing.T) { dockerfile := ` FROM busybox MAINTAINER docker` @@ -310,7 +322,7 @@ func (s *DockerSuite) TestImagesEnsureImagesFromBusyboxShown(c *testing.T) { } // #18181 -func (s *DockerSuite) TestImagesFilterNameWithPort(c *testing.T) { +func (s *DockerCLIImagesSuite) TestImagesFilterNameWithPort(c *testing.T) { tag := "a.b.c.d:5000/hello" dockerCmd(c, "tag", "busybox", tag) out, _ := dockerCmd(c, "images", tag) @@ -321,7 +333,7 @@ func (s *DockerSuite) TestImagesFilterNameWithPort(c *testing.T) { assert.Assert(c, !strings.Contains(out, tag)) } -func (s *DockerSuite) TestImagesFormat(c *testing.T) { +func (s *DockerCLIImagesSuite) TestImagesFormat(c *testing.T) { // testRequires(c, DaemonIsLinux) tag := "myimage" dockerCmd(c, "tag", "busybox", tag+":v1") @@ -337,7 +349,7 @@ func (s *DockerSuite) TestImagesFormat(c *testing.T) { } // ImagesDefaultFormatAndQuiet -func (s *DockerSuite) TestImagesFormatDefaultFormat(c *testing.T) { +func (s *DockerCLIImagesSuite) TestImagesFormatDefaultFormat(c *testing.T) { testRequires(c, DaemonIsLinux) // create container 1 diff --git a/integration-cli/docker_cli_import_test.go b/integration-cli/docker_cli_import_test.go index d8fbeb0fc3..71e9c56116 100644 --- a/integration-cli/docker_cli_import_test.go +++ b/integration-cli/docker_cli_import_test.go @@ -14,7 +14,19 @@ import ( "gotest.tools/v3/icmd" ) -func (s *DockerSuite) TestImportDisplay(c *testing.T) { +type DockerCLIImportSuite struct { + ds *DockerSuite +} + +func (s *DockerCLIImportSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLIImportSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + +func (s *DockerCLIImportSuite) TestImportDisplay(c *testing.T) { testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "-d", "busybox", "true") cleanedContainerID := strings.TrimSpace(out) @@ -32,7 +44,7 @@ func (s *DockerSuite) TestImportDisplay(c *testing.T) { assert.Equal(c, out, "", "command output should've been nothing.") } -func (s *DockerSuite) TestImportBadURL(c *testing.T) { +func (s *DockerCLIImportSuite) TestImportBadURL(c *testing.T) { out, _, err := dockerCmdWithError("import", "https://nosuchdomain.invalid/bad") assert.Assert(c, err != nil, "import was supposed to fail but didn't") // Depending on your system you can get either of these errors @@ -43,7 +55,7 @@ func (s *DockerSuite) TestImportBadURL(c *testing.T) { } } -func (s *DockerSuite) TestImportFile(c *testing.T) { +func (s *DockerCLIImportSuite) TestImportFile(c *testing.T) { testRequires(c, DaemonIsLinux) dockerCmd(c, "run", "--name", "test-import", "busybox", "true") @@ -64,7 +76,7 @@ func (s *DockerSuite) TestImportFile(c *testing.T) { assert.Equal(c, out, "", "command output should've been nothing.") } -func (s *DockerSuite) TestImportGzipped(c *testing.T) { +func (s *DockerCLIImportSuite) TestImportGzipped(c *testing.T) { testRequires(c, DaemonIsLinux) dockerCmd(c, "run", "--name", "test-import", "busybox", "true") @@ -87,7 +99,7 @@ func (s *DockerSuite) TestImportGzipped(c *testing.T) { assert.Equal(c, out, "", "command output should've been nothing.") } -func (s *DockerSuite) TestImportFileWithMessage(c *testing.T) { +func (s *DockerCLIImportSuite) TestImportFileWithMessage(c *testing.T) { testRequires(c, DaemonIsLinux) dockerCmd(c, "run", "--name", "test-import", "busybox", "true") @@ -118,12 +130,12 @@ func (s *DockerSuite) TestImportFileWithMessage(c *testing.T) { assert.Equal(c, out, "", "command output should've been nothing") } -func (s *DockerSuite) TestImportFileNonExistentFile(c *testing.T) { +func (s *DockerCLIImportSuite) TestImportFileNonExistentFile(c *testing.T) { _, _, err := dockerCmdWithError("import", "example.com/myImage.tar") assert.Assert(c, err != nil, "import non-existing file must failed") } -func (s *DockerSuite) TestImportWithQuotedChanges(c *testing.T) { +func (s *DockerCLIImportSuite) TestImportWithQuotedChanges(c *testing.T) { testRequires(c, DaemonIsLinux) cli.DockerCmd(c, "run", "--name", "test-import", "busybox", "true") diff --git a/integration-cli/docker_cli_info_test.go b/integration-cli/docker_cli_info_test.go index f56c517a1c..2244dd5ef8 100644 --- a/integration-cli/docker_cli_info_test.go +++ b/integration-cli/docker_cli_info_test.go @@ -9,8 +9,20 @@ import ( "gotest.tools/v3/assert" ) +type DockerCLIInfoSuite struct { + ds *DockerSuite +} + +func (s *DockerCLIInfoSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLIInfoSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + // ensure docker info succeeds -func (s *DockerSuite) TestInfoEnsureSucceeds(c *testing.T) { +func (s *DockerCLIInfoSuite) TestInfoEnsureSucceeds(c *testing.T) { out, _ := dockerCmd(c, "info") // always shown fields @@ -53,7 +65,7 @@ func (s *DockerSuite) TestInfoEnsureSucceeds(c *testing.T) { } } -func (s *DockerSuite) TestInfoDisplaysRunningContainers(c *testing.T) { +func (s *DockerCLIInfoSuite) TestInfoDisplaysRunningContainers(c *testing.T) { testRequires(c, DaemonIsLinux) existing := existingContainerStates(c) @@ -66,7 +78,7 @@ func (s *DockerSuite) TestInfoDisplaysRunningContainers(c *testing.T) { assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Stopped: %d\n", existing["ContainersStopped"]))) } -func (s *DockerSuite) TestInfoDisplaysPausedContainers(c *testing.T) { +func (s *DockerCLIInfoSuite) TestInfoDisplaysPausedContainers(c *testing.T) { testRequires(c, IsPausable) existing := existingContainerStates(c) @@ -83,7 +95,7 @@ func (s *DockerSuite) TestInfoDisplaysPausedContainers(c *testing.T) { assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Stopped: %d\n", existing["ContainersStopped"]))) } -func (s *DockerSuite) TestInfoDisplaysStoppedContainers(c *testing.T) { +func (s *DockerCLIInfoSuite) TestInfoDisplaysStoppedContainers(c *testing.T) { testRequires(c, DaemonIsLinux) existing := existingContainerStates(c) diff --git a/integration-cli/docker_cli_info_unix_test.go b/integration-cli/docker_cli_info_unix_test.go index f684a6c675..ad319e69b9 100644 --- a/integration-cli/docker_cli_info_unix_test.go +++ b/integration-cli/docker_cli_info_unix_test.go @@ -13,7 +13,7 @@ import ( is "gotest.tools/v3/assert/cmp" ) -func (s *DockerSuite) TestInfoSecurityOptions(c *testing.T) { +func (s *DockerCLIInfoSuite) TestInfoSecurityOptions(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) if !seccompEnabled() && !Apparmor() { c.Skip("test requires Seccomp and/or AppArmor") diff --git a/integration-cli/docker_cli_inspect_test.go b/integration-cli/docker_cli_inspect_test.go index e380e0c8c8..6554792e01 100644 --- a/integration-cli/docker_cli_inspect_test.go +++ b/integration-cli/docker_cli_inspect_test.go @@ -15,13 +15,25 @@ import ( "gotest.tools/v3/icmd" ) +type DockerCLIInspectSuite struct { + ds *DockerSuite +} + +func (s *DockerCLIInspectSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLIInspectSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + func checkValidGraphDriver(c *testing.T, name string) { if name != "devicemapper" && name != "overlay" && name != "vfs" && name != "zfs" && name != "btrfs" && name != "aufs" { c.Fatalf("%v is not a valid graph driver name", name) } } -func (s *DockerSuite) TestInspectImage(c *testing.T) { +func (s *DockerCLIInspectSuite) TestInspectImage(c *testing.T) { testRequires(c, DaemonIsLinux) imageTest := "emptyfs" // It is important that this ID remain stable. If a code change causes @@ -35,13 +47,13 @@ func (s *DockerSuite) TestInspectImage(c *testing.T) { assert.Equal(c, id, imageTestID) } -func (s *DockerSuite) TestInspectInt64(c *testing.T) { +func (s *DockerCLIInspectSuite) TestInspectInt64(c *testing.T) { dockerCmd(c, "run", "-d", "-m=300M", "--name", "inspectTest", "busybox", "true") inspectOut := inspectField(c, "inspectTest", "HostConfig.Memory") assert.Equal(c, inspectOut, "314572800") } -func (s *DockerSuite) TestInspectDefault(c *testing.T) { +func (s *DockerCLIInspectSuite) TestInspectDefault(c *testing.T) { // Both the container and image are named busybox. docker inspect will fetch the container JSON. // If the container JSON is not available, it will go for the image JSON. @@ -52,7 +64,7 @@ func (s *DockerSuite) TestInspectDefault(c *testing.T) { assert.Equal(c, strings.TrimSpace(inspectOut), containerID) } -func (s *DockerSuite) TestInspectStatus(c *testing.T) { +func (s *DockerCLIInspectSuite) TestInspectStatus(c *testing.T) { out := runSleepingContainer(c, "-d") out = strings.TrimSpace(out) @@ -77,7 +89,7 @@ func (s *DockerSuite) TestInspectStatus(c *testing.T) { } -func (s *DockerSuite) TestInspectTypeFlagContainer(c *testing.T) { +func (s *DockerCLIInspectSuite) TestInspectTypeFlagContainer(c *testing.T) { // Both the container and image are named busybox. docker inspect will fetch container // JSON State.Running field. If the field is true, it's a container. runSleepingContainer(c, "--name=busybox", "-d") @@ -87,7 +99,7 @@ func (s *DockerSuite) TestInspectTypeFlagContainer(c *testing.T) { assert.Equal(c, out, "true\n") // not a container JSON } -func (s *DockerSuite) TestInspectTypeFlagWithNoContainer(c *testing.T) { +func (s *DockerCLIInspectSuite) TestInspectTypeFlagWithNoContainer(c *testing.T) { // Run this test on an image named busybox. docker inspect will try to fetch container // JSON. Since there is no container named busybox and --type=container, docker inspect will // not try to get the image JSON. It will throw an error. @@ -99,7 +111,7 @@ func (s *DockerSuite) TestInspectTypeFlagWithNoContainer(c *testing.T) { assert.ErrorContains(c, err, "") } -func (s *DockerSuite) TestInspectTypeFlagWithImage(c *testing.T) { +func (s *DockerCLIInspectSuite) TestInspectTypeFlagWithImage(c *testing.T) { // Both the container and image are named busybox. docker inspect will fetch image // JSON as --type=image. if there is no image with name busybox, docker inspect // will throw an error. @@ -111,7 +123,7 @@ func (s *DockerSuite) TestInspectTypeFlagWithImage(c *testing.T) { assert.Assert(c, !strings.Contains(out, "State")) } -func (s *DockerSuite) TestInspectTypeFlagWithInvalidValue(c *testing.T) { +func (s *DockerCLIInspectSuite) TestInspectTypeFlagWithInvalidValue(c *testing.T) { // Both the container and image are named busybox. docker inspect will fail // as --type=foobar is not a valid value for the flag. @@ -123,7 +135,7 @@ func (s *DockerSuite) TestInspectTypeFlagWithInvalidValue(c *testing.T) { assert.Assert(c, strings.Contains(out, "not a valid value for --type")) } -func (s *DockerSuite) TestInspectImageFilterInt(c *testing.T) { +func (s *DockerCLIInspectSuite) TestInspectImageFilterInt(c *testing.T) { testRequires(c, DaemonIsLinux) imageTest := "emptyfs" out := inspectField(c, imageTest, "Size") @@ -139,7 +151,7 @@ func (s *DockerSuite) TestInspectImageFilterInt(c *testing.T) { assert.Equal(c, result, true) } -func (s *DockerSuite) TestInspectContainerFilterInt(c *testing.T) { +func (s *DockerCLIInspectSuite) TestInspectContainerFilterInt(c *testing.T) { result := icmd.RunCmd(icmd.Cmd{ Command: []string{dockerBinary, "run", "-i", "-a", "stdin", "busybox", "cat"}, Stdin: strings.NewReader("blahblah"), @@ -161,7 +173,7 @@ func (s *DockerSuite) TestInspectContainerFilterInt(c *testing.T) { assert.Equal(c, inspectResult, true) } -func (s *DockerSuite) TestInspectImageGraphDriver(c *testing.T) { +func (s *DockerCLIInspectSuite) TestInspectImageGraphDriver(c *testing.T) { testRequires(c, DaemonIsLinux, Devicemapper) imageTest := "emptyfs" name := inspectField(c, imageTest, "GraphDriver.Name") @@ -179,7 +191,7 @@ func (s *DockerSuite) TestInspectImageGraphDriver(c *testing.T) { assert.Assert(c, err == nil, "failed to inspect DeviceSize of the image: %s, %v", deviceSize, err) } -func (s *DockerSuite) TestInspectContainerGraphDriver(c *testing.T) { +func (s *DockerCLIInspectSuite) TestInspectContainerGraphDriver(c *testing.T) { testRequires(c, DaemonIsLinux, Devicemapper) out, _ := dockerCmd(c, "run", "-d", "busybox", "true") @@ -204,7 +216,7 @@ func (s *DockerSuite) TestInspectContainerGraphDriver(c *testing.T) { assert.Assert(c, err == nil, "failed to inspect DeviceSize of the image: %s, %v", deviceSize, err) } -func (s *DockerSuite) TestInspectBindMountPoint(c *testing.T) { +func (s *DockerCLIInspectSuite) TestInspectBindMountPoint(c *testing.T) { modifier := ",z" prefix, slash := getPrefixAndSlashFromDaemonPlatform() if testEnv.OSType == "windows" { @@ -236,7 +248,7 @@ func (s *DockerSuite) TestInspectBindMountPoint(c *testing.T) { assert.Equal(c, m.RW, false) } -func (s *DockerSuite) TestInspectNamedMountPoint(c *testing.T) { +func (s *DockerCLIInspectSuite) TestInspectNamedMountPoint(c *testing.T) { prefix, slash := getPrefixAndSlashFromDaemonPlatform() dockerCmd(c, "run", "-d", "--name", "test", "-v", "data:"+prefix+slash+"data", "busybox", "cat") @@ -260,7 +272,7 @@ func (s *DockerSuite) TestInspectNamedMountPoint(c *testing.T) { } // #14947 -func (s *DockerSuite) TestInspectTimesAsRFC3339Nano(c *testing.T) { +func (s *DockerCLIInspectSuite) TestInspectTimesAsRFC3339Nano(c *testing.T) { out, _ := dockerCmd(c, "run", "-d", "busybox", "true") id := strings.TrimSpace(out) startedAt := inspectField(c, id, "State.StartedAt") @@ -281,7 +293,7 @@ func (s *DockerSuite) TestInspectTimesAsRFC3339Nano(c *testing.T) { } // #15633 -func (s *DockerSuite) TestInspectLogConfigNoType(c *testing.T) { +func (s *DockerCLIInspectSuite) TestInspectLogConfigNoType(c *testing.T) { dockerCmd(c, "create", "--name=test", "--log-opt", "max-file=42", "busybox") var logConfig container.LogConfig @@ -294,7 +306,7 @@ func (s *DockerSuite) TestInspectLogConfigNoType(c *testing.T) { assert.Equal(c, logConfig.Config["max-file"], "42", fmt.Sprintf("%v", logConfig)) } -func (s *DockerSuite) TestInspectNoSizeFlagContainer(c *testing.T) { +func (s *DockerCLIInspectSuite) TestInspectNoSizeFlagContainer(c *testing.T) { // Both the container and image are named busybox. docker inspect will fetch container // JSON SizeRw and SizeRootFs field. If there is no flag --size/-s, there are no size fields. @@ -305,7 +317,7 @@ func (s *DockerSuite) TestInspectNoSizeFlagContainer(c *testing.T) { assert.Equal(c, strings.TrimSpace(out), ",", fmt.Sprintf("Expected not to display size info: %s", out)) } -func (s *DockerSuite) TestInspectSizeFlagContainer(c *testing.T) { +func (s *DockerCLIInspectSuite) TestInspectSizeFlagContainer(c *testing.T) { runSleepingContainer(c, "--name=busybox", "-d") formatStr := "--format='{{.SizeRw}},{{.SizeRootFs}}'" @@ -316,7 +328,7 @@ func (s *DockerSuite) TestInspectSizeFlagContainer(c *testing.T) { assert.Assert(c, strings.TrimSpace(sz[1]) != "") } -func (s *DockerSuite) TestInspectTemplateError(c *testing.T) { +func (s *DockerCLIInspectSuite) TestInspectTemplateError(c *testing.T) { // Template parsing error for both the container and image. runSleepingContainer(c, "--name=container1", "-d") @@ -329,7 +341,7 @@ func (s *DockerSuite) TestInspectTemplateError(c *testing.T) { assert.Assert(c, strings.Contains(out, "Template parsing error")) } -func (s *DockerSuite) TestInspectJSONFields(c *testing.T) { +func (s *DockerCLIInspectSuite) TestInspectJSONFields(c *testing.T) { runSleepingContainer(c, "--name=busybox", "-d") out, _, err := dockerCmdWithError("inspect", "--type=container", "--format={{.HostConfig.Dns}}", "busybox") @@ -337,7 +349,7 @@ func (s *DockerSuite) TestInspectJSONFields(c *testing.T) { assert.Equal(c, out, "[]\n") } -func (s *DockerSuite) TestInspectByPrefix(c *testing.T) { +func (s *DockerCLIInspectSuite) TestInspectByPrefix(c *testing.T) { id := inspectField(c, "busybox", "Id") assert.Assert(c, strings.HasPrefix(id, "sha256:")) @@ -348,7 +360,7 @@ func (s *DockerSuite) TestInspectByPrefix(c *testing.T) { assert.Equal(c, id, id3) } -func (s *DockerSuite) TestInspectStopWhenNotFound(c *testing.T) { +func (s *DockerCLIInspectSuite) TestInspectStopWhenNotFound(c *testing.T) { runSleepingContainer(c, "--name=busybox1", "-d") runSleepingContainer(c, "--name=busybox2", "-d") result := dockerCmdWithResult("inspect", "--type=container", "--format='{{.Name}}'", "busybox1", "busybox2", "missing") @@ -366,7 +378,7 @@ func (s *DockerSuite) TestInspectStopWhenNotFound(c *testing.T) { assert.Assert(c, strings.Contains(result.Stderr(), "Error: No such container: missing")) } -func (s *DockerSuite) TestInspectHistory(c *testing.T) { +func (s *DockerCLIInspectSuite) TestInspectHistory(c *testing.T) { dockerCmd(c, "run", "--name=testcont", "busybox", "echo", "hello") dockerCmd(c, "commit", "-m", "test comment", "testcont", "testimg") out, _, err := dockerCmdWithError("inspect", "--format='{{.Comment}}'", "testimg") @@ -374,7 +386,7 @@ func (s *DockerSuite) TestInspectHistory(c *testing.T) { assert.Assert(c, strings.Contains(out, "test comment")) } -func (s *DockerSuite) TestInspectContainerNetworkDefault(c *testing.T) { +func (s *DockerCLIInspectSuite) TestInspectContainerNetworkDefault(c *testing.T) { testRequires(c, DaemonIsLinux) contName := "test1" @@ -386,7 +398,7 @@ func (s *DockerSuite) TestInspectContainerNetworkDefault(c *testing.T) { assert.Equal(c, strings.TrimSpace(out), strings.TrimSpace(netOut)) } -func (s *DockerSuite) TestInspectContainerNetworkCustom(c *testing.T) { +func (s *DockerCLIInspectSuite) TestInspectContainerNetworkCustom(c *testing.T) { testRequires(c, DaemonIsLinux) netOut, _ := dockerCmd(c, "network", "create", "net1") @@ -397,7 +409,7 @@ func (s *DockerSuite) TestInspectContainerNetworkCustom(c *testing.T) { assert.Equal(c, strings.TrimSpace(out), strings.TrimSpace(netOut)) } -func (s *DockerSuite) TestInspectRootFS(c *testing.T) { +func (s *DockerCLIInspectSuite) TestInspectRootFS(c *testing.T) { out, _, err := dockerCmdWithError("inspect", "busybox") assert.NilError(c, err) @@ -407,7 +419,7 @@ func (s *DockerSuite) TestInspectRootFS(c *testing.T) { assert.Assert(c, len(imageJSON[0].RootFS.Layers) >= 1) } -func (s *DockerSuite) TestInspectAmpersand(c *testing.T) { +func (s *DockerCLIInspectSuite) TestInspectAmpersand(c *testing.T) { testRequires(c, DaemonIsLinux) name := "test" @@ -417,7 +429,7 @@ func (s *DockerSuite) TestInspectAmpersand(c *testing.T) { assert.Assert(c, strings.Contains(out, `soanni&rtr`)) } -func (s *DockerSuite) TestInspectPlugin(c *testing.T) { +func (s *DockerCLIInspectSuite) TestInspectPlugin(c *testing.T) { testRequires(c, DaemonIsLinux, IsAmd64, Network) _, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag) assert.NilError(c, err) @@ -448,7 +460,7 @@ func (s *DockerSuite) TestInspectPlugin(c *testing.T) { } // Test case for 29185 -func (s *DockerSuite) TestInspectUnknownObject(c *testing.T) { +func (s *DockerCLIInspectSuite) TestInspectUnknownObject(c *testing.T) { // This test should work on both Windows and Linux out, _, err := dockerCmdWithError("inspect", "foobar") assert.ErrorContains(c, err, "") diff --git a/integration-cli/docker_cli_links_test.go b/integration-cli/docker_cli_links_test.go index 0131233e6a..9d45f764d3 100644 --- a/integration-cli/docker_cli_links_test.go +++ b/integration-cli/docker_cli_links_test.go @@ -13,7 +13,19 @@ import ( "gotest.tools/v3/assert/cmp" ) -func (s *DockerSuite) TestLinksPingUnlinkedContainers(c *testing.T) { +type DockerCLILinksSuite struct { + ds *DockerSuite +} + +func (s *DockerCLILinksSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLILinksSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + +func (s *DockerCLILinksSuite) TestLinksPingUnlinkedContainers(c *testing.T) { testRequires(c, DaemonIsLinux) _, exitCode, err := dockerCmdWithError("run", "--rm", "busybox", "sh", "-c", "ping -c 1 alias1 -W 1 && ping -c 1 alias2 -W 1") @@ -22,7 +34,7 @@ func (s *DockerSuite) TestLinksPingUnlinkedContainers(c *testing.T) { } // Test for appropriate error when calling --link with an invalid target container -func (s *DockerSuite) TestLinksInvalidContainerTarget(c *testing.T) { +func (s *DockerCLILinksSuite) TestLinksInvalidContainerTarget(c *testing.T) { testRequires(c, DaemonIsLinux) out, _, err := dockerCmdWithError("run", "--link", "bogus:alias", "busybox", "true") @@ -34,7 +46,7 @@ func (s *DockerSuite) TestLinksInvalidContainerTarget(c *testing.T) { assert.Assert(c, strings.Contains(strings.ToLower(out), "could not get container")) } -func (s *DockerSuite) TestLinksPingLinkedContainers(c *testing.T) { +func (s *DockerCLILinksSuite) TestLinksPingLinkedContainers(c *testing.T) { testRequires(c, DaemonIsLinux) // Test with the three different ways of specifying the default network on Linux testLinkPingOnNetwork(c, "") @@ -78,7 +90,7 @@ func testLinkPingOnNetwork(c *testing.T, network string) { dockerCmd(c, "rm", "-f", "container2") } -func (s *DockerSuite) TestLinksPingLinkedContainersAfterRename(c *testing.T) { +func (s *DockerCLILinksSuite) TestLinksPingLinkedContainersAfterRename(c *testing.T) { testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "-d", "--name", "container1", "busybox", "top") idA := strings.TrimSpace(out) @@ -91,7 +103,7 @@ func (s *DockerSuite) TestLinksPingLinkedContainersAfterRename(c *testing.T) { } -func (s *DockerSuite) TestLinksInspectLinksStarted(c *testing.T) { +func (s *DockerCLILinksSuite) TestLinksInspectLinksStarted(c *testing.T) { testRequires(c, DaemonIsLinux) dockerCmd(c, "run", "-d", "--name", "container1", "busybox", "top") dockerCmd(c, "run", "-d", "--name", "container2", "busybox", "top") @@ -110,7 +122,7 @@ func (s *DockerSuite) TestLinksInspectLinksStarted(c *testing.T) { assert.DeepEqual(c, result, expected) } -func (s *DockerSuite) TestLinksInspectLinksStopped(c *testing.T) { +func (s *DockerCLILinksSuite) TestLinksInspectLinksStopped(c *testing.T) { testRequires(c, DaemonIsLinux) dockerCmd(c, "run", "-d", "--name", "container1", "busybox", "top") @@ -130,7 +142,7 @@ func (s *DockerSuite) TestLinksInspectLinksStopped(c *testing.T) { assert.DeepEqual(c, result, expected) } -func (s *DockerSuite) TestLinksNotStartedParentNotFail(c *testing.T) { +func (s *DockerCLILinksSuite) TestLinksNotStartedParentNotFail(c *testing.T) { testRequires(c, DaemonIsLinux) dockerCmd(c, "create", "--name=first", "busybox", "top") dockerCmd(c, "create", "--name=second", "--link=first:first", "busybox", "top") @@ -138,7 +150,7 @@ func (s *DockerSuite) TestLinksNotStartedParentNotFail(c *testing.T) { } -func (s *DockerSuite) TestLinksHostsFilesInject(c *testing.T) { +func (s *DockerCLILinksSuite) TestLinksHostsFilesInject(c *testing.T) { testRequires(c, DaemonIsLinux) testRequires(c, testEnv.IsLocalDaemon) @@ -156,7 +168,7 @@ func (s *DockerSuite) TestLinksHostsFilesInject(c *testing.T) { assert.Assert(c, strings.Contains(string(contentTwo), "onetwo")) } -func (s *DockerSuite) TestLinksUpdateOnRestart(c *testing.T) { +func (s *DockerCLILinksSuite) TestLinksUpdateOnRestart(c *testing.T) { testRequires(c, DaemonIsLinux) testRequires(c, testEnv.IsLocalDaemon) dockerCmd(c, "run", "-d", "--name", "one", "busybox", "top") @@ -189,7 +201,7 @@ func (s *DockerSuite) TestLinksUpdateOnRestart(c *testing.T) { assert.Equal(c, ip, realIP) } -func (s *DockerSuite) TestLinksEnvs(c *testing.T) { +func (s *DockerCLILinksSuite) TestLinksEnvs(c *testing.T) { testRequires(c, DaemonIsLinux) dockerCmd(c, "run", "-d", "-e", "e1=", "-e", "e2=v2", "-e", "e3=v3=v3", "--name=first", "busybox", "top") out, _ := dockerCmd(c, "run", "--name=second", "--link=first:first", "busybox", "env") @@ -198,7 +210,7 @@ func (s *DockerSuite) TestLinksEnvs(c *testing.T) { assert.Assert(c, strings.Contains(out, "FIRST_ENV_e3=v3=v3")) } -func (s *DockerSuite) TestLinkShortDefinition(c *testing.T) { +func (s *DockerCLILinksSuite) TestLinkShortDefinition(c *testing.T) { testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "-d", "--name", "shortlinkdef", "busybox", "top") @@ -214,7 +226,7 @@ func (s *DockerSuite) TestLinkShortDefinition(c *testing.T) { assert.Equal(c, links, "[\"/shortlinkdef:/link2/shortlinkdef\"]") } -func (s *DockerSuite) TestLinksNetworkHostContainer(c *testing.T) { +func (s *DockerCLILinksSuite) TestLinksNetworkHostContainer(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace) dockerCmd(c, "run", "-d", "--net", "host", "--name", "host_container", "busybox", "top") out, _, err := dockerCmdWithError("run", "--name", "should_fail", "--link", "host_container:tester", "busybox", "true") @@ -225,14 +237,14 @@ func (s *DockerSuite) TestLinksNetworkHostContainer(c *testing.T) { assert.Assert(c, strings.Contains(out, runconfig.ErrConflictHostNetworkAndLinks.Error())) } -func (s *DockerSuite) TestLinksEtcHostsRegularFile(c *testing.T) { +func (s *DockerCLILinksSuite) TestLinksEtcHostsRegularFile(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace) out, _ := dockerCmd(c, "run", "--net=host", "busybox", "ls", "-la", "/etc/hosts") // /etc/hosts should be a regular file assert.Assert(c, cmp.Regexp("^-.+\n$", out)) } -func (s *DockerSuite) TestLinksMultipleWithSameName(c *testing.T) { +func (s *DockerCLILinksSuite) TestLinksMultipleWithSameName(c *testing.T) { testRequires(c, DaemonIsLinux) dockerCmd(c, "run", "-d", "--name=upstream-a", "busybox", "top") dockerCmd(c, "run", "-d", "--name=upstream-b", "busybox", "top") diff --git a/integration-cli/docker_cli_login_test.go b/integration-cli/docker_cli_login_test.go index 04fb9eaa30..fb77f8de19 100644 --- a/integration-cli/docker_cli_login_test.go +++ b/integration-cli/docker_cli_login_test.go @@ -9,7 +9,19 @@ import ( "gotest.tools/v3/assert" ) -func (s *DockerSuite) TestLoginWithoutTTY(c *testing.T) { +type DockerCLILoginSuite struct { + ds *DockerSuite +} + +func (s *DockerCLILoginSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLILoginSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + +func (s *DockerCLILoginSuite) TestLoginWithoutTTY(c *testing.T) { cmd := exec.Command(dockerBinary, "login") // Send to stdin so the process does not get the TTY diff --git a/integration-cli/docker_cli_logs_bench_test.go b/integration-cli/docker_cli_logs_bench_test.go deleted file mode 100644 index 4702b2a4b9..0000000000 --- a/integration-cli/docker_cli_logs_bench_test.go +++ /dev/null @@ -1,31 +0,0 @@ -package main - -import ( - "fmt" - "strings" - "testing" - "time" -) - -func (s *DockerSuite) BenchmarkLogsCLIRotateFollow(c *testing.B) { - out, _ := dockerCmd(c, "run", "-d", "--log-opt", "max-size=1b", "--log-opt", "max-file=10", "busybox", "sh", "-c", "while true; do usleep 50000; echo hello; done") - id := strings.TrimSpace(out) - ch := make(chan error, 1) - go func() { - ch <- nil - out, _, _ := dockerCmdWithError("logs", "-f", id) - // if this returns at all, it's an error - ch <- fmt.Errorf(out) - }() - - <-ch - select { - case <-time.After(30 * time.Second): - // ran for 30 seconds with no problem - return - case err := <-ch: - if err != nil { - c.Fatal(err) - } - } -} diff --git a/integration-cli/docker_cli_logs_test.go b/integration-cli/docker_cli_logs_test.go index fe41f0351b..e46deb91f7 100644 --- a/integration-cli/docker_cli_logs_test.go +++ b/integration-cli/docker_cli_logs_test.go @@ -15,18 +15,30 @@ import ( "gotest.tools/v3/icmd" ) +type DockerCLILogsSuite struct { + ds *DockerSuite +} + +func (s *DockerCLILogsSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLILogsSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + // This used to work, it test a log of PageSize-1 (gh#4851) -func (s *DockerSuite) TestLogsContainerSmallerThanPage(c *testing.T) { +func (s *DockerCLILogsSuite) TestLogsContainerSmallerThanPage(c *testing.T) { testLogsContainerPagination(c, 32767) } // Regression test: When going over the PageSize, it used to panic (gh#4851) -func (s *DockerSuite) TestLogsContainerBiggerThanPage(c *testing.T) { +func (s *DockerCLILogsSuite) TestLogsContainerBiggerThanPage(c *testing.T) { testLogsContainerPagination(c, 32768) } // Regression test: When going much over the PageSize, it used to block (gh#4851) -func (s *DockerSuite) TestLogsContainerMuchBiggerThanPage(c *testing.T) { +func (s *DockerCLILogsSuite) TestLogsContainerMuchBiggerThanPage(c *testing.T) { testLogsContainerPagination(c, 33000) } @@ -38,7 +50,7 @@ func testLogsContainerPagination(c *testing.T, testLen int) { assert.Equal(c, len(out), testLen+1) } -func (s *DockerSuite) TestLogsTimestamps(c *testing.T) { +func (s *DockerCLILogsSuite) TestLogsTimestamps(c *testing.T) { testLen := 100 out, _ := dockerCmd(c, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("for i in $(seq 1 %d); do echo = >> a.a; done; cat a.a", testLen)) @@ -63,7 +75,7 @@ func (s *DockerSuite) TestLogsTimestamps(c *testing.T) { } } -func (s *DockerSuite) TestLogsSeparateStderr(c *testing.T) { +func (s *DockerCLILogsSuite) TestLogsSeparateStderr(c *testing.T) { msg := "stderr_log" out := cli.DockerCmd(c, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("echo %s 1>&2", msg)).Combined() id := strings.TrimSpace(out) @@ -74,7 +86,7 @@ func (s *DockerSuite) TestLogsSeparateStderr(c *testing.T) { }) } -func (s *DockerSuite) TestLogsStderrInStdout(c *testing.T) { +func (s *DockerCLILogsSuite) TestLogsStderrInStdout(c *testing.T) { // TODO Windows: Needs investigation why this fails. Obtained string includes // a bunch of ANSI escape sequences before the "stderr_log" message. testRequires(c, DaemonIsLinux) @@ -89,7 +101,7 @@ func (s *DockerSuite) TestLogsStderrInStdout(c *testing.T) { }) } -func (s *DockerSuite) TestLogsTail(c *testing.T) { +func (s *DockerCLILogsSuite) TestLogsTail(c *testing.T) { testLen := 100 out := cli.DockerCmd(c, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("for i in $(seq 1 %d); do echo =; done;", testLen)).Combined() @@ -121,7 +133,7 @@ func (s *DockerSuite) TestLogsTail(c *testing.T) { assert.Equal(c, len(lines), testLen+1) } -func (s *DockerSuite) TestLogsFollowStopped(c *testing.T) { +func (s *DockerCLILogsSuite) TestLogsFollowStopped(c *testing.T) { dockerCmd(c, "run", "--name=test", "busybox", "echo", "hello") id := getIDByName(c, "test") @@ -142,7 +154,7 @@ func (s *DockerSuite) TestLogsFollowStopped(c *testing.T) { } } -func (s *DockerSuite) TestLogsSince(c *testing.T) { +func (s *DockerCLILogsSuite) TestLogsSince(c *testing.T) { name := "testlogssince" dockerCmd(c, "run", "--name="+name, "busybox", "/bin/sh", "-c", "for i in $(seq 1 3); do sleep 2; echo log$i; done") out, _ := dockerCmd(c, "logs", "-t", name) @@ -177,7 +189,7 @@ func (s *DockerSuite) TestLogsSince(c *testing.T) { } } -func (s *DockerSuite) TestLogsSinceFutureFollow(c *testing.T) { +func (s *DockerCLILogsSuite) TestLogsSinceFutureFollow(c *testing.T) { // TODO Windows TP5 - Figure out why this test is so flakey. Disabled for now. testRequires(c, DaemonIsLinux) name := "testlogssincefuturefollow" @@ -211,7 +223,7 @@ func (s *DockerSuite) TestLogsSinceFutureFollow(c *testing.T) { } // Regression test for #8832 -func (s *DockerSuite) TestLogsFollowSlowStdoutConsumer(c *testing.T) { +func (s *DockerCLILogsSuite) TestLogsFollowSlowStdoutConsumer(c *testing.T) { // TODO Windows: Fix this test for TP5. testRequires(c, DaemonIsLinux) expected := 150000 @@ -269,7 +281,7 @@ func ConsumeWithSpeed(reader io.Reader, chunkSize int, interval time.Duration, s } } -func (s *DockerSuite) TestLogsFollowGoroutinesWithStdout(c *testing.T) { +func (s *DockerCLILogsSuite) TestLogsFollowGoroutinesWithStdout(c *testing.T) { out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "while true; do echo hello; sleep 2; done") id := strings.TrimSpace(out) assert.NilError(c, waitRun(id)) @@ -297,7 +309,7 @@ func (s *DockerSuite) TestLogsFollowGoroutinesWithStdout(c *testing.T) { assert.NilError(c, waitForGoroutines(nroutines)) } -func (s *DockerSuite) TestLogsFollowGoroutinesNoOutput(c *testing.T) { +func (s *DockerCLILogsSuite) TestLogsFollowGoroutinesNoOutput(c *testing.T) { out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "while true; do sleep 2; done") id := strings.TrimSpace(out) assert.NilError(c, waitRun(id)) @@ -315,14 +327,14 @@ func (s *DockerSuite) TestLogsFollowGoroutinesNoOutput(c *testing.T) { assert.NilError(c, waitForGoroutines(nroutines)) } -func (s *DockerSuite) TestLogsCLIContainerNotFound(c *testing.T) { +func (s *DockerCLILogsSuite) TestLogsCLIContainerNotFound(c *testing.T) { name := "testlogsnocontainer" out, _, _ := dockerCmdWithError("logs", name) message := fmt.Sprintf("No such container: %s\n", name) assert.Assert(c, strings.Contains(out, message)) } -func (s *DockerSuite) TestLogsWithDetails(c *testing.T) { +func (s *DockerCLILogsSuite) TestLogsWithDetails(c *testing.T) { dockerCmd(c, "run", "--name=test", "--label", "foo=bar", "-e", "baz=qux", "--log-opt", "labels=foo", "--log-opt", "env=baz", "busybox", "echo", "hello") out, _ := dockerCmd(c, "logs", "--details", "--timestamps", "test") diff --git a/integration-cli/docker_cli_netmode_test.go b/integration-cli/docker_cli_netmode_test.go index fe6d9487ac..48807bb0e0 100644 --- a/integration-cli/docker_cli_netmode_test.go +++ b/integration-cli/docker_cli_netmode_test.go @@ -14,6 +14,18 @@ import ( // the command executed in a container did really run PS correctly. const stringCheckPS = "PID USER" +type DockerCLINetmodeSuite struct { + ds *DockerSuite +} + +func (s *DockerCLINetmodeSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLINetmodeSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + // DockerCmdWithFail executes a docker command that is supposed to fail and returns // the output, the exit code. If the command returns a Nil error, it will fail and // stop the tests. @@ -23,14 +35,14 @@ func dockerCmdWithFail(c *testing.T, args ...string) (string, int) { return out, status } -func (s *DockerSuite) TestNetHostnameWithNetHost(c *testing.T) { +func (s *DockerCLINetmodeSuite) TestNetHostnameWithNetHost(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace) out, _ := dockerCmd(c, "run", "--net=host", "busybox", "ps") assert.Assert(c, strings.Contains(out, stringCheckPS)) } -func (s *DockerSuite) TestNetHostname(c *testing.T) { +func (s *DockerCLINetmodeSuite) TestNetHostname(c *testing.T) { testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "-h=name", "busybox", "ps") @@ -47,28 +59,28 @@ func (s *DockerSuite) TestNetHostname(c *testing.T) { assert.Assert(c, strings.Contains(strings.ToLower(out), "not found")) } -func (s *DockerSuite) TestConflictContainerNetworkAndLinks(c *testing.T) { +func (s *DockerCLINetmodeSuite) TestConflictContainerNetworkAndLinks(c *testing.T) { testRequires(c, DaemonIsLinux) out, _ := dockerCmdWithFail(c, "run", "--net=container:other", "--link=zip:zap", "busybox", "ps") assert.Assert(c, strings.Contains(out, runconfig.ErrConflictContainerNetworkAndLinks.Error())) } -func (s *DockerSuite) TestConflictContainerNetworkHostAndLinks(c *testing.T) { +func (s *DockerCLINetmodeSuite) TestConflictContainerNetworkHostAndLinks(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace) out, _ := dockerCmdWithFail(c, "run", "--net=host", "--link=zip:zap", "busybox", "ps") assert.Assert(c, strings.Contains(out, runconfig.ErrConflictHostNetworkAndLinks.Error())) } -func (s *DockerSuite) TestConflictNetworkModeNetHostAndOptions(c *testing.T) { +func (s *DockerCLINetmodeSuite) TestConflictNetworkModeNetHostAndOptions(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace) out, _ := dockerCmdWithFail(c, "run", "--net=host", "--mac-address=92:d0:c6:0a:29:33", "busybox", "ps") assert.Assert(c, strings.Contains(out, runconfig.ErrConflictContainerNetworkAndMac.Error())) } -func (s *DockerSuite) TestConflictNetworkModeAndOptions(c *testing.T) { +func (s *DockerCLINetmodeSuite) TestConflictNetworkModeAndOptions(c *testing.T) { testRequires(c, DaemonIsLinux) out, _ := dockerCmdWithFail(c, "run", "--net=container:other", "--dns=8.8.8.8", "busybox", "ps") diff --git a/integration-cli/docker_cli_network_test.go b/integration-cli/docker_cli_network_test.go index ad1c95876f..ebe19d0af7 100644 --- a/integration-cli/docker_cli_network_test.go +++ b/integration-cli/docker_cli_network_test.go @@ -2,10 +2,23 @@ package main import ( "net/http/httptest" + "testing" "github.com/docker/docker/integration-cli/daemon" ) +type DockerCLINetworkSuite struct { + ds *DockerSuite +} + +func (s *DockerCLINetworkSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLINetworkSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + type DockerNetworkSuite struct { server *httptest.Server ds *DockerSuite diff --git a/integration-cli/docker_cli_network_unix_test.go b/integration-cli/docker_cli_network_unix_test.go index ea5da4b401..0b2be9758e 100644 --- a/integration-cli/docker_cli_network_unix_test.go +++ b/integration-cli/docker_cli_network_unix_test.go @@ -383,12 +383,12 @@ func (s *DockerNetworkSuite) TestDockerNetworkCreateLabel(c *testing.T) { assertNwNotAvailable(c, testNet) } -func (s *DockerSuite) TestDockerNetworkDeleteNotExists(c *testing.T) { +func (s *DockerCLINetworkSuite) TestDockerNetworkDeleteNotExists(c *testing.T) { out, _, err := dockerCmdWithError("network", "rm", "test") assert.ErrorContains(c, err, "", out) } -func (s *DockerSuite) TestDockerNetworkDeleteMultiple(c *testing.T) { +func (s *DockerCLINetworkSuite) TestDockerNetworkDeleteMultiple(c *testing.T) { dockerCmd(c, "network", "create", "testDelMulti0") assertNwIsAvailable(c, "testDelMulti0") dockerCmd(c, "network", "create", "testDelMulti1") @@ -412,7 +412,7 @@ func (s *DockerSuite) TestDockerNetworkDeleteMultiple(c *testing.T) { assertNwIsAvailable(c, "testDelMulti2") } -func (s *DockerSuite) TestDockerNetworkInspect(c *testing.T) { +func (s *DockerCLINetworkSuite) TestDockerNetworkInspect(c *testing.T) { out, _ := dockerCmd(c, "network", "inspect", "host") var networkResources []types.NetworkResource err := json.Unmarshal([]byte(out), &networkResources) @@ -423,7 +423,7 @@ func (s *DockerSuite) TestDockerNetworkInspect(c *testing.T) { assert.Equal(c, strings.TrimSpace(out), "host") } -func (s *DockerSuite) TestDockerNetworkInspectWithID(c *testing.T) { +func (s *DockerCLINetworkSuite) TestDockerNetworkInspectWithID(c *testing.T) { out, _ := dockerCmd(c, "network", "create", "test2") networkID := strings.TrimSpace(out) assertNwIsAvailable(c, "test2") @@ -434,7 +434,7 @@ func (s *DockerSuite) TestDockerNetworkInspectWithID(c *testing.T) { assert.Equal(c, strings.TrimSpace(out), networkID) } -func (s *DockerSuite) TestDockerInspectMultipleNetwork(c *testing.T) { +func (s *DockerCLINetworkSuite) TestDockerInspectMultipleNetwork(c *testing.T) { result := dockerCmdWithResult("network", "inspect", "host", "none") result.Assert(c, icmd.Success) @@ -444,7 +444,7 @@ func (s *DockerSuite) TestDockerInspectMultipleNetwork(c *testing.T) { assert.Equal(c, len(networkResources), 2) } -func (s *DockerSuite) TestDockerInspectMultipleNetworksIncludingNonexistent(c *testing.T) { +func (s *DockerCLINetworkSuite) TestDockerInspectMultipleNetworksIncludingNonexistent(c *testing.T) { // non-existent network was not at the beginning of the inspect list // This should print an error, return an exitCode 1 and print the host network result := dockerCmdWithResult("network", "inspect", "host", "nonexistent") @@ -483,7 +483,7 @@ func (s *DockerSuite) TestDockerInspectMultipleNetworksIncludingNonexistent(c *t assert.Equal(c, len(networkResources), 1) } -func (s *DockerSuite) TestDockerInspectNetworkWithContainerName(c *testing.T) { +func (s *DockerCLINetworkSuite) TestDockerInspectNetworkWithContainerName(c *testing.T) { dockerCmd(c, "network", "create", "brNetForInspect") assertNwIsAvailable(c, "brNetForInspect") defer func() { @@ -999,7 +999,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkMacInspect(c *testing.T) { assert.Equal(c, mac, "a0:b1:c2:d3:e4:f5") } -func (s *DockerSuite) TestInspectAPIMultipleNetworks(c *testing.T) { +func (s *DockerCLINetworkSuite) TestInspectAPIMultipleNetworks(c *testing.T) { dockerCmd(c, "network", "create", "mybridge1") dockerCmd(c, "network", "create", "mybridge2") out, _ := dockerCmd(c, "run", "-d", "busybox", "top") @@ -1418,7 +1418,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectLinkLocalIP(c *testing.T) { assert.NilError(c, err) } -func (s *DockerSuite) TestUserDefinedNetworkConnectDisconnectLink(c *testing.T) { +func (s *DockerCLINetworkSuite) TestUserDefinedNetworkConnectDisconnectLink(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm) dockerCmd(c, "network", "create", "-d", "bridge", "foo1") dockerCmd(c, "network", "create", "-d", "bridge", "foo2") @@ -1492,7 +1492,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectWithAliasOnDefaultNetworks( } } -func (s *DockerSuite) TestUserDefinedNetworkConnectDisconnectAlias(c *testing.T) { +func (s *DockerCLINetworkSuite) TestUserDefinedNetworkConnectDisconnectAlias(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm) dockerCmd(c, "network", "create", "-d", "bridge", "net1") dockerCmd(c, "network", "create", "-d", "bridge", "net2") @@ -1546,7 +1546,7 @@ func (s *DockerSuite) TestUserDefinedNetworkConnectDisconnectAlias(c *testing.T) assert.Assert(c, strings.Contains(out, runconfig.ErrUnsupportedNetworkAndAlias.Error())) } -func (s *DockerSuite) TestUserDefinedNetworkConnectivity(c *testing.T) { +func (s *DockerCLINetworkSuite) TestUserDefinedNetworkConnectivity(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace) dockerCmd(c, "network", "create", "-d", "bridge", "br.net1") @@ -1569,7 +1569,7 @@ func (s *DockerSuite) TestUserDefinedNetworkConnectivity(c *testing.T) { assert.ErrorContains(c, err, "") } -func (s *DockerSuite) TestEmbeddedDNSInvalidInput(c *testing.T) { +func (s *DockerCLINetworkSuite) TestEmbeddedDNSInvalidInput(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace) dockerCmd(c, "network", "create", "-d", "bridge", "nw1") @@ -1577,7 +1577,7 @@ func (s *DockerSuite) TestEmbeddedDNSInvalidInput(c *testing.T) { dockerCmd(c, "run", "-i", "--net=nw1", "--name=c1", "debian:bullseye-slim", "bash", "-c", "echo InvalidQuery > /dev/udp/127.0.0.11/53") } -func (s *DockerSuite) TestDockerNetworkConnectFailsNoInspectChange(c *testing.T) { +func (s *DockerCLINetworkSuite) TestDockerNetworkConnectFailsNoInspectChange(c *testing.T) { dockerCmd(c, "run", "-d", "--name=bb", "busybox", "top") assert.Assert(c, waitRun("bb") == nil) defer dockerCmd(c, "stop", "bb") @@ -1592,7 +1592,7 @@ func (s *DockerSuite) TestDockerNetworkConnectFailsNoInspectChange(c *testing.T) assert.Equal(c, ns1, ns0) } -func (s *DockerSuite) TestDockerNetworkInternalMode(c *testing.T) { +func (s *DockerCLINetworkSuite) TestDockerNetworkInternalMode(c *testing.T) { dockerCmd(c, "network", "create", "--driver=bridge", "--internal", "internal") assertNwIsAvailable(c, "internal") nr := getNetworkResource(c, "internal") diff --git a/integration-cli/docker_cli_plugins_logdriver_test.go b/integration-cli/docker_cli_plugins_logdriver_test.go index 0c521ade7c..6952408faf 100644 --- a/integration-cli/docker_cli_plugins_logdriver_test.go +++ b/integration-cli/docker_cli_plugins_logdriver_test.go @@ -9,7 +9,19 @@ import ( "gotest.tools/v3/assert" ) -func (s *DockerSuite) TestPluginLogDriver(c *testing.T) { +type DockerCLIPluginLogDriverSuite struct { + ds *DockerSuite +} + +func (s *DockerCLIPluginLogDriverSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLIPluginLogDriverSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + +func (s *DockerCLIPluginLogDriverSuite) TestPluginLogDriver(c *testing.T) { testRequires(c, IsAmd64, DaemonIsLinux) pluginName := "cpuguy83/docker-logdriver-test:latest" @@ -29,7 +41,7 @@ func (s *DockerSuite) TestPluginLogDriver(c *testing.T) { } // Make sure log drivers are listed in info, and v2 plugins are not. -func (s *DockerSuite) TestPluginLogDriverInfoList(c *testing.T) { +func (s *DockerCLIPluginLogDriverSuite) TestPluginLogDriverInfoList(c *testing.T) { testRequires(c, IsAmd64, DaemonIsLinux) pluginName := "cpuguy83/docker-logdriver-test" diff --git a/integration-cli/docker_cli_plugins_test.go b/integration-cli/docker_cli_plugins_test.go index 7161867669..8e6912fd1c 100644 --- a/integration-cli/docker_cli_plugins_test.go +++ b/integration-cli/docker_cli_plugins_test.go @@ -28,6 +28,18 @@ var ( npNameWithTag = npName + ":" + pTag ) +type DockerCLIPluginsSuite struct { + ds *DockerSuite +} + +func (s *DockerCLIPluginsSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLIPluginsSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + func (ps *DockerPluginSuite) TestPluginBasicOps(c *testing.T) { plugin := ps.getPluginRepoWithTag() _, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", plugin) @@ -69,7 +81,7 @@ func (ps *DockerPluginSuite) TestPluginForceRemove(c *testing.T) { assert.Assert(c, strings.Contains(out, pNameWithTag)) } -func (s *DockerSuite) TestPluginActive(c *testing.T) { +func (s *DockerCLIPluginsSuite) TestPluginActive(c *testing.T) { testRequires(c, DaemonIsLinux, IsAmd64, Network) _, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag) @@ -91,7 +103,7 @@ func (s *DockerSuite) TestPluginActive(c *testing.T) { assert.Assert(c, strings.Contains(out, pNameWithTag)) } -func (s *DockerSuite) TestPluginActiveNetwork(c *testing.T) { +func (s *DockerCLIPluginsSuite) TestPluginActiveNetwork(c *testing.T) { testRequires(c, DaemonIsLinux, IsAmd64, Network) _, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", npNameWithTag) assert.NilError(c, err) @@ -136,7 +148,7 @@ func (ps *DockerPluginSuite) TestPluginInstallDisable(c *testing.T) { assert.Assert(c, strings.Contains(strings.TrimSpace(out), pName)) } -func (s *DockerSuite) TestPluginInstallDisableVolumeLs(c *testing.T) { +func (s *DockerCLIPluginsSuite) TestPluginInstallDisableVolumeLs(c *testing.T) { testRequires(c, DaemonIsLinux, IsAmd64, Network) out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", "--disable", pName) assert.NilError(c, err) @@ -316,7 +328,7 @@ func (ps *DockerPluginSuite) TestPluginInspect(c *testing.T) { } // Test case for https://github.com/docker/docker/pull/29186#discussion_r91277345 -func (s *DockerSuite) TestPluginInspectOnWindows(c *testing.T) { +func (s *DockerCLIPluginsSuite) TestPluginInspectOnWindows(c *testing.T) { // This test should work on Windows only testRequires(c, DaemonIsWindows) @@ -411,7 +423,7 @@ enabled: false`, id, name) assert.Assert(c, strings.Contains(strings.TrimSpace(out), expectedOutput)) } -func (s *DockerSuite) TestPluginUpgrade(c *testing.T) { +func (s *DockerCLIPluginsSuite) TestPluginUpgrade(c *testing.T) { testRequires(c, DaemonIsLinux, Network, testEnv.IsLocalDaemon, IsAmd64, NotUserNamespace) plugin := "cpuguy83/docker-volume-driver-plugin-local:latest" pluginV2 := "cpuguy83/docker-volume-driver-plugin-local:v2" @@ -442,7 +454,7 @@ func (s *DockerSuite) TestPluginUpgrade(c *testing.T) { dockerCmd(c, "run", "--rm", "-v", "bananas:/apple", "busybox", "sh", "-c", "ls -lh /apple/core") } -func (s *DockerSuite) TestPluginMetricsCollector(c *testing.T) { +func (s *DockerCLIPluginsSuite) TestPluginMetricsCollector(c *testing.T) { testRequires(c, DaemonIsLinux, Network, testEnv.IsLocalDaemon, IsAmd64) d := daemon.New(c, dockerBinary, dockerdBinary) d.Start(c) diff --git a/integration-cli/docker_cli_port_test.go b/integration-cli/docker_cli_port_test.go index dd41d9891f..7c7eccabcf 100644 --- a/integration-cli/docker_cli_port_test.go +++ b/integration-cli/docker_cli_port_test.go @@ -12,7 +12,19 @@ import ( "gotest.tools/v3/assert" ) -func (s *DockerSuite) TestPortList(c *testing.T) { +type DockerCLIPortSuite struct { + ds *DockerSuite +} + +func (s *DockerCLIPortSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLIPortSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + +func (s *DockerCLIPortSuite) TestPortList(c *testing.T) { testRequires(c, DaemonIsLinux) // one port out, _ := dockerCmd(c, "run", "-d", "-p", "9876:80", "busybox", "top") @@ -241,7 +253,7 @@ func stopRemoveContainer(id string, c *testing.T) { dockerCmd(c, "rm", "-f", id) } -func (s *DockerSuite) TestUnpublishedPortsInPsOutput(c *testing.T) { +func (s *DockerCLIPortSuite) TestUnpublishedPortsInPsOutput(c *testing.T) { testRequires(c, DaemonIsLinux) // Run busybox with command line expose (equivalent to EXPOSE in image's Dockerfile) for the following ports port1 := 80 @@ -312,7 +324,7 @@ func (s *DockerSuite) TestUnpublishedPortsInPsOutput(c *testing.T) { assert.Assert(c, strings.Contains(out, expBnd2)) } -func (s *DockerSuite) TestPortHostBinding(c *testing.T) { +func (s *DockerCLIPortSuite) TestPortHostBinding(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace) out, _ := dockerCmd(c, "run", "-d", "-p", "9876:80", "busybox", "nc", "-l", "-p", "80") firstID := strings.TrimSpace(out) @@ -332,7 +344,7 @@ func (s *DockerSuite) TestPortHostBinding(c *testing.T) { assert.Assert(c, err != nil, "out: %s", out) } -func (s *DockerSuite) TestPortExposeHostBinding(c *testing.T) { +func (s *DockerCLIPortSuite) TestPortExposeHostBinding(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace) out, _ := dockerCmd(c, "run", "-d", "-P", "--expose", "80", "busybox", "nc", "-l", "-p", "80") firstID := strings.TrimSpace(out) @@ -349,7 +361,7 @@ func (s *DockerSuite) TestPortExposeHostBinding(c *testing.T) { assert.Assert(c, err != nil, "out: %s", out) } -func (s *DockerSuite) TestPortBindingOnSandbox(c *testing.T) { +func (s *DockerCLIPortSuite) TestPortBindingOnSandbox(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace) dockerCmd(c, "network", "create", "--internal", "-d", "bridge", "internal-net") nr := getNetworkResource(c, "internal-net") diff --git a/integration-cli/docker_cli_proxy_test.go b/integration-cli/docker_cli_proxy_test.go index a803328665..e138e5e39c 100644 --- a/integration-cli/docker_cli_proxy_test.go +++ b/integration-cli/docker_cli_proxy_test.go @@ -9,7 +9,19 @@ import ( "gotest.tools/v3/icmd" ) -func (s *DockerSuite) TestCLIProxyDisableProxyUnixSock(c *testing.T) { +type DockerCLIProxySuite struct { + ds *DockerSuite +} + +func (s *DockerCLIProxySuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLIProxySuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + +func (s *DockerCLIProxySuite) TestCLIProxyDisableProxyUnixSock(c *testing.T) { testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) icmd.RunCmd(icmd.Cmd{ diff --git a/integration-cli/docker_cli_prune_test.go b/integration-cli/docker_cli_prune_test.go new file mode 100644 index 0000000000..2243b8a72b --- /dev/null +++ b/integration-cli/docker_cli_prune_test.go @@ -0,0 +1,5 @@ +package main + +type DockerCLIPruneSuite struct { + ds *DockerSuite +} diff --git a/integration-cli/docker_cli_prune_unix_test.go b/integration-cli/docker_cli_prune_unix_test.go index f3afe70a20..b8a12efc46 100644 --- a/integration-cli/docker_cli_prune_unix_test.go +++ b/integration-cli/docker_cli_prune_unix_test.go @@ -20,6 +20,14 @@ import ( "gotest.tools/v3/poll" ) +func (s *DockerCLIPruneSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLIPruneSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + func pruneNetworkAndVerify(c *testing.T, d *daemon.Daemon, kept, pruned []string) { _, err := d.Cmd("network", "prune", "--force") assert.NilError(c, err) @@ -109,7 +117,7 @@ func (s *DockerDaemonSuite) TestPruneImageDangling(c *testing.T) { assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id)) } -func (s *DockerSuite) TestPruneContainerUntil(c *testing.T) { +func (s *DockerCLIPruneSuite) TestPruneContainerUntil(c *testing.T) { out := cli.DockerCmd(c, "run", "-d", "busybox").Combined() id1 := strings.TrimSpace(out) cli.WaitExited(c, id1, 5*time.Second) @@ -128,7 +136,7 @@ func (s *DockerSuite) TestPruneContainerUntil(c *testing.T) { assert.Assert(c, strings.Contains(strings.TrimSpace(out), id2)) } -func (s *DockerSuite) TestPruneContainerLabel(c *testing.T) { +func (s *DockerCLIPruneSuite) TestPruneContainerLabel(c *testing.T) { out := cli.DockerCmd(c, "run", "-d", "--label", "foo", "busybox").Combined() id1 := strings.TrimSpace(out) cli.WaitExited(c, id1, 5*time.Second) @@ -180,7 +188,7 @@ func (s *DockerSuite) TestPruneContainerLabel(c *testing.T) { assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2)) } -func (s *DockerSuite) TestPruneVolumeLabel(c *testing.T) { +func (s *DockerCLIPruneSuite) TestPruneVolumeLabel(c *testing.T) { out, _ := dockerCmd(c, "volume", "create", "--label", "foo") id1 := strings.TrimSpace(out) assert.Assert(c, id1 != "") @@ -232,7 +240,7 @@ func (s *DockerSuite) TestPruneVolumeLabel(c *testing.T) { assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2)) } -func (s *DockerSuite) TestPruneNetworkLabel(c *testing.T) { +func (s *DockerCLIPruneSuite) TestPruneNetworkLabel(c *testing.T) { dockerCmd(c, "network", "create", "--label", "foo", "n1") dockerCmd(c, "network", "create", "--label", "bar", "n2") dockerCmd(c, "network", "create", "n3") diff --git a/integration-cli/docker_cli_ps_test.go b/integration-cli/docker_cli_ps_test.go index f4439aebbd..d9411990e1 100644 --- a/integration-cli/docker_cli_ps_test.go +++ b/integration-cli/docker_cli_ps_test.go @@ -18,7 +18,19 @@ import ( "gotest.tools/v3/skip" ) -func (s *DockerSuite) TestPsListContainersBase(c *testing.T) { +type DockerCLIPsSuite struct { + ds *DockerSuite +} + +func (s *DockerCLIPsSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLIPsSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + +func (s *DockerCLIPsSuite) TestPsListContainersBase(c *testing.T) { existingContainers := ExistingContainerIDs(c) out := runSleepingContainer(c, "-d") @@ -139,7 +151,7 @@ func assertContainerList(out string, expected []string) bool { return true } -func (s *DockerSuite) TestPsListContainersSize(c *testing.T) { +func (s *DockerCLIPsSuite) TestPsListContainersSize(c *testing.T) { // Problematic on Windows as it doesn't report the size correctly @swernli testRequires(c, DaemonIsLinux) dockerCmd(c, "run", "-d", "busybox") @@ -179,7 +191,7 @@ func (s *DockerSuite) TestPsListContainersSize(c *testing.T) { assert.Assert(c, strings.Contains(foundSize, expectedSize), "Expected size %q, got %q", expectedSize, foundSize) } -func (s *DockerSuite) TestPsListContainersFilterStatus(c *testing.T) { +func (s *DockerCLIPsSuite) TestPsListContainersFilterStatus(c *testing.T) { existingContainers := ExistingContainerIDs(c) // start exited container @@ -226,7 +238,7 @@ func (s *DockerSuite) TestPsListContainersFilterStatus(c *testing.T) { } } -func (s *DockerSuite) TestPsListContainersFilterHealth(c *testing.T) { +func (s *DockerCLIPsSuite) TestPsListContainersFilterHealth(c *testing.T) { skip.If(c, RuntimeIsWindowsContainerd(), "FIXME. Hang on Windows + containerd combination") existingContainers := ExistingContainerIDs(c) // Test legacy no health check @@ -270,7 +282,7 @@ func (s *DockerSuite) TestPsListContainersFilterHealth(c *testing.T) { assert.Equal(c, containerOut, containerID, fmt.Sprintf("Expected containerID %s, got %s for healthy filter, output: %q", containerID, containerOut, out)) } -func (s *DockerSuite) TestPsListContainersFilterID(c *testing.T) { +func (s *DockerCLIPsSuite) TestPsListContainersFilterID(c *testing.T) { // start container out, _ := dockerCmd(c, "run", "-d", "busybox") firstID := strings.TrimSpace(out) @@ -284,7 +296,7 @@ func (s *DockerSuite) TestPsListContainersFilterID(c *testing.T) { assert.Equal(c, containerOut, firstID[:12], fmt.Sprintf("Expected id %s, got %s for exited filter, output: %q", firstID[:12], containerOut, out)) } -func (s *DockerSuite) TestPsListContainersFilterName(c *testing.T) { +func (s *DockerCLIPsSuite) TestPsListContainersFilterName(c *testing.T) { // start container dockerCmd(c, "run", "--name=a_name_to_match", "busybox") id := getIDByName(c, "a_name_to_match") @@ -306,7 +318,7 @@ func (s *DockerSuite) TestPsListContainersFilterName(c *testing.T) { // - Create an image based on the previous image (images_ps_filter_test2) // - Run containers for each of those image (busybox, images_ps_filter_test1, images_ps_filter_test2) // - Filter them out :P -func (s *DockerSuite) TestPsListContainersFilterAncestorImage(c *testing.T) { +func (s *DockerCLIPsSuite) TestPsListContainersFilterAncestorImage(c *testing.T) { existingContainers := ExistingContainerIDs(c) // Build images @@ -401,7 +413,7 @@ func checkPsAncestorFilterOutput(c *testing.T, out string, filterName string, ex } } -func (s *DockerSuite) TestPsListContainersFilterLabel(c *testing.T) { +func (s *DockerCLIPsSuite) TestPsListContainersFilterLabel(c *testing.T) { // start container dockerCmd(c, "run", "--name=first", "-l", "match=me", "-l", "second=tag", "busybox") firstID := getIDByName(c, "first") @@ -437,7 +449,7 @@ func (s *DockerSuite) TestPsListContainersFilterLabel(c *testing.T) { assert.Assert(c, !strings.Contains(containerOut, thirdID)) } -func (s *DockerSuite) TestPsListContainersFilterExited(c *testing.T) { +func (s *DockerCLIPsSuite) TestPsListContainersFilterExited(c *testing.T) { // TODO Flaky on Windows CI [both RS1 and RS5] // On slower machines the container may not have exited // yet when we filter below by exit status/exit value. @@ -468,7 +480,7 @@ func (s *DockerSuite) TestPsListContainersFilterExited(c *testing.T) { assert.Assert(c, !strings.Contains(out, strings.TrimSpace(secondZero))) } -func (s *DockerSuite) TestPsRightTagName(c *testing.T) { +func (s *DockerCLIPsSuite) TestPsRightTagName(c *testing.T) { // TODO Investigate further why this fails on Windows to Windows CI testRequires(c, DaemonIsLinux) @@ -514,7 +526,7 @@ func (s *DockerSuite) TestPsRightTagName(c *testing.T) { } } -func (s *DockerSuite) TestPsListContainersFilterCreated(c *testing.T) { +func (s *DockerCLIPsSuite) TestPsListContainersFilterCreated(c *testing.T) { // create a container out, _ := dockerCmd(c, "create", "busybox") cID := strings.TrimSpace(out) @@ -544,7 +556,7 @@ func (s *DockerSuite) TestPsListContainersFilterCreated(c *testing.T) { } // Test for GitHub issue #12595 -func (s *DockerSuite) TestPsImageIDAfterUpdate(c *testing.T) { +func (s *DockerCLIPsSuite) TestPsImageIDAfterUpdate(c *testing.T) { // TODO: Investigate why this fails on Windows to Windows CI further. testRequires(c, DaemonIsLinux) originalImageName := "busybox:TestPsImageIDAfterUpdate-original" @@ -593,7 +605,7 @@ func (s *DockerSuite) TestPsImageIDAfterUpdate(c *testing.T) { } -func (s *DockerSuite) TestPsNotShowPortsOfStoppedContainer(c *testing.T) { +func (s *DockerCLIPsSuite) TestPsNotShowPortsOfStoppedContainer(c *testing.T) { testRequires(c, DaemonIsLinux) dockerCmd(c, "run", "--name=foo", "-d", "-p", "6000:5000", "busybox", "top") assert.Assert(c, waitRun("foo") == nil) @@ -607,7 +619,7 @@ func (s *DockerSuite) TestPsNotShowPortsOfStoppedContainer(c *testing.T) { assert.Equal(c, ports, "", "Should not got %v", expected) } -func (s *DockerSuite) TestPsShowMounts(c *testing.T) { +func (s *DockerCLIPsSuite) TestPsShowMounts(c *testing.T) { existingContainers := ExistingContainerNames(c) prefix, slash := getPrefixAndSlashFromDaemonPlatform() @@ -707,7 +719,7 @@ func (s *DockerSuite) TestPsShowMounts(c *testing.T) { assert.Equal(c, len(strings.TrimSpace(out)), 0) } -func (s *DockerSuite) TestPsListContainersFilterNetwork(c *testing.T) { +func (s *DockerCLIPsSuite) TestPsListContainersFilterNetwork(c *testing.T) { existing := ExistingContainerIDs(c) // TODO default network on Windows is not called "bridge", and creating a @@ -784,7 +796,7 @@ func (s *DockerSuite) TestPsListContainersFilterNetwork(c *testing.T) { assert.Assert(c, strings.Contains(containerOut, "onbridgenetwork"), "Missing the container on network\n") } -func (s *DockerSuite) TestPsByOrder(c *testing.T) { +func (s *DockerCLIPsSuite) TestPsByOrder(c *testing.T) { out := runSleepingContainer(c, "--name", "xyz-abc") container1 := strings.TrimSpace(out) @@ -803,7 +815,7 @@ func (s *DockerSuite) TestPsByOrder(c *testing.T) { assert.Equal(c, strings.TrimSpace(out), fmt.Sprintf("%s\n%s", container2, container1)) } -func (s *DockerSuite) TestPsListContainersFilterPorts(c *testing.T) { +func (s *DockerCLIPsSuite) TestPsListContainersFilterPorts(c *testing.T) { testRequires(c, DaemonIsLinux) existingContainers := ExistingContainerIDs(c) @@ -853,7 +865,7 @@ func (s *DockerSuite) TestPsListContainersFilterPorts(c *testing.T) { assert.Assert(c, strings.TrimSpace(out) != id3) } -func (s *DockerSuite) TestPsNotShowLinknamesOfDeletedContainer(c *testing.T) { +func (s *DockerCLIPsSuite) TestPsNotShowLinknamesOfDeletedContainer(c *testing.T) { testRequires(c, DaemonIsLinux, MinimumAPIVersion("1.31")) existingContainers := ExistingContainerNames(c) diff --git a/integration-cli/docker_cli_pull_test.go b/integration-cli/docker_cli_pull_test.go index e0f3639087..27af1f7eed 100644 --- a/integration-cli/docker_cli_pull_test.go +++ b/integration-cli/docker_cli_pull_test.go @@ -13,6 +13,18 @@ import ( is "gotest.tools/v3/assert/cmp" ) +type DockerCLIPullSuite struct { + ds *DockerSuite +} + +func (s *DockerCLIPullSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLIPullSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + // TestPullFromCentralRegistry pulls an image from the central registry and verifies that the client // prints all expected output. func (s *DockerHubPullSuite) TestPullFromCentralRegistry(c *testing.T) { @@ -263,14 +275,14 @@ func (s *DockerHubPullSuite) TestPullClientDisconnect(c *testing.T) { } // Regression test for https://github.com/docker/docker/issues/26429 -func (s *DockerSuite) TestPullLinuxImageFailsOnWindows(c *testing.T) { +func (s *DockerCLIPullSuite) TestPullLinuxImageFailsOnWindows(c *testing.T) { testRequires(c, DaemonIsWindows, Network) _, _, err := dockerCmdWithError("pull", "ubuntu") assert.ErrorContains(c, err, "no matching manifest for windows") } // Regression test for https://github.com/docker/docker/issues/28892 -func (s *DockerSuite) TestPullWindowsImageFailsOnLinux(c *testing.T) { +func (s *DockerCLIPullSuite) TestPullWindowsImageFailsOnLinux(c *testing.T) { testRequires(c, DaemonIsLinux, Network) _, _, err := dockerCmdWithError("pull", "mcr.microsoft.com/windows/servercore:ltsc2019") assert.ErrorContains(c, err, "no matching manifest for linux") diff --git a/integration-cli/docker_cli_push_test.go b/integration-cli/docker_cli_push_test.go index d3af28e46e..d883b6956f 100644 --- a/integration-cli/docker_cli_push_test.go +++ b/integration-cli/docker_cli_push_test.go @@ -17,6 +17,18 @@ import ( "gotest.tools/v3/icmd" ) +type DockerCLIPushSuite struct { + ds *DockerSuite +} + +func (s *DockerCLIPushSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLIPushSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + func (s *DockerRegistrySuite) TestPushBusyboxImage(c *testing.T) { repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL) // tag the image to upload it to the private registry @@ -26,7 +38,7 @@ func (s *DockerRegistrySuite) TestPushBusyboxImage(c *testing.T) { } // pushing an image without a prefix should throw an error -func (s *DockerSuite) TestPushUnprefixedRepo(c *testing.T) { +func (s *DockerCLIPushSuite) TestPushUnprefixedRepo(c *testing.T) { out, _, err := dockerCmdWithError("push", "busybox") assert.ErrorContains(c, err, "", "pushing an unprefixed repo didn't result in a non-zero exit status: %s", out) } @@ -208,7 +220,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestPushNoCredentialsNoRetry(c *testin } // This may be flaky but it's needed not to regress on unauthorized push, see #21054 -func (s *DockerSuite) TestPushToCentralRegistryUnauthorized(c *testing.T) { +func (s *DockerCLIPushSuite) TestPushToCentralRegistryUnauthorized(c *testing.T) { testRequires(c, Network) repoName := "test/busybox" dockerCmd(c, "tag", "busybox", repoName) diff --git a/integration-cli/docker_cli_restart_test.go b/integration-cli/docker_cli_restart_test.go index a9c9d176d5..14ed3bc77d 100644 --- a/integration-cli/docker_cli_restart_test.go +++ b/integration-cli/docker_cli_restart_test.go @@ -14,7 +14,19 @@ import ( "gotest.tools/v3/skip" ) -func (s *DockerSuite) TestRestartStoppedContainer(c *testing.T) { +type DockerCLIRestartSuite struct { + ds *DockerSuite +} + +func (s *DockerCLIRestartSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLIRestartSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + +func (s *DockerCLIRestartSuite) TestRestartStoppedContainer(c *testing.T) { dockerCmd(c, "run", "--name=test", "busybox", "echo", "foobar") cleanedContainerID := getIDByName(c, "test") @@ -31,7 +43,7 @@ func (s *DockerSuite) TestRestartStoppedContainer(c *testing.T) { assert.Equal(c, out, "foobar\nfoobar\n") } -func (s *DockerSuite) TestRestartRunningContainer(c *testing.T) { +func (s *DockerCLIRestartSuite) TestRestartRunningContainer(c *testing.T) { out, _ := dockerCmd(c, "run", "-d", "busybox", "sh", "-c", "echo foobar && sleep 30 && echo 'should not print this'") cleanedContainerID := strings.TrimSpace(out) @@ -54,7 +66,7 @@ func (s *DockerSuite) TestRestartRunningContainer(c *testing.T) { } // Test that restarting a container with a volume does not create a new volume on restart. Regression test for #819. -func (s *DockerSuite) TestRestartWithVolumes(c *testing.T) { +func (s *DockerCLIRestartSuite) TestRestartWithVolumes(c *testing.T) { prefix, slash := getPrefixAndSlashFromDaemonPlatform() out := runSleepingContainer(c, "-d", "-v", prefix+slash+"test") @@ -79,7 +91,7 @@ func (s *DockerSuite) TestRestartWithVolumes(c *testing.T) { assert.Equal(c, source, sourceAfterRestart) } -func (s *DockerSuite) TestRestartDisconnectedContainer(c *testing.T) { +func (s *DockerCLIRestartSuite) TestRestartDisconnectedContainer(c *testing.T) { testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon, NotUserNamespace, NotArm) // Run a container on the default bridge network @@ -96,7 +108,7 @@ func (s *DockerSuite) TestRestartDisconnectedContainer(c *testing.T) { assert.Assert(c, exitCode == 0, out) } -func (s *DockerSuite) TestRestartPolicyNO(c *testing.T) { +func (s *DockerCLIRestartSuite) TestRestartPolicyNO(c *testing.T) { out, _ := dockerCmd(c, "create", "--restart=no", "busybox") id := strings.TrimSpace(out) @@ -104,7 +116,7 @@ func (s *DockerSuite) TestRestartPolicyNO(c *testing.T) { assert.Equal(c, name, "no") } -func (s *DockerSuite) TestRestartPolicyAlways(c *testing.T) { +func (s *DockerCLIRestartSuite) TestRestartPolicyAlways(c *testing.T) { out, _ := dockerCmd(c, "create", "--restart=always", "busybox") id := strings.TrimSpace(out) @@ -117,7 +129,7 @@ func (s *DockerSuite) TestRestartPolicyAlways(c *testing.T) { assert.Equal(c, MaximumRetryCount, "0") } -func (s *DockerSuite) TestRestartPolicyOnFailure(c *testing.T) { +func (s *DockerCLIRestartSuite) TestRestartPolicyOnFailure(c *testing.T) { out, _, err := dockerCmdWithError("create", "--restart=on-failure:-1", "busybox") assert.ErrorContains(c, err, "", out) assert.Assert(c, strings.Contains(out, "maximum retry count cannot be negative")) @@ -152,7 +164,7 @@ func (s *DockerSuite) TestRestartPolicyOnFailure(c *testing.T) { // a good container with --restart=on-failure:3 // MaximumRetryCount!=0; RestartCount=0 -func (s *DockerSuite) TestRestartContainerwithGoodContainer(c *testing.T) { +func (s *DockerCLIRestartSuite) TestRestartContainerwithGoodContainer(c *testing.T) { out, _ := dockerCmd(c, "run", "-d", "--restart=on-failure:3", "busybox", "true") id := strings.TrimSpace(out) @@ -166,7 +178,7 @@ func (s *DockerSuite) TestRestartContainerwithGoodContainer(c *testing.T) { assert.Equal(c, MaximumRetryCount, "3") } -func (s *DockerSuite) TestRestartContainerSuccess(c *testing.T) { +func (s *DockerCLIRestartSuite) TestRestartContainerSuccess(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon) // Skipped for Hyper-V isolated containers. Test is currently written // such that it assumes there is a host process to kill. In Hyper-V @@ -199,7 +211,7 @@ func (s *DockerSuite) TestRestartContainerSuccess(c *testing.T) { assert.NilError(c, err) } -func (s *DockerSuite) TestRestartWithPolicyUserDefinedNetwork(c *testing.T) { +func (s *DockerCLIRestartSuite) TestRestartWithPolicyUserDefinedNetwork(c *testing.T) { // TODO Windows. This may be portable following HNS integration post TP5. testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon, NotUserNamespace, NotArm) dockerCmd(c, "network", "create", "-d", "bridge", "udNet") @@ -243,7 +255,7 @@ func (s *DockerSuite) TestRestartWithPolicyUserDefinedNetwork(c *testing.T) { assert.NilError(c, err) } -func (s *DockerSuite) TestRestartPolicyAfterRestart(c *testing.T) { +func (s *DockerCLIRestartSuite) TestRestartPolicyAfterRestart(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon) // Skipped for Hyper-V isolated containers. Test is currently written // such that it assumes there is a host process to kill. In Hyper-V @@ -280,7 +292,7 @@ func (s *DockerSuite) TestRestartPolicyAfterRestart(c *testing.T) { assert.NilError(c, err) } -func (s *DockerSuite) TestRestartContainerwithRestartPolicy(c *testing.T) { +func (s *DockerCLIRestartSuite) TestRestartContainerwithRestartPolicy(c *testing.T) { out1, _ := dockerCmd(c, "run", "-d", "--restart=on-failure:3", "busybox", "false") out2, _ := dockerCmd(c, "run", "-d", "--restart=always", "busybox", "false") @@ -311,7 +323,7 @@ func (s *DockerSuite) TestRestartContainerwithRestartPolicy(c *testing.T) { assert.NilError(c, err) } -func (s *DockerSuite) TestRestartAutoRemoveContainer(c *testing.T) { +func (s *DockerCLIRestartSuite) TestRestartAutoRemoveContainer(c *testing.T) { out := runSleepingContainer(c, "--rm") id := strings.TrimSpace(out) diff --git a/integration-cli/docker_cli_rmi_test.go b/integration-cli/docker_cli_rmi_test.go index f0bb557f95..a5bee932a7 100644 --- a/integration-cli/docker_cli_rmi_test.go +++ b/integration-cli/docker_cli_rmi_test.go @@ -13,7 +13,19 @@ import ( "gotest.tools/v3/icmd" ) -func (s *DockerSuite) TestRmiWithContainerFails(c *testing.T) { +type DockerCLIRmiSuite struct { + ds *DockerSuite +} + +func (s *DockerCLIRmiSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLIRmiSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + +func (s *DockerCLIRmiSuite) TestRmiWithContainerFails(c *testing.T) { errSubstr := "is using it" // create a container @@ -33,7 +45,7 @@ func (s *DockerSuite) TestRmiWithContainerFails(c *testing.T) { assert.Assert(c, strings.Contains(images, "busybox")) } -func (s *DockerSuite) TestRmiTag(c *testing.T) { +func (s *DockerCLIRmiSuite) TestRmiTag(c *testing.T) { imagesBefore, _ := dockerCmd(c, "images", "-a") dockerCmd(c, "tag", "busybox", "utest:tag1") dockerCmd(c, "tag", "busybox", "utest/docker:tag2") @@ -61,7 +73,7 @@ func (s *DockerSuite) TestRmiTag(c *testing.T) { } } -func (s *DockerSuite) TestRmiImgIDMultipleTag(c *testing.T) { +func (s *DockerCLIRmiSuite) TestRmiImgIDMultipleTag(c *testing.T) { out := cli.DockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir '/busybox-one'").Combined() containerID := strings.TrimSpace(out) @@ -102,7 +114,7 @@ func (s *DockerSuite) TestRmiImgIDMultipleTag(c *testing.T) { assert.Assert(c, !strings.Contains(imagesAfter, imgID[:12]), "ImageID:%q; ImagesAfter: %q", imgID, imagesAfter) } -func (s *DockerSuite) TestRmiImgIDForce(c *testing.T) { +func (s *DockerCLIRmiSuite) TestRmiImgIDForce(c *testing.T) { out := cli.DockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir '/busybox-test'").Combined() containerID := strings.TrimSpace(out) @@ -140,7 +152,7 @@ func (s *DockerSuite) TestRmiImgIDForce(c *testing.T) { } // See https://github.com/docker/docker/issues/14116 -func (s *DockerSuite) TestRmiImageIDForceWithRunningContainersAndMultipleTags(c *testing.T) { +func (s *DockerCLIRmiSuite) TestRmiImageIDForceWithRunningContainersAndMultipleTags(c *testing.T) { dockerfile := "FROM busybox\nRUN echo test 14116\n" buildImageSuccessfully(c, "test-14116", build.WithDockerfile(dockerfile)) imgID := getIDByName(c, "test-14116") @@ -155,7 +167,7 @@ func (s *DockerSuite) TestRmiImageIDForceWithRunningContainersAndMultipleTags(c assert.Assert(c, strings.Contains(out, "(cannot be forced) - image is being used by running container")) } -func (s *DockerSuite) TestRmiTagWithExistingContainers(c *testing.T) { +func (s *DockerCLIRmiSuite) TestRmiTagWithExistingContainers(c *testing.T) { container := "test-delete-tag" newtag := "busybox:newtag" bb := "busybox:latest" @@ -167,7 +179,7 @@ func (s *DockerSuite) TestRmiTagWithExistingContainers(c *testing.T) { assert.Equal(c, strings.Count(out, "Untagged: "), 1) } -func (s *DockerSuite) TestRmiForceWithExistingContainers(c *testing.T) { +func (s *DockerCLIRmiSuite) TestRmiForceWithExistingContainers(c *testing.T) { image := "busybox-clone" icmd.RunCmd(icmd.Cmd{ @@ -181,7 +193,7 @@ MAINTAINER foo`), dockerCmd(c, "rmi", "-f", image) } -func (s *DockerSuite) TestRmiWithMultipleRepositories(c *testing.T) { +func (s *DockerCLIRmiSuite) TestRmiWithMultipleRepositories(c *testing.T) { newRepo := "127.0.0.1:5000/busybox" oldRepo := "busybox" newTag := "busybox:test" @@ -195,7 +207,7 @@ func (s *DockerSuite) TestRmiWithMultipleRepositories(c *testing.T) { assert.Assert(c, strings.Contains(out, "Untagged: "+newTag)) } -func (s *DockerSuite) TestRmiForceWithMultipleRepositories(c *testing.T) { +func (s *DockerCLIRmiSuite) TestRmiForceWithMultipleRepositories(c *testing.T) { imageName := "rmiimage" tag1 := imageName + ":tag1" tag2 := imageName + ":tag2" @@ -212,7 +224,7 @@ func (s *DockerSuite) TestRmiForceWithMultipleRepositories(c *testing.T) { assert.Assert(c, strings.Contains(images, imageName), "Built image missing %q; Images: %q", imageName, images) } -func (s *DockerSuite) TestRmiBlank(c *testing.T) { +func (s *DockerCLIRmiSuite) TestRmiBlank(c *testing.T) { out, _, err := dockerCmdWithError("rmi", " ") // Should have failed to delete ' ' image assert.ErrorContains(c, err, "") @@ -222,7 +234,7 @@ func (s *DockerSuite) TestRmiBlank(c *testing.T) { assert.Assert(c, strings.Contains(out, "image name cannot be blank"), "out: %s", out) } -func (s *DockerSuite) TestRmiContainerImageNotFound(c *testing.T) { +func (s *DockerCLIRmiSuite) TestRmiContainerImageNotFound(c *testing.T) { // Build 2 images for testing. imageNames := []string{"test1", "test2"} imageIds := make([]string, 2) @@ -248,7 +260,7 @@ func (s *DockerSuite) TestRmiContainerImageNotFound(c *testing.T) { } // #13422 -func (s *DockerSuite) TestRmiUntagHistoryLayer(c *testing.T) { +func (s *DockerCLIRmiSuite) TestRmiUntagHistoryLayer(c *testing.T) { image := "tmp1" // Build an image for testing. dockerfile := `FROM busybox @@ -291,7 +303,7 @@ RUN echo 2 #layer2 assert.Assert(c, strings.Contains(out, fmt.Sprintf("Untagged: %s:latest", newTag))) } -func (*DockerSuite) TestRmiParentImageFail(c *testing.T) { +func (*DockerCLIRmiSuite) TestRmiParentImageFail(c *testing.T) { buildImageSuccessfully(c, "test", build.WithDockerfile(` FROM busybox RUN echo hello`)) @@ -304,7 +316,7 @@ func (*DockerSuite) TestRmiParentImageFail(c *testing.T) { } } -func (s *DockerSuite) TestRmiWithParentInUse(c *testing.T) { +func (s *DockerCLIRmiSuite) TestRmiWithParentInUse(c *testing.T) { out, _ := dockerCmd(c, "create", "busybox") cID := strings.TrimSpace(out) @@ -321,7 +333,7 @@ func (s *DockerSuite) TestRmiWithParentInUse(c *testing.T) { } // #18873 -func (s *DockerSuite) TestRmiByIDHardConflict(c *testing.T) { +func (s *DockerCLIRmiSuite) TestRmiByIDHardConflict(c *testing.T) { dockerCmd(c, "create", "busybox") imgID := inspectField(c, "busybox:latest", "Id") diff --git a/integration-cli/docker_cli_run_test.go b/integration-cli/docker_cli_run_test.go index ff7db05b3c..c0780a1579 100644 --- a/integration-cli/docker_cli_run_test.go +++ b/integration-cli/docker_cli_run_test.go @@ -38,8 +38,20 @@ import ( "gotest.tools/v3/skip" ) +type DockerCLIRunSuite struct { + ds *DockerSuite +} + +func (s *DockerCLIRunSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLIRunSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + // "test123" should be printed by docker run -func (s *DockerSuite) TestRunEchoStdout(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunEchoStdout(c *testing.T) { out, _ := dockerCmd(c, "run", "busybox", "echo", "test123") if out != "test123\n" { c.Fatalf("container should've printed 'test123', got '%s'", out) @@ -47,7 +59,7 @@ func (s *DockerSuite) TestRunEchoStdout(c *testing.T) { } // "test" should be printed -func (s *DockerSuite) TestRunEchoNamedContainer(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunEchoNamedContainer(c *testing.T) { out, _ := dockerCmd(c, "run", "--name", "testfoonamedcontainer", "busybox", "echo", "test") if out != "test\n" { c.Errorf("container should've printed 'test'") @@ -56,7 +68,7 @@ func (s *DockerSuite) TestRunEchoNamedContainer(c *testing.T) { // docker run should not leak file descriptors. This test relies on Unix // specific functionality and cannot run on Windows. -func (s *DockerSuite) TestRunLeakyFileDescriptors(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunLeakyFileDescriptors(c *testing.T) { testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "busybox", "ls", "-C", "/proc/self/fd") @@ -68,7 +80,7 @@ func (s *DockerSuite) TestRunLeakyFileDescriptors(c *testing.T) { // it should be possible to lookup Google DNS // this will fail when Internet access is unavailable -func (s *DockerSuite) TestRunLookupGoogleDNS(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunLookupGoogleDNS(c *testing.T) { testRequires(c, Network, NotArm) if testEnv.OSType == "windows" { // nslookup isn't present in Windows busybox. Is built-in. Further, @@ -81,19 +93,19 @@ func (s *DockerSuite) TestRunLookupGoogleDNS(c *testing.T) { } // the exit code should be 0 -func (s *DockerSuite) TestRunExitCodeZero(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunExitCodeZero(c *testing.T) { dockerCmd(c, "run", "busybox", "true") } // the exit code should be 1 -func (s *DockerSuite) TestRunExitCodeOne(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunExitCodeOne(c *testing.T) { _, exitCode, err := dockerCmdWithError("run", "busybox", "false") assert.ErrorContains(c, err, "") assert.Equal(c, exitCode, 1) } // it should be possible to pipe in data via stdin to a process running in a container -func (s *DockerSuite) TestRunStdinPipe(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunStdinPipe(c *testing.T) { // TODO Windows: This needs some work to make compatible. testRequires(c, DaemonIsLinux) result := icmd.RunCmd(icmd.Cmd{ @@ -117,7 +129,7 @@ func (s *DockerSuite) TestRunStdinPipe(c *testing.T) { } // the container's ID should be printed when starting a container in detached mode -func (s *DockerSuite) TestRunDetachedContainerIDPrinting(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunDetachedContainerIDPrinting(c *testing.T) { out, _ := dockerCmd(c, "run", "-d", "busybox", "true") out = strings.TrimSpace(out) @@ -132,7 +144,7 @@ func (s *DockerSuite) TestRunDetachedContainerIDPrinting(c *testing.T) { } // the working directory should be set correctly -func (s *DockerSuite) TestRunWorkingDirectory(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWorkingDirectory(c *testing.T) { dir := "/root" image := "busybox" if testEnv.OSType == "windows" { @@ -155,7 +167,7 @@ func (s *DockerSuite) TestRunWorkingDirectory(c *testing.T) { } // pinging Google's DNS resolver should fail when we disable the networking -func (s *DockerSuite) TestRunWithoutNetworking(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithoutNetworking(c *testing.T) { count := "-c" image := "busybox" if testEnv.OSType == "windows" { @@ -174,7 +186,7 @@ func (s *DockerSuite) TestRunWithoutNetworking(c *testing.T) { } // test --link use container name to link target -func (s *DockerSuite) TestRunLinksContainerWithContainerName(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunLinksContainerWithContainerName(c *testing.T) { // TODO Windows: This test cannot run on a Windows daemon as the networking // settings are not populated back yet on inspect. testRequires(c, DaemonIsLinux) @@ -189,7 +201,7 @@ func (s *DockerSuite) TestRunLinksContainerWithContainerName(c *testing.T) { } // test --link use container id to link target -func (s *DockerSuite) TestRunLinksContainerWithContainerID(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunLinksContainerWithContainerID(c *testing.T) { // TODO Windows: This test cannot run on a Windows daemon as the networking // settings are not populated back yet on inspect. testRequires(c, DaemonIsLinux) @@ -204,7 +216,7 @@ func (s *DockerSuite) TestRunLinksContainerWithContainerID(c *testing.T) { } } -func (s *DockerSuite) TestUserDefinedNetworkLinks(c *testing.T) { +func (s *DockerCLIRunSuite) TestUserDefinedNetworkLinks(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm) dockerCmd(c, "network", "create", "-d", "bridge", "udlinkNet") @@ -240,7 +252,7 @@ func (s *DockerSuite) TestUserDefinedNetworkLinks(c *testing.T) { assert.NilError(c, err) } -func (s *DockerSuite) TestUserDefinedNetworkLinksWithRestart(c *testing.T) { +func (s *DockerCLIRunSuite) TestUserDefinedNetworkLinksWithRestart(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm) dockerCmd(c, "network", "create", "-d", "bridge", "udlinkNet") @@ -278,7 +290,7 @@ func (s *DockerSuite) TestUserDefinedNetworkLinksWithRestart(c *testing.T) { assert.NilError(c, err) } -func (s *DockerSuite) TestRunWithNetAliasOnDefaultNetworks(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithNetAliasOnDefaultNetworks(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm) defaults := []string{"bridge", "host", "none"} @@ -289,7 +301,7 @@ func (s *DockerSuite) TestRunWithNetAliasOnDefaultNetworks(c *testing.T) { } } -func (s *DockerSuite) TestUserDefinedNetworkAlias(c *testing.T) { +func (s *DockerCLIRunSuite) TestUserDefinedNetworkAlias(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm) dockerCmd(c, "network", "create", "-d", "bridge", "net1") @@ -335,14 +347,14 @@ func (s *DockerSuite) TestUserDefinedNetworkAlias(c *testing.T) { } // Issue 9677. -func (s *DockerSuite) TestRunWithDaemonFlags(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithDaemonFlags(c *testing.T) { out, _, err := dockerCmdWithError("--exec-opt", "foo=bar", "run", "-i", "busybox", "true") assert.ErrorContains(c, err, "") assert.Assert(c, strings.Contains(out, "unknown flag: --exec-opt")) } // Regression test for #4979 -func (s *DockerSuite) TestRunWithVolumesFromExited(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithVolumesFromExited(c *testing.T) { var ( out string @@ -372,7 +384,7 @@ func (s *DockerSuite) TestRunWithVolumesFromExited(c *testing.T) { // Volume path is a symlink which also exists on the host, and the host side is a file not a dir // But the volume call is just a normal volume, not a bind mount -func (s *DockerSuite) TestRunCreateVolumesInSymlinkDir(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunCreateVolumesInSymlinkDir(c *testing.T) { var ( dockerFile string containerPath string @@ -416,7 +428,7 @@ func (s *DockerSuite) TestRunCreateVolumesInSymlinkDir(c *testing.T) { } // Volume path is a symlink in the container -func (s *DockerSuite) TestRunCreateVolumesInSymlinkDir2(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunCreateVolumesInSymlinkDir2(c *testing.T) { var ( dockerFile string containerPath string @@ -440,13 +452,13 @@ func (s *DockerSuite) TestRunCreateVolumesInSymlinkDir2(c *testing.T) { dockerCmd(c, "run", "-v", containerPath, name, cmd) } -func (s *DockerSuite) TestRunVolumesMountedAsReadonly(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunVolumesMountedAsReadonly(c *testing.T) { if _, code, err := dockerCmdWithError("run", "-v", "/test:/test:ro", "busybox", "touch", "/test/somefile"); err == nil || code == 0 { c.Fatalf("run should fail because volume is ro: exit code %d", code) } } -func (s *DockerSuite) TestRunVolumesFromInReadonlyModeFails(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunVolumesFromInReadonlyModeFails(c *testing.T) { var ( volumeDir string fileInVol string @@ -467,7 +479,7 @@ func (s *DockerSuite) TestRunVolumesFromInReadonlyModeFails(c *testing.T) { } // Regression test for #1201 -func (s *DockerSuite) TestRunVolumesFromInReadWriteMode(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunVolumesFromInReadWriteMode(c *testing.T) { var ( volumeDir string fileInVol string @@ -490,7 +502,7 @@ func (s *DockerSuite) TestRunVolumesFromInReadWriteMode(c *testing.T) { dockerCmd(c, "run", "--volumes-from", "parent", "busybox", "touch", fileInVol) } -func (s *DockerSuite) TestVolumesFromGetsProperMode(c *testing.T) { +func (s *DockerCLIRunSuite) TestVolumesFromGetsProperMode(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon) prefix, slash := getPrefixAndSlashFromDaemonPlatform() hostpath := RandomTmpDirPath("test", testEnv.OSType) @@ -515,7 +527,7 @@ func (s *DockerSuite) TestVolumesFromGetsProperMode(c *testing.T) { } // Test for GH#10618 -func (s *DockerSuite) TestRunNoDupVolumes(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunNoDupVolumes(c *testing.T) { path1 := RandomTmpDirPath("test1", testEnv.OSType) path2 := RandomTmpDirPath("test2", testEnv.OSType) @@ -567,7 +579,7 @@ func (s *DockerSuite) TestRunNoDupVolumes(c *testing.T) { } // Test for #1351 -func (s *DockerSuite) TestRunApplyVolumesFromBeforeVolumes(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunApplyVolumesFromBeforeVolumes(c *testing.T) { prefix := "" if testEnv.OSType == "windows" { prefix = `c:` @@ -576,7 +588,7 @@ func (s *DockerSuite) TestRunApplyVolumesFromBeforeVolumes(c *testing.T) { dockerCmd(c, "run", "--volumes-from", "parent", "-v", prefix+"/test", "busybox", "cat", prefix+"/test/foo") } -func (s *DockerSuite) TestRunMultipleVolumesFrom(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunMultipleVolumesFrom(c *testing.T) { prefix := "" if testEnv.OSType == "windows" { prefix = `c:` @@ -587,7 +599,7 @@ func (s *DockerSuite) TestRunMultipleVolumesFrom(c *testing.T) { } // this tests verifies the ID format for the container -func (s *DockerSuite) TestRunVerifyContainerID(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunVerifyContainerID(c *testing.T) { out, exit, err := dockerCmdWithError("run", "-d", "busybox", "true") if err != nil { c.Fatal(err) @@ -606,7 +618,7 @@ func (s *DockerSuite) TestRunVerifyContainerID(c *testing.T) { } // Test that creating a container with a volume doesn't crash. Regression test for #995. -func (s *DockerSuite) TestRunCreateVolume(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunCreateVolume(c *testing.T) { prefix := "" if testEnv.OSType == "windows" { prefix = `c:` @@ -616,7 +628,7 @@ func (s *DockerSuite) TestRunCreateVolume(c *testing.T) { // Test that creating a volume with a symlink in its path works correctly. Test for #5152. // Note that this bug happens only with symlinks with a target that starts with '/'. -func (s *DockerSuite) TestRunCreateVolumeWithSymlink(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunCreateVolumeWithSymlink(c *testing.T) { // Cannot run on Windows as relies on Linux-specific functionality (sh -c mount...) testRequires(c, DaemonIsLinux) workingDirectory, err := os.MkdirTemp("", "TestRunCreateVolumeWithSymlink") @@ -652,7 +664,7 @@ func (s *DockerSuite) TestRunCreateVolumeWithSymlink(c *testing.T) { } // Tests that a volume path that has a symlink exists in a container mounting it with `--volumes-from`. -func (s *DockerSuite) TestRunVolumesFromSymlinkPath(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunVolumesFromSymlinkPath(c *testing.T) { // This test cannot run on a Windows daemon as // Windows does not support symlinks inside a volume path testRequires(c, DaemonIsLinux) @@ -693,7 +705,7 @@ func (s *DockerSuite) TestRunVolumesFromSymlinkPath(c *testing.T) { } } -func (s *DockerSuite) TestRunExitCode(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunExitCode(c *testing.T) { var ( exit int err error @@ -709,7 +721,7 @@ func (s *DockerSuite) TestRunExitCode(c *testing.T) { } } -func (s *DockerSuite) TestRunUserDefaults(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunUserDefaults(c *testing.T) { expected := "uid=0(root) gid=0(root)" if testEnv.OSType == "windows" { expected = "uid=0(root) gid=0(root) groups=0(root)" @@ -720,7 +732,7 @@ func (s *DockerSuite) TestRunUserDefaults(c *testing.T) { } } -func (s *DockerSuite) TestRunUserByName(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunUserByName(c *testing.T) { // TODO Windows: This test cannot run on a Windows daemon as Windows does // not support the use of -u testRequires(c, DaemonIsLinux) @@ -730,7 +742,7 @@ func (s *DockerSuite) TestRunUserByName(c *testing.T) { } } -func (s *DockerSuite) TestRunUserByID(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunUserByID(c *testing.T) { // TODO Windows: This test cannot run on a Windows daemon as Windows does // not support the use of -u testRequires(c, DaemonIsLinux) @@ -740,7 +752,7 @@ func (s *DockerSuite) TestRunUserByID(c *testing.T) { } } -func (s *DockerSuite) TestRunUserByIDBig(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunUserByIDBig(c *testing.T) { // TODO Windows: This test cannot run on a Windows daemon as Windows does // not support the use of -u testRequires(c, DaemonIsLinux, NotArm) @@ -753,7 +765,7 @@ func (s *DockerSuite) TestRunUserByIDBig(c *testing.T) { } } -func (s *DockerSuite) TestRunUserByIDNegative(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunUserByIDNegative(c *testing.T) { // TODO Windows: This test cannot run on a Windows daemon as Windows does // not support the use of -u testRequires(c, DaemonIsLinux) @@ -766,7 +778,7 @@ func (s *DockerSuite) TestRunUserByIDNegative(c *testing.T) { } } -func (s *DockerSuite) TestRunUserByIDZero(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunUserByIDZero(c *testing.T) { // TODO Windows: This test cannot run on a Windows daemon as Windows does // not support the use of -u testRequires(c, DaemonIsLinux) @@ -779,7 +791,7 @@ func (s *DockerSuite) TestRunUserByIDZero(c *testing.T) { } } -func (s *DockerSuite) TestRunUserNotFound(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunUserNotFound(c *testing.T) { // TODO Windows: This test cannot run on a Windows daemon as Windows does // not support the use of -u testRequires(c, DaemonIsLinux) @@ -789,7 +801,7 @@ func (s *DockerSuite) TestRunUserNotFound(c *testing.T) { } } -func (s *DockerSuite) TestRunTwoConcurrentContainers(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunTwoConcurrentContainers(c *testing.T) { sleepTime := "2" group := sync.WaitGroup{} group.Add(2) @@ -811,7 +823,7 @@ func (s *DockerSuite) TestRunTwoConcurrentContainers(c *testing.T) { } } -func (s *DockerSuite) TestRunEnvironment(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunEnvironment(c *testing.T) { // TODO Windows: Environment handling is different between Linux and // Windows and this test relies currently on unix functionality. testRequires(c, DaemonIsLinux) @@ -850,7 +862,7 @@ func (s *DockerSuite) TestRunEnvironment(c *testing.T) { } } -func (s *DockerSuite) TestRunEnvironmentErase(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunEnvironmentErase(c *testing.T) { // TODO Windows: Environment handling is different between Linux and // Windows and this test relies currently on unix functionality. testRequires(c, DaemonIsLinux) @@ -883,7 +895,7 @@ func (s *DockerSuite) TestRunEnvironmentErase(c *testing.T) { } } -func (s *DockerSuite) TestRunEnvironmentOverride(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunEnvironmentOverride(c *testing.T) { // TODO Windows: Environment handling is different between Linux and // Windows and this test relies currently on unix functionality. testRequires(c, DaemonIsLinux) @@ -916,7 +928,7 @@ func (s *DockerSuite) TestRunEnvironmentOverride(c *testing.T) { } } -func (s *DockerSuite) TestRunContainerNetwork(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunContainerNetwork(c *testing.T) { if testEnv.OSType == "windows" { // Windows busybox does not have ping. Use built in ping instead. dockerCmd(c, "run", testEnv.PlatformDefaults.BaseImage, "ping", "-n", "1", "127.0.0.1") @@ -925,7 +937,7 @@ func (s *DockerSuite) TestRunContainerNetwork(c *testing.T) { } } -func (s *DockerSuite) TestRunNetHostNotAllowedWithLinks(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunNetHostNotAllowedWithLinks(c *testing.T) { // TODO Windows: This is Linux specific as --link is not supported and // this will be deprecated in favor of container networking model. testRequires(c, DaemonIsLinux, NotUserNamespace) @@ -942,7 +954,7 @@ func (s *DockerSuite) TestRunNetHostNotAllowedWithLinks(c *testing.T) { // and use "--net=host" (as the original issue submitter did), as the same // codepath is executed with "docker run -h ". Both were manually // tested, but this testcase takes the simpler path of using "run -h .." -func (s *DockerSuite) TestRunFullHostnameSet(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunFullHostnameSet(c *testing.T) { // TODO Windows: -h is not yet functional. testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "-h", "foo.bar.baz", "busybox", "hostname") @@ -951,7 +963,7 @@ func (s *DockerSuite) TestRunFullHostnameSet(c *testing.T) { } } -func (s *DockerSuite) TestRunPrivilegedCanMknod(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunPrivilegedCanMknod(c *testing.T) { // Not applicable for Windows as Windows daemon does not support // the concept of --privileged, and mknod is a Unix concept. testRequires(c, DaemonIsLinux, NotUserNamespace) @@ -961,7 +973,7 @@ func (s *DockerSuite) TestRunPrivilegedCanMknod(c *testing.T) { } } -func (s *DockerSuite) TestRunUnprivilegedCanMknod(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunUnprivilegedCanMknod(c *testing.T) { // Not applicable for Windows as Windows daemon does not support // the concept of --privileged, and mknod is a Unix concept. testRequires(c, DaemonIsLinux, NotUserNamespace) @@ -971,7 +983,7 @@ func (s *DockerSuite) TestRunUnprivilegedCanMknod(c *testing.T) { } } -func (s *DockerSuite) TestRunCapDropInvalid(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunCapDropInvalid(c *testing.T) { // Not applicable for Windows as there is no concept of --cap-drop testRequires(c, DaemonIsLinux) out, _, err := dockerCmdWithError("run", "--cap-drop=CHPASS", "busybox", "ls") @@ -980,7 +992,7 @@ func (s *DockerSuite) TestRunCapDropInvalid(c *testing.T) { } } -func (s *DockerSuite) TestRunCapDropCannotMknod(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunCapDropCannotMknod(c *testing.T) { // Not applicable for Windows as there is no concept of --cap-drop or mknod testRequires(c, DaemonIsLinux) out, _, err := dockerCmdWithError("run", "--cap-drop=MKNOD", "busybox", "sh", "-c", "mknod /tmp/sda b 8 0 && echo ok") @@ -993,7 +1005,7 @@ func (s *DockerSuite) TestRunCapDropCannotMknod(c *testing.T) { } } -func (s *DockerSuite) TestRunCapDropCannotMknodLowerCase(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunCapDropCannotMknodLowerCase(c *testing.T) { // Not applicable for Windows as there is no concept of --cap-drop or mknod testRequires(c, DaemonIsLinux) out, _, err := dockerCmdWithError("run", "--cap-drop=mknod", "busybox", "sh", "-c", "mknod /tmp/sda b 8 0 && echo ok") @@ -1006,7 +1018,7 @@ func (s *DockerSuite) TestRunCapDropCannotMknodLowerCase(c *testing.T) { } } -func (s *DockerSuite) TestRunCapDropALLCannotMknod(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunCapDropALLCannotMknod(c *testing.T) { // Not applicable for Windows as there is no concept of --cap-drop or mknod testRequires(c, DaemonIsLinux) out, _, err := dockerCmdWithError("run", "--cap-drop=ALL", "--cap-add=SETGID", "busybox", "sh", "-c", "mknod /tmp/sda b 8 0 && echo ok") @@ -1018,7 +1030,7 @@ func (s *DockerSuite) TestRunCapDropALLCannotMknod(c *testing.T) { } } -func (s *DockerSuite) TestRunCapDropALLAddMknodCanMknod(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunCapDropALLAddMknodCanMknod(c *testing.T) { // Not applicable for Windows as there is no concept of --cap-drop or mknod testRequires(c, DaemonIsLinux, NotUserNamespace) out, _ := dockerCmd(c, "run", "--cap-drop=ALL", "--cap-add=MKNOD", "--cap-add=SETGID", "busybox", "sh", "-c", "mknod /tmp/sda b 8 0 && echo ok") @@ -1028,7 +1040,7 @@ func (s *DockerSuite) TestRunCapDropALLAddMknodCanMknod(c *testing.T) { } } -func (s *DockerSuite) TestRunCapAddInvalid(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunCapAddInvalid(c *testing.T) { // Not applicable for Windows as there is no concept of --cap-add testRequires(c, DaemonIsLinux) out, _, err := dockerCmdWithError("run", "--cap-add=CHPASS", "busybox", "ls") @@ -1037,7 +1049,7 @@ func (s *DockerSuite) TestRunCapAddInvalid(c *testing.T) { } } -func (s *DockerSuite) TestRunCapAddCanDownInterface(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunCapAddCanDownInterface(c *testing.T) { // Not applicable for Windows as there is no concept of --cap-add testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "--cap-add=NET_ADMIN", "busybox", "sh", "-c", "ip link set eth0 down && echo ok") @@ -1047,7 +1059,7 @@ func (s *DockerSuite) TestRunCapAddCanDownInterface(c *testing.T) { } } -func (s *DockerSuite) TestRunCapAddALLCanDownInterface(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunCapAddALLCanDownInterface(c *testing.T) { // Not applicable for Windows as there is no concept of --cap-add testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "--cap-add=ALL", "busybox", "sh", "-c", "ip link set eth0 down && echo ok") @@ -1057,7 +1069,7 @@ func (s *DockerSuite) TestRunCapAddALLCanDownInterface(c *testing.T) { } } -func (s *DockerSuite) TestRunCapAddALLDropNetAdminCanDownInterface(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunCapAddALLDropNetAdminCanDownInterface(c *testing.T) { // Not applicable for Windows as there is no concept of --cap-add testRequires(c, DaemonIsLinux) out, _, err := dockerCmdWithError("run", "--cap-add=ALL", "--cap-drop=NET_ADMIN", "busybox", "sh", "-c", "ip link set eth0 down && echo ok") @@ -1069,7 +1081,7 @@ func (s *DockerSuite) TestRunCapAddALLDropNetAdminCanDownInterface(c *testing.T) } } -func (s *DockerSuite) TestRunGroupAdd(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunGroupAdd(c *testing.T) { // Not applicable for Windows as there is no concept of --group-add testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "--group-add=audio", "--group-add=staff", "--group-add=777", "busybox", "sh", "-c", "id") @@ -1080,7 +1092,7 @@ func (s *DockerSuite) TestRunGroupAdd(c *testing.T) { } } -func (s *DockerSuite) TestRunPrivilegedCanMount(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunPrivilegedCanMount(c *testing.T) { // Not applicable for Windows as there is no concept of --privileged testRequires(c, DaemonIsLinux, NotUserNamespace) out, _ := dockerCmd(c, "run", "--privileged", "busybox", "sh", "-c", "mount -t tmpfs none /tmp && echo ok") @@ -1090,7 +1102,7 @@ func (s *DockerSuite) TestRunPrivilegedCanMount(c *testing.T) { } } -func (s *DockerSuite) TestRunUnprivilegedCannotMount(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunUnprivilegedCannotMount(c *testing.T) { // Not applicable for Windows as there is no concept of unprivileged testRequires(c, DaemonIsLinux) out, _, err := dockerCmdWithError("run", "busybox", "sh", "-c", "mount -t tmpfs none /tmp && echo ok") @@ -1103,7 +1115,7 @@ func (s *DockerSuite) TestRunUnprivilegedCannotMount(c *testing.T) { } } -func (s *DockerSuite) TestRunSysNotWritableInNonPrivilegedContainers(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunSysNotWritableInNonPrivilegedContainers(c *testing.T) { // Not applicable for Windows as there is no concept of unprivileged testRequires(c, DaemonIsLinux, NotArm) if _, code, err := dockerCmdWithError("run", "busybox", "touch", "/sys/kernel/profiling"); err == nil || code == 0 { @@ -1111,7 +1123,7 @@ func (s *DockerSuite) TestRunSysNotWritableInNonPrivilegedContainers(c *testing. } } -func (s *DockerSuite) TestRunSysWritableInPrivilegedContainers(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunSysWritableInPrivilegedContainers(c *testing.T) { // Not applicable for Windows as there is no concept of unprivileged testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm) if _, code, err := dockerCmdWithError("run", "--privileged", "busybox", "touch", "/sys/kernel/profiling"); err != nil || code != 0 { @@ -1119,7 +1131,7 @@ func (s *DockerSuite) TestRunSysWritableInPrivilegedContainers(c *testing.T) { } } -func (s *DockerSuite) TestRunProcNotWritableInNonPrivilegedContainers(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunProcNotWritableInNonPrivilegedContainers(c *testing.T) { // Not applicable for Windows as there is no concept of unprivileged testRequires(c, DaemonIsLinux) if _, code, err := dockerCmdWithError("run", "busybox", "touch", "/proc/sysrq-trigger"); err == nil || code == 0 { @@ -1127,7 +1139,7 @@ func (s *DockerSuite) TestRunProcNotWritableInNonPrivilegedContainers(c *testing } } -func (s *DockerSuite) TestRunProcWritableInPrivilegedContainers(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunProcWritableInPrivilegedContainers(c *testing.T) { // Not applicable for Windows as there is no concept of --privileged testRequires(c, DaemonIsLinux, NotUserNamespace) if _, code := dockerCmd(c, "run", "--privileged", "busybox", "sh", "-c", "touch /proc/sysrq-trigger"); code != 0 { @@ -1135,7 +1147,7 @@ func (s *DockerSuite) TestRunProcWritableInPrivilegedContainers(c *testing.T) { } } -func (s *DockerSuite) TestRunDeviceNumbers(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunDeviceNumbers(c *testing.T) { // Not applicable on Windows as /dev/ is a Unix specific concept // TODO: NotUserNamespace could be removed here if "root" "root" is replaced w user testRequires(c, DaemonIsLinux, NotUserNamespace) @@ -1151,7 +1163,7 @@ func (s *DockerSuite) TestRunDeviceNumbers(c *testing.T) { } } -func (s *DockerSuite) TestRunThatCharacterDevicesActLikeCharacterDevices(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunThatCharacterDevicesActLikeCharacterDevices(c *testing.T) { // Not applicable on Windows as /dev/ is a Unix specific concept testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "busybox", "sh", "-c", "dd if=/dev/zero of=/zero bs=1k count=5 2> /dev/null ; du -h /zero") @@ -1160,13 +1172,13 @@ func (s *DockerSuite) TestRunThatCharacterDevicesActLikeCharacterDevices(c *test } } -func (s *DockerSuite) TestRunUnprivilegedWithChroot(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunUnprivilegedWithChroot(c *testing.T) { // Not applicable on Windows as it does not support chroot testRequires(c, DaemonIsLinux) dockerCmd(c, "run", "busybox", "chroot", "/", "true") } -func (s *DockerSuite) TestRunAddingOptionalDevices(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunAddingOptionalDevices(c *testing.T) { // Not applicable on Windows as Windows does not support --device testRequires(c, DaemonIsLinux, NotUserNamespace) out, _ := dockerCmd(c, "run", "--device", "/dev/zero:/dev/nulo", "busybox", "sh", "-c", "ls /dev/nulo") @@ -1175,7 +1187,7 @@ func (s *DockerSuite) TestRunAddingOptionalDevices(c *testing.T) { } } -func (s *DockerSuite) TestRunAddingOptionalDevicesNoSrc(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunAddingOptionalDevicesNoSrc(c *testing.T) { // Not applicable on Windows as Windows does not support --device testRequires(c, DaemonIsLinux, NotUserNamespace) out, _ := dockerCmd(c, "run", "--device", "/dev/zero:rw", "busybox", "sh", "-c", "ls /dev/zero") @@ -1184,7 +1196,7 @@ func (s *DockerSuite) TestRunAddingOptionalDevicesNoSrc(c *testing.T) { } } -func (s *DockerSuite) TestRunAddingOptionalDevicesInvalidMode(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunAddingOptionalDevicesInvalidMode(c *testing.T) { // Not applicable on Windows as Windows does not support --device testRequires(c, DaemonIsLinux, NotUserNamespace) _, _, err := dockerCmdWithError("run", "--device", "/dev/zero:ro", "busybox", "sh", "-c", "ls /dev/zero") @@ -1193,7 +1205,7 @@ func (s *DockerSuite) TestRunAddingOptionalDevicesInvalidMode(c *testing.T) { } } -func (s *DockerSuite) TestRunModeHostname(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunModeHostname(c *testing.T) { // Not applicable on Windows as Windows does not support -h testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux, NotUserNamespace) @@ -1214,18 +1226,18 @@ func (s *DockerSuite) TestRunModeHostname(c *testing.T) { } } -func (s *DockerSuite) TestRunRootWorkdir(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunRootWorkdir(c *testing.T) { out, _ := dockerCmd(c, "run", "--workdir", "/", "busybox", "pwd") expected := "/\n" if testEnv.OSType == "windows" { expected = "C:" + expected } if out != expected { - c.Fatalf("pwd returned %q (expected %s)", s, expected) + c.Fatalf("pwd returned %q (expected %s)", out, expected) } } -func (s *DockerSuite) TestRunAllowBindMountingRoot(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunAllowBindMountingRoot(c *testing.T) { if testEnv.OSType == "windows" { // Windows busybox will fail with Permission Denied on items such as pagefile.sys dockerCmd(c, "run", "-v", `c:\:c:\host`, testEnv.PlatformDefaults.BaseImage, "cmd", "-c", "dir", `c:\host`) @@ -1234,7 +1246,7 @@ func (s *DockerSuite) TestRunAllowBindMountingRoot(c *testing.T) { } } -func (s *DockerSuite) TestRunDisallowBindMountingRootToRoot(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunDisallowBindMountingRootToRoot(c *testing.T) { mount := "/:/" targetDir := "/host" if testEnv.OSType == "windows" { @@ -1248,7 +1260,7 @@ func (s *DockerSuite) TestRunDisallowBindMountingRootToRoot(c *testing.T) { } // Verify that a container gets default DNS when only localhost resolvers exist -func (s *DockerSuite) TestRunDNSDefaultOptions(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunDNSDefaultOptions(c *testing.T) { // Not applicable on Windows as this is testing Unix specific functionality testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) @@ -1282,7 +1294,7 @@ func (s *DockerSuite) TestRunDNSDefaultOptions(c *testing.T) { } } -func (s *DockerSuite) TestRunDNSOptions(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunDNSOptions(c *testing.T) { // Not applicable on Windows as Windows does not support --dns*, or // the Unix-specific functionality of resolv.conf. testRequires(c, DaemonIsLinux) @@ -1306,7 +1318,7 @@ func (s *DockerSuite) TestRunDNSOptions(c *testing.T) { } } -func (s *DockerSuite) TestRunDNSRepeatOptions(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunDNSRepeatOptions(c *testing.T) { testRequires(c, DaemonIsLinux) out := cli.DockerCmd(c, "run", "--dns=1.1.1.1", "--dns=2.2.2.2", "--dns-search=mydomain", "--dns-search=mydomain2", "--dns-opt=ndots:9", "--dns-opt=timeout:3", "busybox", "cat", "/etc/resolv.conf").Stdout() @@ -1316,7 +1328,7 @@ func (s *DockerSuite) TestRunDNSRepeatOptions(c *testing.T) { } } -func (s *DockerSuite) TestRunDNSOptionsBasedOnHostResolvConf(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunDNSOptionsBasedOnHostResolvConf(c *testing.T) { // Not applicable on Windows as testing Unix specific functionality testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) @@ -1398,7 +1410,7 @@ func (s *DockerSuite) TestRunDNSOptionsBasedOnHostResolvConf(c *testing.T) { // Test to see if a non-root user can resolve a DNS name. Also // check if the container resolv.conf file has at least 0644 perm. -func (s *DockerSuite) TestRunNonRootUserResolvName(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunNonRootUserResolvName(c *testing.T) { // Not applicable on Windows as Windows does not support --user testRequires(c, testEnv.IsLocalDaemon, Network, DaemonIsLinux, NotArm) @@ -1420,7 +1432,7 @@ func (s *DockerSuite) TestRunNonRootUserResolvName(c *testing.T) { // Test if container resolv.conf gets updated the next time it restarts // if host /etc/resolv.conf has changed. This only applies if the container // uses the host's /etc/resolv.conf and does not have any dns options provided. -func (s *DockerSuite) TestRunResolvconfUpdate(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunResolvconfUpdate(c *testing.T) { // Not applicable on Windows as testing unix specific functionality testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) c.Skip("Unstable test, to be re-activated once #19937 is resolved") @@ -1571,7 +1583,7 @@ func (s *DockerSuite) TestRunResolvconfUpdate(c *testing.T) { // cleanup, restore original resolv.conf happens in defer func() } -func (s *DockerSuite) TestRunAddHost(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunAddHost(c *testing.T) { // Not applicable on Windows as it does not support --add-host testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "--add-host=extra:86.75.30.9", "busybox", "grep", "extra", "/etc/hosts") @@ -1583,7 +1595,7 @@ func (s *DockerSuite) TestRunAddHost(c *testing.T) { } // Regression test for #6983 -func (s *DockerSuite) TestRunAttachStdErrOnlyTTYMode(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunAttachStdErrOnlyTTYMode(c *testing.T) { _, exitCode := dockerCmd(c, "run", "-t", "-a", "stderr", "busybox", "true") if exitCode != 0 { c.Fatalf("Container should have exited with error code 0") @@ -1591,7 +1603,7 @@ func (s *DockerSuite) TestRunAttachStdErrOnlyTTYMode(c *testing.T) { } // Regression test for #6983 -func (s *DockerSuite) TestRunAttachStdOutOnlyTTYMode(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunAttachStdOutOnlyTTYMode(c *testing.T) { _, exitCode := dockerCmd(c, "run", "-t", "-a", "stdout", "busybox", "true") if exitCode != 0 { c.Fatalf("Container should have exited with error code 0") @@ -1599,7 +1611,7 @@ func (s *DockerSuite) TestRunAttachStdOutOnlyTTYMode(c *testing.T) { } // Regression test for #6983 -func (s *DockerSuite) TestRunAttachStdOutAndErrTTYMode(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunAttachStdOutAndErrTTYMode(c *testing.T) { _, exitCode := dockerCmd(c, "run", "-t", "-a", "stdout", "-a", "stderr", "busybox", "true") if exitCode != 0 { c.Fatalf("Container should have exited with error code 0") @@ -1608,7 +1620,7 @@ func (s *DockerSuite) TestRunAttachStdOutAndErrTTYMode(c *testing.T) { // Test for #10388 - this will run the same test as TestRunAttachStdOutAndErrTTYMode // but using --attach instead of -a to make sure we read the flag correctly -func (s *DockerSuite) TestRunAttachWithDetach(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunAttachWithDetach(c *testing.T) { icmd.RunCommand(dockerBinary, "run", "-d", "--attach", "stdout", "busybox", "true").Assert(c, icmd.Expected{ ExitCode: 1, Error: "exit status 1", @@ -1616,7 +1628,7 @@ func (s *DockerSuite) TestRunAttachWithDetach(c *testing.T) { }) } -func (s *DockerSuite) TestRunState(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunState(c *testing.T) { // TODO Windows: This needs some rework as Windows busybox does not support top testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "-d", "busybox", "top") @@ -1653,7 +1665,7 @@ func (s *DockerSuite) TestRunState(c *testing.T) { } // Test for #1737 -func (s *DockerSuite) TestRunCopyVolumeUIDGID(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunCopyVolumeUIDGID(c *testing.T) { // Not applicable on Windows as it does not support uid or gid in this way testRequires(c, DaemonIsLinux) name := "testrunvolumesuidgid" @@ -1671,7 +1683,7 @@ func (s *DockerSuite) TestRunCopyVolumeUIDGID(c *testing.T) { } // Test for #1582 -func (s *DockerSuite) TestRunCopyVolumeContent(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunCopyVolumeContent(c *testing.T) { // TODO Windows, post RS1. Windows does not yet support volume functionality // that copies from the image to the volume. testRequires(c, DaemonIsLinux) @@ -1686,7 +1698,7 @@ func (s *DockerSuite) TestRunCopyVolumeContent(c *testing.T) { } } -func (s *DockerSuite) TestRunCleanupCmdOnEntrypoint(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunCleanupCmdOnEntrypoint(c *testing.T) { name := "testrunmdcleanuponentrypoint" buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox ENTRYPOINT ["echo"] @@ -1711,7 +1723,7 @@ func (s *DockerSuite) TestRunCleanupCmdOnEntrypoint(c *testing.T) { } // TestRunWorkdirExistsAndIsFile checks that if 'docker run -w' with existing file can be detected -func (s *DockerSuite) TestRunWorkdirExistsAndIsFile(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWorkdirExistsAndIsFile(c *testing.T) { existingFile := "/bin/cat" expected := "not a directory" if testEnv.OSType == "windows" { @@ -1725,7 +1737,7 @@ func (s *DockerSuite) TestRunWorkdirExistsAndIsFile(c *testing.T) { } } -func (s *DockerSuite) TestRunExitOnStdinClose(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunExitOnStdinClose(c *testing.T) { name := "testrunexitonstdinclose" meow := "/bin/cat" @@ -1782,7 +1794,7 @@ func (s *DockerSuite) TestRunExitOnStdinClose(c *testing.T) { } // Test run -i --restart xxx doesn't hang -func (s *DockerSuite) TestRunInteractiveWithRestartPolicy(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunInteractiveWithRestartPolicy(c *testing.T) { name := "test-inter-restart" result := icmd.RunCmd(icmd.Cmd{ @@ -1797,7 +1809,7 @@ func (s *DockerSuite) TestRunInteractiveWithRestartPolicy(c *testing.T) { } // Test for #2267 -func (s *DockerSuite) TestRunWriteSpecialFilesAndNotCommit(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWriteSpecialFilesAndNotCommit(c *testing.T) { // Cannot run on Windows as this files are not present in Windows testRequires(c, DaemonIsLinux) @@ -1845,7 +1857,7 @@ func sliceEq(a, b []string) bool { return true } -func (s *DockerSuite) TestRunWithBadDevice(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithBadDevice(c *testing.T) { // Cannot run on Windows as Windows does not support --device testRequires(c, DaemonIsLinux) name := "baddevice" @@ -1860,7 +1872,7 @@ func (s *DockerSuite) TestRunWithBadDevice(c *testing.T) { } } -func (s *DockerSuite) TestRunEntrypoint(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunEntrypoint(c *testing.T) { name := "entrypoint" out, _ := dockerCmd(c, "run", "--name", name, "--entrypoint", "echo", "busybox", "-n", "foobar") @@ -1871,7 +1883,7 @@ func (s *DockerSuite) TestRunEntrypoint(c *testing.T) { } } -func (s *DockerSuite) TestRunBindMounts(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunBindMounts(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon) if testEnv.OSType == "linux" { testRequires(c, DaemonIsLinux, NotUserNamespace) @@ -1922,7 +1934,7 @@ func (s *DockerSuite) TestRunBindMounts(c *testing.T) { // Ensure that CIDFile gets deleted if it's empty // Perform this test by making `docker run` fail -func (s *DockerSuite) TestRunCidFileCleanupIfEmpty(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunCidFileCleanupIfEmpty(c *testing.T) { // Skip on Windows. Base image on Windows has a CMD set in the image. testRequires(c, DaemonIsLinux) @@ -1953,7 +1965,7 @@ func (s *DockerSuite) TestRunCidFileCleanupIfEmpty(c *testing.T) { // #2098 - Docker cidFiles only contain short version of the containerId // sudo docker run --cidfile /tmp/docker_tesc.cid ubuntu echo "test" // TestRunCidFile tests that run --cidfile returns the longid -func (s *DockerSuite) TestRunCidFileCheckIDLength(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunCidFileCheckIDLength(c *testing.T) { tmpDir, err := os.MkdirTemp("", "TestRunCidFile") if err != nil { c.Fatal(err) @@ -1977,7 +1989,7 @@ func (s *DockerSuite) TestRunCidFileCheckIDLength(c *testing.T) { } } -func (s *DockerSuite) TestRunSetMacAddress(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunSetMacAddress(c *testing.T) { skip.If(c, RuntimeIsWindowsContainerd(), "FIXME: Broken on Windows + containerd combination") mac := "12:34:56:78:9a:bc" var out string @@ -1994,7 +2006,7 @@ func (s *DockerSuite) TestRunSetMacAddress(c *testing.T) { } } -func (s *DockerSuite) TestRunInspectMacAddress(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunInspectMacAddress(c *testing.T) { // TODO Windows. Network settings are not propagated back to inspect. testRequires(c, DaemonIsLinux) mac := "12:34:56:78:9a:bc" @@ -2008,7 +2020,7 @@ func (s *DockerSuite) TestRunInspectMacAddress(c *testing.T) { } // test docker run use an invalid mac address -func (s *DockerSuite) TestRunWithInvalidMacAddress(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithInvalidMacAddress(c *testing.T) { out, _, err := dockerCmdWithError("run", "--mac-address", "92:d0:c6:0a:29", "busybox") // use an invalid mac address should with an error out if err == nil || !strings.Contains(out, "is not a valid mac address") { @@ -2016,7 +2028,7 @@ func (s *DockerSuite) TestRunWithInvalidMacAddress(c *testing.T) { } } -func (s *DockerSuite) TestRunDeallocatePortOnMissingIptablesRule(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunDeallocatePortOnMissingIptablesRule(c *testing.T) { // TODO Windows. Network settings are not propagated back to inspect. testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) @@ -2032,7 +2044,7 @@ func (s *DockerSuite) TestRunDeallocatePortOnMissingIptablesRule(c *testing.T) { cli.DockerCmd(c, "run", "-d", "-p", "23:23", "busybox", "top") } -func (s *DockerSuite) TestRunPortInUse(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunPortInUse(c *testing.T) { // TODO Windows. The duplicate NAT message returned by Windows will be // changing as is currently completely undecipherable. Does need modifying // to run sh rather than top though as top isn't in Windows busybox. @@ -2051,7 +2063,7 @@ func (s *DockerSuite) TestRunPortInUse(c *testing.T) { } // https://github.com/docker/docker/issues/12148 -func (s *DockerSuite) TestRunAllocatePortInReservedRange(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunAllocatePortInReservedRange(c *testing.T) { // TODO Windows. -P is not yet supported testRequires(c, DaemonIsLinux) // allocate a dynamic port to get the most recent @@ -2071,7 +2083,7 @@ func (s *DockerSuite) TestRunAllocatePortInReservedRange(c *testing.T) { } // Regression test for #7792 -func (s *DockerSuite) TestRunMountOrdering(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunMountOrdering(c *testing.T) { // TODO Windows: Post RS1. Windows does not support nested mounts. testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux, NotUserNamespace) prefix, _ := getPrefixAndSlashFromDaemonPlatform() @@ -2116,7 +2128,7 @@ func (s *DockerSuite) TestRunMountOrdering(c *testing.T) { } // Regression test for https://github.com/docker/docker/issues/8259 -func (s *DockerSuite) TestRunReuseBindVolumeThatIsSymlink(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunReuseBindVolumeThatIsSymlink(c *testing.T) { // Not applicable on Windows as Windows does not support volumes testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux, NotUserNamespace) prefix, _ := getPrefixAndSlashFromDaemonPlatform() @@ -2142,7 +2154,7 @@ func (s *DockerSuite) TestRunReuseBindVolumeThatIsSymlink(c *testing.T) { } // GH#10604: Test an "/etc" volume doesn't overlay special bind mounts in container -func (s *DockerSuite) TestRunCreateVolumeEtc(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunCreateVolumeEtc(c *testing.T) { // While Windows supports volumes, it does not support --add-host hence // this test is not applicable on Windows. testRequires(c, DaemonIsLinux) @@ -2163,7 +2175,7 @@ func (s *DockerSuite) TestRunCreateVolumeEtc(c *testing.T) { } } -func (s *DockerSuite) TestVolumesNoCopyData(c *testing.T) { +func (s *DockerCLIRunSuite) TestVolumesNoCopyData(c *testing.T) { // TODO Windows (Post RS1). Windows does not support volumes which // are pre-populated such as is built in the dockerfile used in this test. testRequires(c, DaemonIsLinux) @@ -2183,7 +2195,7 @@ func (s *DockerSuite) TestVolumesNoCopyData(c *testing.T) { } } -func (s *DockerSuite) TestRunNoOutputFromPullInStdout(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunNoOutputFromPullInStdout(c *testing.T) { // just run with unknown image cmd := exec.Command(dockerBinary, "run", "asdfsg") stdout := bytes.NewBuffer(nil) @@ -2196,7 +2208,7 @@ func (s *DockerSuite) TestRunNoOutputFromPullInStdout(c *testing.T) { } } -func (s *DockerSuite) TestRunVolumesCleanPaths(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunVolumesCleanPaths(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon) prefix, slash := getPrefixAndSlashFromDaemonPlatform() buildImageSuccessfully(c, "run_volumes_clean_paths", build.WithDockerfile(`FROM busybox @@ -2227,7 +2239,7 @@ func (s *DockerSuite) TestRunVolumesCleanPaths(c *testing.T) { } // Regression test for #3631 -func (s *DockerSuite) TestRunSlowStdoutConsumer(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunSlowStdoutConsumer(c *testing.T) { // TODO Windows: This should be able to run on Windows if can find an // alternate to /dev/zero and /dev/stdout. testRequires(c, DaemonIsLinux) @@ -2255,7 +2267,7 @@ func (s *DockerSuite) TestRunSlowStdoutConsumer(c *testing.T) { } } -func (s *DockerSuite) TestRunAllowPortRangeThroughExpose(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunAllowPortRangeThroughExpose(c *testing.T) { // TODO Windows: -P is not currently supported. Also network // settings are not propagated back. testRequires(c, DaemonIsLinux) @@ -2278,13 +2290,13 @@ func (s *DockerSuite) TestRunAllowPortRangeThroughExpose(c *testing.T) { } } -func (s *DockerSuite) TestRunExposePort(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunExposePort(c *testing.T) { out, _, err := dockerCmdWithError("run", "--expose", "80000", "busybox") assert.Assert(c, err != nil, "--expose with an invalid port should error out") assert.Assert(c, strings.Contains(out, "invalid range format for --expose")) } -func (s *DockerSuite) TestRunModeIpcHost(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunModeIpcHost(c *testing.T) { // Not applicable on Windows as uses Unix-specific capabilities testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux, NotUserNamespace) @@ -2306,7 +2318,7 @@ func (s *DockerSuite) TestRunModeIpcHost(c *testing.T) { } } -func (s *DockerSuite) TestRunModeIpcContainerNotExists(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunModeIpcContainerNotExists(c *testing.T) { // Not applicable on Windows as uses Unix-specific capabilities testRequires(c, DaemonIsLinux) out, _, err := dockerCmdWithError("run", "-d", "--ipc", "container:abcd1234", "busybox", "top") @@ -2315,7 +2327,7 @@ func (s *DockerSuite) TestRunModeIpcContainerNotExists(c *testing.T) { } } -func (s *DockerSuite) TestRunModeIpcContainerNotRunning(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunModeIpcContainerNotRunning(c *testing.T) { // Not applicable on Windows as uses Unix-specific capabilities testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) @@ -2328,7 +2340,7 @@ func (s *DockerSuite) TestRunModeIpcContainerNotRunning(c *testing.T) { } } -func (s *DockerSuite) TestRunModePIDContainer(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunModePIDContainer(c *testing.T) { // Not applicable on Windows as uses Unix-specific capabilities testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) @@ -2353,7 +2365,7 @@ func (s *DockerSuite) TestRunModePIDContainer(c *testing.T) { } } -func (s *DockerSuite) TestRunModePIDContainerNotExists(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunModePIDContainerNotExists(c *testing.T) { // Not applicable on Windows as uses Unix-specific capabilities testRequires(c, DaemonIsLinux) out, _, err := dockerCmdWithError("run", "-d", "--pid", "container:abcd1234", "busybox", "top") @@ -2362,7 +2374,7 @@ func (s *DockerSuite) TestRunModePIDContainerNotExists(c *testing.T) { } } -func (s *DockerSuite) TestRunModePIDContainerNotRunning(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunModePIDContainerNotRunning(c *testing.T) { // Not applicable on Windows as uses Unix-specific capabilities testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) @@ -2375,7 +2387,7 @@ func (s *DockerSuite) TestRunModePIDContainerNotRunning(c *testing.T) { } } -func (s *DockerSuite) TestRunMountShmMqueueFromHost(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunMountShmMqueueFromHost(c *testing.T) { // Not applicable on Windows as uses Unix-specific capabilities testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux, NotUserNamespace) @@ -2399,7 +2411,7 @@ func (s *DockerSuite) TestRunMountShmMqueueFromHost(c *testing.T) { } } -func (s *DockerSuite) TestContainerNetworkMode(c *testing.T) { +func (s *DockerCLIRunSuite) TestContainerNetworkMode(c *testing.T) { // Not applicable on Windows as uses Unix-specific capabilities testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) @@ -2420,7 +2432,7 @@ func (s *DockerSuite) TestContainerNetworkMode(c *testing.T) { } } -func (s *DockerSuite) TestRunModeUTSHost(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunModeUTSHost(c *testing.T) { // Not applicable on Windows as uses Unix-specific capabilities testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) @@ -2445,7 +2457,7 @@ func (s *DockerSuite) TestRunModeUTSHost(c *testing.T) { assert.Assert(c, strings.Contains(out, runconfig.ErrConflictUTSHostname.Error())) } -func (s *DockerSuite) TestRunTLSVerify(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunTLSVerify(c *testing.T) { // Remote daemons use TLS and this test is not applicable when TLS is required. testRequires(c, testEnv.IsLocalDaemon) if out, code, err := dockerCmdWithError("ps"); err != nil || code != 0 { @@ -2461,7 +2473,7 @@ func (s *DockerSuite) TestRunTLSVerify(c *testing.T) { result.Assert(c, icmd.Expected{ExitCode: 1, Err: "cert"}) } -func (s *DockerSuite) TestRunPortFromDockerRangeInUse(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunPortFromDockerRangeInUse(c *testing.T) { // TODO Windows. Once moved to libnetwork/CNM, this may be able to be // re-instated. testRequires(c, DaemonIsLinux) @@ -2492,7 +2504,7 @@ func (s *DockerSuite) TestRunPortFromDockerRangeInUse(c *testing.T) { dockerCmd(c, "port", id) } -func (s *DockerSuite) TestRunTTYWithPipe(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunTTYWithPipe(c *testing.T) { errChan := make(chan error, 1) go func() { defer close(errChan) @@ -2524,7 +2536,7 @@ func (s *DockerSuite) TestRunTTYWithPipe(c *testing.T) { } } -func (s *DockerSuite) TestRunNonLocalMacAddress(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunNonLocalMacAddress(c *testing.T) { addr := "00:16:3E:08:00:50" args := []string{"run", "--mac-address", addr} expected := addr @@ -2541,7 +2553,7 @@ func (s *DockerSuite) TestRunNonLocalMacAddress(c *testing.T) { } } -func (s *DockerSuite) TestRunNetHost(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunNetHost(c *testing.T) { // Not applicable on Windows as uses Unix-specific capabilities testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux, NotUserNamespace) @@ -2563,7 +2575,7 @@ func (s *DockerSuite) TestRunNetHost(c *testing.T) { } } -func (s *DockerSuite) TestRunNetHostTwiceSameName(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunNetHostTwiceSameName(c *testing.T) { // TODO Windows. As Windows networking evolves and converges towards // CNM, this test may be possible to enable on Windows. testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux, NotUserNamespace) @@ -2572,7 +2584,7 @@ func (s *DockerSuite) TestRunNetHostTwiceSameName(c *testing.T) { dockerCmd(c, "run", "--rm", "--name=thost", "--net=host", "busybox", "true") } -func (s *DockerSuite) TestRunNetContainerWhichHost(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunNetContainerWhichHost(c *testing.T) { // Not applicable on Windows as uses Unix-specific capabilities testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux, NotUserNamespace) @@ -2590,7 +2602,7 @@ func (s *DockerSuite) TestRunNetContainerWhichHost(c *testing.T) { } } -func (s *DockerSuite) TestRunAllowPortRangeThroughPublish(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunAllowPortRangeThroughPublish(c *testing.T) { // TODO Windows. This may be possible to enable in the future. However, // Windows does not currently support --expose, or populate the network // settings seen through inspect. @@ -2614,7 +2626,7 @@ func (s *DockerSuite) TestRunAllowPortRangeThroughPublish(c *testing.T) { } } -func (s *DockerSuite) TestRunSetDefaultRestartPolicy(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunSetDefaultRestartPolicy(c *testing.T) { runSleepingContainer(c, "--name=testrunsetdefaultrestartpolicy") out := inspectField(c, "testrunsetdefaultrestartpolicy", "HostConfig.RestartPolicy.Name") if out != "no" { @@ -2622,7 +2634,7 @@ func (s *DockerSuite) TestRunSetDefaultRestartPolicy(c *testing.T) { } } -func (s *DockerSuite) TestRunRestartMaxRetries(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunRestartMaxRetries(c *testing.T) { out, _ := dockerCmd(c, "run", "-d", "--restart=on-failure:3", "busybox", "false") timeout := 10 * time.Second if testEnv.OSType == "windows" { @@ -2645,11 +2657,11 @@ func (s *DockerSuite) TestRunRestartMaxRetries(c *testing.T) { } } -func (s *DockerSuite) TestRunContainerWithWritableRootfs(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunContainerWithWritableRootfs(c *testing.T) { dockerCmd(c, "run", "--rm", "busybox", "touch", "/file") } -func (s *DockerSuite) TestRunContainerWithReadonlyRootfs(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunContainerWithReadonlyRootfs(c *testing.T) { // Not applicable on Windows which does not support --read-only testRequires(c, DaemonIsLinux, UserNamespaceROMount) @@ -2661,7 +2673,7 @@ func (s *DockerSuite) TestRunContainerWithReadonlyRootfs(c *testing.T) { testReadOnlyFile(c, testPriv, "/file", "/etc/hosts", "/etc/resolv.conf", "/etc/hostname") } -func (s *DockerSuite) TestPermissionsPtsReadonlyRootfs(c *testing.T) { +func (s *DockerCLIRunSuite) TestPermissionsPtsReadonlyRootfs(c *testing.T) { // Not applicable on Windows due to use of Unix specific functionality, plus // the use of --read-only which is not supported. testRequires(c, DaemonIsLinux, UserNamespaceROMount) @@ -2700,7 +2712,7 @@ func testReadOnlyFile(c *testing.T, testPriv bool, filenames ...string) { } } -func (s *DockerSuite) TestRunContainerWithReadonlyEtcHostsAndLinkedContainer(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunContainerWithReadonlyEtcHostsAndLinkedContainer(c *testing.T) { // Not applicable on Windows which does not support --link testRequires(c, DaemonIsLinux, UserNamespaceROMount) @@ -2712,7 +2724,7 @@ func (s *DockerSuite) TestRunContainerWithReadonlyEtcHostsAndLinkedContainer(c * } } -func (s *DockerSuite) TestRunContainerWithReadonlyRootfsWithDNSFlag(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunContainerWithReadonlyRootfsWithDNSFlag(c *testing.T) { // Not applicable on Windows which does not support either --read-only or --dns. testRequires(c, DaemonIsLinux, UserNamespaceROMount) @@ -2722,7 +2734,7 @@ func (s *DockerSuite) TestRunContainerWithReadonlyRootfsWithDNSFlag(c *testing.T } } -func (s *DockerSuite) TestRunContainerWithReadonlyRootfsWithAddHostFlag(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunContainerWithReadonlyRootfsWithAddHostFlag(c *testing.T) { // Not applicable on Windows which does not support --read-only testRequires(c, DaemonIsLinux, UserNamespaceROMount) @@ -2732,7 +2744,7 @@ func (s *DockerSuite) TestRunContainerWithReadonlyRootfsWithAddHostFlag(c *testi } } -func (s *DockerSuite) TestRunVolumesFromRestartAfterRemoved(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunVolumesFromRestartAfterRemoved(c *testing.T) { prefix, _ := getPrefixAndSlashFromDaemonPlatform() runSleepingContainer(c, "--name=voltest", "-v", prefix+"/foo") runSleepingContainer(c, "--name=restarter", "--volumes-from", "voltest") @@ -2745,7 +2757,7 @@ func (s *DockerSuite) TestRunVolumesFromRestartAfterRemoved(c *testing.T) { } // run container with --rm should remove container if exit code != 0 -func (s *DockerSuite) TestRunContainerWithRmFlagExitCodeNotEqualToZero(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunContainerWithRmFlagExitCodeNotEqualToZero(c *testing.T) { name := "flowers" cli.Docker(cli.Args("run", "--name", name, "--rm", "busybox", "ls", "/notexists")).Assert(c, icmd.Expected{ ExitCode: 1, @@ -2754,7 +2766,7 @@ func (s *DockerSuite) TestRunContainerWithRmFlagExitCodeNotEqualToZero(c *testin poll.WaitOn(c, containerRemoved(name)) } -func (s *DockerSuite) TestRunContainerWithRmFlagCannotStartContainer(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunContainerWithRmFlagCannotStartContainer(c *testing.T) { name := "sparkles" cli.Docker(cli.Args("run", "--name", name, "--rm", "busybox", "commandNotFound")).Assert(c, icmd.Expected{ ExitCode: 127, @@ -2777,7 +2789,7 @@ func containerRemoved(name string) poll.Check { } } -func (s *DockerSuite) TestRunPIDHostWithChildIsKillable(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunPIDHostWithChildIsKillable(c *testing.T) { // Not applicable on Windows as uses Unix specific functionality testRequires(c, DaemonIsLinux, NotUserNamespace) name := "ibuildthecloud" @@ -2800,7 +2812,7 @@ func (s *DockerSuite) TestRunPIDHostWithChildIsKillable(c *testing.T) { } } -func (s *DockerSuite) TestRunWithTooSmallMemoryLimit(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithTooSmallMemoryLimit(c *testing.T) { // TODO Windows. This may be possible to enable once Windows supports memory limits on containers testRequires(c, DaemonIsLinux) // this memory limit is 1 byte less than the min (daemon.linuxMinMemory), which is 6MB (6291456 bytes) @@ -2810,7 +2822,7 @@ func (s *DockerSuite) TestRunWithTooSmallMemoryLimit(c *testing.T) { } } -func (s *DockerSuite) TestRunWriteToProcAsound(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWriteToProcAsound(c *testing.T) { // Not applicable on Windows as uses Unix specific functionality testRequires(c, DaemonIsLinux) _, code, err := dockerCmdWithError("run", "busybox", "sh", "-c", "echo 111 >> /proc/asound/version") @@ -2819,7 +2831,7 @@ func (s *DockerSuite) TestRunWriteToProcAsound(c *testing.T) { } } -func (s *DockerSuite) TestRunReadProcTimer(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunReadProcTimer(c *testing.T) { // Not applicable on Windows as uses Unix specific functionality testRequires(c, DaemonIsLinux) out, code, err := dockerCmdWithError("run", "busybox", "cat", "/proc/timer_stats") @@ -2834,7 +2846,7 @@ func (s *DockerSuite) TestRunReadProcTimer(c *testing.T) { } } -func (s *DockerSuite) TestRunReadProcLatency(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunReadProcLatency(c *testing.T) { // Not applicable on Windows as uses Unix specific functionality testRequires(c, DaemonIsLinux) // some kernels don't have this configured so skip the test if this file is not found @@ -2855,7 +2867,7 @@ func (s *DockerSuite) TestRunReadProcLatency(c *testing.T) { } } -func (s *DockerSuite) TestRunReadFilteredProc(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunReadFilteredProc(c *testing.T) { // Not applicable on Windows as uses Unix specific functionality testRequires(c, Apparmor, DaemonIsLinux, NotUserNamespace) @@ -2878,7 +2890,7 @@ func (s *DockerSuite) TestRunReadFilteredProc(c *testing.T) { } } -func (s *DockerSuite) TestMountIntoProc(c *testing.T) { +func (s *DockerCLIRunSuite) TestMountIntoProc(c *testing.T) { // Not applicable on Windows as uses Unix specific functionality testRequires(c, DaemonIsLinux) _, code, err := dockerCmdWithError("run", "-v", "/proc//sys", "busybox", "true") @@ -2887,14 +2899,14 @@ func (s *DockerSuite) TestMountIntoProc(c *testing.T) { } } -func (s *DockerSuite) TestMountIntoSys(c *testing.T) { +func (s *DockerCLIRunSuite) TestMountIntoSys(c *testing.T) { // Not applicable on Windows as uses Unix specific functionality testRequires(c, DaemonIsLinux) testRequires(c, NotUserNamespace) dockerCmd(c, "run", "-v", "/sys/fs/cgroup", "busybox", "true") } -func (s *DockerSuite) TestRunUnshareProc(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunUnshareProc(c *testing.T) { // Not applicable on Windows as uses Unix specific functionality testRequires(c, Apparmor, DaemonIsLinux, NotUserNamespace) @@ -2952,7 +2964,7 @@ func (s *DockerSuite) TestRunUnshareProc(c *testing.T) { } } -func (s *DockerSuite) TestRunPublishPort(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunPublishPort(c *testing.T) { // TODO Windows: This may be possible once Windows moves to libnetwork and CNM testRequires(c, DaemonIsLinux) dockerCmd(c, "run", "-d", "--name", "test", "--expose", "8080", "busybox", "top") @@ -2964,7 +2976,7 @@ func (s *DockerSuite) TestRunPublishPort(c *testing.T) { } // Issue #10184. -func (s *DockerSuite) TestDevicePermissions(c *testing.T) { +func (s *DockerCLIRunSuite) TestDevicePermissions(c *testing.T) { // Not applicable on Windows as uses Unix specific functionality testRequires(c, DaemonIsLinux) const permissions = "crw-rw-rw-" @@ -2977,7 +2989,7 @@ func (s *DockerSuite) TestDevicePermissions(c *testing.T) { } } -func (s *DockerSuite) TestRunCapAddCHOWN(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunCapAddCHOWN(c *testing.T) { // Not applicable on Windows as uses Unix specific functionality testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "--cap-drop=ALL", "--cap-add=CHOWN", "busybox", "sh", "-c", "adduser -D -H newuser && chown newuser /home && echo ok") @@ -2988,7 +3000,7 @@ func (s *DockerSuite) TestRunCapAddCHOWN(c *testing.T) { } // https://github.com/docker/docker/pull/14498 -func (s *DockerSuite) TestVolumeFromMixedRWOptions(c *testing.T) { +func (s *DockerCLIRunSuite) TestVolumeFromMixedRWOptions(c *testing.T) { prefix, slash := getPrefixAndSlashFromDaemonPlatform() dockerCmd(c, "run", "--name", "parent", "-v", prefix+"/test", "busybox", "true") @@ -3011,7 +3023,7 @@ func (s *DockerSuite) TestVolumeFromMixedRWOptions(c *testing.T) { } } -func (s *DockerSuite) TestRunWriteFilteredProc(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWriteFilteredProc(c *testing.T) { // Not applicable on Windows as uses Unix specific functionality testRequires(c, Apparmor, DaemonIsLinux, NotUserNamespace) @@ -3038,7 +3050,7 @@ func (s *DockerSuite) TestRunWriteFilteredProc(c *testing.T) { } } -func (s *DockerSuite) TestRunNetworkFilesBindMount(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunNetworkFilesBindMount(c *testing.T) { // Not applicable on Windows as uses Unix specific functionality testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) @@ -3062,7 +3074,7 @@ func (s *DockerSuite) TestRunNetworkFilesBindMount(c *testing.T) { } } -func (s *DockerSuite) TestRunNetworkFilesBindMountRO(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunNetworkFilesBindMountRO(c *testing.T) { // Not applicable on Windows as uses Unix specific functionality testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) @@ -3084,7 +3096,7 @@ func (s *DockerSuite) TestRunNetworkFilesBindMountRO(c *testing.T) { } } -func (s *DockerSuite) TestRunNetworkFilesBindMountROFilesystem(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunNetworkFilesBindMountROFilesystem(c *testing.T) { // Not applicable on Windows as uses Unix specific functionality testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux, UserNamespaceROMount) @@ -3113,7 +3125,7 @@ func (s *DockerSuite) TestRunNetworkFilesBindMountROFilesystem(c *testing.T) { } } -func (s *DockerSuite) TestPtraceContainerProcsFromHost(c *testing.T) { +func (s *DockerCLIRunSuite) TestPtraceContainerProcsFromHost(c *testing.T) { // Not applicable on Windows as uses Unix specific functionality testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) @@ -3128,7 +3140,7 @@ func (s *DockerSuite) TestPtraceContainerProcsFromHost(c *testing.T) { } } -func (s *DockerSuite) TestAppArmorDeniesPtrace(c *testing.T) { +func (s *DockerCLIRunSuite) TestAppArmorDeniesPtrace(c *testing.T) { // Not applicable on Windows as uses Unix specific functionality testRequires(c, testEnv.IsLocalDaemon, Apparmor, DaemonIsLinux) @@ -3140,7 +3152,7 @@ func (s *DockerSuite) TestAppArmorDeniesPtrace(c *testing.T) { } } -func (s *DockerSuite) TestAppArmorTraceSelf(c *testing.T) { +func (s *DockerCLIRunSuite) TestAppArmorTraceSelf(c *testing.T) { // Not applicable on Windows as uses Unix specific functionality testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon, Apparmor) @@ -3150,7 +3162,7 @@ func (s *DockerSuite) TestAppArmorTraceSelf(c *testing.T) { } } -func (s *DockerSuite) TestAppArmorDeniesChmodProc(c *testing.T) { +func (s *DockerCLIRunSuite) TestAppArmorDeniesChmodProc(c *testing.T) { // Not applicable on Windows as uses Unix specific functionality testRequires(c, testEnv.IsLocalDaemon, Apparmor, DaemonIsLinux, NotUserNamespace) _, exitCode, _ := dockerCmdWithError("run", "busybox", "chmod", "744", "/proc/cpuinfo") @@ -3163,7 +3175,7 @@ func (s *DockerSuite) TestAppArmorDeniesChmodProc(c *testing.T) { } } -func (s *DockerSuite) TestRunCapAddSYSTIME(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunCapAddSYSTIME(c *testing.T) { // Not applicable on Windows as uses Unix specific functionality testRequires(c, DaemonIsLinux) @@ -3171,7 +3183,7 @@ func (s *DockerSuite) TestRunCapAddSYSTIME(c *testing.T) { } // run create container failed should clean up the container -func (s *DockerSuite) TestRunCreateContainerFailedCleanUp(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunCreateContainerFailedCleanUp(c *testing.T) { // TODO Windows. This may be possible to enable once link is supported testRequires(c, DaemonIsLinux) name := "unique_name" @@ -3183,7 +3195,7 @@ func (s *DockerSuite) TestRunCreateContainerFailedCleanUp(c *testing.T) { assert.Equal(c, containerID, "", fmt.Sprintf("Expected not to have this container: %s!", containerID)) } -func (s *DockerSuite) TestRunNamedVolume(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunNamedVolume(c *testing.T) { prefix, _ := getPrefixAndSlashFromDaemonPlatform() testRequires(c, DaemonIsLinux) dockerCmd(c, "run", "--name=test", "-v", "testing:"+prefix+"/foo", "busybox", "sh", "-c", "echo hello > "+prefix+"/foo/bar") @@ -3195,7 +3207,7 @@ func (s *DockerSuite) TestRunNamedVolume(c *testing.T) { assert.Equal(c, strings.TrimSpace(out), "hello") } -func (s *DockerSuite) TestRunWithUlimits(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithUlimits(c *testing.T) { // Not applicable on Windows as uses Unix specific functionality testRequires(c, DaemonIsLinux) @@ -3206,7 +3218,7 @@ func (s *DockerSuite) TestRunWithUlimits(c *testing.T) { } } -func (s *DockerSuite) TestRunContainerWithCgroupParent(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunContainerWithCgroupParent(c *testing.T) { // Not applicable on Windows as uses Unix specific functionality testRequires(c, DaemonIsLinux) @@ -3241,7 +3253,7 @@ func testRunContainerWithCgroupParent(c *testing.T, cgroupParent, name string) { } // TestRunInvalidCgroupParent checks that a specially-crafted cgroup parent doesn't cause Docker to crash or start modifying /. -func (s *DockerSuite) TestRunInvalidCgroupParent(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunInvalidCgroupParent(c *testing.T) { // Not applicable on Windows as uses Unix specific functionality testRequires(c, DaemonIsLinux) @@ -3280,7 +3292,7 @@ func testRunInvalidCgroupParent(c *testing.T, cgroupParent, cleanCgroupParent, n } } -func (s *DockerSuite) TestRunContainerWithCgroupMountRO(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunContainerWithCgroupMountRO(c *testing.T) { // Not applicable on Windows as uses Unix specific functionality // --read-only + userns has remount issues testRequires(c, DaemonIsLinux, NotUserNamespace) @@ -3296,7 +3308,7 @@ func (s *DockerSuite) TestRunContainerWithCgroupMountRO(c *testing.T) { } } -func (s *DockerSuite) TestRunContainerNetworkModeToSelf(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunContainerNetworkModeToSelf(c *testing.T) { // Not applicable on Windows which does not support --net=container testRequires(c, DaemonIsLinux) out, _, err := dockerCmdWithError("run", "--name=me", "--net=container:me", "busybox", "true") @@ -3305,7 +3317,7 @@ func (s *DockerSuite) TestRunContainerNetworkModeToSelf(c *testing.T) { } } -func (s *DockerSuite) TestRunContainerNetModeWithDNSMacHosts(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunContainerNetModeWithDNSMacHosts(c *testing.T) { // Not applicable on Windows which does not support --net=container testRequires(c, DaemonIsLinux) out, _, err := dockerCmdWithError("run", "-d", "--name", "parent", "busybox", "top") @@ -3329,7 +3341,7 @@ func (s *DockerSuite) TestRunContainerNetModeWithDNSMacHosts(c *testing.T) { } } -func (s *DockerSuite) TestRunContainerNetModeWithExposePort(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunContainerNetModeWithExposePort(c *testing.T) { // Not applicable on Windows which does not support --net=container testRequires(c, DaemonIsLinux) dockerCmd(c, "run", "-d", "--name", "parent", "busybox", "top") @@ -3350,7 +3362,7 @@ func (s *DockerSuite) TestRunContainerNetModeWithExposePort(c *testing.T) { } } -func (s *DockerSuite) TestRunLinkToContainerNetMode(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunLinkToContainerNetMode(c *testing.T) { // Not applicable on Windows which does not support --net=container or --link testRequires(c, DaemonIsLinux) dockerCmd(c, "run", "--name", "test", "-d", "busybox", "top") @@ -3360,7 +3372,7 @@ func (s *DockerSuite) TestRunLinkToContainerNetMode(c *testing.T) { dockerCmd(c, "run", "-d", "--link=child:child", "busybox", "top") } -func (s *DockerSuite) TestRunLoopbackOnlyExistsWhenNetworkingDisabled(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunLoopbackOnlyExistsWhenNetworkingDisabled(c *testing.T) { // TODO Windows: This may be possible to convert. testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "--net=none", "busybox", "ip", "-o", "-4", "a", "show", "up") @@ -3386,7 +3398,7 @@ func (s *DockerSuite) TestRunLoopbackOnlyExistsWhenNetworkingDisabled(c *testing } // Issue #4681 -func (s *DockerSuite) TestRunLoopbackWhenNetworkDisabled(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunLoopbackWhenNetworkDisabled(c *testing.T) { if testEnv.OSType == "windows" { dockerCmd(c, "run", "--net=none", testEnv.PlatformDefaults.BaseImage, "ping", "-n", "1", "127.0.0.1") } else { @@ -3394,7 +3406,7 @@ func (s *DockerSuite) TestRunLoopbackWhenNetworkDisabled(c *testing.T) { } } -func (s *DockerSuite) TestRunModeNetContainerHostname(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunModeNetContainerHostname(c *testing.T) { // Windows does not support --net=container testRequires(c, DaemonIsLinux) @@ -3407,7 +3419,7 @@ func (s *DockerSuite) TestRunModeNetContainerHostname(c *testing.T) { } } -func (s *DockerSuite) TestRunNetworkNotInitializedNoneMode(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunNetworkNotInitializedNoneMode(c *testing.T) { // TODO Windows: Network settings are not currently propagated. This may // be resolved in the future with the move to libnetwork and CNM. testRequires(c, DaemonIsLinux) @@ -3419,7 +3431,7 @@ func (s *DockerSuite) TestRunNetworkNotInitializedNoneMode(c *testing.T) { } } -func (s *DockerSuite) TestTwoContainersInNetHost(c *testing.T) { +func (s *DockerCLIRunSuite) TestTwoContainersInNetHost(c *testing.T) { // Not applicable as Windows does not support --net=host testRequires(c, DaemonIsLinux, NotUserNamespace, NotUserNamespace) dockerCmd(c, "run", "-d", "--net=host", "--name=first", "busybox", "top") @@ -3428,7 +3440,7 @@ func (s *DockerSuite) TestTwoContainersInNetHost(c *testing.T) { dockerCmd(c, "stop", "second") } -func (s *DockerSuite) TestContainersInUserDefinedNetwork(c *testing.T) { +func (s *DockerCLIRunSuite) TestContainersInUserDefinedNetwork(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm) dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork") dockerCmd(c, "run", "-d", "--net=testnetwork", "--name=first", "busybox", "top") @@ -3436,7 +3448,7 @@ func (s *DockerSuite) TestContainersInUserDefinedNetwork(c *testing.T) { dockerCmd(c, "run", "-t", "--net=testnetwork", "--name=second", "busybox", "ping", "-c", "1", "first") } -func (s *DockerSuite) TestContainersInMultipleNetworks(c *testing.T) { +func (s *DockerCLIRunSuite) TestContainersInMultipleNetworks(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm) // Create 2 networks using bridge driver dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork1") @@ -3455,7 +3467,7 @@ func (s *DockerSuite) TestContainersInMultipleNetworks(c *testing.T) { dockerCmd(c, "exec", "second", "ping", "-c", "1", "first.testnetwork2") } -func (s *DockerSuite) TestContainersNetworkIsolation(c *testing.T) { +func (s *DockerCLIRunSuite) TestContainersNetworkIsolation(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm) // Create 2 networks using bridge driver dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork1") @@ -3482,7 +3494,7 @@ func (s *DockerSuite) TestContainersNetworkIsolation(c *testing.T) { assert.ErrorContains(c, err, "") } -func (s *DockerSuite) TestNetworkRmWithActiveContainers(c *testing.T) { +func (s *DockerCLIRunSuite) TestNetworkRmWithActiveContainers(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace) // Create 2 networks using bridge driver dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork1") @@ -3500,7 +3512,7 @@ func (s *DockerSuite) TestNetworkRmWithActiveContainers(c *testing.T) { assert.ErrorContains(c, err, "") } -func (s *DockerSuite) TestContainerRestartInMultipleNetworks(c *testing.T) { +func (s *DockerCLIRunSuite) TestContainerRestartInMultipleNetworks(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm) // Create 2 networks using bridge driver dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork1") @@ -3532,7 +3544,7 @@ func (s *DockerSuite) TestContainerRestartInMultipleNetworks(c *testing.T) { dockerCmd(c, "exec", "second", "ping", "-c", "1", "first.testnetwork2") } -func (s *DockerSuite) TestContainerWithConflictingHostNetworks(c *testing.T) { +func (s *DockerCLIRunSuite) TestContainerWithConflictingHostNetworks(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace) // Run a container with --net=host dockerCmd(c, "run", "-d", "--net=host", "--name=first", "busybox", "top") @@ -3546,7 +3558,7 @@ func (s *DockerSuite) TestContainerWithConflictingHostNetworks(c *testing.T) { assert.ErrorContains(c, err, "") } -func (s *DockerSuite) TestContainerWithConflictingSharedNetwork(c *testing.T) { +func (s *DockerCLIRunSuite) TestContainerWithConflictingSharedNetwork(c *testing.T) { testRequires(c, DaemonIsLinux) dockerCmd(c, "run", "-d", "--name=first", "busybox", "top") assert.Assert(c, waitRun("first") == nil) @@ -3563,7 +3575,7 @@ func (s *DockerSuite) TestContainerWithConflictingSharedNetwork(c *testing.T) { assert.Assert(c, strings.Contains(out, runconfig.ErrConflictSharedNetwork.Error())) } -func (s *DockerSuite) TestContainerWithConflictingNoneNetwork(c *testing.T) { +func (s *DockerCLIRunSuite) TestContainerWithConflictingNoneNetwork(c *testing.T) { testRequires(c, DaemonIsLinux) dockerCmd(c, "run", "-d", "--net=none", "--name=first", "busybox", "top") assert.Assert(c, waitRun("first") == nil) @@ -3585,7 +3597,7 @@ func (s *DockerSuite) TestContainerWithConflictingNoneNetwork(c *testing.T) { } // #11957 - stdin with no tty does not exit if stdin is not closed even though container exited -func (s *DockerSuite) TestRunStdinBlockedAfterContainerExit(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunStdinBlockedAfterContainerExit(c *testing.T) { cmd := exec.Command(dockerBinary, "run", "-i", "--name=test", "busybox", "true") in, err := cmd.StdinPipe() assert.NilError(c, err) @@ -3608,7 +3620,7 @@ func (s *DockerSuite) TestRunStdinBlockedAfterContainerExit(c *testing.T) { } } -func (s *DockerSuite) TestRunWrongCpusetCpusFlagValue(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWrongCpusetCpusFlagValue(c *testing.T) { // TODO Windows: This needs validation (error out) in the daemon. testRequires(c, DaemonIsLinux) out, exitCode, err := dockerCmdWithError("run", "--cpuset-cpus", "1-10,11--", "busybox", "true") @@ -3619,7 +3631,7 @@ func (s *DockerSuite) TestRunWrongCpusetCpusFlagValue(c *testing.T) { } } -func (s *DockerSuite) TestRunWrongCpusetMemsFlagValue(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWrongCpusetMemsFlagValue(c *testing.T) { // TODO Windows: This needs validation (error out) in the daemon. testRequires(c, DaemonIsLinux) out, exitCode, err := dockerCmdWithError("run", "--cpuset-mems", "1-42--", "busybox", "true") @@ -3631,7 +3643,7 @@ func (s *DockerSuite) TestRunWrongCpusetMemsFlagValue(c *testing.T) { } // TestRunNonExecutableCmd checks that 'docker run busybox foo' exits with error code 127' -func (s *DockerSuite) TestRunNonExecutableCmd(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunNonExecutableCmd(c *testing.T) { name := "testNonExecutableCmd" icmd.RunCommand(dockerBinary, "run", "--name", name, "busybox", "foo").Assert(c, icmd.Expected{ ExitCode: 127, @@ -3640,7 +3652,7 @@ func (s *DockerSuite) TestRunNonExecutableCmd(c *testing.T) { } // TestRunNonExistingCmd checks that 'docker run busybox /bin/foo' exits with code 127. -func (s *DockerSuite) TestRunNonExistingCmd(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunNonExistingCmd(c *testing.T) { name := "testNonExistingCmd" icmd.RunCommand(dockerBinary, "run", "--name", name, "busybox", "/bin/foo").Assert(c, icmd.Expected{ ExitCode: 127, @@ -3651,7 +3663,7 @@ func (s *DockerSuite) TestRunNonExistingCmd(c *testing.T) { // TestCmdCannotBeInvoked checks that 'docker run busybox /etc' exits with 126, or // 127 on Windows. The difference is that in Windows, the container must be started // as that's when the check is made (and yes, by its design...) -func (s *DockerSuite) TestCmdCannotBeInvoked(c *testing.T) { +func (s *DockerCLIRunSuite) TestCmdCannotBeInvoked(c *testing.T) { expected := 126 if testEnv.OSType == "windows" { expected = 127 @@ -3665,7 +3677,7 @@ func (s *DockerSuite) TestCmdCannotBeInvoked(c *testing.T) { // TestRunNonExistingImage checks that 'docker run foo' exits with error msg 125 and contains 'Unable to find image' // FIXME(vdemeester) should be a unit test -func (s *DockerSuite) TestRunNonExistingImage(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunNonExistingImage(c *testing.T) { icmd.RunCommand(dockerBinary, "run", "foo").Assert(c, icmd.Expected{ ExitCode: 125, Err: "Unable to find image", @@ -3674,7 +3686,7 @@ func (s *DockerSuite) TestRunNonExistingImage(c *testing.T) { // TestDockerFails checks that 'docker run -foo busybox' exits with 125 to signal docker run failed // FIXME(vdemeester) should be a unit test -func (s *DockerSuite) TestDockerFails(c *testing.T) { +func (s *DockerCLIRunSuite) TestDockerFails(c *testing.T) { icmd.RunCommand(dockerBinary, "run", "-foo", "busybox").Assert(c, icmd.Expected{ ExitCode: 125, Error: "exit status 125", @@ -3682,7 +3694,7 @@ func (s *DockerSuite) TestDockerFails(c *testing.T) { } // TestRunInvalidReference invokes docker run with a bad reference. -func (s *DockerSuite) TestRunInvalidReference(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunInvalidReference(c *testing.T) { out, exit, _ := dockerCmdWithError("run", "busybox@foo") if exit == 0 { c.Fatalf("expected non-zero exist code; received %d", exit) @@ -3694,7 +3706,7 @@ func (s *DockerSuite) TestRunInvalidReference(c *testing.T) { } // Test fix for issue #17854 -func (s *DockerSuite) TestRunInitLayerPathOwnership(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunInitLayerPathOwnership(c *testing.T) { // Not applicable on Windows as it does not support Linux uid/gid ownership testRequires(c, DaemonIsLinux) name := "testetcfileownership" @@ -3711,7 +3723,7 @@ func (s *DockerSuite) TestRunInitLayerPathOwnership(c *testing.T) { } } -func (s *DockerSuite) TestRunWithOomScoreAdj(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithOomScoreAdj(c *testing.T) { testRequires(c, DaemonIsLinux) expected := "642" @@ -3722,7 +3734,7 @@ func (s *DockerSuite) TestRunWithOomScoreAdj(c *testing.T) { } } -func (s *DockerSuite) TestRunWithOomScoreAdjInvalidRange(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithOomScoreAdjInvalidRange(c *testing.T) { testRequires(c, DaemonIsLinux) out, _, err := dockerCmdWithError("run", "--oom-score-adj", "1001", "busybox", "true") @@ -3739,14 +3751,14 @@ func (s *DockerSuite) TestRunWithOomScoreAdjInvalidRange(c *testing.T) { } } -func (s *DockerSuite) TestRunNamedVolumesMountedAsShared(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunNamedVolumesMountedAsShared(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace) out, exitCode, _ := dockerCmdWithError("run", "-v", "foo:/test:shared", "busybox", "touch", "/test/somefile") assert.Assert(c, exitCode != 0) assert.Assert(c, strings.Contains(out, "invalid mount config")) } -func (s *DockerSuite) TestRunNamedVolumeCopyImageData(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunNamedVolumeCopyImageData(c *testing.T) { testRequires(c, DaemonIsLinux) testImg := "testvolumecopy" @@ -3760,7 +3772,7 @@ func (s *DockerSuite) TestRunNamedVolumeCopyImageData(c *testing.T) { assert.Equal(c, strings.TrimSpace(out), "hello") } -func (s *DockerSuite) TestRunNamedVolumeNotRemoved(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunNamedVolumeNotRemoved(c *testing.T) { prefix, _ := getPrefixAndSlashFromDaemonPlatform() dockerCmd(c, "volume", "create", "test") @@ -3777,7 +3789,7 @@ func (s *DockerSuite) TestRunNamedVolumeNotRemoved(c *testing.T) { assert.Assert(c, strings.Contains(out, "test")) } -func (s *DockerSuite) TestRunNamedVolumesFromNotRemoved(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunNamedVolumesFromNotRemoved(c *testing.T) { prefix, _ := getPrefixAndSlashFromDaemonPlatform() dockerCmd(c, "volume", "create", "test") @@ -3808,7 +3820,7 @@ func (s *DockerSuite) TestRunNamedVolumesFromNotRemoved(c *testing.T) { assert.Assert(c, !strings.Contains(strings.TrimSpace(out), vname)) } -func (s *DockerSuite) TestRunAttachFailedNoLeak(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunAttachFailedNoLeak(c *testing.T) { nroutines, err := getGoroutineNumber() assert.NilError(c, err) @@ -3837,14 +3849,14 @@ func (s *DockerSuite) TestRunAttachFailedNoLeak(c *testing.T) { } // Test for one character directory name case (#20122) -func (s *DockerSuite) TestRunVolumeWithOneCharacter(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunVolumeWithOneCharacter(c *testing.T) { testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "-v", "/tmp/q:/foo", "busybox", "sh", "-c", "find /foo") assert.Equal(c, strings.TrimSpace(out), "/foo") } -func (s *DockerSuite) TestRunVolumeCopyFlag(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunVolumeCopyFlag(c *testing.T) { testRequires(c, DaemonIsLinux) // Windows does not support copying data from image to the volume buildImageSuccessfully(c, "volumecopy", build.WithDockerfile(`FROM busybox RUN mkdir /foo && echo hello > /foo/bar @@ -3879,7 +3891,7 @@ func (s *DockerSuite) TestRunVolumeCopyFlag(c *testing.T) { } // Test case for #21976 -func (s *DockerSuite) TestRunDNSInHostMode(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunDNSInHostMode(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace) expectedOutput := "nameserver 127.0.0.1" @@ -3914,7 +3926,7 @@ func (s *DockerSuite) TestRunDNSInHostMode(c *testing.T) { } // Test case for #21976 -func (s *DockerSuite) TestRunAddHostInHostMode(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunAddHostInHostMode(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace) expectedOutput := "1.2.3.4\textra" @@ -3922,7 +3934,7 @@ func (s *DockerSuite) TestRunAddHostInHostMode(c *testing.T) { assert.Assert(c, strings.Contains(out, expectedOutput), "Expected '%s', but got %q", expectedOutput, out) } -func (s *DockerSuite) TestRunRmAndWait(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunRmAndWait(c *testing.T) { dockerCmd(c, "run", "--name=test", "--rm", "-d", "busybox", "sh", "-c", "sleep 3;exit 2") out, code, err := dockerCmdWithError("wait", "test") @@ -3932,7 +3944,7 @@ func (s *DockerSuite) TestRunRmAndWait(c *testing.T) { } // Test that auto-remove is performed by the daemon (API 1.25 and above) -func (s *DockerSuite) TestRunRm(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunRm(c *testing.T) { name := "miss-me-when-im-gone" cli.DockerCmd(c, "run", "--name="+name, "--rm", "busybox") @@ -3943,7 +3955,7 @@ func (s *DockerSuite) TestRunRm(c *testing.T) { } // Test that auto-remove is performed by the client on API versions that do not support daemon-side api-remove (API < 1.25) -func (s *DockerSuite) TestRunRmPre125Api(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunRmPre125Api(c *testing.T) { name := "miss-me-when-im-gone" envs := appendBaseEnv(os.Getenv("DOCKER_TLS_VERIFY") != "", "DOCKER_API_VERSION=1.24") cli.Docker(cli.Args("run", "--name="+name, "--rm", "busybox"), cli.WithEnvironmentVariables(envs...)).Assert(c, icmd.Success) @@ -3955,7 +3967,7 @@ func (s *DockerSuite) TestRunRmPre125Api(c *testing.T) { } // Test case for #23498 -func (s *DockerSuite) TestRunUnsetEntrypoint(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunUnsetEntrypoint(c *testing.T) { testRequires(c, DaemonIsLinux) name := "test-entrypoint" dockerfile := `FROM busybox @@ -4006,7 +4018,7 @@ func (s *DockerDaemonSuite) TestRunWithUlimitAndDaemonDefault(c *testing.T) { assert.Assert(c, strings.Contains(out, "[nofile=42:42]")) } -func (s *DockerSuite) TestRunStoppedLoggingDriverNoLeak(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunStoppedLoggingDriverNoLeak(c *testing.T) { nroutines, err := getGoroutineNumber() assert.NilError(c, err) @@ -4019,7 +4031,7 @@ func (s *DockerSuite) TestRunStoppedLoggingDriverNoLeak(c *testing.T) { // Handles error conditions for --credentialspec. Validating E2E success cases // requires additional infrastructure (AD for example) on CI servers. -func (s *DockerSuite) TestRunCredentialSpecFailures(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunCredentialSpecFailures(c *testing.T) { testRequires(c, DaemonIsWindows) attempts := []struct{ value, expectedError string }{ @@ -4038,7 +4050,7 @@ func (s *DockerSuite) TestRunCredentialSpecFailures(c *testing.T) { } // Windows specific test to validate credential specs with a well-formed spec. -func (s *DockerSuite) TestRunCredentialSpecWellFormed(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunCredentialSpecWellFormed(c *testing.T) { testRequires(c, DaemonIsWindows, testEnv.IsLocalDaemon) validCredSpecs := readFile(`fixtures\credentialspecs\valid.json`, c) @@ -4054,7 +4066,7 @@ func (s *DockerSuite) TestRunCredentialSpecWellFormed(c *testing.T) { } } -func (s *DockerSuite) TestRunDuplicateMount(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunDuplicateMount(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux, NotUserNamespace) tmpFile, err := os.CreateTemp("", "touch-me") @@ -4074,7 +4086,7 @@ func (s *DockerSuite) TestRunDuplicateMount(c *testing.T) { assert.Assert(c, strings.Contains(out, "null")) } -func (s *DockerSuite) TestRunWindowsWithCPUCount(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWindowsWithCPUCount(c *testing.T) { testRequires(c, DaemonIsWindows) out, _ := dockerCmd(c, "run", "--cpu-count=1", "--name", "test", "busybox", "echo", "testing") @@ -4084,7 +4096,7 @@ func (s *DockerSuite) TestRunWindowsWithCPUCount(c *testing.T) { assert.Equal(c, out, "1") } -func (s *DockerSuite) TestRunWindowsWithCPUShares(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWindowsWithCPUShares(c *testing.T) { testRequires(c, DaemonIsWindows) out, _ := dockerCmd(c, "run", "--cpu-shares=1000", "--name", "test", "busybox", "echo", "testing") @@ -4094,7 +4106,7 @@ func (s *DockerSuite) TestRunWindowsWithCPUShares(c *testing.T) { assert.Equal(c, out, "1000") } -func (s *DockerSuite) TestRunWindowsWithCPUPercent(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWindowsWithCPUPercent(c *testing.T) { testRequires(c, DaemonIsWindows) out, _ := dockerCmd(c, "run", "--cpu-percent=80", "--name", "test", "busybox", "echo", "testing") @@ -4104,7 +4116,7 @@ func (s *DockerSuite) TestRunWindowsWithCPUPercent(c *testing.T) { assert.Equal(c, out, "80") } -func (s *DockerSuite) TestRunProcessIsolationWithCPUCountCPUSharesAndCPUPercent(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunProcessIsolationWithCPUCountCPUSharesAndCPUPercent(c *testing.T) { testRequires(c, DaemonIsWindows, testEnv.DaemonInfo.Isolation.IsProcess) out, _ := dockerCmd(c, "run", "--cpu-count=1", "--cpu-shares=1000", "--cpu-percent=80", "--name", "test", "busybox", "echo", "testing") @@ -4121,7 +4133,7 @@ func (s *DockerSuite) TestRunProcessIsolationWithCPUCountCPUSharesAndCPUPercent( assert.Equal(c, out, "0") } -func (s *DockerSuite) TestRunHypervIsolationWithCPUCountCPUSharesAndCPUPercent(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunHypervIsolationWithCPUCountCPUSharesAndCPUPercent(c *testing.T) { testRequires(c, DaemonIsWindows, testEnv.DaemonInfo.Isolation.IsHyperV) out, _ := dockerCmd(c, "run", "--cpu-count=1", "--cpu-shares=1000", "--cpu-percent=80", "--name", "test", "busybox", "echo", "testing") @@ -4137,7 +4149,7 @@ func (s *DockerSuite) TestRunHypervIsolationWithCPUCountCPUSharesAndCPUPercent(c } // Test for #25099 -func (s *DockerSuite) TestRunEmptyEnv(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunEmptyEnv(c *testing.T) { testRequires(c, DaemonIsLinux) expectedOutput := "invalid environment variable:" @@ -4156,7 +4168,7 @@ func (s *DockerSuite) TestRunEmptyEnv(c *testing.T) { } // #28658 -func (s *DockerSuite) TestSlowStdinClosing(c *testing.T) { +func (s *DockerCLIRunSuite) TestSlowStdinClosing(c *testing.T) { if DaemonIsWindows() { skip.If(c, testEnv.GitHubActions()) } @@ -4194,7 +4206,7 @@ func (s *delayedReader) Read([]byte) (int, error) { } // #28823 (originally #28639) -func (s *DockerSuite) TestRunMountReadOnlyDevShm(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunMountReadOnlyDevShm(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux, NotUserNamespace) emptyDir, err := os.MkdirTemp("", "test-read-only-dev-shm") assert.NilError(c, err) @@ -4206,7 +4218,7 @@ func (s *DockerSuite) TestRunMountReadOnlyDevShm(c *testing.T) { assert.Assert(c, strings.Contains(out, "Read-only file system")) } -func (s *DockerSuite) TestRunMount(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunMount(c *testing.T) { testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon, NotUserNamespace) // mnt1, mnt2, and testCatFooBar are commonly used in multiple test cases @@ -4383,7 +4395,7 @@ func (s *DockerSuite) TestRunMount(c *testing.T) { // Test that passing a FQDN as hostname properly sets hostname, and // /etc/hostname. Test case for 29100 -func (s *DockerSuite) TestRunHostnameFQDN(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunHostnameFQDN(c *testing.T) { testRequires(c, DaemonIsLinux) expectedOutput := "foobar.example.com\nfoobar.example.com\nfoobar\nexample.com\nfoobar.example.com" @@ -4396,7 +4408,7 @@ func (s *DockerSuite) TestRunHostnameFQDN(c *testing.T) { } // Test case for 29129 -func (s *DockerSuite) TestRunHostnameInHostMode(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunHostnameInHostMode(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace) expectedOutput := "foobar\nfoobar" @@ -4404,7 +4416,7 @@ func (s *DockerSuite) TestRunHostnameInHostMode(c *testing.T) { assert.Equal(c, strings.TrimSpace(out), expectedOutput) } -func (s *DockerSuite) TestRunAddDeviceCgroupRule(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunAddDeviceCgroupRule(c *testing.T) { testRequires(c, DaemonIsLinux) deviceRule := "c 7:128 rwm" @@ -4419,7 +4431,7 @@ func (s *DockerSuite) TestRunAddDeviceCgroupRule(c *testing.T) { } // Verifies that running as local system is operating correctly on Windows -func (s *DockerSuite) TestWindowsRunAsSystem(c *testing.T) { +func (s *DockerCLIRunSuite) TestWindowsRunAsSystem(c *testing.T) { testRequires(c, DaemonIsWindows) out, _ := dockerCmd(c, "run", "--net=none", `--user=nt authority\system`, "--hostname=XYZZY", minimalBaseImage(), "cmd", "/c", `@echo %USERNAME%`) assert.Equal(c, strings.TrimSpace(out), "XYZZY$") diff --git a/integration-cli/docker_cli_run_unix_test.go b/integration-cli/docker_cli_run_unix_test.go index ef3d38769e..381776b239 100644 --- a/integration-cli/docker_cli_run_unix_test.go +++ b/integration-cli/docker_cli_run_unix_test.go @@ -31,7 +31,7 @@ import ( ) // #6509 -func (s *DockerSuite) TestRunRedirectStdout(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunRedirectStdout(c *testing.T) { checkRedirect := func(command string) { _, tty, err := pty.Open() assert.Assert(c, err == nil, "Could not open pty") @@ -59,7 +59,7 @@ func (s *DockerSuite) TestRunRedirectStdout(c *testing.T) { } // Test recursive bind mount works by default -func (s *DockerSuite) TestRunWithVolumesIsRecursive(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithVolumesIsRecursive(c *testing.T) { // /tmp gets permission denied testRequires(c, NotUserNamespace, testEnv.IsLocalDaemon) tmpDir, err := os.MkdirTemp("", "docker_recursive_mount_test") @@ -80,7 +80,7 @@ func (s *DockerSuite) TestRunWithVolumesIsRecursive(c *testing.T) { assert.Assert(c, strings.Contains(out, filepath.Base(f.Name())), "Recursive bind mount test failed. Expected file not found") } -func (s *DockerSuite) TestRunDeviceDirectory(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunDeviceDirectory(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm) if _, err := os.Stat("/dev/snd"); err != nil { c.Skip("Host does not have /dev/snd") @@ -93,7 +93,7 @@ func (s *DockerSuite) TestRunDeviceDirectory(c *testing.T) { } // TestRunAttachDetach checks attaching and detaching with the default escape sequence. -func (s *DockerSuite) TestRunAttachDetach(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunAttachDetach(c *testing.T) { name := "attach-detach" dockerCmd(c, "run", "--name", name, "-itd", "busybox", "cat") @@ -144,7 +144,7 @@ func (s *DockerSuite) TestRunAttachDetach(c *testing.T) { } // TestRunAttachDetachFromFlag checks attaching and detaching with the escape sequence specified via flags. -func (s *DockerSuite) TestRunAttachDetachFromFlag(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunAttachDetachFromFlag(c *testing.T) { name := "attach-detach" keyCtrlA := []byte{1} keyA := []byte{97} @@ -205,7 +205,7 @@ func (s *DockerSuite) TestRunAttachDetachFromFlag(c *testing.T) { } // TestRunAttachDetachFromInvalidFlag checks attaching and detaching with the escape sequence specified via flags. -func (s *DockerSuite) TestRunAttachDetachFromInvalidFlag(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunAttachDetachFromInvalidFlag(c *testing.T) { name := "attach-detach" dockerCmd(c, "run", "--name", name, "-itd", "busybox", "top") assert.Assert(c, waitRun(name) == nil) @@ -238,7 +238,7 @@ func (s *DockerSuite) TestRunAttachDetachFromInvalidFlag(c *testing.T) { } // TestRunAttachDetachFromConfig checks attaching and detaching with the escape sequence specified via config file. -func (s *DockerSuite) TestRunAttachDetachFromConfig(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunAttachDetachFromConfig(c *testing.T) { keyCtrlA := []byte{1} keyA := []byte{97} @@ -318,7 +318,7 @@ func (s *DockerSuite) TestRunAttachDetachFromConfig(c *testing.T) { } // TestRunAttachDetachKeysOverrideConfig checks attaching and detaching with the detach flags, making sure it overrides config file -func (s *DockerSuite) TestRunAttachDetachKeysOverrideConfig(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunAttachDetachKeysOverrideConfig(c *testing.T) { keyCtrlA := []byte{1} keyA := []byte{97} @@ -397,7 +397,7 @@ func (s *DockerSuite) TestRunAttachDetachKeysOverrideConfig(c *testing.T) { assert.Equal(c, running, "true", "expected container to still be running") } -func (s *DockerSuite) TestRunAttachInvalidDetachKeySequencePreserved(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunAttachInvalidDetachKeySequencePreserved(c *testing.T) { name := "attach-detach" keyA := []byte{97} keyB := []byte{98} @@ -448,7 +448,7 @@ func (s *DockerSuite) TestRunAttachInvalidDetachKeySequencePreserved(c *testing. } // "test" should be printed -func (s *DockerSuite) TestRunWithCPUQuota(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithCPUQuota(c *testing.T) { testRequires(c, cpuCfsQuota) file := "/sys/fs/cgroup/cpu/cpu.cfs_quota_us" @@ -459,7 +459,7 @@ func (s *DockerSuite) TestRunWithCPUQuota(c *testing.T) { assert.Equal(c, out, "8000", "setting the CPU CFS quota failed") } -func (s *DockerSuite) TestRunWithCpuPeriod(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithCpuPeriod(c *testing.T) { testRequires(c, cpuCfsPeriod) file := "/sys/fs/cgroup/cpu/cpu.cfs_period_us" @@ -473,7 +473,7 @@ func (s *DockerSuite) TestRunWithCpuPeriod(c *testing.T) { assert.Equal(c, out, "50000", "setting the CPU CFS period failed") } -func (s *DockerSuite) TestRunWithInvalidCpuPeriod(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithInvalidCpuPeriod(c *testing.T) { testRequires(c, cpuCfsPeriod) out, _, err := dockerCmdWithError("run", "--cpu-period", "900", "busybox", "true") assert.ErrorContains(c, err, "") @@ -489,7 +489,7 @@ func (s *DockerSuite) TestRunWithInvalidCpuPeriod(c *testing.T) { assert.Assert(c, strings.Contains(out, expected)) } -func (s *DockerSuite) TestRunWithCPUShares(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithCPUShares(c *testing.T) { testRequires(c, cpuShare) file := "/sys/fs/cgroup/cpu/cpu.shares" @@ -501,7 +501,7 @@ func (s *DockerSuite) TestRunWithCPUShares(c *testing.T) { } // "test" should be printed -func (s *DockerSuite) TestRunEchoStdoutWithCPUSharesAndMemoryLimit(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunEchoStdoutWithCPUSharesAndMemoryLimit(c *testing.T) { testRequires(c, cpuShare) testRequires(c, memoryLimitSupport) cli.DockerCmd(c, "run", "--cpu-shares", "1000", "-m", "32m", "busybox", "echo", "test").Assert(c, icmd.Expected{ @@ -509,7 +509,7 @@ func (s *DockerSuite) TestRunEchoStdoutWithCPUSharesAndMemoryLimit(c *testing.T) }) } -func (s *DockerSuite) TestRunWithCpusetCpus(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithCpusetCpus(c *testing.T) { testRequires(c, cgroupCpuset) file := "/sys/fs/cgroup/cpuset/cpuset.cpus" @@ -520,7 +520,7 @@ func (s *DockerSuite) TestRunWithCpusetCpus(c *testing.T) { assert.Equal(c, out, "0") } -func (s *DockerSuite) TestRunWithCpusetMems(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithCpusetMems(c *testing.T) { testRequires(c, cgroupCpuset) file := "/sys/fs/cgroup/cpuset/cpuset.mems" @@ -531,7 +531,7 @@ func (s *DockerSuite) TestRunWithCpusetMems(c *testing.T) { assert.Equal(c, out, "0") } -func (s *DockerSuite) TestRunWithBlkioWeight(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithBlkioWeight(c *testing.T) { testRequires(c, blkioWeight) file := "/sys/fs/cgroup/blkio/blkio.weight" @@ -542,7 +542,7 @@ func (s *DockerSuite) TestRunWithBlkioWeight(c *testing.T) { assert.Equal(c, out, "300") } -func (s *DockerSuite) TestRunWithInvalidBlkioWeight(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithInvalidBlkioWeight(c *testing.T) { testRequires(c, blkioWeight) out, _, err := dockerCmdWithError("run", "--blkio-weight", "5", "busybox", "true") assert.ErrorContains(c, err, "", out) @@ -550,37 +550,37 @@ func (s *DockerSuite) TestRunWithInvalidBlkioWeight(c *testing.T) { assert.Assert(c, strings.Contains(out, expected)) } -func (s *DockerSuite) TestRunWithInvalidPathforBlkioWeightDevice(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithInvalidPathforBlkioWeightDevice(c *testing.T) { testRequires(c, blkioWeight) out, _, err := dockerCmdWithError("run", "--blkio-weight-device", "/dev/sdX:100", "busybox", "true") assert.ErrorContains(c, err, "", out) } -func (s *DockerSuite) TestRunWithInvalidPathforBlkioDeviceReadBps(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithInvalidPathforBlkioDeviceReadBps(c *testing.T) { testRequires(c, blkioWeight) out, _, err := dockerCmdWithError("run", "--device-read-bps", "/dev/sdX:500", "busybox", "true") assert.ErrorContains(c, err, "", out) } -func (s *DockerSuite) TestRunWithInvalidPathforBlkioDeviceWriteBps(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithInvalidPathforBlkioDeviceWriteBps(c *testing.T) { testRequires(c, blkioWeight) out, _, err := dockerCmdWithError("run", "--device-write-bps", "/dev/sdX:500", "busybox", "true") assert.ErrorContains(c, err, "", out) } -func (s *DockerSuite) TestRunWithInvalidPathforBlkioDeviceReadIOps(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithInvalidPathforBlkioDeviceReadIOps(c *testing.T) { testRequires(c, blkioWeight) out, _, err := dockerCmdWithError("run", "--device-read-iops", "/dev/sdX:500", "busybox", "true") assert.ErrorContains(c, err, "", out) } -func (s *DockerSuite) TestRunWithInvalidPathforBlkioDeviceWriteIOps(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithInvalidPathforBlkioDeviceWriteIOps(c *testing.T) { testRequires(c, blkioWeight) out, _, err := dockerCmdWithError("run", "--device-write-iops", "/dev/sdX:500", "busybox", "true") assert.ErrorContains(c, err, "", out) } -func (s *DockerSuite) TestRunOOMExitCode(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunOOMExitCode(c *testing.T) { testRequires(c, memoryLimitSupport, swapMemorySupport, NotPpc64le) errChan := make(chan error, 1) go func() { @@ -600,7 +600,7 @@ func (s *DockerSuite) TestRunOOMExitCode(c *testing.T) { } } -func (s *DockerSuite) TestRunWithMemoryLimit(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithMemoryLimit(c *testing.T) { testRequires(c, memoryLimitSupport) file := "/sys/fs/cgroup/memory/memory.limit_in_bytes" @@ -616,14 +616,14 @@ func (s *DockerSuite) TestRunWithMemoryLimit(c *testing.T) { // memory limit, this means the processes in the container can use // 16M memory and as much swap memory as they need (if the host // supports swap memory). -func (s *DockerSuite) TestRunWithoutMemoryswapLimit(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithoutMemoryswapLimit(c *testing.T) { testRequires(c, DaemonIsLinux) testRequires(c, memoryLimitSupport) testRequires(c, swapMemorySupport) dockerCmd(c, "run", "-m", "32m", "--memory-swap", "-1", "busybox", "true") } -func (s *DockerSuite) TestRunWithSwappiness(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithSwappiness(c *testing.T) { testRequires(c, memorySwappinessSupport) file := "/sys/fs/cgroup/memory/memory.swappiness" out, _ := dockerCmd(c, "run", "--memory-swappiness", "0", "--name", "test", "busybox", "cat", file) @@ -633,7 +633,7 @@ func (s *DockerSuite) TestRunWithSwappiness(c *testing.T) { assert.Equal(c, out, "0") } -func (s *DockerSuite) TestRunWithSwappinessInvalid(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithSwappinessInvalid(c *testing.T) { testRequires(c, memorySwappinessSupport) out, _, err := dockerCmdWithError("run", "--memory-swappiness", "101", "busybox", "true") assert.ErrorContains(c, err, "") @@ -644,7 +644,7 @@ func (s *DockerSuite) TestRunWithSwappinessInvalid(c *testing.T) { assert.Assert(c, strings.Contains(out, expected), "Expected output to contain %q, not %q", out, expected) } -func (s *DockerSuite) TestRunWithMemoryReservation(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithMemoryReservation(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon, memoryReservationSupport) file := "/sys/fs/cgroup/memory/memory.soft_limit_in_bytes" @@ -655,7 +655,7 @@ func (s *DockerSuite) TestRunWithMemoryReservation(c *testing.T) { assert.Equal(c, out, "209715200") } -func (s *DockerSuite) TestRunWithMemoryReservationInvalid(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithMemoryReservationInvalid(c *testing.T) { testRequires(c, memoryLimitSupport) testRequires(c, testEnv.IsLocalDaemon, memoryReservationSupport) out, _, err := dockerCmdWithError("run", "-m", "500M", "--memory-reservation", "800M", "busybox", "true") @@ -668,7 +668,7 @@ func (s *DockerSuite) TestRunWithMemoryReservationInvalid(c *testing.T) { assert.Assert(c, strings.Contains(strings.TrimSpace(out), expected), "run container should fail with invalid memory reservation") } -func (s *DockerSuite) TestStopContainerSignal(c *testing.T) { +func (s *DockerCLIRunSuite) TestStopContainerSignal(c *testing.T) { out, _ := dockerCmd(c, "run", "--stop-signal", "SIGUSR1", "-d", "busybox", "/bin/sh", "-c", `trap 'echo "exit trapped"; exit 0' USR1; while true; do sleep 1; done`) containerID := strings.TrimSpace(out) @@ -680,7 +680,7 @@ func (s *DockerSuite) TestStopContainerSignal(c *testing.T) { assert.Assert(c, strings.Contains(out, "exit trapped"), "Expected `exit trapped` in the log") } -func (s *DockerSuite) TestRunSwapLessThanMemoryLimit(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunSwapLessThanMemoryLimit(c *testing.T) { testRequires(c, memoryLimitSupport) testRequires(c, swapMemorySupport) out, _, err := dockerCmdWithError("run", "-m", "16m", "--memory-swap", "15m", "busybox", "echo", "test") @@ -690,7 +690,7 @@ func (s *DockerSuite) TestRunSwapLessThanMemoryLimit(c *testing.T) { assert.Assert(c, strings.Contains(out, expected)) } -func (s *DockerSuite) TestRunInvalidCpusetCpusFlagValue(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunInvalidCpusetCpusFlagValue(c *testing.T) { testRequires(c, cgroupCpuset, testEnv.IsLocalDaemon) sysInfo := sysinfo.New() @@ -709,7 +709,7 @@ func (s *DockerSuite) TestRunInvalidCpusetCpusFlagValue(c *testing.T) { assert.Assert(c, strings.Contains(out, expected)) } -func (s *DockerSuite) TestRunInvalidCpusetMemsFlagValue(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunInvalidCpusetMemsFlagValue(c *testing.T) { testRequires(c, cgroupCpuset) sysInfo := sysinfo.New() @@ -728,7 +728,7 @@ func (s *DockerSuite) TestRunInvalidCpusetMemsFlagValue(c *testing.T) { assert.Assert(c, strings.Contains(out, expected)) } -func (s *DockerSuite) TestRunInvalidCPUShares(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunInvalidCPUShares(c *testing.T) { testRequires(c, cpuShare, DaemonIsLinux) out, _, err := dockerCmdWithError("run", "--cpu-shares", "1", "busybox", "echo", "test") assert.ErrorContains(c, err, "", out) @@ -746,7 +746,7 @@ func (s *DockerSuite) TestRunInvalidCPUShares(c *testing.T) { assert.Assert(c, strings.Contains(out, expected)) } -func (s *DockerSuite) TestRunWithDefaultShmSize(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithDefaultShmSize(c *testing.T) { testRequires(c, DaemonIsLinux) name := "shm-default" @@ -759,7 +759,7 @@ func (s *DockerSuite) TestRunWithDefaultShmSize(c *testing.T) { assert.Equal(c, shmSize, "67108864") } -func (s *DockerSuite) TestRunWithShmSize(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithShmSize(c *testing.T) { testRequires(c, DaemonIsLinux) name := "shm" @@ -772,7 +772,7 @@ func (s *DockerSuite) TestRunWithShmSize(c *testing.T) { assert.Equal(c, shmSize, "1073741824") } -func (s *DockerSuite) TestRunTmpfsMountsEnsureOrdered(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunTmpfsMountsEnsureOrdered(c *testing.T) { tmpFile, err := os.CreateTemp("", "test") assert.NilError(c, err) defer tmpFile.Close() @@ -780,7 +780,7 @@ func (s *DockerSuite) TestRunTmpfsMountsEnsureOrdered(c *testing.T) { assert.Assert(c, strings.Contains(out, "test")) } -func (s *DockerSuite) TestRunTmpfsMounts(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunTmpfsMounts(c *testing.T) { // TODO Windows (Post TP5): This test cannot run on a Windows daemon as // Windows does not support tmpfs mounts. testRequires(c, DaemonIsLinux) @@ -801,7 +801,7 @@ func (s *DockerSuite) TestRunTmpfsMounts(c *testing.T) { } } -func (s *DockerSuite) TestRunTmpfsMountsOverrideImageVolumes(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunTmpfsMountsOverrideImageVolumes(c *testing.T) { name := "img-with-volumes" buildImageSuccessfully(c, name, build.WithDockerfile(` FROM busybox @@ -813,7 +813,7 @@ func (s *DockerSuite) TestRunTmpfsMountsOverrideImageVolumes(c *testing.T) { } // Test case for #22420 -func (s *DockerSuite) TestRunTmpfsMountsWithOptions(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunTmpfsMountsWithOptions(c *testing.T) { testRequires(c, DaemonIsLinux) expectedOptions := []string{"rw", "nosuid", "nodev", "noexec", "relatime"} @@ -851,7 +851,7 @@ func (s *DockerSuite) TestRunTmpfsMountsWithOptions(c *testing.T) { } } -func (s *DockerSuite) TestRunSysctls(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunSysctls(c *testing.T) { testRequires(c, DaemonIsLinux) var err error @@ -882,7 +882,7 @@ func (s *DockerSuite) TestRunSysctls(c *testing.T) { } // TestRunSeccompProfileDenyUnshare checks that 'docker run --security-opt seccomp=/tmp/profile.json debian:bullseye-slim unshare' exits with operation not permitted. -func (s *DockerSuite) TestRunSeccompProfileDenyUnshare(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunSeccompProfileDenyUnshare(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon, seccompEnabled, NotArm, Apparmor) jsonData := `{ "defaultAction": "SCMP_ACT_ALLOW", @@ -911,7 +911,7 @@ func (s *DockerSuite) TestRunSeccompProfileDenyUnshare(c *testing.T) { } // TestRunSeccompProfileDenyChmod checks that 'docker run --security-opt seccomp=/tmp/profile.json busybox chmod 400 /etc/hostname' exits with operation not permitted. -func (s *DockerSuite) TestRunSeccompProfileDenyChmod(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunSeccompProfileDenyChmod(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon, seccompEnabled) jsonData := `{ "defaultAction": "SCMP_ACT_ALLOW", @@ -946,7 +946,7 @@ func (s *DockerSuite) TestRunSeccompProfileDenyChmod(c *testing.T) { // TestRunSeccompProfileDenyUnshareUserns checks that 'docker run debian:bullseye-slim unshare --map-root-user --user sh -c whoami' with a specific profile to // deny unshare of a userns exits with operation not permitted. -func (s *DockerSuite) TestRunSeccompProfileDenyUnshareUserns(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunSeccompProfileDenyUnshareUserns(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon, seccompEnabled, NotArm, Apparmor) // from sched.h jsonData := fmt.Sprintf(`{ @@ -984,7 +984,7 @@ func (s *DockerSuite) TestRunSeccompProfileDenyUnshareUserns(c *testing.T) { // TestRunSeccompProfileDenyCloneUserns checks that 'docker run syscall-test' // with a the default seccomp profile exits with operation not permitted. -func (s *DockerSuite) TestRunSeccompProfileDenyCloneUserns(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunSeccompProfileDenyCloneUserns(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon, seccompEnabled) ensureSyscallTest(c) @@ -996,7 +996,7 @@ func (s *DockerSuite) TestRunSeccompProfileDenyCloneUserns(c *testing.T) { // TestRunSeccompUnconfinedCloneUserns checks that // 'docker run --security-opt seccomp=unconfined syscall-test' allows creating a userns. -func (s *DockerSuite) TestRunSeccompUnconfinedCloneUserns(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunSeccompUnconfinedCloneUserns(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon, seccompEnabled, UserNamespaceInKernel, NotUserNamespace, unprivilegedUsernsClone) ensureSyscallTest(c) @@ -1009,7 +1009,7 @@ func (s *DockerSuite) TestRunSeccompUnconfinedCloneUserns(c *testing.T) { // TestRunSeccompAllowPrivCloneUserns checks that 'docker run --privileged syscall-test' // allows creating a userns. -func (s *DockerSuite) TestRunSeccompAllowPrivCloneUserns(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunSeccompAllowPrivCloneUserns(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon, seccompEnabled, UserNamespaceInKernel, NotUserNamespace) ensureSyscallTest(c) @@ -1021,7 +1021,7 @@ func (s *DockerSuite) TestRunSeccompAllowPrivCloneUserns(c *testing.T) { // TestRunSeccompProfileAllow32Bit checks that 32 bit code can run on x86_64 // with the default seccomp profile. -func (s *DockerSuite) TestRunSeccompProfileAllow32Bit(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunSeccompProfileAllow32Bit(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon, seccompEnabled, IsAmd64) ensureSyscallTest(c) @@ -1029,14 +1029,14 @@ func (s *DockerSuite) TestRunSeccompProfileAllow32Bit(c *testing.T) { } // TestRunSeccompAllowSetrlimit checks that 'docker run debian:bullseye-slim ulimit -v 1048510' succeeds. -func (s *DockerSuite) TestRunSeccompAllowSetrlimit(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunSeccompAllowSetrlimit(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon, seccompEnabled) // ulimit uses setrlimit, so we want to make sure we don't break it icmd.RunCommand(dockerBinary, "run", "debian:bullseye-slim", "bash", "-c", "ulimit -v 1048510").Assert(c, icmd.Success) } -func (s *DockerSuite) TestRunSeccompDefaultProfileAcct(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunSeccompDefaultProfileAcct(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon, seccompEnabled, NotUserNamespace) ensureSyscallTest(c) @@ -1066,7 +1066,7 @@ func (s *DockerSuite) TestRunSeccompDefaultProfileAcct(c *testing.T) { } } -func (s *DockerSuite) TestRunSeccompDefaultProfileNS(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunSeccompDefaultProfileNS(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon, seccompEnabled, NotUserNamespace) ensureSyscallTest(c) @@ -1103,7 +1103,7 @@ func (s *DockerSuite) TestRunSeccompDefaultProfileNS(c *testing.T) { // TestRunNoNewPrivSetuid checks that --security-opt='no-new-privileges=true' prevents // effective uid transitions on executing setuid binaries. -func (s *DockerSuite) TestRunNoNewPrivSetuid(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunNoNewPrivSetuid(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace, testEnv.IsLocalDaemon) ensureNNPTest(c) @@ -1116,7 +1116,7 @@ func (s *DockerSuite) TestRunNoNewPrivSetuid(c *testing.T) { // TestLegacyRunNoNewPrivSetuid checks that --security-opt=no-new-privileges prevents // effective uid transitions on executing setuid binaries. -func (s *DockerSuite) TestLegacyRunNoNewPrivSetuid(c *testing.T) { +func (s *DockerCLIRunSuite) TestLegacyRunNoNewPrivSetuid(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace, testEnv.IsLocalDaemon) ensureNNPTest(c) @@ -1127,7 +1127,7 @@ func (s *DockerSuite) TestLegacyRunNoNewPrivSetuid(c *testing.T) { }) } -func (s *DockerSuite) TestUserNoEffectiveCapabilitiesChown(c *testing.T) { +func (s *DockerCLIRunSuite) TestUserNoEffectiveCapabilitiesChown(c *testing.T) { testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) ensureSyscallTest(c) @@ -1145,7 +1145,7 @@ func (s *DockerSuite) TestUserNoEffectiveCapabilitiesChown(c *testing.T) { }) } -func (s *DockerSuite) TestUserNoEffectiveCapabilitiesDacOverride(c *testing.T) { +func (s *DockerCLIRunSuite) TestUserNoEffectiveCapabilitiesDacOverride(c *testing.T) { testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) ensureSyscallTest(c) @@ -1158,7 +1158,7 @@ func (s *DockerSuite) TestUserNoEffectiveCapabilitiesDacOverride(c *testing.T) { }) } -func (s *DockerSuite) TestUserNoEffectiveCapabilitiesFowner(c *testing.T) { +func (s *DockerCLIRunSuite) TestUserNoEffectiveCapabilitiesFowner(c *testing.T) { testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) ensureSyscallTest(c) @@ -1174,7 +1174,7 @@ func (s *DockerSuite) TestUserNoEffectiveCapabilitiesFowner(c *testing.T) { // TODO CAP_KILL -func (s *DockerSuite) TestUserNoEffectiveCapabilitiesSetuid(c *testing.T) { +func (s *DockerCLIRunSuite) TestUserNoEffectiveCapabilitiesSetuid(c *testing.T) { testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) ensureSyscallTest(c) @@ -1192,7 +1192,7 @@ func (s *DockerSuite) TestUserNoEffectiveCapabilitiesSetuid(c *testing.T) { }) } -func (s *DockerSuite) TestUserNoEffectiveCapabilitiesSetgid(c *testing.T) { +func (s *DockerCLIRunSuite) TestUserNoEffectiveCapabilitiesSetgid(c *testing.T) { testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) ensureSyscallTest(c) @@ -1220,7 +1220,7 @@ func sysctlExists(s string) bool { return err == nil } -func (s *DockerSuite) TestUserNoEffectiveCapabilitiesNetBindService(c *testing.T) { +func (s *DockerCLIRunSuite) TestUserNoEffectiveCapabilitiesNetBindService(c *testing.T) { testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) ensureSyscallTest(c) @@ -1249,7 +1249,7 @@ func (s *DockerSuite) TestUserNoEffectiveCapabilitiesNetBindService(c *testing.T }) } -func (s *DockerSuite) TestUserNoEffectiveCapabilitiesNetRaw(c *testing.T) { +func (s *DockerCLIRunSuite) TestUserNoEffectiveCapabilitiesNetRaw(c *testing.T) { testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) ensureSyscallTest(c) @@ -1267,7 +1267,7 @@ func (s *DockerSuite) TestUserNoEffectiveCapabilitiesNetRaw(c *testing.T) { }) } -func (s *DockerSuite) TestUserNoEffectiveCapabilitiesChroot(c *testing.T) { +func (s *DockerCLIRunSuite) TestUserNoEffectiveCapabilitiesChroot(c *testing.T) { testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) ensureSyscallTest(c) @@ -1285,7 +1285,7 @@ func (s *DockerSuite) TestUserNoEffectiveCapabilitiesChroot(c *testing.T) { }) } -func (s *DockerSuite) TestUserNoEffectiveCapabilitiesMknod(c *testing.T) { +func (s *DockerCLIRunSuite) TestUserNoEffectiveCapabilitiesMknod(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace, testEnv.IsLocalDaemon) ensureSyscallTest(c) @@ -1307,7 +1307,7 @@ func (s *DockerSuite) TestUserNoEffectiveCapabilitiesMknod(c *testing.T) { // TODO CAP_AUDIT_WRITE // TODO CAP_SETFCAP -func (s *DockerSuite) TestRunApparmorProcDirectory(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunApparmorProcDirectory(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon, Apparmor) // running w seccomp unconfined tests the apparmor profile @@ -1326,7 +1326,7 @@ func (s *DockerSuite) TestRunApparmorProcDirectory(c *testing.T) { // make sure the default profile can be successfully parsed (using unshare as it is // something which we know is blocked in the default profile) -func (s *DockerSuite) TestRunSeccompWithDefaultProfile(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunSeccompWithDefaultProfile(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon, seccompEnabled) out, _, err := dockerCmdWithError("run", "--security-opt", "seccomp=../profiles/seccomp/default.json", "debian:bullseye-slim", "unshare", "--map-root-user", "--user", "sh", "-c", "whoami") @@ -1335,7 +1335,7 @@ func (s *DockerSuite) TestRunSeccompWithDefaultProfile(c *testing.T) { } // TestRunDeviceSymlink checks run with device that follows symlink (#13840 and #22271) -func (s *DockerSuite) TestRunDeviceSymlink(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunDeviceSymlink(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm, testEnv.IsLocalDaemon) if _, err := os.Stat("/dev/zero"); err != nil { c.Skip("Host does not have /dev/zero") @@ -1382,7 +1382,7 @@ func (s *DockerSuite) TestRunDeviceSymlink(c *testing.T) { } // TestRunPIDsLimit makes sure the pids cgroup is set with --pids-limit -func (s *DockerSuite) TestRunPIDsLimit(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunPIDsLimit(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon, pidsLimit) file := "/sys/fs/cgroup/pids/pids.max" @@ -1393,7 +1393,7 @@ func (s *DockerSuite) TestRunPIDsLimit(c *testing.T) { assert.Equal(c, out, "4", "setting the pids limit failed") } -func (s *DockerSuite) TestRunPrivilegedAllowedDevices(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunPrivilegedAllowedDevices(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace) file := "/sys/fs/cgroup/devices/devices.list" @@ -1402,7 +1402,7 @@ func (s *DockerSuite) TestRunPrivilegedAllowedDevices(c *testing.T) { assert.Equal(c, strings.TrimSpace(out), "a *:* rwm") } -func (s *DockerSuite) TestRunUserDeviceAllowed(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunUserDeviceAllowed(c *testing.T) { testRequires(c, DaemonIsLinux) fi, err := os.Stat("/dev/snd/timer") @@ -1543,7 +1543,7 @@ func (s *DockerDaemonSuite) TestRunWithDaemonDefaultSeccompProfile(c *testing.T) assert.Assert(c, strings.Contains(out, "Operation not permitted")) } -func (s *DockerSuite) TestRunWithNanoCPUs(c *testing.T) { +func (s *DockerCLIRunSuite) TestRunWithNanoCPUs(c *testing.T) { testRequires(c, cpuCfsQuota, cpuCfsPeriod) file1 := "/sys/fs/cgroup/cpu/cpu.cfs_quota_us" diff --git a/integration-cli/docker_cli_save_load_test.go b/integration-cli/docker_cli_save_load_test.go index 5bbd440b3c..0f9e1d5255 100644 --- a/integration-cli/docker_cli_save_load_test.go +++ b/integration-cli/docker_cli_save_load_test.go @@ -22,8 +22,20 @@ import ( "gotest.tools/v3/icmd" ) +type DockerCLISaveLoadSuite struct { + ds *DockerSuite +} + +func (s *DockerCLISaveLoadSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLISaveLoadSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + // save a repo using gz compression and try to load it using stdout -func (s *DockerSuite) TestSaveXzAndLoadRepoStdout(c *testing.T) { +func (s *DockerCLISaveLoadSuite) TestSaveXzAndLoadRepoStdout(c *testing.T) { testRequires(c, DaemonIsLinux) name := "test-save-xz-and-load-repo-stdout" dockerCmd(c, "run", "--name", name, "busybox", "true") @@ -52,7 +64,7 @@ func (s *DockerSuite) TestSaveXzAndLoadRepoStdout(c *testing.T) { } // save a repo using xz+gz compression and try to load it using stdout -func (s *DockerSuite) TestSaveXzGzAndLoadRepoStdout(c *testing.T) { +func (s *DockerCLISaveLoadSuite) TestSaveXzGzAndLoadRepoStdout(c *testing.T) { testRequires(c, DaemonIsLinux) name := "test-save-xz-gz-and-load-repo-stdout" dockerCmd(c, "run", "--name", name, "busybox", "true") @@ -81,7 +93,7 @@ func (s *DockerSuite) TestSaveXzGzAndLoadRepoStdout(c *testing.T) { assert.ErrorContains(c, err, "", "the repo should not exist: %v", after) } -func (s *DockerSuite) TestSaveSingleTag(c *testing.T) { +func (s *DockerCLISaveLoadSuite) TestSaveSingleTag(c *testing.T) { testRequires(c, DaemonIsLinux) repoName := "foobar-save-single-tag-test" dockerCmd(c, "tag", "busybox:latest", fmt.Sprintf("%v:latest", repoName)) @@ -96,7 +108,7 @@ func (s *DockerSuite) TestSaveSingleTag(c *testing.T) { assert.NilError(c, err, "failed to save repo with image ID and 'repositories' file: %s, %v", out, err) } -func (s *DockerSuite) TestSaveCheckTimes(c *testing.T) { +func (s *DockerCLISaveLoadSuite) TestSaveCheckTimes(c *testing.T) { testRequires(c, DaemonIsLinux) repoName := "busybox:latest" out, _ := dockerCmd(c, "inspect", repoName) @@ -115,7 +127,7 @@ func (s *DockerSuite) TestSaveCheckTimes(c *testing.T) { assert.NilError(c, err, "failed to save repo with image ID and 'repositories' file: %s, %v", out, err) } -func (s *DockerSuite) TestSaveImageId(c *testing.T) { +func (s *DockerCLISaveLoadSuite) TestSaveImageId(c *testing.T) { testRequires(c, DaemonIsLinux) repoName := "foobar-save-image-id-test" dockerCmd(c, "tag", "emptyfs:latest", fmt.Sprintf("%v:latest", repoName)) @@ -154,7 +166,7 @@ func (s *DockerSuite) TestSaveImageId(c *testing.T) { } // save a repo and try to load it using flags -func (s *DockerSuite) TestSaveAndLoadRepoFlags(c *testing.T) { +func (s *DockerCLISaveLoadSuite) TestSaveAndLoadRepoFlags(c *testing.T) { testRequires(c, DaemonIsLinux) name := "test-save-and-load-repo-flags" dockerCmd(c, "run", "--name", name, "busybox", "true") @@ -175,7 +187,7 @@ func (s *DockerSuite) TestSaveAndLoadRepoFlags(c *testing.T) { assert.Equal(c, before, after, "inspect is not the same after a save / load") } -func (s *DockerSuite) TestSaveWithNoExistImage(c *testing.T) { +func (s *DockerCLISaveLoadSuite) TestSaveWithNoExistImage(c *testing.T) { testRequires(c, DaemonIsLinux) imgName := "foobar-non-existing-image" @@ -185,7 +197,7 @@ func (s *DockerSuite) TestSaveWithNoExistImage(c *testing.T) { assert.Assert(c, strings.Contains(out, fmt.Sprintf("No such image: %s", imgName))) } -func (s *DockerSuite) TestSaveMultipleNames(c *testing.T) { +func (s *DockerCLISaveLoadSuite) TestSaveMultipleNames(c *testing.T) { testRequires(c, DaemonIsLinux) repoName := "foobar-save-multi-name-test" @@ -203,7 +215,7 @@ func (s *DockerSuite) TestSaveMultipleNames(c *testing.T) { assert.NilError(c, err, "failed to save multiple repos: %s, %v", out, err) } -func (s *DockerSuite) TestSaveRepoWithMultipleImages(c *testing.T) { +func (s *DockerCLISaveLoadSuite) TestSaveRepoWithMultipleImages(c *testing.T) { testRequires(c, DaemonIsLinux) makeImage := func(from string, tag string) string { var ( @@ -255,7 +267,7 @@ func (s *DockerSuite) TestSaveRepoWithMultipleImages(c *testing.T) { } // Issue #6722 #5892 ensure directories are included in changes -func (s *DockerSuite) TestSaveDirectoryPermissions(c *testing.T) { +func (s *DockerCLISaveLoadSuite) TestSaveDirectoryPermissions(c *testing.T) { testRequires(c, DaemonIsLinux) layerEntries := []string{"opt/", "opt/a/", "opt/a/b/", "opt/a/b/c"} layerEntriesAUFS := []string{"./", ".wh..wh.aufs", ".wh..wh.orph/", ".wh..wh.plnk/", "opt/", "opt/a/", "opt/a/b/", "opt/a/b/c"} @@ -329,7 +341,7 @@ func listTar(f io.Reader) ([]string, error) { // Test loading a weird image where one of the layers is of zero size. // The layer.tar file is actually zero bytes, no padding or anything else. // See issue: 18170 -func (s *DockerSuite) TestLoadZeroSizeLayer(c *testing.T) { +func (s *DockerCLISaveLoadSuite) TestLoadZeroSizeLayer(c *testing.T) { // this will definitely not work if using remote daemon // very weird test testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) @@ -337,7 +349,7 @@ func (s *DockerSuite) TestLoadZeroSizeLayer(c *testing.T) { dockerCmd(c, "load", "-i", "testdata/emptyLayer.tar") } -func (s *DockerSuite) TestSaveLoadParents(c *testing.T) { +func (s *DockerCLISaveLoadSuite) TestSaveLoadParents(c *testing.T) { testRequires(c, DaemonIsLinux) makeImage := func(from string, addfile string) string { @@ -376,7 +388,7 @@ func (s *DockerSuite) TestSaveLoadParents(c *testing.T) { assert.Equal(c, inspectOut, "") } -func (s *DockerSuite) TestSaveLoadNoTag(c *testing.T) { +func (s *DockerCLISaveLoadSuite) TestSaveLoadNoTag(c *testing.T) { testRequires(c, DaemonIsLinux) name := "saveloadnotag" diff --git a/integration-cli/docker_cli_save_load_unix_test.go b/integration-cli/docker_cli_save_load_unix_test.go index 89776b9263..d0ae355a11 100644 --- a/integration-cli/docker_cli_save_load_unix_test.go +++ b/integration-cli/docker_cli_save_load_unix_test.go @@ -19,7 +19,7 @@ import ( ) // save a repo and try to load it using stdout -func (s *DockerSuite) TestSaveAndLoadRepoStdout(c *testing.T) { +func (s *DockerCLISaveLoadSuite) TestSaveAndLoadRepoStdout(c *testing.T) { name := "test-save-and-load-repo-stdout" dockerCmd(c, "run", "--name", name, "busybox", "true") @@ -70,7 +70,7 @@ func (s *DockerSuite) TestSaveAndLoadRepoStdout(c *testing.T) { assert.Assert(c, strings.Contains(string(buf[:n]), "cowardly refusing"), "help output is not being yielded") } -func (s *DockerSuite) TestSaveAndLoadWithProgressBar(c *testing.T) { +func (s *DockerCLISaveLoadSuite) TestSaveAndLoadWithProgressBar(c *testing.T) { name := "test-load" buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox RUN touch aa @@ -88,7 +88,7 @@ func (s *DockerSuite) TestSaveAndLoadWithProgressBar(c *testing.T) { } // fail because load didn't receive data from stdin -func (s *DockerSuite) TestLoadNoStdinFail(c *testing.T) { +func (s *DockerCLISaveLoadSuite) TestLoadNoStdinFail(c *testing.T) { pty, tty, err := pty.Open() assert.NilError(c, err) ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) diff --git a/integration-cli/docker_cli_search_test.go b/integration-cli/docker_cli_search_test.go index a61c5e7cdc..3c60ca9df9 100644 --- a/integration-cli/docker_cli_search_test.go +++ b/integration-cli/docker_cli_search_test.go @@ -8,13 +8,25 @@ import ( "gotest.tools/v3/assert" ) +type DockerCLISearchSuite struct { + ds *DockerSuite +} + +func (s *DockerCLISearchSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLISearchSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + // search for repos named "registry" on the central registry -func (s *DockerSuite) TestSearchOnCentralRegistry(c *testing.T) { +func (s *DockerCLISearchSuite) TestSearchOnCentralRegistry(c *testing.T) { out, _ := dockerCmd(c, "search", "busybox") assert.Assert(c, strings.Contains(out, "Busybox base image."), "couldn't find any repository named (or containing) 'Busybox base image.'") } -func (s *DockerSuite) TestSearchStarsOptionWithWrongParameter(c *testing.T) { +func (s *DockerCLISearchSuite) TestSearchStarsOptionWithWrongParameter(c *testing.T) { out, _, err := dockerCmdWithError("search", "--filter", "stars=a", "busybox") assert.ErrorContains(c, err, "", out) assert.Assert(c, strings.Contains(out, "invalid filter"), "couldn't find the invalid filter warning") @@ -32,7 +44,7 @@ func (s *DockerSuite) TestSearchStarsOptionWithWrongParameter(c *testing.T) { assert.Assert(c, strings.Contains(out, "invalid filter"), "couldn't find the invalid filter warning") } -func (s *DockerSuite) TestSearchCmdOptions(c *testing.T) { +func (s *DockerCLISearchSuite) TestSearchCmdOptions(c *testing.T) { outSearchCmd, _ := dockerCmd(c, "search", "busybox") assert.Assert(c, strings.Count(outSearchCmd, "\n") > 3, outSearchCmd) @@ -60,12 +72,12 @@ func (s *DockerSuite) TestSearchCmdOptions(c *testing.T) { } // search for repos which start with "ubuntu-" on the central registry -func (s *DockerSuite) TestSearchOnCentralRegistryWithDash(c *testing.T) { +func (s *DockerCLISearchSuite) TestSearchOnCentralRegistryWithDash(c *testing.T) { dockerCmd(c, "search", "ubuntu-") } // test case for #23055 -func (s *DockerSuite) TestSearchWithLimit(c *testing.T) { +func (s *DockerCLISearchSuite) TestSearchWithLimit(c *testing.T) { for _, limit := range []int{10, 50, 100} { out, _, err := dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker") assert.NilError(c, err) diff --git a/integration-cli/docker_cli_sni_test.go b/integration-cli/docker_cli_sni_test.go index 90e4f095d5..23dc0969c9 100644 --- a/integration-cli/docker_cli_sni_test.go +++ b/integration-cli/docker_cli_sni_test.go @@ -14,7 +14,19 @@ import ( "gotest.tools/v3/assert" ) -func (s *DockerSuite) TestClientSetsTLSServerName(c *testing.T) { +type DockerCLISNISuite struct { + ds *DockerSuite +} + +func (s *DockerCLISNISuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLISNISuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + +func (s *DockerCLISNISuite) TestClientSetsTLSServerName(c *testing.T) { c.Skip("Flakey test") // there may be more than one hit to the server for each registry request var serverNameReceived []string diff --git a/integration-cli/docker_cli_start_test.go b/integration-cli/docker_cli_start_test.go index 45271911c7..eb91b69574 100644 --- a/integration-cli/docker_cli_start_test.go +++ b/integration-cli/docker_cli_start_test.go @@ -11,8 +11,20 @@ import ( "gotest.tools/v3/icmd" ) +type DockerCLIStartSuite struct { + ds *DockerSuite +} + +func (s *DockerCLIStartSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLIStartSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + // Regression test for https://github.com/docker/docker/issues/7843 -func (s *DockerSuite) TestStartAttachReturnsOnError(c *testing.T) { +func (s *DockerCLIStartSuite) TestStartAttachReturnsOnError(c *testing.T) { // Windows does not support link testRequires(c, DaemonIsLinux) dockerCmd(c, "run", "--name", "test", "busybox") @@ -41,7 +53,7 @@ func (s *DockerSuite) TestStartAttachReturnsOnError(c *testing.T) { } // gh#8555: Exit code should be passed through when using start -a -func (s *DockerSuite) TestStartAttachCorrectExitCode(c *testing.T) { +func (s *DockerCLIStartSuite) TestStartAttachCorrectExitCode(c *testing.T) { testRequires(c, DaemonIsLinux) out := cli.DockerCmd(c, "run", "-d", "busybox", "sh", "-c", "sleep 2; exit 1").Stdout() out = strings.TrimSpace(out) @@ -54,7 +66,7 @@ func (s *DockerSuite) TestStartAttachCorrectExitCode(c *testing.T) { }) } -func (s *DockerSuite) TestStartAttachSilent(c *testing.T) { +func (s *DockerCLIStartSuite) TestStartAttachSilent(c *testing.T) { name := "teststartattachcorrectexitcode" dockerCmd(c, "run", "--name", name, "busybox", "echo", "test") @@ -66,7 +78,7 @@ func (s *DockerSuite) TestStartAttachSilent(c *testing.T) { assert.Equal(c, startOut, "test\n") } -func (s *DockerSuite) TestStartRecordError(c *testing.T) { +func (s *DockerCLIStartSuite) TestStartRecordError(c *testing.T) { // TODO Windows CI: Requires further porting work. Should be possible. testRequires(c, DaemonIsLinux) // when container runs successfully, we should not have state.Error @@ -90,7 +102,7 @@ func (s *DockerSuite) TestStartRecordError(c *testing.T) { assert.Equal(c, stateErr, "") } -func (s *DockerSuite) TestStartPausedContainer(c *testing.T) { +func (s *DockerCLIStartSuite) TestStartPausedContainer(c *testing.T) { // Windows does not support pausing containers testRequires(c, IsPausable) @@ -105,7 +117,7 @@ func (s *DockerSuite) TestStartPausedContainer(c *testing.T) { assert.Assert(c, strings.Contains(strings.ToLower(out), "cannot start a paused container, try unpause instead")) } -func (s *DockerSuite) TestStartMultipleContainers(c *testing.T) { +func (s *DockerCLIStartSuite) TestStartMultipleContainers(c *testing.T) { // Windows does not support --link testRequires(c, DaemonIsLinux) // run a container named 'parent' and create two container link to `parent` @@ -141,7 +153,7 @@ func (s *DockerSuite) TestStartMultipleContainers(c *testing.T) { } } -func (s *DockerSuite) TestStartAttachMultipleContainers(c *testing.T) { +func (s *DockerCLIStartSuite) TestStartAttachMultipleContainers(c *testing.T) { // run multiple containers to test for _, container := range []string{"test1", "test2", "test3"} { runSleepingContainer(c, "--name", container) @@ -170,7 +182,7 @@ func (s *DockerSuite) TestStartAttachMultipleContainers(c *testing.T) { } // Test case for #23716 -func (s *DockerSuite) TestStartAttachWithRename(c *testing.T) { +func (s *DockerCLIStartSuite) TestStartAttachWithRename(c *testing.T) { testRequires(c, DaemonIsLinux) cli.DockerCmd(c, "create", "-t", "--name", "before", "busybox") go func() { @@ -185,7 +197,7 @@ func (s *DockerSuite) TestStartAttachWithRename(c *testing.T) { assert.Assert(c, !strings.Contains(result.Stderr(), "No such container")) } -func (s *DockerSuite) TestStartReturnCorrectExitCode(c *testing.T) { +func (s *DockerCLIStartSuite) TestStartReturnCorrectExitCode(c *testing.T) { cli.DockerCmd(c, "create", "--restart=on-failure:2", "--name", "withRestart", "busybox", "sh", "-c", "exit 11") cli.DockerCmd(c, "create", "--rm", "--name", "withRm", "busybox", "sh", "-c", "exit 12") cli.Docker(cli.Args("start", "-a", "withRestart")).Assert(c, icmd.Expected{ExitCode: 11}) diff --git a/integration-cli/docker_cli_stats_test.go b/integration-cli/docker_cli_stats_test.go index 5941e6b294..c29f10cab4 100644 --- a/integration-cli/docker_cli_stats_test.go +++ b/integration-cli/docker_cli_stats_test.go @@ -13,7 +13,19 @@ import ( is "gotest.tools/v3/assert/cmp" ) -func (s *DockerSuite) TestStatsNoStream(c *testing.T) { +type DockerCLIStatsSuite struct { + ds *DockerSuite +} + +func (s *DockerCLIStatsSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLIStatsSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + +func (s *DockerCLIStatsSuite) TestStatsNoStream(c *testing.T) { // Windows does not support stats testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "run", "-d", "busybox", "top") @@ -42,7 +54,7 @@ func (s *DockerSuite) TestStatsNoStream(c *testing.T) { } } -func (s *DockerSuite) TestStatsContainerNotFound(c *testing.T) { +func (s *DockerCLIStatsSuite) TestStatsContainerNotFound(c *testing.T) { // Windows does not support stats testRequires(c, DaemonIsLinux) @@ -55,7 +67,7 @@ func (s *DockerSuite) TestStatsContainerNotFound(c *testing.T) { assert.Assert(c, is.Contains(out, "No such container: notfound"), "Expected to fail on not found container stats with --no-stream, got %q instead", out) } -func (s *DockerSuite) TestStatsAllRunningNoStream(c *testing.T) { +func (s *DockerCLIStatsSuite) TestStatsAllRunningNoStream(c *testing.T) { // Windows does not support stats testRequires(c, DaemonIsLinux) @@ -91,7 +103,7 @@ func (s *DockerSuite) TestStatsAllRunningNoStream(c *testing.T) { assert.Assert(c, realData != nil, "stat result are empty: %s", out) } -func (s *DockerSuite) TestStatsAllNoStream(c *testing.T) { +func (s *DockerCLIStatsSuite) TestStatsAllNoStream(c *testing.T) { // Windows does not support stats testRequires(c, DaemonIsLinux) @@ -121,7 +133,7 @@ func (s *DockerSuite) TestStatsAllNoStream(c *testing.T) { assert.Assert(c, realData == nil, "stat result of %s should be empty : %s", id1, out) } -func (s *DockerSuite) TestStatsAllNewContainersAdded(c *testing.T) { +func (s *DockerCLIStatsSuite) TestStatsAllNewContainersAdded(c *testing.T) { // Windows does not support stats testRequires(c, DaemonIsLinux) @@ -162,7 +174,7 @@ func (s *DockerSuite) TestStatsAllNewContainersAdded(c *testing.T) { } } -func (s *DockerSuite) TestStatsFormatAll(c *testing.T) { +func (s *DockerCLIStatsSuite) TestStatsFormatAll(c *testing.T) { // Windows does not support stats testRequires(c, DaemonIsLinux) diff --git a/integration-cli/docker_cli_top_test.go b/integration-cli/docker_cli_top_test.go index 9bc29f39c6..5426992376 100644 --- a/integration-cli/docker_cli_top_test.go +++ b/integration-cli/docker_cli_top_test.go @@ -8,7 +8,19 @@ import ( "gotest.tools/v3/icmd" ) -func (s *DockerSuite) TestTopMultipleArgs(c *testing.T) { +type DockerCLITopSuite struct { + ds *DockerSuite +} + +func (s *DockerCLITopSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLITopSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + +func (s *DockerCLITopSuite) TestTopMultipleArgs(c *testing.T) { out := runSleepingContainer(c, "-d") cleanedContainerID := strings.TrimSpace(out) @@ -23,7 +35,7 @@ func (s *DockerSuite) TestTopMultipleArgs(c *testing.T) { result.Assert(c, expected) } -func (s *DockerSuite) TestTopNonPrivileged(c *testing.T) { +func (s *DockerCLITopSuite) TestTopNonPrivileged(c *testing.T) { out := runSleepingContainer(c, "-d") cleanedContainerID := strings.TrimSpace(out) @@ -47,7 +59,7 @@ func (s *DockerSuite) TestTopNonPrivileged(c *testing.T) { // TestTopWindowsCoreProcesses validates that there are lines for the critical // processes which are found in a Windows container. Note Windows is architecturally // very different to Linux in this regard. -func (s *DockerSuite) TestTopWindowsCoreProcesses(c *testing.T) { +func (s *DockerCLITopSuite) TestTopWindowsCoreProcesses(c *testing.T) { testRequires(c, DaemonIsWindows) out := runSleepingContainer(c, "-d") cleanedContainerID := strings.TrimSpace(out) @@ -58,7 +70,7 @@ func (s *DockerSuite) TestTopWindowsCoreProcesses(c *testing.T) { } } -func (s *DockerSuite) TestTopPrivileged(c *testing.T) { +func (s *DockerCLITopSuite) TestTopPrivileged(c *testing.T) { // Windows does not support --privileged testRequires(c, DaemonIsLinux, NotUserNamespace) out, _ := dockerCmd(c, "run", "--privileged", "-i", "-d", "busybox", "top") diff --git a/integration-cli/docker_cli_update_test.go b/integration-cli/docker_cli_update_test.go new file mode 100644 index 0000000000..06917ed064 --- /dev/null +++ b/integration-cli/docker_cli_update_test.go @@ -0,0 +1,5 @@ +package main + +type DockerCLIUpdateSuite struct { + ds *DockerSuite +} diff --git a/integration-cli/docker_cli_update_unix_test.go b/integration-cli/docker_cli_update_unix_test.go index 459b70e646..32ff33363f 100644 --- a/integration-cli/docker_cli_update_unix_test.go +++ b/integration-cli/docker_cli_update_unix_test.go @@ -19,7 +19,15 @@ import ( "gotest.tools/v3/assert" ) -func (s *DockerSuite) TestUpdateRunningContainer(c *testing.T) { +func (s *DockerCLIUpdateSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLIUpdateSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + +func (s *DockerCLIUpdateSuite) TestUpdateRunningContainer(c *testing.T) { testRequires(c, DaemonIsLinux) testRequires(c, memoryLimitSupport) @@ -34,7 +42,7 @@ func (s *DockerSuite) TestUpdateRunningContainer(c *testing.T) { assert.Equal(c, strings.TrimSpace(out), "524288000") } -func (s *DockerSuite) TestUpdateRunningContainerWithRestart(c *testing.T) { +func (s *DockerCLIUpdateSuite) TestUpdateRunningContainerWithRestart(c *testing.T) { testRequires(c, DaemonIsLinux) testRequires(c, memoryLimitSupport) @@ -50,7 +58,7 @@ func (s *DockerSuite) TestUpdateRunningContainerWithRestart(c *testing.T) { assert.Equal(c, strings.TrimSpace(out), "524288000") } -func (s *DockerSuite) TestUpdateStoppedContainer(c *testing.T) { +func (s *DockerCLIUpdateSuite) TestUpdateStoppedContainer(c *testing.T) { testRequires(c, DaemonIsLinux) testRequires(c, memoryLimitSupport) @@ -65,7 +73,7 @@ func (s *DockerSuite) TestUpdateStoppedContainer(c *testing.T) { assert.Equal(c, strings.TrimSpace(out), "524288000") } -func (s *DockerSuite) TestUpdatePausedContainer(c *testing.T) { +func (s *DockerCLIUpdateSuite) TestUpdatePausedContainer(c *testing.T) { testRequires(c, DaemonIsLinux) testRequires(c, cpuShare) @@ -82,7 +90,7 @@ func (s *DockerSuite) TestUpdatePausedContainer(c *testing.T) { assert.Equal(c, strings.TrimSpace(out), "500") } -func (s *DockerSuite) TestUpdateWithUntouchedFields(c *testing.T) { +func (s *DockerCLIUpdateSuite) TestUpdateWithUntouchedFields(c *testing.T) { testRequires(c, DaemonIsLinux) testRequires(c, memoryLimitSupport) testRequires(c, cpuShare) @@ -100,7 +108,7 @@ func (s *DockerSuite) TestUpdateWithUntouchedFields(c *testing.T) { assert.Equal(c, strings.TrimSpace(out), "800") } -func (s *DockerSuite) TestUpdateContainerInvalidValue(c *testing.T) { +func (s *DockerCLIUpdateSuite) TestUpdateContainerInvalidValue(c *testing.T) { testRequires(c, DaemonIsLinux) testRequires(c, memoryLimitSupport) @@ -112,7 +120,7 @@ func (s *DockerSuite) TestUpdateContainerInvalidValue(c *testing.T) { assert.Assert(c, strings.Contains(out, expected)) } -func (s *DockerSuite) TestUpdateContainerWithoutFlags(c *testing.T) { +func (s *DockerCLIUpdateSuite) TestUpdateContainerWithoutFlags(c *testing.T) { testRequires(c, DaemonIsLinux) testRequires(c, memoryLimitSupport) @@ -122,7 +130,7 @@ func (s *DockerSuite) TestUpdateContainerWithoutFlags(c *testing.T) { assert.ErrorContains(c, err, "") } -func (s *DockerSuite) TestUpdateSwapMemoryOnly(c *testing.T) { +func (s *DockerCLIUpdateSuite) TestUpdateSwapMemoryOnly(c *testing.T) { testRequires(c, DaemonIsLinux) testRequires(c, memoryLimitSupport) testRequires(c, swapMemorySupport) @@ -138,7 +146,7 @@ func (s *DockerSuite) TestUpdateSwapMemoryOnly(c *testing.T) { assert.Equal(c, strings.TrimSpace(out), "629145600") } -func (s *DockerSuite) TestUpdateInvalidSwapMemory(c *testing.T) { +func (s *DockerCLIUpdateSuite) TestUpdateInvalidSwapMemory(c *testing.T) { testRequires(c, DaemonIsLinux) testRequires(c, memoryLimitSupport) testRequires(c, swapMemorySupport) @@ -163,7 +171,7 @@ func (s *DockerSuite) TestUpdateInvalidSwapMemory(c *testing.T) { assert.Equal(c, strings.TrimSpace(out), "629145600") } -func (s *DockerSuite) TestUpdateStats(c *testing.T) { +func (s *DockerCLIUpdateSuite) TestUpdateStats(c *testing.T) { testRequires(c, DaemonIsLinux) testRequires(c, memoryLimitSupport) testRequires(c, cpuCfsQuota) @@ -192,7 +200,7 @@ func (s *DockerSuite) TestUpdateStats(c *testing.T) { assert.Equal(c, preMemLimit, curMemLimit) } -func (s *DockerSuite) TestUpdateMemoryWithSwapMemory(c *testing.T) { +func (s *DockerCLIUpdateSuite) TestUpdateMemoryWithSwapMemory(c *testing.T) { testRequires(c, DaemonIsLinux) testRequires(c, memoryLimitSupport) testRequires(c, swapMemorySupport) @@ -206,7 +214,7 @@ func (s *DockerSuite) TestUpdateMemoryWithSwapMemory(c *testing.T) { dockerCmd(c, "update", "--memory", "800M", "--memory-swap", "1000M", name) } -func (s *DockerSuite) TestUpdateNotAffectMonitorRestartPolicy(c *testing.T) { +func (s *DockerCLIUpdateSuite) TestUpdateNotAffectMonitorRestartPolicy(c *testing.T) { testRequires(c, DaemonIsLinux, cpuShare) out, _ := dockerCmd(c, "run", "-tid", "--restart=always", "busybox", "sh") @@ -234,7 +242,7 @@ func (s *DockerSuite) TestUpdateNotAffectMonitorRestartPolicy(c *testing.T) { assert.NilError(c, waitRun(id)) } -func (s *DockerSuite) TestUpdateWithNanoCPUs(c *testing.T) { +func (s *DockerCLIUpdateSuite) TestUpdateWithNanoCPUs(c *testing.T) { testRequires(c, cpuCfsQuota, cpuCfsPeriod) file1 := "/sys/fs/cgroup/cpu/cpu.cfs_quota_us" diff --git a/integration-cli/docker_cli_volume_test.go b/integration-cli/docker_cli_volume_test.go index 2dae8ff43b..46de060ef3 100644 --- a/integration-cli/docker_cli_volume_test.go +++ b/integration-cli/docker_cli_volume_test.go @@ -18,7 +18,19 @@ import ( "gotest.tools/v3/icmd" ) -func (s *DockerSuite) TestVolumeCLICreate(c *testing.T) { +type DockerCLIVolumeSuite struct { + ds *DockerSuite +} + +func (s *DockerCLIVolumeSuite) TearDownTest(c *testing.T) { + s.ds.TearDownTest(c) +} + +func (s *DockerCLIVolumeSuite) OnTimeout(c *testing.T) { + s.ds.OnTimeout(c) +} + +func (s *DockerCLIVolumeSuite) TestVolumeCLICreate(c *testing.T) { dockerCmd(c, "volume", "create") _, _, err := dockerCmdWithError("volume", "create", "-d", "nosuchdriver") @@ -34,7 +46,7 @@ func (s *DockerSuite) TestVolumeCLICreate(c *testing.T) { assert.Equal(c, name, "test2") } -func (s *DockerSuite) TestVolumeCLIInspect(c *testing.T) { +func (s *DockerCLIVolumeSuite) TestVolumeCLIInspect(c *testing.T) { assert.Assert(c, exec.Command(dockerBinary, "volume", "inspect", "doesnotexist").Run() != nil, "volume inspect should error on non-existent volume") out, _ := dockerCmd(c, "volume", "create") name := strings.TrimSpace(out) @@ -46,7 +58,7 @@ func (s *DockerSuite) TestVolumeCLIInspect(c *testing.T) { assert.Equal(c, strings.TrimSpace(out), "test") } -func (s *DockerSuite) TestVolumeCLIInspectMulti(c *testing.T) { +func (s *DockerCLIVolumeSuite) TestVolumeCLIInspectMulti(c *testing.T) { dockerCmd(c, "volume", "create", "test1") dockerCmd(c, "volume", "create", "test2") dockerCmd(c, "volume", "create", "test3") @@ -63,7 +75,7 @@ func (s *DockerSuite) TestVolumeCLIInspectMulti(c *testing.T) { assert.Assert(c, strings.Contains(out, "test3")) } -func (s *DockerSuite) TestVolumeCLILs(c *testing.T) { +func (s *DockerCLIVolumeSuite) TestVolumeCLILs(c *testing.T) { prefix, _ := getPrefixAndSlashFromDaemonPlatform() dockerCmd(c, "volume", "create", "aaa") @@ -76,7 +88,7 @@ func (s *DockerSuite) TestVolumeCLILs(c *testing.T) { assertVolumesInList(c, out, []string{"aaa", "soo", "test"}) } -func (s *DockerSuite) TestVolumeLsFormat(c *testing.T) { +func (s *DockerCLIVolumeSuite) TestVolumeLsFormat(c *testing.T) { dockerCmd(c, "volume", "create", "aaa") dockerCmd(c, "volume", "create", "test") dockerCmd(c, "volume", "create", "soo") @@ -85,7 +97,7 @@ func (s *DockerSuite) TestVolumeLsFormat(c *testing.T) { assertVolumesInList(c, out, []string{"aaa", "soo", "test"}) } -func (s *DockerSuite) TestVolumeLsFormatDefaultFormat(c *testing.T) { +func (s *DockerCLIVolumeSuite) TestVolumeLsFormatDefaultFormat(c *testing.T) { dockerCmd(c, "volume", "create", "aaa") dockerCmd(c, "volume", "create", "test") dockerCmd(c, "volume", "create", "soo") @@ -118,7 +130,7 @@ func assertVolumesInList(c *testing.T, out string, expected []string) { } } -func (s *DockerSuite) TestVolumeCLILsFilterDangling(c *testing.T) { +func (s *DockerCLIVolumeSuite) TestVolumeCLILsFilterDangling(c *testing.T) { prefix, _ := getPrefixAndSlashFromDaemonPlatform() dockerCmd(c, "volume", "create", "testnotinuse1") dockerCmd(c, "volume", "create", "testisinuse1") @@ -163,19 +175,19 @@ func (s *DockerSuite) TestVolumeCLILsFilterDangling(c *testing.T) { assert.Assert(c, strings.Contains(out, "testisinuse2\n"), "expected volume 'testisinuse2' in output") } -func (s *DockerSuite) TestVolumeCLILsErrorWithInvalidFilterName(c *testing.T) { +func (s *DockerCLIVolumeSuite) TestVolumeCLILsErrorWithInvalidFilterName(c *testing.T) { out, _, err := dockerCmdWithError("volume", "ls", "-f", "FOO=123") assert.ErrorContains(c, err, "") assert.Assert(c, strings.Contains(out, "invalid filter")) } -func (s *DockerSuite) TestVolumeCLILsWithIncorrectFilterValue(c *testing.T) { +func (s *DockerCLIVolumeSuite) TestVolumeCLILsWithIncorrectFilterValue(c *testing.T) { out, _, err := dockerCmdWithError("volume", "ls", "-f", "dangling=invalid") assert.ErrorContains(c, err, "") assert.Assert(c, strings.Contains(out, "invalid filter")) } -func (s *DockerSuite) TestVolumeCLIRm(c *testing.T) { +func (s *DockerCLIVolumeSuite) TestVolumeCLIRm(c *testing.T) { prefix, _ := getPrefixAndSlashFromDaemonPlatform() out, _ := dockerCmd(c, "volume", "create") id := strings.TrimSpace(out) @@ -207,7 +219,7 @@ func (s *DockerSuite) TestVolumeCLIRm(c *testing.T) { } // FIXME(vdemeester) should be a unit test in cli/command/volume package -func (s *DockerSuite) TestVolumeCLINoArgs(c *testing.T) { +func (s *DockerCLIVolumeSuite) TestVolumeCLINoArgs(c *testing.T) { out, _ := dockerCmd(c, "volume") // no args should produce the cmd usage output usage := "Usage: docker volume COMMAND" @@ -229,7 +241,7 @@ func (s *DockerSuite) TestVolumeCLINoArgs(c *testing.T) { assert.Assert(c, strings.Contains(result.Stderr(), "unknown flag: --no-such-flag")) } -func (s *DockerSuite) TestVolumeCLIInspectTmplError(c *testing.T) { +func (s *DockerCLIVolumeSuite) TestVolumeCLIInspectTmplError(c *testing.T) { out, _ := dockerCmd(c, "volume", "create") name := strings.TrimSpace(out) @@ -239,7 +251,7 @@ func (s *DockerSuite) TestVolumeCLIInspectTmplError(c *testing.T) { assert.Assert(c, strings.Contains(out, "Template parsing error")) } -func (s *DockerSuite) TestVolumeCLICreateWithOpts(c *testing.T) { +func (s *DockerCLIVolumeSuite) TestVolumeCLICreateWithOpts(c *testing.T) { testRequires(c, DaemonIsLinux) dockerCmd(c, "volume", "create", "-d", "local", "test", "--opt=type=tmpfs", "--opt=device=tmpfs", "--opt=o=size=1m,uid=1000") @@ -263,7 +275,7 @@ func (s *DockerSuite) TestVolumeCLICreateWithOpts(c *testing.T) { assert.Equal(c, found, true) } -func (s *DockerSuite) TestVolumeCLICreateLabel(c *testing.T) { +func (s *DockerCLIVolumeSuite) TestVolumeCLICreateLabel(c *testing.T) { testVol := "testvolcreatelabel" testLabel := "foo" testValue := "bar" @@ -275,7 +287,7 @@ func (s *DockerSuite) TestVolumeCLICreateLabel(c *testing.T) { assert.Equal(c, strings.TrimSpace(out), testValue) } -func (s *DockerSuite) TestVolumeCLICreateLabelMultiple(c *testing.T) { +func (s *DockerCLIVolumeSuite) TestVolumeCLICreateLabelMultiple(c *testing.T) { testVol := "testvolcreatelabel" testLabels := map[string]string{ @@ -302,7 +314,7 @@ func (s *DockerSuite) TestVolumeCLICreateLabelMultiple(c *testing.T) { } } -func (s *DockerSuite) TestVolumeCLILsFilterLabels(c *testing.T) { +func (s *DockerCLIVolumeSuite) TestVolumeCLILsFilterLabels(c *testing.T) { testVol1 := "testvolcreatelabel-1" _, _, err := dockerCmdWithError("volume", "create", "--label", "foo=bar1", testVol1) assert.NilError(c, err) @@ -330,7 +342,7 @@ func (s *DockerSuite) TestVolumeCLILsFilterLabels(c *testing.T) { assert.Equal(c, len(outArr), 1, fmt.Sprintf("\n%s", out)) } -func (s *DockerSuite) TestVolumeCLILsFilterDrivers(c *testing.T) { +func (s *DockerCLIVolumeSuite) TestVolumeCLILsFilterDrivers(c *testing.T) { // using default volume driver local to create volumes testVol1 := "testvol-1" _, _, err := dockerCmdWithError("volume", "create", testVol1) @@ -360,7 +372,7 @@ func (s *DockerSuite) TestVolumeCLILsFilterDrivers(c *testing.T) { assert.Equal(c, len(outArr), 1, fmt.Sprintf("\n%s", out)) } -func (s *DockerSuite) TestVolumeCLIRmForceUsage(c *testing.T) { +func (s *DockerCLIVolumeSuite) TestVolumeCLIRmForceUsage(c *testing.T) { out, _ := dockerCmd(c, "volume", "create") id := strings.TrimSpace(out) @@ -368,7 +380,7 @@ func (s *DockerSuite) TestVolumeCLIRmForceUsage(c *testing.T) { dockerCmd(c, "volume", "rm", "--force", "nonexist") } -func (s *DockerSuite) TestVolumeCLIRmForce(c *testing.T) { +func (s *DockerCLIVolumeSuite) TestVolumeCLIRmForce(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) name := "test" @@ -392,7 +404,7 @@ func (s *DockerSuite) TestVolumeCLIRmForce(c *testing.T) { // TestVolumeCLIRmForceInUse verifies that repeated `docker volume rm -f` calls does not remove a volume // if it is in use. Test case for https://github.com/docker/docker/issues/31446 -func (s *DockerSuite) TestVolumeCLIRmForceInUse(c *testing.T) { +func (s *DockerCLIVolumeSuite) TestVolumeCLIRmForceInUse(c *testing.T) { name := "testvolume" out, _ := dockerCmd(c, "volume", "create", name) id := strings.TrimSpace(out) @@ -428,7 +440,7 @@ func (s *DockerSuite) TestVolumeCLIRmForceInUse(c *testing.T) { assert.Assert(c, !strings.Contains(out, name)) } -func (s *DockerSuite) TestVolumeCliInspectWithVolumeOpts(c *testing.T) { +func (s *DockerCLIVolumeSuite) TestVolumeCliInspectWithVolumeOpts(c *testing.T) { testRequires(c, DaemonIsLinux) // Without options @@ -449,7 +461,7 @@ func (s *DockerSuite) TestVolumeCliInspectWithVolumeOpts(c *testing.T) { } // Test case (1) for 21845: duplicate targets for --volumes-from -func (s *DockerSuite) TestDuplicateMountpointsForVolumesFrom(c *testing.T) { +func (s *DockerCLIVolumeSuite) TestDuplicateMountpointsForVolumesFrom(c *testing.T) { testRequires(c, DaemonIsLinux) image := "vimage" @@ -490,7 +502,7 @@ func (s *DockerSuite) TestDuplicateMountpointsForVolumesFrom(c *testing.T) { } // Test case (2) for 21845: duplicate targets for --volumes-from and -v (bind) -func (s *DockerSuite) TestDuplicateMountpointsForVolumesFromAndBind(c *testing.T) { +func (s *DockerCLIVolumeSuite) TestDuplicateMountpointsForVolumesFromAndBind(c *testing.T) { testRequires(c, DaemonIsLinux) image := "vimage" @@ -532,7 +544,7 @@ func (s *DockerSuite) TestDuplicateMountpointsForVolumesFromAndBind(c *testing.T } // Test case (3) for 21845: duplicate targets for --volumes-from and `Mounts` (API only) -func (s *DockerSuite) TestDuplicateMountpointsForVolumesFromAndMounts(c *testing.T) { +func (s *DockerCLIVolumeSuite) TestDuplicateMountpointsForVolumesFromAndMounts(c *testing.T) { testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) image := "vimage" diff --git a/integration-cli/docker_deprecated_api_v124_test.go b/integration-cli/docker_deprecated_api_v124_test.go index ea778fdede..a6cf73a696 100644 --- a/integration-cli/docker_deprecated_api_v124_test.go +++ b/integration-cli/docker_deprecated_api_v124_test.go @@ -18,7 +18,7 @@ func formatV123StartAPIURL(url string) string { return "/v1.23" + url } -func (s *DockerSuite) TestDeprecatedContainerAPIStartHostConfig(c *testing.T) { +func (s *DockerAPISuite) TestDeprecatedContainerAPIStartHostConfig(c *testing.T) { name := "test-deprecated-api-124" dockerCmd(c, "create", "--name", name, "busybox") config := map[string]interface{}{ @@ -37,7 +37,7 @@ func (s *DockerSuite) TestDeprecatedContainerAPIStartHostConfig(c *testing.T) { } } -func (s *DockerSuite) TestDeprecatedContainerAPIStartVolumeBinds(c *testing.T) { +func (s *DockerAPISuite) TestDeprecatedContainerAPIStartVolumeBinds(c *testing.T) { // TODO Windows CI: Investigate further why this fails on Windows to Windows CI. testRequires(c, DaemonIsLinux) path := "/foo" @@ -68,7 +68,7 @@ func (s *DockerSuite) TestDeprecatedContainerAPIStartVolumeBinds(c *testing.T) { } // Test for GH#10618 -func (s *DockerSuite) TestDeprecatedContainerAPIStartDupVolumeBinds(c *testing.T) { +func (s *DockerAPISuite) TestDeprecatedContainerAPIStartDupVolumeBinds(c *testing.T) { // TODO Windows to Windows CI - Port this testRequires(c, DaemonIsLinux) name := "testdups" @@ -101,7 +101,7 @@ func (s *DockerSuite) TestDeprecatedContainerAPIStartDupVolumeBinds(c *testing.T assert.Assert(c, strings.Contains(string(buf), "Duplicate mount point"), "Expected failure due to duplicate bind mounts to same path, instead got: %q with error: %v", string(buf), err) } -func (s *DockerSuite) TestDeprecatedContainerAPIStartVolumesFrom(c *testing.T) { +func (s *DockerAPISuite) TestDeprecatedContainerAPIStartVolumesFrom(c *testing.T) { // TODO Windows to Windows CI - Port this testRequires(c, DaemonIsLinux) volName := "voltst" @@ -134,7 +134,7 @@ func (s *DockerSuite) TestDeprecatedContainerAPIStartVolumesFrom(c *testing.T) { } // #9981 - Allow a docker created volume (ie, one in /var/lib/docker/volumes) to be used to overwrite (via passing in Binds on api start) an existing volume -func (s *DockerSuite) TestDeprecatedPostContainerBindNormalVolume(c *testing.T) { +func (s *DockerAPISuite) TestDeprecatedPostContainerBindNormalVolume(c *testing.T) { // TODO Windows to Windows CI - Port this testRequires(c, DaemonIsLinux) dockerCmd(c, "create", "-v", "/foo", "--name=one", "busybox") @@ -154,7 +154,7 @@ func (s *DockerSuite) TestDeprecatedPostContainerBindNormalVolume(c *testing.T) assert.Equal(c, fooDir2, fooDir, "expected volume path to be %s, got: %s", fooDir, fooDir2) } -func (s *DockerSuite) TestDeprecatedStartWithTooLowMemoryLimit(c *testing.T) { +func (s *DockerAPISuite) TestDeprecatedStartWithTooLowMemoryLimit(c *testing.T) { // TODO Windows: Port once memory is supported testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "create", "busybox") @@ -179,7 +179,7 @@ func (s *DockerSuite) TestDeprecatedStartWithTooLowMemoryLimit(c *testing.T) { } // #14640 -func (s *DockerSuite) TestDeprecatedPostContainersStartWithoutLinksInHostConfig(c *testing.T) { +func (s *DockerAPISuite) TestDeprecatedPostContainersStartWithoutLinksInHostConfig(c *testing.T) { // TODO Windows: Windows doesn't support supplying a hostconfig on start. // An alternate test could be written to validate the negative testing aspect of this testRequires(c, DaemonIsLinux) @@ -196,7 +196,7 @@ func (s *DockerSuite) TestDeprecatedPostContainersStartWithoutLinksInHostConfig( } // #14640 -func (s *DockerSuite) TestDeprecatedPostContainersStartWithLinksInHostConfig(c *testing.T) { +func (s *DockerAPISuite) TestDeprecatedPostContainersStartWithLinksInHostConfig(c *testing.T) { // TODO Windows: Windows doesn't support supplying a hostconfig on start. // An alternate test could be written to validate the negative testing aspect of this testRequires(c, DaemonIsLinux) @@ -214,7 +214,7 @@ func (s *DockerSuite) TestDeprecatedPostContainersStartWithLinksInHostConfig(c * } // #14640 -func (s *DockerSuite) TestDeprecatedPostContainersStartWithLinksInHostConfigIdLinked(c *testing.T) { +func (s *DockerAPISuite) TestDeprecatedPostContainersStartWithLinksInHostConfigIdLinked(c *testing.T) { // Windows does not support links testRequires(c, DaemonIsLinux) name := "test-host-config-links" @@ -233,7 +233,7 @@ func (s *DockerSuite) TestDeprecatedPostContainersStartWithLinksInHostConfigIdLi b.Close() } -func (s *DockerSuite) TestDeprecatedStartWithNilDNS(c *testing.T) { +func (s *DockerAPISuite) TestDeprecatedStartWithNilDNS(c *testing.T) { // TODO Windows: Add once DNS is supported testRequires(c, DaemonIsLinux) out, _ := dockerCmd(c, "create", "busybox")