From 142b1f8bfb3a1459660a5877b48f2bd7d17ba5d6 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 15 Jan 2018 15:28:10 +0100 Subject: [PATCH 1/4] Remove deprecated environment.DockerBasePath() Signed-off-by: Sebastiaan van Stijn --- integration-cli/docker_cli_build_test.go | 8 ++++---- integration-cli/docker_cli_by_digest_test.go | 4 ++-- integration-cli/docker_cli_cp_to_container_unix_test.go | 2 +- integration-cli/docker_cli_plugins_test.go | 6 +++--- integration-cli/docker_cli_run_test.go | 2 +- integration-cli/environment/environment.go | 7 ------- 6 files changed, 11 insertions(+), 18 deletions(-) diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index 8ae5e05ed8..541182c69f 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -1514,7 +1514,7 @@ func (s *DockerSuite) TestBuildContextCleanup(c *check.C) { testRequires(c, SameHostDaemon) name := "testbuildcontextcleanup" - entries, err := ioutil.ReadDir(filepath.Join(testEnv.DockerBasePath(), "tmp")) + entries, err := ioutil.ReadDir(filepath.Join(testEnv.DaemonInfo.DockerRootDir, "tmp")) if err != nil { c.Fatalf("failed to list contents of tmp dir: %s", err) } @@ -1522,7 +1522,7 @@ func (s *DockerSuite) TestBuildContextCleanup(c *check.C) { buildImageSuccessfully(c, name, build.WithDockerfile(`FROM `+minimalBaseImage()+` ENTRYPOINT ["/bin/echo"]`)) - entriesFinal, err := ioutil.ReadDir(filepath.Join(testEnv.DockerBasePath(), "tmp")) + entriesFinal, err := ioutil.ReadDir(filepath.Join(testEnv.DaemonInfo.DockerRootDir, "tmp")) if err != nil { c.Fatalf("failed to list contents of tmp dir: %s", err) } @@ -1536,7 +1536,7 @@ func (s *DockerSuite) TestBuildContextCleanupFailedBuild(c *check.C) { testRequires(c, SameHostDaemon) name := "testbuildcontextcleanup" - entries, err := ioutil.ReadDir(filepath.Join(testEnv.DockerBasePath(), "tmp")) + entries, err := ioutil.ReadDir(filepath.Join(testEnv.DaemonInfo.DockerRootDir, "tmp")) if err != nil { c.Fatalf("failed to list contents of tmp dir: %s", err) } @@ -1546,7 +1546,7 @@ func (s *DockerSuite) TestBuildContextCleanupFailedBuild(c *check.C) { ExitCode: 1, }) - entriesFinal, err := ioutil.ReadDir(filepath.Join(testEnv.DockerBasePath(), "tmp")) + entriesFinal, err := ioutil.ReadDir(filepath.Join(testEnv.DaemonInfo.DockerRootDir, "tmp")) if err != nil { c.Fatalf("failed to list contents of tmp dir: %s", err) } diff --git a/integration-cli/docker_cli_by_digest_test.go b/integration-cli/docker_cli_by_digest_test.go index 3a974cfad9..2d5dd486e7 100644 --- a/integration-cli/docker_cli_by_digest_test.go +++ b/integration-cli/docker_cli_by_digest_test.go @@ -635,7 +635,7 @@ func (s *DockerRegistrySuite) TestPullFailsWithAlteredLayer(c *check.C) { // digest verification for the target layer digest. // Remove distribution cache to force a re-pull of the blobs - if err := os.RemoveAll(filepath.Join(testEnv.DockerBasePath(), "image", s.d.StorageDriver(), "distribution")); err != nil { + if err := os.RemoveAll(filepath.Join(testEnv.DaemonInfo.DockerRootDir, "image", s.d.StorageDriver(), "distribution")); err != nil { c.Fatalf("error clearing distribution cache: %v", err) } @@ -678,7 +678,7 @@ func (s *DockerSchema1RegistrySuite) TestPullFailsWithAlteredLayer(c *check.C) { // digest verification for the target layer digest. // Remove distribution cache to force a re-pull of the blobs - if err := os.RemoveAll(filepath.Join(testEnv.DockerBasePath(), "image", s.d.StorageDriver(), "distribution")); err != nil { + if err := os.RemoveAll(filepath.Join(testEnv.DaemonInfo.DockerRootDir, "image", s.d.StorageDriver(), "distribution")); err != nil { c.Fatalf("error clearing distribution cache: %v", err) } 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 fa55b6ee24..8f830dcf9d 100644 --- a/integration-cli/docker_cli_cp_to_container_unix_test.go +++ b/integration-cli/docker_cli_cp_to_container_unix_test.go @@ -64,7 +64,7 @@ func (s *DockerSuite) TestCpCheckDestOwnership(c *check.C) { } func getRootUIDGID() (int, int, error) { - uidgid := strings.Split(filepath.Base(testEnv.DockerBasePath()), ".") + uidgid := strings.Split(filepath.Base(testEnv.DaemonInfo.DockerRootDir), ".") if len(uidgid) == 1 { //user namespace remapping is not turned on; return 0 return 0, 0, nil diff --git a/integration-cli/docker_cli_plugins_test.go b/integration-cli/docker_cli_plugins_test.go index 310067e386..e49c428490 100644 --- a/integration-cli/docker_cli_plugins_test.go +++ b/integration-cli/docker_cli_plugins_test.go @@ -55,7 +55,7 @@ func (ps *DockerPluginSuite) TestPluginBasicOps(c *check.C) { c.Assert(err, checker.IsNil) c.Assert(out, checker.Contains, plugin) - _, err = os.Stat(filepath.Join(testEnv.DockerBasePath(), "plugins", id)) + _, err = os.Stat(filepath.Join(testEnv.DaemonInfo.DockerRootDir, "plugins", id)) if !os.IsNotExist(err) { c.Fatal(err) } @@ -506,14 +506,14 @@ func (s *DockerSuite) TestPluginUpgrade(c *check.C) { id := strings.TrimSpace(out) // make sure "v2" does not exists - _, err = os.Stat(filepath.Join(testEnv.DockerBasePath(), "plugins", id, "rootfs", "v2")) + _, err = os.Stat(filepath.Join(testEnv.DaemonInfo.DockerRootDir, "plugins", id, "rootfs", "v2")) c.Assert(os.IsNotExist(err), checker.True, check.Commentf(out)) dockerCmd(c, "plugin", "disable", "-f", plugin) dockerCmd(c, "plugin", "upgrade", "--grant-all-permissions", "--skip-remote-check", plugin, pluginV2) // make sure "v2" file exists - _, err = os.Stat(filepath.Join(testEnv.DockerBasePath(), "plugins", id, "rootfs", "v2")) + _, err = os.Stat(filepath.Join(testEnv.DaemonInfo.DockerRootDir, "plugins", id, "rootfs", "v2")) c.Assert(err, checker.IsNil) dockerCmd(c, "plugin", "enable", plugin) diff --git a/integration-cli/docker_cli_run_test.go b/integration-cli/docker_cli_run_test.go index 1749df07c1..3b52e0f942 100644 --- a/integration-cli/docker_cli_run_test.go +++ b/integration-cli/docker_cli_run_test.go @@ -4232,7 +4232,7 @@ func (s *DockerSuite) TestRunCredentialSpecFailures(c *check.C) { func (s *DockerSuite) TestRunCredentialSpecWellFormed(c *check.C) { testRequires(c, DaemonIsWindows, SameHostDaemon) validCS := readFile(`fixtures\credentialspecs\valid.json`, c) - writeFile(filepath.Join(testEnv.DockerBasePath(), `credentialspecs\valid.json`), validCS, c) + writeFile(filepath.Join(testEnv.DaemonInfo.DockerRootDir, `credentialspecs\valid.json`), validCS, c) dockerCmd(c, "run", `--security-opt=credentialspec=file://valid.json`, "busybox", "true") } diff --git a/integration-cli/environment/environment.go b/integration-cli/environment/environment.go index 0decc06983..988440ce1c 100644 --- a/integration-cli/environment/environment.go +++ b/integration-cli/environment/environment.go @@ -49,13 +49,6 @@ func New() (*Execution, error) { }, nil } -// DockerBasePath is the base path of the docker folder (by default it is -/var/run/docker) -// TODO: remove -// Deprecated: use Execution.DaemonInfo.DockerRootDir -func (e *Execution) DockerBasePath() string { - return e.DaemonInfo.DockerRootDir -} - // ExperimentalDaemon tell whether the main daemon has // experimental features enabled or not // Deprecated: use DaemonInfo.ExperimentalBuild From da8032d7d351a2073f54ec0121a796800b6b1a46 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 15 Jan 2018 15:30:05 +0100 Subject: [PATCH 2/4] Remove deprecated environment.ExperimentalDaemon() Signed-off-by: Sebastiaan van Stijn --- integration-cli/check_test.go | 12 ++++++------ integration-cli/docker_cli_daemon_test.go | 10 +++++----- .../docker_cli_external_graphdriver_unix_test.go | 2 +- .../docker_cli_external_volume_driver_unix_test.go | 2 +- integration-cli/docker_cli_info_test.go | 12 ++++++------ integration-cli/docker_cli_network_unix_test.go | 2 +- integration-cli/docker_hub_pull_suite_test.go | 2 +- integration-cli/environment/environment.go | 7 ------- 8 files changed, 21 insertions(+), 28 deletions(-) diff --git a/integration-cli/check_test.go b/integration-cli/check_test.go index 49504c6306..dd802fbc11 100644 --- a/integration-cli/check_test.go +++ b/integration-cli/check_test.go @@ -129,7 +129,7 @@ func (s *DockerRegistrySuite) SetUpTest(c *check.C) { testRequires(c, DaemonIsLinux, registry.Hosting, SameHostDaemon) s.reg = setupRegistry(c, false, "", "") s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ - Experimental: testEnv.ExperimentalDaemon(), + Experimental: testEnv.DaemonInfo.ExperimentalBuild, }) } @@ -163,7 +163,7 @@ func (s *DockerSchema1RegistrySuite) SetUpTest(c *check.C) { testRequires(c, DaemonIsLinux, registry.Hosting, NotArm64, SameHostDaemon) s.reg = setupRegistry(c, true, "", "") s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ - Experimental: testEnv.ExperimentalDaemon(), + Experimental: testEnv.DaemonInfo.ExperimentalBuild, }) } @@ -197,7 +197,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) SetUpTest(c *check.C) { testRequires(c, DaemonIsLinux, registry.Hosting, SameHostDaemon) s.reg = setupRegistry(c, false, "htpasswd", "") s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ - Experimental: testEnv.ExperimentalDaemon(), + Experimental: testEnv.DaemonInfo.ExperimentalBuild, }) } @@ -232,7 +232,7 @@ func (s *DockerRegistryAuthTokenSuite) OnTimeout(c *check.C) { func (s *DockerRegistryAuthTokenSuite) SetUpTest(c *check.C) { testRequires(c, DaemonIsLinux, registry.Hosting, SameHostDaemon) s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ - Experimental: testEnv.ExperimentalDaemon(), + Experimental: testEnv.DaemonInfo.ExperimentalBuild, }) } @@ -273,7 +273,7 @@ func (s *DockerDaemonSuite) OnTimeout(c *check.C) { func (s *DockerDaemonSuite) SetUpTest(c *check.C) { testRequires(c, DaemonIsLinux, SameHostDaemon) s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ - Experimental: testEnv.ExperimentalDaemon(), + Experimental: testEnv.DaemonInfo.ExperimentalBuild, }) } @@ -331,7 +331,7 @@ func (s *DockerSwarmSuite) SetUpTest(c *check.C) { func (s *DockerSwarmSuite) AddDaemon(c *check.C, joinSwarm, manager bool) *daemon.Swarm { d := &daemon.Swarm{ Daemon: daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ - Experimental: testEnv.ExperimentalDaemon(), + Experimental: testEnv.DaemonInfo.ExperimentalBuild, }), Port: defaultSwarmPort + s.portIndex, } diff --git a/integration-cli/docker_cli_daemon_test.go b/integration-cli/docker_cli_daemon_test.go index 5fbfac9a40..40ed956b8a 100644 --- a/integration-cli/docker_cli_daemon_test.go +++ b/integration-cli/docker_cli_daemon_test.go @@ -1434,7 +1434,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithSocketAsVolume(c *check.C) { // A subsequent daemon restart should clean up said mounts. func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonAndContainerKill(c *check.C) { d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ - Experimental: testEnv.ExperimentalDaemon(), + Experimental: testEnv.DaemonInfo.ExperimentalBuild, }) d.StartWithBusybox(c) @@ -1474,7 +1474,7 @@ func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonAndContainerKill(c *chec // os.Interrupt should perform a graceful daemon shutdown and hence cleanup mounts. func (s *DockerDaemonSuite) TestCleanupMountsAfterGracefulShutdown(c *check.C) { d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ - Experimental: testEnv.ExperimentalDaemon(), + Experimental: testEnv.DaemonInfo.ExperimentalBuild, }) d.StartWithBusybox(c) @@ -1695,7 +1695,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartLocalVolumes(c *check.C) { // FIXME(vdemeester) should be a unit test func (s *DockerDaemonSuite) TestDaemonCorruptedLogDriverAddress(c *check.C) { d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ - Experimental: testEnv.ExperimentalDaemon(), + Experimental: testEnv.DaemonInfo.ExperimentalBuild, }) c.Assert(d.StartWithError("--log-driver=syslog", "--log-opt", "syslog-address=corrupted:42"), check.NotNil) expected := "Failed to set log opts: syslog-address should be in form proto://address" @@ -1705,7 +1705,7 @@ func (s *DockerDaemonSuite) TestDaemonCorruptedLogDriverAddress(c *check.C) { // FIXME(vdemeester) should be a unit test func (s *DockerDaemonSuite) TestDaemonCorruptedFluentdAddress(c *check.C) { d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ - Experimental: testEnv.ExperimentalDaemon(), + Experimental: testEnv.DaemonInfo.ExperimentalBuild, }) c.Assert(d.StartWithError("--log-driver=fluentd", "--log-opt", "fluentd-address=corrupted:c"), check.NotNil) expected := "Failed to set log opts: invalid fluentd-address corrupted:c: " @@ -3082,7 +3082,7 @@ func (s *DockerDaemonSuite) TestDaemonIpcModeShareableFromConfig(c *check.C) { func testDaemonStartIpcMode(c *check.C, from, mode string, valid bool) { d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ - Experimental: testEnv.ExperimentalDaemon(), + Experimental: testEnv.DaemonInfo.ExperimentalBuild, }) c.Logf("Checking IpcMode %s set from %s\n", mode, from) var serr error diff --git a/integration-cli/docker_cli_external_graphdriver_unix_test.go b/integration-cli/docker_cli_external_graphdriver_unix_test.go index 8e766bcc31..3265336d68 100644 --- a/integration-cli/docker_cli_external_graphdriver_unix_test.go +++ b/integration-cli/docker_cli_external_graphdriver_unix_test.go @@ -53,7 +53,7 @@ type graphEventsCounter struct { func (s *DockerExternalGraphdriverSuite) SetUpTest(c *check.C) { s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ - Experimental: testEnv.ExperimentalDaemon(), + Experimental: testEnv.DaemonInfo.ExperimentalBuild, }) } diff --git a/integration-cli/docker_cli_external_volume_driver_unix_test.go b/integration-cli/docker_cli_external_volume_driver_unix_test.go index 2e2de972d5..ff3d50fb03 100644 --- a/integration-cli/docker_cli_external_volume_driver_unix_test.go +++ b/integration-cli/docker_cli_external_volume_driver_unix_test.go @@ -52,7 +52,7 @@ type DockerExternalVolumeSuite struct { func (s *DockerExternalVolumeSuite) SetUpTest(c *check.C) { testRequires(c, SameHostDaemon) s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ - Experimental: testEnv.ExperimentalDaemon(), + Experimental: testEnv.DaemonInfo.ExperimentalBuild, }) s.ec = &eventCounter{} } diff --git a/integration-cli/docker_cli_info_test.go b/integration-cli/docker_cli_info_test.go index d7ce238bfd..180464888d 100644 --- a/integration-cli/docker_cli_info_test.go +++ b/integration-cli/docker_cli_info_test.go @@ -44,7 +44,7 @@ func (s *DockerSuite) TestInfoEnsureSucceeds(c *check.C) { stringsToCheck = append(stringsToCheck, "Runtimes:", "Default Runtime: runc") } - if testEnv.ExperimentalDaemon() { + if testEnv.DaemonInfo.ExperimentalBuild { stringsToCheck = append(stringsToCheck, "Experimental: true") } else { stringsToCheck = append(stringsToCheck, "Experimental: false") @@ -72,7 +72,7 @@ func (s *DockerSuite) TestInfoDiscoveryBackend(c *check.C) { testRequires(c, SameHostDaemon, DaemonIsLinux) d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ - Experimental: testEnv.ExperimentalDaemon(), + Experimental: testEnv.DaemonInfo.ExperimentalBuild, }) discoveryBackend := "consul://consuladdr:consulport/some/path" discoveryAdvertise := "1.1.1.1:2375" @@ -91,7 +91,7 @@ func (s *DockerSuite) TestInfoDiscoveryInvalidAdvertise(c *check.C) { testRequires(c, SameHostDaemon, DaemonIsLinux) d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ - Experimental: testEnv.ExperimentalDaemon(), + Experimental: testEnv.DaemonInfo.ExperimentalBuild, }) discoveryBackend := "consul://consuladdr:consulport/some/path" @@ -110,7 +110,7 @@ func (s *DockerSuite) TestInfoDiscoveryAdvertiseInterfaceName(c *check.C) { testRequires(c, SameHostDaemon, Network, DaemonIsLinux) d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ - Experimental: testEnv.ExperimentalDaemon(), + Experimental: testEnv.DaemonInfo.ExperimentalBuild, }) discoveryBackend := "consul://consuladdr:consulport/some/path" discoveryAdvertise := "eth0" @@ -183,7 +183,7 @@ func (s *DockerSuite) TestInfoDebug(c *check.C) { testRequires(c, SameHostDaemon, DaemonIsLinux) d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ - Experimental: testEnv.ExperimentalDaemon(), + Experimental: testEnv.DaemonInfo.ExperimentalBuild, }) d.Start(c, "--debug") defer d.Stop(c) @@ -206,7 +206,7 @@ func (s *DockerSuite) TestInsecureRegistries(c *check.C) { registryHost := "insecurehost.com:5000" d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ - Experimental: testEnv.ExperimentalDaemon(), + Experimental: testEnv.DaemonInfo.ExperimentalBuild, }) d.Start(c, "--insecure-registry="+registryCIDR, "--insecure-registry="+registryHost) defer d.Stop(c) diff --git a/integration-cli/docker_cli_network_unix_test.go b/integration-cli/docker_cli_network_unix_test.go index 4bb542386b..90e4f6c1f2 100644 --- a/integration-cli/docker_cli_network_unix_test.go +++ b/integration-cli/docker_cli_network_unix_test.go @@ -50,7 +50,7 @@ type DockerNetworkSuite struct { func (s *DockerNetworkSuite) SetUpTest(c *check.C) { s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ - Experimental: testEnv.ExperimentalDaemon(), + Experimental: testEnv.DaemonInfo.ExperimentalBuild, }) } diff --git a/integration-cli/docker_hub_pull_suite_test.go b/integration-cli/docker_hub_pull_suite_test.go index 286a3913ce..a8d6aedad3 100644 --- a/integration-cli/docker_hub_pull_suite_test.go +++ b/integration-cli/docker_hub_pull_suite_test.go @@ -41,7 +41,7 @@ func newDockerHubPullSuite() *DockerHubPullSuite { func (s *DockerHubPullSuite) SetUpSuite(c *check.C) { testRequires(c, DaemonIsLinux, SameHostDaemon) s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ - Experimental: testEnv.ExperimentalDaemon(), + Experimental: testEnv.DaemonInfo.ExperimentalBuild, }) s.d.Start(c) } diff --git a/integration-cli/environment/environment.go b/integration-cli/environment/environment.go index 988440ce1c..06fafeda0a 100644 --- a/integration-cli/environment/environment.go +++ b/integration-cli/environment/environment.go @@ -49,13 +49,6 @@ func New() (*Execution, error) { }, nil } -// ExperimentalDaemon tell whether the main daemon has -// experimental features enabled or not -// Deprecated: use DaemonInfo.ExperimentalBuild -func (e *Execution) ExperimentalDaemon() bool { - return e.DaemonInfo.ExperimentalBuild -} - // DaemonPlatform is held globally so that tests can make intelligent // decisions on how to configure themselves according to the platform // of the daemon. This is initialized in docker_utils by sending From dfedc9ef6214500526c29fbf9a46aca9cecbeb57 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 15 Jan 2018 15:31:02 +0100 Subject: [PATCH 3/4] Remove deprecated environment.MinimalBaseImage() Signed-off-by: Sebastiaan van Stijn --- .../docker_api_containers_windows_test.go | 2 +- integration-cli/docker_cli_build_test.go | 24 +++++++-------- integration-cli/docker_cli_create_test.go | 2 +- integration-cli/docker_cli_run_test.go | 30 +++++++++---------- integration-cli/docker_utils_test.go | 2 +- integration-cli/environment/environment.go | 6 ---- 6 files changed, 30 insertions(+), 36 deletions(-) diff --git a/integration-cli/docker_api_containers_windows_test.go b/integration-cli/docker_api_containers_windows_test.go index 4cbe067cd5..ae60cfec00 100644 --- a/integration-cli/docker_api_containers_windows_test.go +++ b/integration-cli/docker_api_containers_windows_test.go @@ -47,7 +47,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsBindNamedPipe(c *check.C) { name := "test-bind-npipe" data := map[string]interface{}{ - "Image": testEnv.MinimalBaseImage(), + "Image": testEnv.PlatformDefaults.BaseImage, "Cmd": []string{"cmd", "/c", cmd}, "HostConfig": map[string]interface{}{"Mounts": []map[string]interface{}{{"Type": "npipe", "Source": hostPipeName, "Target": containerPipeName}}}, } diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index 541182c69f..cb3b047a46 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -603,7 +603,7 @@ RUN [ $(cat "/test dir/test_file6") = 'test6' ]`, command, command, command, com func (s *DockerSuite) TestBuildCopyFileWithWhitespaceOnWindows(c *check.C) { testRequires(c, DaemonIsWindows) - dockerfile := `FROM ` + testEnv.MinimalBaseImage() + ` + dockerfile := `FROM ` + testEnv.PlatformDefaults.BaseImage + ` RUN mkdir "C:/test dir" RUN mkdir "C:/test_dir" COPY [ "test file1", "/test_file1" ] @@ -5148,7 +5148,7 @@ func (s *DockerSuite) TestBuildWorkdirWindowsPath(c *check.C) { testRequires(c, DaemonIsWindows) name := "testbuildworkdirwindowspath" buildImageSuccessfully(c, name, build.WithDockerfile(` - FROM `+testEnv.MinimalBaseImage()+` + FROM `+testEnv.PlatformDefaults.BaseImage+` RUN mkdir C:\\work WORKDIR C:\\work RUN if "%CD%" NEQ "C:\work" exit -1 @@ -6143,7 +6143,7 @@ func (s *DockerTrustSuite) TestBuildMultiStageTrusted(c *check.C) { func (s *DockerSuite) TestBuildMultiStageMultipleBuildsWindows(c *check.C) { testRequires(c, DaemonIsWindows) dockerfile := ` - FROM ` + testEnv.MinimalBaseImage() + ` + FROM ` + testEnv.PlatformDefaults.BaseImage + ` COPY foo c:\\bar` ctx := fakecontext.New(c, "", fakecontext.WithDockerfile(dockerfile), @@ -6156,7 +6156,7 @@ func (s *DockerSuite) TestBuildMultiStageMultipleBuildsWindows(c *check.C) { dockerfile = ` FROM build1:latest - FROM ` + testEnv.MinimalBaseImage() + ` + FROM ` + testEnv.PlatformDefaults.BaseImage + ` COPY --from=0 c:\\bar / COPY foo /` ctx = fakecontext.New(c, "", @@ -6177,8 +6177,8 @@ func (s *DockerSuite) TestBuildMultiStageMultipleBuildsWindows(c *check.C) { func (s *DockerSuite) TestBuildCopyFromForbidWindowsSystemPaths(c *check.C) { testRequires(c, DaemonIsWindows) dockerfile := ` - FROM ` + testEnv.MinimalBaseImage() + ` - FROM ` + testEnv.MinimalBaseImage() + ` + FROM ` + testEnv.PlatformDefaults.BaseImage + ` + FROM ` + testEnv.PlatformDefaults.BaseImage + ` COPY --from=0 %s c:\\oscopy ` exp := icmd.Expected{ @@ -6194,8 +6194,8 @@ func (s *DockerSuite) TestBuildCopyFromForbidWindowsSystemPaths(c *check.C) { func (s *DockerSuite) TestBuildCopyFromForbidWindowsRelativePaths(c *check.C) { testRequires(c, DaemonIsWindows) dockerfile := ` - FROM ` + testEnv.MinimalBaseImage() + ` - FROM ` + testEnv.MinimalBaseImage() + ` + FROM ` + testEnv.PlatformDefaults.BaseImage + ` + FROM ` + testEnv.PlatformDefaults.BaseImage + ` COPY --from=0 %s c:\\oscopy ` exp := icmd.Expected{ @@ -6212,9 +6212,9 @@ func (s *DockerSuite) TestBuildCopyFromForbidWindowsRelativePaths(c *check.C) { func (s *DockerSuite) TestBuildCopyFromWindowsIsCaseInsensitive(c *check.C) { testRequires(c, DaemonIsWindows) dockerfile := ` - FROM ` + testEnv.MinimalBaseImage() + ` + FROM ` + testEnv.PlatformDefaults.BaseImage + ` COPY foo / - FROM ` + testEnv.MinimalBaseImage() + ` + FROM ` + testEnv.PlatformDefaults.BaseImage + ` COPY --from=0 c:\\fOo c:\\copied RUN type c:\\copied ` @@ -6294,7 +6294,7 @@ func (s *DockerSuite) TestBuildOpaqueDirectory(c *check.C) { func (s *DockerSuite) TestBuildWindowsUser(c *check.C) { testRequires(c, DaemonIsWindows) name := "testbuildwindowsuser" - buildImage(name, build.WithDockerfile(`FROM `+testEnv.MinimalBaseImage()+` + buildImage(name, build.WithDockerfile(`FROM `+testEnv.PlatformDefaults.BaseImage+` RUN net user user /add USER user RUN set username @@ -6325,7 +6325,7 @@ func (s *DockerSuite) TestBuildWindowsEnvCaseInsensitive(c *check.C) { testRequires(c, DaemonIsWindows) name := "testbuildwindowsenvcaseinsensitive" buildImageSuccessfully(c, name, build.WithDockerfile(` - FROM `+testEnv.MinimalBaseImage()+` + FROM `+testEnv.PlatformDefaults.BaseImage+` ENV FOO=bar foo=baz `)) res := inspectFieldJSON(c, name, "Config.Env") diff --git a/integration-cli/docker_cli_create_test.go b/integration-cli/docker_cli_create_test.go index 8e123142b9..67bc98ee3f 100644 --- a/integration-cli/docker_cli_create_test.go +++ b/integration-cli/docker_cli_create_test.go @@ -225,7 +225,7 @@ func (s *DockerSuite) TestCreateHostnameWithNumber(c *check.C) { image := "busybox" // Busybox on Windows does not implement hostname command if testEnv.DaemonPlatform() == "windows" { - image = testEnv.MinimalBaseImage() + image = testEnv.PlatformDefaults.BaseImage } out, _ := dockerCmd(c, "run", "-h", "web.0", image, "hostname") c.Assert(strings.TrimSpace(out), checker.Equals, "web.0", check.Commentf("hostname not set, expected `web.0`, got: %s", out)) diff --git a/integration-cli/docker_cli_run_test.go b/integration-cli/docker_cli_run_test.go index 3b52e0f942..79be835edb 100644 --- a/integration-cli/docker_cli_run_test.go +++ b/integration-cli/docker_cli_run_test.go @@ -75,7 +75,7 @@ func (s *DockerSuite) TestRunLookupGoogleDNS(c *check.C) { if testEnv.DaemonPlatform() == "windows" { // nslookup isn't present in Windows busybox. Is built-in. Further, // nslookup isn't present in nanoserver. Hence just use PowerShell... - dockerCmd(c, "run", testEnv.MinimalBaseImage(), "powershell", "Resolve-DNSName", "google.com") + dockerCmd(c, "run", testEnv.PlatformDefaults.BaseImage, "powershell", "Resolve-DNSName", "google.com") } else { dockerCmd(c, "run", "busybox", "nslookup", "google.com") } @@ -162,7 +162,7 @@ func (s *DockerSuite) TestRunWithoutNetworking(c *check.C) { image := "busybox" if testEnv.DaemonPlatform() == "windows" { count = "-n" - image = testEnv.MinimalBaseImage() + image = testEnv.PlatformDefaults.BaseImage } // First using the long form --net @@ -355,7 +355,7 @@ func (s *DockerSuite) TestRunWithVolumesFromExited(c *check.C) { // Create a file in a volume if testEnv.DaemonPlatform() == "windows" { - out, exitCode = dockerCmd(c, "run", "--name", "test-data", "--volume", `c:\some\dir`, testEnv.MinimalBaseImage(), "cmd", "/c", `echo hello > c:\some\dir\file`) + out, exitCode = dockerCmd(c, "run", "--name", "test-data", "--volume", `c:\some\dir`, testEnv.PlatformDefaults.BaseImage, "cmd", "/c", `echo hello > c:\some\dir\file`) } else { out, exitCode = dockerCmd(c, "run", "--name", "test-data", "--volume", "/some/dir", "busybox", "touch", "/some/dir/file") } @@ -365,7 +365,7 @@ func (s *DockerSuite) TestRunWithVolumesFromExited(c *check.C) { // Read the file from another container using --volumes-from to access the volume in the second container if testEnv.DaemonPlatform() == "windows" { - out, exitCode = dockerCmd(c, "run", "--volumes-from", "test-data", testEnv.MinimalBaseImage(), "cmd", "/c", `type c:\some\dir\file`) + out, exitCode = dockerCmd(c, "run", "--volumes-from", "test-data", testEnv.PlatformDefaults.BaseImage, "cmd", "/c", `type c:\some\dir\file`) } else { out, exitCode = dockerCmd(c, "run", "--volumes-from", "test-data", "busybox", "cat", "/some/dir/file") } @@ -407,7 +407,7 @@ func (s *DockerSuite) TestRunCreateVolumesInSymlinkDir(c *check.C) { f.Close() if testEnv.DaemonPlatform() == "windows" { - dockerFile = fmt.Sprintf("FROM %s\nRUN mkdir %s\nRUN mklink /D c:\\test %s", testEnv.MinimalBaseImage(), dir, dir) + dockerFile = fmt.Sprintf("FROM %s\nRUN mkdir %s\nRUN mklink /D c:\\test %s", testEnv.PlatformDefaults.BaseImage, dir, dir) containerPath = `c:\test\test` cmd = "tasklist" } else { @@ -432,7 +432,7 @@ func (s *DockerSuite) TestRunCreateVolumesInSymlinkDir2(c *check.C) { name := "test-volume-symlink2" if testEnv.DaemonPlatform() == "windows" { - dockerFile = fmt.Sprintf("FROM %s\nRUN mkdir c:\\%s\nRUN mklink /D c:\\test c:\\%s", testEnv.MinimalBaseImage(), name, name) + dockerFile = fmt.Sprintf("FROM %s\nRUN mkdir c:\\%s\nRUN mklink /D c:\\test c:\\%s", testEnv.PlatformDefaults.BaseImage, name, name) containerPath = `c:\test\test` cmd = "tasklist" } else { @@ -670,7 +670,7 @@ func (s *DockerSuite) TestRunVolumesFromSymlinkPath(c *check.C) { if testEnv.DaemonPlatform() == "windows" { prefix = `c:` - dfContents = `FROM ` + testEnv.MinimalBaseImage() + ` + dfContents = `FROM ` + testEnv.PlatformDefaults.BaseImage + ` RUN mkdir c:\home RUN mklink /D c:\foo c:\home VOLUME ["c:/foo/bar"] @@ -922,7 +922,7 @@ func (s *DockerSuite) TestRunEnvironmentOverride(c *check.C) { func (s *DockerSuite) TestRunContainerNetwork(c *check.C) { if testEnv.DaemonPlatform() == "windows" { // Windows busybox does not have ping. Use built in ping instead. - dockerCmd(c, "run", testEnv.MinimalBaseImage(), "ping", "-n", "1", "127.0.0.1") + dockerCmd(c, "run", testEnv.PlatformDefaults.BaseImage, "ping", "-n", "1", "127.0.0.1") } else { dockerCmd(c, "run", "busybox", "ping", "-c", "1", "127.0.0.1") } @@ -1231,7 +1231,7 @@ func (s *DockerSuite) TestRunRootWorkdir(c *check.C) { func (s *DockerSuite) TestRunAllowBindMountingRoot(c *check.C) { if testEnv.DaemonPlatform() == "windows" { // Windows busybox will fail with Permission Denied on items such as pagefile.sys - dockerCmd(c, "run", "-v", `c:\:c:\host`, testEnv.MinimalBaseImage(), "cmd", "-c", "dir", `c:\host`) + dockerCmd(c, "run", "-v", `c:\:c:\host`, testEnv.PlatformDefaults.BaseImage, "cmd", "-c", "dir", `c:\host`) } else { dockerCmd(c, "run", "-v", "/:/host", "busybox", "ls", "/host") } @@ -1705,14 +1705,14 @@ func (s *DockerSuite) TestRunCleanupCmdOnEntrypoint(c *check.C) { out = strings.TrimSpace(out) expected := "root" if testEnv.DaemonPlatform() == "windows" { - if strings.Contains(testEnv.MinimalBaseImage(), "windowsservercore") { + if strings.Contains(testEnv.PlatformDefaults.BaseImage, "windowsservercore") { expected = `user manager\containeradministrator` } else { expected = `ContainerAdministrator` // nanoserver } } if out != expected { - c.Fatalf("Expected output %s, got %q. %s", expected, out, testEnv.MinimalBaseImage()) + c.Fatalf("Expected output %s, got %q. %s", expected, out, testEnv.PlatformDefaults.BaseImage) } } @@ -1944,7 +1944,7 @@ func (s *DockerSuite) TestRunCidFileCleanupIfEmpty(c *check.C) { image := "emptyfs" if testEnv.DaemonPlatform() == "windows" { // Windows can't support an emptyfs image. Just use the regular Windows image - image = testEnv.MinimalBaseImage() + image = testEnv.PlatformDefaults.BaseImage } out, _, err := dockerCmdWithError("run", "--cidfile", tmpCidFile, image) if err == nil { @@ -2561,7 +2561,7 @@ func (s *DockerSuite) TestRunNonLocalMacAddress(c *check.C) { if testEnv.DaemonPlatform() != "windows" { args = append(args, "busybox", "ifconfig") } else { - args = append(args, testEnv.MinimalBaseImage(), "ipconfig", "/all") + args = append(args, testEnv.PlatformDefaults.BaseImage, "ipconfig", "/all") expected = strings.Replace(strings.ToUpper(addr), ":", "-", -1) } @@ -3483,7 +3483,7 @@ func (s *DockerSuite) TestRunLoopbackOnlyExistsWhenNetworkingDisabled(c *check.C // Issue #4681 func (s *DockerSuite) TestRunLoopbackWhenNetworkDisabled(c *check.C) { if testEnv.DaemonPlatform() == "windows" { - dockerCmd(c, "run", "--net=none", testEnv.MinimalBaseImage(), "ping", "-n", "1", "127.0.0.1") + dockerCmd(c, "run", "--net=none", testEnv.PlatformDefaults.BaseImage, "ping", "-n", "1", "127.0.0.1") } else { dockerCmd(c, "run", "--net=none", "busybox", "ping", "-c", "1", "127.0.0.1") } @@ -4253,7 +4253,7 @@ func (s *DockerSuite) TestRunServicingContainer(c *check.C) { c.Skip("Disabled on post-RS3 builds") } - out := cli.DockerCmd(c, "run", "-d", testEnv.MinimalBaseImage(), "cmd", "/c", "mkdir c:\\programdata\\Microsoft\\Windows\\ContainerUpdates\\000_000_d99f45d0-ffc8-4af7-bd9c-ea6a62e035c9_200 && sc control cexecsvc 255").Combined() + out := cli.DockerCmd(c, "run", "-d", testEnv.PlatformDefaults.BaseImage, "cmd", "/c", "mkdir c:\\programdata\\Microsoft\\Windows\\ContainerUpdates\\000_000_d99f45d0-ffc8-4af7-bd9c-ea6a62e035c9_200 && sc control cexecsvc 255").Combined() containerID := strings.TrimSpace(out) cli.WaitExited(c, containerID, 60*time.Second) diff --git a/integration-cli/docker_utils_test.go b/integration-cli/docker_utils_test.go index 1bda2c7239..6eda88c684 100644 --- a/integration-cli/docker_utils_test.go +++ b/integration-cli/docker_utils_test.go @@ -399,7 +399,7 @@ func runSleepingContainerInImage(c *check.C, image string, extraArgs ...string) // minimalBaseImage returns the name of the minimal base image for the current // daemon platform. func minimalBaseImage() string { - return testEnv.MinimalBaseImage() + return testEnv.PlatformDefaults.BaseImage } func getGoroutineNumber() (int, error) { diff --git a/integration-cli/environment/environment.go b/integration-cli/environment/environment.go index 06fafeda0a..11eca5879a 100644 --- a/integration-cli/environment/environment.go +++ b/integration-cli/environment/environment.go @@ -57,9 +57,3 @@ func New() (*Execution, error) { func (e *Execution) DaemonPlatform() string { return e.OSType } - -// MinimalBaseImage is the image used for minimal builds (it depends on the platform) -// Deprecated: use Execution.PlatformDefaults.BaseImage -func (e *Execution) MinimalBaseImage() string { - return e.PlatformDefaults.BaseImage -} From 18a771a761654e241ae8d1e85aa0c0a6164c5d27 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 15 Jan 2018 15:32:06 +0100 Subject: [PATCH 4/4] Remove deprecated environment.DaemonPlatform() Signed-off-by: Sebastiaan van Stijn --- integration-cli/docker_api_build_test.go | 2 +- integration-cli/docker_api_containers_test.go | 8 +- integration-cli/docker_api_images_test.go | 4 +- integration-cli/docker_api_inspect_test.go | 2 +- integration-cli/docker_api_stats_test.go | 6 +- integration-cli/docker_api_test.go | 2 +- integration-cli/docker_cli_build_test.go | 44 +++++------ integration-cli/docker_cli_commit_test.go | 2 +- integration-cli/docker_cli_create_test.go | 6 +- integration-cli/docker_cli_diff_test.go | 2 +- integration-cli/docker_cli_events_test.go | 2 +- integration-cli/docker_cli_info_test.go | 2 +- integration-cli/docker_cli_inspect_test.go | 6 +- integration-cli/docker_cli_ps_test.go | 2 +- integration-cli/docker_cli_rename_test.go | 2 +- integration-cli/docker_cli_restart_test.go | 2 +- integration-cli/docker_cli_rmi_test.go | 4 +- integration-cli/docker_cli_run_test.go | 74 +++++++++---------- integration-cli/docker_cli_top_test.go | 4 +- integration-cli/docker_cli_update_test.go | 2 +- .../docker_deprecated_api_v124_test.go | 8 +- integration-cli/environment/environment.go | 9 --- integration-cli/fixtures_linux_daemon_test.go | 4 +- integration-cli/test_vars_test.go | 2 +- integration-cli/utils_test.go | 2 +- 25 files changed, 97 insertions(+), 106 deletions(-) diff --git a/integration-cli/docker_api_build_test.go b/integration-cli/docker_api_build_test.go index 3f43c95432..5f83394f69 100644 --- a/integration-cli/docker_api_build_test.go +++ b/integration-cli/docker_api_build_test.go @@ -30,7 +30,7 @@ func (s *DockerSuite) TestBuildAPIDockerFileRemote(c *check.C) { testRequires(c, NotUserNamespace) var testD string - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { testD = `FROM busybox RUN find / -name ba* RUN find /tmp/` diff --git a/integration-cli/docker_api_containers_test.go b/integration-cli/docker_api_containers_test.go index cd3566f4b4..02e8e9f7d2 100644 --- a/integration-cli/docker_api_containers_test.go +++ b/integration-cli/docker_api_containers_test.go @@ -1016,7 +1016,7 @@ func (s *DockerSuite) TestContainerAPIWait(c *check.C) { name := "test-api-wait" sleepCmd := "/bin/sleep" - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { sleepCmd = "sleep" } dockerCmd(c, "run", "--name", name, "busybox", sleepCmd, "2") @@ -1216,7 +1216,7 @@ func (s *DockerSuite) TestContainerAPIDeleteRemoveVolume(c *check.C) { testRequires(c, SameHostDaemon) vol := "/testvolume" - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { vol = `c:\testvolume` } @@ -1890,7 +1890,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *check.C) { var ( testImg string ) - if testEnv.DaemonPlatform() != "windows" { + if testEnv.OSType != "windows" { testImg = "test-mount-config" buildImageSuccessfully(c, testImg, build.WithDockerfile(` FROM busybox @@ -1987,7 +1987,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *check.C) { } } - if testEnv.DaemonPlatform() != "windows" { // Windows does not support volume populate + if testEnv.OSType != "windows" { // Windows does not support volume populate cases = append(cases, []testCase{ { spec: mounttypes.Mount{Type: "volume", Target: destPath, VolumeOptions: &mounttypes.VolumeOptions{NoCopy: true}}, diff --git a/integration-cli/docker_api_images_test.go b/integration-cli/docker_api_images_test.go index fba69dc682..10cb52eeb0 100644 --- a/integration-cli/docker_api_images_test.go +++ b/integration-cli/docker_api_images_test.go @@ -80,7 +80,7 @@ func (s *DockerSuite) TestAPIImagesDelete(c *check.C) { c.Assert(err, checker.IsNil) defer cli.Close() - if testEnv.DaemonPlatform() != "windows" { + if testEnv.OSType != "windows" { testRequires(c, Network) } name := "test-api-images-delete" @@ -104,7 +104,7 @@ func (s *DockerSuite) TestAPIImagesHistory(c *check.C) { c.Assert(err, checker.IsNil) defer cli.Close() - if testEnv.DaemonPlatform() != "windows" { + if testEnv.OSType != "windows" { testRequires(c, Network) } name := "test-api-images-history" diff --git a/integration-cli/docker_api_inspect_test.go b/integration-cli/docker_api_inspect_test.go index 38f3f4dd83..52a889f08b 100644 --- a/integration-cli/docker_api_inspect_test.go +++ b/integration-cli/docker_api_inspect_test.go @@ -28,7 +28,7 @@ func (s *DockerSuite) TestInspectAPIContainerResponse(c *check.C) { var cases []acase - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { cases = []acase{ {"v1.25", append(keysBase, "Mounts")}, } diff --git a/integration-cli/docker_api_stats_test.go b/integration-cli/docker_api_stats_test.go index 7c9de1c083..1818c3b4ea 100644 --- a/integration-cli/docker_api_stats_test.go +++ b/integration-cli/docker_api_stats_test.go @@ -39,7 +39,7 @@ func (s *DockerSuite) TestAPIStatsNoStreamGetCpu(c *check.C) { var cpuPercent = 0.0 - if testEnv.DaemonPlatform() != "windows" { + if testEnv.OSType != "windows" { cpuDelta := float64(v.CPUStats.CPUUsage.TotalUsage - v.PreCPUStats.CPUUsage.TotalUsage) systemDelta := float64(v.CPUStats.SystemUsage - v.PreCPUStats.SystemUsage) cpuPercent = (cpuDelta / systemDelta) * float64(len(v.CPUStats.CPUUsage.PercpuUsage)) * 100.0 @@ -105,7 +105,7 @@ func (s *DockerSuite) TestAPIStatsNetworkStats(c *check.C) { // Retrieve the container address net := "bridge" - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { net = "nat" } contIP := findContainerIP(c, id, net) @@ -153,7 +153,7 @@ func (s *DockerSuite) TestAPIStatsNetworkStats(c *check.C) { // On Linux, account for ARP. expRxPkts := preRxPackets + uint64(numPings) expTxPkts := preTxPackets + uint64(numPings) - if testEnv.DaemonPlatform() != "windows" { + if testEnv.OSType != "windows" { expRxPkts++ expTxPkts++ } diff --git a/integration-cli/docker_api_test.go b/integration-cli/docker_api_test.go index af189b9d07..e5b454fbf2 100644 --- a/integration-cli/docker_api_test.go +++ b/integration-cli/docker_api_test.go @@ -33,7 +33,7 @@ func (s *DockerSuite) TestAPIGetEnabledCORS(c *check.C) { } func (s *DockerSuite) TestAPIClientVersionOldNotSupported(c *check.C) { - if testEnv.DaemonPlatform() != runtime.GOOS { + if testEnv.OSType != runtime.GOOS { c.Skip("Daemon platform doesn't match test platform") } if api.MinVersion == api.DefaultVersion { diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index cb3b047a46..be1f656794 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -40,7 +40,7 @@ func (s *DockerSuite) TestBuildJSONEmptyRun(c *check.C) { func (s *DockerSuite) TestBuildShCmdJSONEntrypoint(c *check.C) { name := "testbuildshcmdjsonentrypoint" expected := "/bin/sh -c echo test" - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { expected = "cmd /S /C echo test" } @@ -78,7 +78,7 @@ func (s *DockerSuite) TestBuildEnvironmentReplacementVolume(c *check.C) { var volumePath string - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { volumePath = "c:/quux" } else { volumePath = "/quux" @@ -135,7 +135,7 @@ func (s *DockerSuite) TestBuildEnvironmentReplacementWorkdir(c *check.C) { res := inspectFieldJSON(c, name, "Config.WorkingDir") expected := `"/work"` - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { expected = `"C:\\work"` } if res != expected { @@ -1304,7 +1304,7 @@ func (s *DockerSuite) TestBuildRelativeWorkdir(c *check.C) { expectedFinal string ) - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { expected1 = `C:/` expected2 = `C:/test1` expected3 = `C:/test2` @@ -1383,7 +1383,7 @@ func (s *DockerSuite) TestBuildWorkdirWithEnvVariables(c *check.C) { name := "testbuildworkdirwithenvvariables" var expected string - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { expected = `C:\test1\test2` } else { expected = `/test1/test2` @@ -1405,7 +1405,7 @@ func (s *DockerSuite) TestBuildRelativeCopy(c *check.C) { testRequires(c, NotUserNamespace) var expected string - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { expected = `C:/test1/test2` } else { expected = `/test1/test2` @@ -2189,7 +2189,7 @@ func (s *DockerSuite) TestBuildAddFileNotFound(c *check.C) { name := "testbuildaddnotfound" expected := "foo: no such file or directory" - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { expected = "foo: The system cannot find the file specified" } @@ -2243,7 +2243,7 @@ func (s *DockerSuite) TestBuildOnBuild(c *check.C) { // gh #2446 func (s *DockerSuite) TestBuildAddToSymlinkDest(c *check.C) { makeLink := `ln -s /foo /bar` - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { makeLink = `mklink /D C:\bar C:\foo` } name := "testbuildaddtosymlinkdest" @@ -3198,7 +3198,7 @@ func (s *DockerSuite) TestBuildCmdShDashC(c *check.C) { res := inspectFieldJSON(c, name, "Config.Cmd") expected := `["/bin/sh","-c","echo cmd"]` - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { expected = `["cmd","/S","/C","echo cmd"]` } if res != expected { @@ -3271,7 +3271,7 @@ func (s *DockerSuite) TestBuildEntrypointCanBeOverriddenByChildInspect(c *check. expected = `["/bin/sh","-c","echo quux"]` ) - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { expected = `["cmd","/S","/C","echo quux"]` } @@ -3328,7 +3328,7 @@ func (s *DockerSuite) TestBuildVerifySingleQuoteFails(c *check.C) { // it should barf on it. name := "testbuildsinglequotefails" expectedExitCode := 2 - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { expectedExitCode = 127 } @@ -3344,7 +3344,7 @@ func (s *DockerSuite) TestBuildVerboseOut(c *check.C) { name := "testbuildverboseout" expected := "\n123\n" - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { expected = "\n123\r\n" } @@ -3360,7 +3360,7 @@ func (s *DockerSuite) TestBuildWithTabs(c *check.C) { res := inspectFieldJSON(c, name, "ContainerConfig.Cmd") expected1 := `["/bin/sh","-c","echo\tone\t\ttwo"]` expected2 := `["/bin/sh","-c","echo\u0009one\u0009\u0009two"]` // syntactically equivalent, and what Go 1.3 generates - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { expected1 = `["cmd","/S","/C","echo\tone\t\ttwo"]` expected2 = `["cmd","/S","/C","echo\u0009one\u0009\u0009two"]` // syntactically equivalent, and what Go 1.3 generates } @@ -3555,7 +3555,7 @@ func (s *DockerSuite) TestBuildStderr(c *check.C) { result.Assert(c, icmd.Success) // Windows to non-Windows should have a security warning - if runtime.GOOS == "windows" && testEnv.DaemonPlatform() != "windows" && !strings.Contains(result.Stdout(), "SECURITY WARNING:") { + if runtime.GOOS == "windows" && testEnv.OSType != "windows" && !strings.Contains(result.Stdout(), "SECURITY WARNING:") { c.Fatalf("Stdout contains unexpected output: %q", result.Stdout()) } @@ -3667,7 +3667,7 @@ func (s *DockerSuite) TestBuildVolumesRetainContents(c *check.C) { volName = "/foo" ) - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { volName = "C:/foo" } @@ -3968,7 +3968,7 @@ RUN echo " \ expected := "\n foo \n" // Windows uses the builtin echo, which preserves quotes - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { expected = "\" foo \"" } @@ -4002,7 +4002,7 @@ func (s *DockerSuite) TestBuildMissingArgs(c *check.C) { "INSERT": {}, } - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { skipCmds = map[string]struct{}{ "CMD": {}, "RUN": {}, @@ -4135,7 +4135,7 @@ func (s *DockerSuite) TestBuildRUNErrMsg(c *check.C) { name := "testbuildbadrunerrmsg" shell := "/bin/sh -c" exitCode := 127 - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { shell = "cmd /S /C" // architectural - Windows has to start the container to determine the exe is bad, Linux does not exitCode = 1 @@ -4287,7 +4287,7 @@ func (s *DockerTrustSuite) TestTrustedBuildTagIgnoresOtherDelegationRoles(c *che func (s *DockerSuite) TestBuildNullStringInAddCopyVolume(c *check.C) { name := "testbuildnullstringinaddcopyvolume" volName := "nullvolume" - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { volName = `C:\\nullvolume` } @@ -4327,7 +4327,7 @@ func (s *DockerSuite) TestBuildBuildTimeArg(c *check.C) { envKey := "foo" envVal := "bar" var dockerfile string - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { // Bugs in Windows busybox port - use the default base image and native cmd stuff dockerfile = fmt.Sprintf(`FROM `+minimalBaseImage()+` ARG %s @@ -4942,7 +4942,7 @@ func (s *DockerSuite) TestBuildMultiStageUnusedArg(c *check.C) { func (s *DockerSuite) TestBuildNoNamedVolume(c *check.C) { volName := "testname:/foo" - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { volName = "testname:C:\\foo" } dockerCmd(c, "run", "-v", volName, "busybox", "sh", "-c", "touch /foo/oops") @@ -6345,7 +6345,7 @@ WORKDIR /foo/bar // The Windows busybox image has a blank `cmd` lookingFor := `["sh"]` - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { lookingFor = "null" } c.Assert(strings.TrimSpace(out), checker.Equals, lookingFor) diff --git a/integration-cli/docker_cli_commit_test.go b/integration-cli/docker_cli_commit_test.go index 057c2d6f14..b0f21cef50 100644 --- a/integration-cli/docker_cli_commit_test.go +++ b/integration-cli/docker_cli_commit_test.go @@ -125,7 +125,7 @@ func (s *DockerSuite) TestCommitChange(c *check.C) { // ENV. On windows, the container doesn't have a `PATH` ENV variable so // the ordering is the same as the cli. expectedEnv := "[PATH=/foo DEBUG=true test=1]" - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { expectedEnv = "[DEBUG=true test=1 PATH=/foo]" } diff --git a/integration-cli/docker_cli_create_test.go b/integration-cli/docker_cli_create_test.go index 67bc98ee3f..448af9f199 100644 --- a/integration-cli/docker_cli_create_test.go +++ b/integration-cli/docker_cli_create_test.go @@ -60,7 +60,7 @@ func (s *DockerSuite) TestCreateArgs(c *check.C) { // Make sure we can grow the container's rootfs at creation time. func (s *DockerSuite) TestCreateGrowRootfs(c *check.C) { // Windows and Devicemapper support growing the rootfs - if testEnv.DaemonPlatform() != "windows" { + if testEnv.OSType != "windows" { testRequires(c, Devicemapper) } out, _ := dockerCmd(c, "create", "--storage-opt", "size=120G", "busybox") @@ -224,7 +224,7 @@ func (s *DockerSuite) TestCreateLabelFromImage(c *check.C) { func (s *DockerSuite) TestCreateHostnameWithNumber(c *check.C) { image := "busybox" // Busybox on Windows does not implement hostname command - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { image = testEnv.PlatformDefaults.BaseImage } out, _ := dockerCmd(c, "run", "-h", "web.0", image, "hostname") @@ -378,7 +378,7 @@ func (s *DockerSuite) TestCreateWithWorkdir(c *check.C) { dockerCmd(c, "create", "--name", name, "-w", dir, "busybox") // Windows does not create the workdir until the container is started - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { dockerCmd(c, "start", name) } dockerCmd(c, "cp", fmt.Sprintf("%s:%s", name, dir), prefix+slash+"tmp") diff --git a/integration-cli/docker_cli_diff_test.go b/integration-cli/docker_cli_diff_test.go index 3e95a7378a..614beee43c 100644 --- a/integration-cli/docker_cli_diff_test.go +++ b/integration-cli/docker_cli_diff_test.go @@ -20,7 +20,7 @@ func (s *DockerSuite) TestDiffFilenameShownInOutput(c *check.C) { // a "Files/" prefix. containerID := strings.TrimSpace(out) lookingFor := "A /foo/bar" - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { cli.WaitExited(c, containerID, 60*time.Second) lookingFor = "C Files/foo/bar" } diff --git a/integration-cli/docker_cli_events_test.go b/integration-cli/docker_cli_events_test.go index b75dcc1512..be91087b66 100644 --- a/integration-cli/docker_cli_events_test.go +++ b/integration-cli/docker_cli_events_test.go @@ -659,7 +659,7 @@ func (s *DockerSuite) TestEventsContainerRestart(c *check.C) { // wait until test2 is auto removed. waitTime := 10 * time.Second - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { // Windows takes longer... waitTime = 90 * time.Second } diff --git a/integration-cli/docker_cli_info_test.go b/integration-cli/docker_cli_info_test.go index 180464888d..35a2532196 100644 --- a/integration-cli/docker_cli_info_test.go +++ b/integration-cli/docker_cli_info_test.go @@ -36,7 +36,7 @@ func (s *DockerSuite) TestInfoEnsureSucceeds(c *check.C) { "Live Restore Enabled:", } - if testEnv.DaemonPlatform() == "linux" { + if testEnv.OSType == "linux" { stringsToCheck = append(stringsToCheck, "Init Binary:", "Security Options:", "containerd version:", "runc version:", "init version:") } diff --git a/integration-cli/docker_cli_inspect_test.go b/integration-cli/docker_cli_inspect_test.go index 13eb2d38aa..bf2ee71e95 100644 --- a/integration-cli/docker_cli_inspect_test.go +++ b/integration-cli/docker_cli_inspect_test.go @@ -61,7 +61,7 @@ func (s *DockerSuite) TestInspectStatus(c *check.C) { // Windows does not support pause/unpause on Windows Server Containers. // (RS1 does for Hyper-V Containers, but production CI is not setup for that) - if testEnv.DaemonPlatform() != "windows" { + if testEnv.OSType != "windows" { dockerCmd(c, "pause", out) inspectOut = inspectField(c, out, "State.Status") c.Assert(inspectOut, checker.Equals, "paused") @@ -206,7 +206,7 @@ func (s *DockerSuite) TestInspectContainerGraphDriver(c *check.C) { func (s *DockerSuite) TestInspectBindMountPoint(c *check.C) { modifier := ",z" prefix, slash := getPrefixAndSlashFromDaemonPlatform() - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { modifier = "" // Linux creates the host directory if it doesn't exist. Windows does not. os.Mkdir(`c:\data`, os.ModeDir) @@ -229,7 +229,7 @@ func (s *DockerSuite) TestInspectBindMountPoint(c *check.C) { c.Assert(m.Driver, checker.Equals, "") c.Assert(m.Source, checker.Equals, prefix+slash+"data") c.Assert(m.Destination, checker.Equals, prefix+slash+"data") - if testEnv.DaemonPlatform() != "windows" { // Windows does not set mode + if testEnv.OSType != "windows" { // Windows does not set mode c.Assert(m.Mode, checker.Equals, "ro"+modifier) } c.Assert(m.RW, checker.Equals, false) diff --git a/integration-cli/docker_cli_ps_test.go b/integration-cli/docker_cli_ps_test.go index bea1261202..6fe91f6565 100644 --- a/integration-cli/docker_cli_ps_test.go +++ b/integration-cli/docker_cli_ps_test.go @@ -216,7 +216,7 @@ func (s *DockerSuite) TestPsListContainersFilterStatus(c *check.C) { }) // Windows doesn't support pausing of containers - if testEnv.DaemonPlatform() != "windows" { + if testEnv.OSType != "windows" { // pause running container out = cli.DockerCmd(c, "run", "-itd", "busybox").Combined() pausedID := strings.TrimSpace(out) diff --git a/integration-cli/docker_cli_rename_test.go b/integration-cli/docker_cli_rename_test.go index de277596fe..e9d63684c8 100644 --- a/integration-cli/docker_cli_rename_test.go +++ b/integration-cli/docker_cli_rename_test.go @@ -93,7 +93,7 @@ func (s *DockerSuite) TestRenameAnonymousContainer(c *check.C) { dockerCmd(c, "start", "container1") count := "-c" - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { count = "-n" } diff --git a/integration-cli/docker_cli_restart_test.go b/integration-cli/docker_cli_restart_test.go index cf6b135ede..1b4c928b9a 100644 --- a/integration-cli/docker_cli_restart_test.go +++ b/integration-cli/docker_cli_restart_test.go @@ -269,7 +269,7 @@ func (s *DockerSuite) TestRestartContainerwithRestartPolicy(c *check.C) { id1 := strings.TrimSpace(string(out1)) id2 := strings.TrimSpace(string(out2)) waitTimeout := 15 * time.Second - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { waitTimeout = 150 * time.Second } err := waitInspect(id1, "{{ .State.Restarting }} {{ .State.Running }}", "false false", waitTimeout) diff --git a/integration-cli/docker_cli_rmi_test.go b/integration-cli/docker_cli_rmi_test.go index 52c8837d28..aedfa13a81 100644 --- a/integration-cli/docker_cli_rmi_test.go +++ b/integration-cli/docker_cli_rmi_test.go @@ -68,7 +68,7 @@ func (s *DockerSuite) TestRmiImgIDMultipleTag(c *check.C) { // Wait for it to exit as cannot commit a running container on Windows, and // it will take a few seconds to exit - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { cli.WaitExited(c, containerID, 60*time.Second) } @@ -109,7 +109,7 @@ func (s *DockerSuite) TestRmiImgIDForce(c *check.C) { // Wait for it to exit as cannot commit a running container on Windows, and // it will take a few seconds to exit - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { cli.WaitExited(c, containerID, 60*time.Second) } diff --git a/integration-cli/docker_cli_run_test.go b/integration-cli/docker_cli_run_test.go index 79be835edb..620f79e7ad 100644 --- a/integration-cli/docker_cli_run_test.go +++ b/integration-cli/docker_cli_run_test.go @@ -72,7 +72,7 @@ func (s *DockerSuite) TestRunLeakyFileDescriptors(c *check.C) { // this will fail when Internet access is unavailable func (s *DockerSuite) TestRunLookupGoogleDNS(c *check.C) { testRequires(c, Network, NotArm) - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { // nslookup isn't present in Windows busybox. Is built-in. Further, // nslookup isn't present in nanoserver. Hence just use PowerShell... dockerCmd(c, "run", testEnv.PlatformDefaults.BaseImage, "powershell", "Resolve-DNSName", "google.com") @@ -137,7 +137,7 @@ func (s *DockerSuite) TestRunDetachedContainerIDPrinting(c *check.C) { func (s *DockerSuite) TestRunWorkingDirectory(c *check.C) { dir := "/root" image := "busybox" - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { dir = `C:/Windows` } @@ -160,7 +160,7 @@ func (s *DockerSuite) TestRunWorkingDirectory(c *check.C) { func (s *DockerSuite) TestRunWithoutNetworking(c *check.C) { count := "-c" image := "busybox" - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { count = "-n" image = testEnv.PlatformDefaults.BaseImage } @@ -354,7 +354,7 @@ func (s *DockerSuite) TestRunWithVolumesFromExited(c *check.C) { ) // Create a file in a volume - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { out, exitCode = dockerCmd(c, "run", "--name", "test-data", "--volume", `c:\some\dir`, testEnv.PlatformDefaults.BaseImage, "cmd", "/c", `echo hello > c:\some\dir\file`) } else { out, exitCode = dockerCmd(c, "run", "--name", "test-data", "--volume", "/some/dir", "busybox", "touch", "/some/dir/file") @@ -364,7 +364,7 @@ func (s *DockerSuite) TestRunWithVolumesFromExited(c *check.C) { } // Read the file from another container using --volumes-from to access the volume in the second container - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { out, exitCode = dockerCmd(c, "run", "--volumes-from", "test-data", testEnv.PlatformDefaults.BaseImage, "cmd", "/c", `type c:\some\dir\file`) } else { out, exitCode = dockerCmd(c, "run", "--volumes-from", "test-data", "busybox", "cat", "/some/dir/file") @@ -396,7 +396,7 @@ func (s *DockerSuite) TestRunCreateVolumesInSymlinkDir(c *check.C) { // In the case of Windows to Windows CI, if the machine is setup so that // the temp directory is not the C: drive, this test is invalid and will // not work. - if testEnv.DaemonPlatform() == "windows" && strings.ToLower(dir[:1]) != "c" { + if testEnv.OSType == "windows" && strings.ToLower(dir[:1]) != "c" { c.Skip("Requires TEMP to point to C: drive") } @@ -406,7 +406,7 @@ func (s *DockerSuite) TestRunCreateVolumesInSymlinkDir(c *check.C) { } f.Close() - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { dockerFile = fmt.Sprintf("FROM %s\nRUN mkdir %s\nRUN mklink /D c:\\test %s", testEnv.PlatformDefaults.BaseImage, dir, dir) containerPath = `c:\test\test` cmd = "tasklist" @@ -431,7 +431,7 @@ func (s *DockerSuite) TestRunCreateVolumesInSymlinkDir2(c *check.C) { testRequires(c, SameHostDaemon, DaemonIsLinux) name := "test-volume-symlink2" - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { dockerFile = fmt.Sprintf("FROM %s\nRUN mkdir c:\\%s\nRUN mklink /D c:\\test c:\\%s", testEnv.PlatformDefaults.BaseImage, name, name) containerPath = `c:\test\test` cmd = "tasklist" @@ -455,7 +455,7 @@ func (s *DockerSuite) TestRunVolumesFromInReadonlyModeFails(c *check.C) { volumeDir string fileInVol string ) - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { volumeDir = `c:/test` // Forward-slash as using busybox fileInVol = `c:/test/file` } else { @@ -476,7 +476,7 @@ func (s *DockerSuite) TestRunVolumesFromInReadWriteMode(c *check.C) { volumeDir string fileInVol string ) - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { volumeDir = `c:/test` // Forward-slash as using busybox fileInVol = `c:/test/file` } else { @@ -497,7 +497,7 @@ func (s *DockerSuite) TestRunVolumesFromInReadWriteMode(c *check.C) { func (s *DockerSuite) TestVolumesFromGetsProperMode(c *check.C) { testRequires(c, SameHostDaemon) prefix, slash := getPrefixAndSlashFromDaemonPlatform() - hostpath := RandomTmpDirPath("test", testEnv.DaemonPlatform()) + hostpath := RandomTmpDirPath("test", testEnv.OSType) if err := os.MkdirAll(hostpath, 0755); err != nil { c.Fatalf("Failed to create %s: %q", hostpath, err) } @@ -520,11 +520,11 @@ func (s *DockerSuite) TestVolumesFromGetsProperMode(c *check.C) { // Test for GH#10618 func (s *DockerSuite) TestRunNoDupVolumes(c *check.C) { - path1 := RandomTmpDirPath("test1", testEnv.DaemonPlatform()) - path2 := RandomTmpDirPath("test2", testEnv.DaemonPlatform()) + path1 := RandomTmpDirPath("test1", testEnv.OSType) + path2 := RandomTmpDirPath("test2", testEnv.OSType) someplace := ":/someplace" - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { // Windows requires that the source directory exists before calling HCS testRequires(c, SameHostDaemon) someplace = `:c:\someplace` @@ -573,7 +573,7 @@ func (s *DockerSuite) TestRunNoDupVolumes(c *check.C) { // Test for #1351 func (s *DockerSuite) TestRunApplyVolumesFromBeforeVolumes(c *check.C) { prefix := "" - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { prefix = `c:` } dockerCmd(c, "run", "--name", "parent", "-v", prefix+"/test", "busybox", "touch", prefix+"/test/foo") @@ -582,7 +582,7 @@ func (s *DockerSuite) TestRunApplyVolumesFromBeforeVolumes(c *check.C) { func (s *DockerSuite) TestRunMultipleVolumesFrom(c *check.C) { prefix := "" - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { prefix = `c:` } dockerCmd(c, "run", "--name", "parent1", "-v", prefix+"/test", "busybox", "touch", prefix+"/test/foo") @@ -612,7 +612,7 @@ func (s *DockerSuite) TestRunVerifyContainerID(c *check.C) { // Test that creating a container with a volume doesn't crash. Regression test for #995. func (s *DockerSuite) TestRunCreateVolume(c *check.C) { prefix := "" - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { prefix = `c:` } dockerCmd(c, "run", "-v", prefix+"/var/lib/data", "busybox", "true") @@ -668,7 +668,7 @@ func (s *DockerSuite) TestRunVolumesFromSymlinkPath(c *check.C) { RUN ln -s home /foo VOLUME ["/foo/bar"]` - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { prefix = `c:` dfContents = `FROM ` + testEnv.PlatformDefaults.BaseImage + ` RUN mkdir c:\home @@ -714,7 +714,7 @@ func (s *DockerSuite) TestRunExitCode(c *check.C) { func (s *DockerSuite) TestRunUserDefaults(c *check.C) { expected := "uid=0(root) gid=0(root)" - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { expected = "uid=1000(ContainerAdministrator) gid=1000(ContainerAdministrator)" } out, _ := dockerCmd(c, "run", "busybox", "id") @@ -920,7 +920,7 @@ func (s *DockerSuite) TestRunEnvironmentOverride(c *check.C) { } func (s *DockerSuite) TestRunContainerNetwork(c *check.C) { - if testEnv.DaemonPlatform() == "windows" { + 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") } else { @@ -1220,7 +1220,7 @@ func (s *DockerSuite) TestRunModeHostname(c *check.C) { func (s *DockerSuite) TestRunRootWorkdir(c *check.C) { out, _ := dockerCmd(c, "run", "--workdir", "/", "busybox", "pwd") expected := "/\n" - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { expected = "C:" + expected } if out != expected { @@ -1229,7 +1229,7 @@ func (s *DockerSuite) TestRunRootWorkdir(c *check.C) { } func (s *DockerSuite) TestRunAllowBindMountingRoot(c *check.C) { - if testEnv.DaemonPlatform() == "windows" { + 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`) } else { @@ -1240,7 +1240,7 @@ func (s *DockerSuite) TestRunAllowBindMountingRoot(c *check.C) { func (s *DockerSuite) TestRunDisallowBindMountingRootToRoot(c *check.C) { mount := "/:/" targetDir := "/host" - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { mount = `c:\:c\` targetDir = "c:/host" // Forward slash as using busybox } @@ -1704,7 +1704,7 @@ func (s *DockerSuite) TestRunCleanupCmdOnEntrypoint(c *check.C) { } out = strings.TrimSpace(out) expected := "root" - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { if strings.Contains(testEnv.PlatformDefaults.BaseImage, "windowsservercore") { expected = `user manager\containeradministrator` } else { @@ -1720,7 +1720,7 @@ func (s *DockerSuite) TestRunCleanupCmdOnEntrypoint(c *check.C) { func (s *DockerSuite) TestRunWorkdirExistsAndIsFile(c *check.C) { existingFile := "/bin/cat" expected := "not a directory" - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { existingFile = `\windows\system32\ntdll.dll` expected = `The directory name is invalid.` } @@ -1736,7 +1736,7 @@ func (s *DockerSuite) TestRunExitOnStdinClose(c *check.C) { meow := "/bin/cat" delay := 60 - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { meow = "cat" } runCmd := exec.Command(dockerBinary, "run", "--name", name, "-i", "busybox", meow) @@ -1881,7 +1881,7 @@ func (s *DockerSuite) TestRunEntrypoint(c *check.C) { func (s *DockerSuite) TestRunBindMounts(c *check.C) { testRequires(c, SameHostDaemon) - if testEnv.DaemonPlatform() == "linux" { + if testEnv.OSType == "linux" { testRequires(c, DaemonIsLinux, NotUserNamespace) } @@ -1902,7 +1902,7 @@ func (s *DockerSuite) TestRunBindMounts(c *check.C) { } // test writing to bind mount - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { dockerCmd(c, "run", "-v", fmt.Sprintf(`%s:c:\tmp:rw`, tmpDir), "busybox", "touch", "c:/tmp/holla") } else { dockerCmd(c, "run", "-v", fmt.Sprintf("%s:/tmp:rw", tmpDir), "busybox", "touch", "/tmp/holla") @@ -1917,7 +1917,7 @@ func (s *DockerSuite) TestRunBindMounts(c *check.C) { } // Windows does not (and likely never will) support mounting a single file - if testEnv.DaemonPlatform() != "windows" { + if testEnv.OSType != "windows" { // test mount a file dockerCmd(c, "run", "-v", fmt.Sprintf("%s/holla:/tmp/holla:rw", tmpDir), "busybox", "sh", "-c", "echo -n 'yotta' > /tmp/holla") content := readFile(path.Join(tmpDir, "holla"), c) // Will fail if the file doesn't exist @@ -1942,7 +1942,7 @@ func (s *DockerSuite) TestRunCidFileCleanupIfEmpty(c *check.C) { tmpCidFile := path.Join(tmpDir, "cid") image := "emptyfs" - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { // Windows can't support an emptyfs image. Just use the regular Windows image image = testEnv.PlatformDefaults.BaseImage } @@ -1988,7 +1988,7 @@ func (s *DockerSuite) TestRunCidFileCheckIDLength(c *check.C) { func (s *DockerSuite) TestRunSetMacAddress(c *check.C) { mac := "12:34:56:78:9a:bc" var out string - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { out, _ = dockerCmd(c, "run", "-i", "--rm", fmt.Sprintf("--mac-address=%s", mac), "busybox", "sh", "-c", "ipconfig /all | grep 'Physical Address' | awk '{print $12}'") mac = strings.Replace(strings.ToUpper(mac), ":", "-", -1) // To Windows-style MACs } else { @@ -2185,7 +2185,7 @@ func (s *DockerSuite) TestVolumesNoCopyData(c *check.C) { c.Fatalf("Data was copied on volumes-from but shouldn't be:\n%q", out) } - tmpDir := RandomTmpDirPath("docker_test_bind_mount_copy_data", testEnv.DaemonPlatform()) + tmpDir := RandomTmpDirPath("docker_test_bind_mount_copy_data", testEnv.OSType) if out, _, err := dockerCmdWithError("run", "-v", tmpDir+":/foo", "dataimage", "ls", "-lh", "/foo/bar"); err == nil || !strings.Contains(out, "No such file or directory") { c.Fatalf("Data was copied on bind mount but shouldn't be:\n%q", out) } @@ -2558,7 +2558,7 @@ func (s *DockerSuite) TestRunNonLocalMacAddress(c *check.C) { args := []string{"run", "--mac-address", addr} expected := addr - if testEnv.DaemonPlatform() != "windows" { + if testEnv.OSType != "windows" { args = append(args, "busybox", "ifconfig") } else { args = append(args, testEnv.PlatformDefaults.BaseImage, "ipconfig", "/all") @@ -2654,7 +2654,7 @@ func (s *DockerSuite) TestRunSetDefaultRestartPolicy(c *check.C) { func (s *DockerSuite) TestRunRestartMaxRetries(c *check.C) { out, _ := dockerCmd(c, "run", "-d", "--restart=on-failure:3", "busybox", "false") timeout := 10 * time.Second - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { timeout = 120 * time.Second } @@ -3022,7 +3022,7 @@ func (s *DockerSuite) TestVolumeFromMixedRWOptions(c *check.C) { dockerCmd(c, "run", "--volumes-from", "parent:ro", "--name", "test-volumes-1", "busybox", "true") dockerCmd(c, "run", "--volumes-from", "parent:rw", "--name", "test-volumes-2", "busybox", "true") - if testEnv.DaemonPlatform() != "windows" { + if testEnv.OSType != "windows" { mRO, err := inspectMountPoint("test-volumes-1", prefix+slash+"test") c.Assert(err, checker.IsNil, check.Commentf("failed to inspect mount point")) if mRO.RW { @@ -3482,7 +3482,7 @@ func (s *DockerSuite) TestRunLoopbackOnlyExistsWhenNetworkingDisabled(c *check.C // Issue #4681 func (s *DockerSuite) TestRunLoopbackWhenNetworkDisabled(c *check.C) { - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { dockerCmd(c, "run", "--net=none", testEnv.PlatformDefaults.BaseImage, "ping", "-n", "1", "127.0.0.1") } else { dockerCmd(c, "run", "--net=none", "busybox", "ping", "-c", "1", "127.0.0.1") @@ -3749,7 +3749,7 @@ func (s *DockerSuite) TestRunNonExistingCmd(c *check.C) { // as that's when the check is made (and yes, by its design...) func (s *DockerSuite) TestCmdCannotBeInvoked(c *check.C) { expected := 126 - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { expected = 127 } name := "testCmdCannotBeInvoked" diff --git a/integration-cli/docker_cli_top_test.go b/integration-cli/docker_cli_top_test.go index f52f24014e..b8924d3b50 100644 --- a/integration-cli/docker_cli_top_test.go +++ b/integration-cli/docker_cli_top_test.go @@ -13,7 +13,7 @@ func (s *DockerSuite) TestTopMultipleArgs(c *check.C) { cleanedContainerID := strings.TrimSpace(out) var expected icmd.Expected - switch testEnv.DaemonPlatform() { + switch testEnv.OSType { case "windows": expected = icmd.Expected{ExitCode: 1, Err: "Windows does not support arguments to top"} default: @@ -34,7 +34,7 @@ func (s *DockerSuite) TestTopNonPrivileged(c *check.C) { // Windows will list the name of the launched executable which in this case is busybox.exe, without the parameters. // Linux will display the command executed in the container var lookingFor string - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { lookingFor = "busybox.exe" } else { lookingFor = "top" diff --git a/integration-cli/docker_cli_update_test.go b/integration-cli/docker_cli_update_test.go index 5b9b7304c5..dce137ebf8 100644 --- a/integration-cli/docker_cli_update_test.go +++ b/integration-cli/docker_cli_update_test.go @@ -13,7 +13,7 @@ import ( func (s *DockerSuite) TestUpdateRestartPolicy(c *check.C) { out := cli.DockerCmd(c, "run", "-d", "--restart=on-failure:3", "busybox", "sh", "-c", "sleep 1 && false").Combined() timeout := 60 * time.Second - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { timeout = 180 * time.Second } diff --git a/integration-cli/docker_deprecated_api_v124_test.go b/integration-cli/docker_deprecated_api_v124_test.go index 214ae08667..279efddd8e 100644 --- a/integration-cli/docker_deprecated_api_v124_test.go +++ b/integration-cli/docker_deprecated_api_v124_test.go @@ -36,7 +36,7 @@ func (s *DockerSuite) TestDeprecatedContainerAPIStartVolumeBinds(c *check.C) { // TODO Windows CI: Investigate further why this fails on Windows to Windows CI. testRequires(c, DaemonIsLinux) path := "/foo" - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { path = `c:\foo` } name := "testing" @@ -49,7 +49,7 @@ func (s *DockerSuite) TestDeprecatedContainerAPIStartVolumeBinds(c *check.C) { c.Assert(err, checker.IsNil) c.Assert(res.StatusCode, checker.Equals, http.StatusCreated) - bindPath := RandomTmpDirPath("test", testEnv.DaemonPlatform()) + bindPath := RandomTmpDirPath("test", testEnv.OSType) config = map[string]interface{}{ "Binds": []string{bindPath + ":" + path}, } @@ -76,8 +76,8 @@ func (s *DockerSuite) TestDeprecatedContainerAPIStartDupVolumeBinds(c *check.C) c.Assert(err, checker.IsNil) c.Assert(res.StatusCode, checker.Equals, http.StatusCreated) - bindPath1 := RandomTmpDirPath("test1", testEnv.DaemonPlatform()) - bindPath2 := RandomTmpDirPath("test2", testEnv.DaemonPlatform()) + bindPath1 := RandomTmpDirPath("test1", testEnv.OSType) + bindPath2 := RandomTmpDirPath("test2", testEnv.OSType) config = map[string]interface{}{ "Binds": []string{bindPath1 + ":/tmp", bindPath2 + ":/tmp"}, diff --git a/integration-cli/environment/environment.go b/integration-cli/environment/environment.go index 11eca5879a..7fd6743c71 100644 --- a/integration-cli/environment/environment.go +++ b/integration-cli/environment/environment.go @@ -48,12 +48,3 @@ func New() (*Execution, error) { dockerBinary: dockerBinary, }, nil } - -// DaemonPlatform is held globally so that tests can make intelligent -// decisions on how to configure themselves according to the platform -// of the daemon. This is initialized in docker_utils by sending -// a version call to the daemon and examining the response header. -// Deprecated: use Execution.OSType -func (e *Execution) DaemonPlatform() string { - return e.OSType -} diff --git a/integration-cli/fixtures_linux_daemon_test.go b/integration-cli/fixtures_linux_daemon_test.go index 6ac4511215..e1cad449f4 100644 --- a/integration-cli/fixtures_linux_daemon_test.go +++ b/integration-cli/fixtures_linux_daemon_test.go @@ -38,7 +38,7 @@ func ensureSyscallTest(c *check.C) { // if no match, must build in docker, which is significantly slower // (slower mostly because of the vfs graphdriver) - if testEnv.DaemonPlatform() != runtime.GOOS { + if testEnv.OSType != runtime.GOOS { ensureSyscallTestBuild(c) return } @@ -93,7 +93,7 @@ func ensureSyscallTestBuild(c *check.C) { func ensureNNPTest(c *check.C) { defer testEnv.ProtectImage(c, "nnp-test:latest") - if testEnv.DaemonPlatform() != runtime.GOOS { + if testEnv.OSType != runtime.GOOS { ensureNNPTestBuild(c) return } diff --git a/integration-cli/test_vars_test.go b/integration-cli/test_vars_test.go index 139279ccd1..82ec58e9e7 100644 --- a/integration-cli/test_vars_test.go +++ b/integration-cli/test_vars_test.go @@ -4,7 +4,7 @@ package main // the command is for a sleeping container based on the daemon platform. // The Windows busybox image does not have a `top` command. func sleepCommandForDaemonPlatform() []string { - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { return []string{"sleep", "240"} } return []string{"top"} diff --git a/integration-cli/utils_test.go b/integration-cli/utils_test.go index 1146e1b2fc..6c18c222d2 100644 --- a/integration-cli/utils_test.go +++ b/integration-cli/utils_test.go @@ -14,7 +14,7 @@ import ( ) func getPrefixAndSlashFromDaemonPlatform() (prefix, slash string) { - if testEnv.DaemonPlatform() == "windows" { + if testEnv.OSType == "windows" { return "c:", `\` } return "", "/"