From f24c530c7436ea4a2f47c2c0596a64ffd4f95dce Mon Sep 17 00:00:00 2001 From: Ahmet Alp Balkan Date: Wed, 18 Feb 2015 20:06:23 -0800 Subject: [PATCH] integ-cli: Skip tests assuming daemon/cli are on the same host Some integration-cli tests assume daemon and cli are running on the same machine and therefore they examine side effects of executed docker commands on docker host by reading files or running other sort of commands. In case of windows/darwin CLI tests these provide little or no value and should be OK to skip. List of skipped tests: - `TestContainerNetworkMode` - `TestCpVolumePath` - `TestCreateVolumesCreated` - `TestBuildContextCleanup` - `TestBuildContextCleanupFailedBuild` - `TestLinksEtcHostsContentMatch` - `TestRmContainerWithRemovedVolume` - `TestRunModeIpcHost` - `TestRunModeIpcContainer` - `TestRunModePidHost` - `TestRunNetHost` - `TestRunDeallocatePortOnMissingIptablesRule` - `TestRunPortInUse` - `TestRunPortProxy` - `TestRunMountOrdering` - `TestRunModeHostname` - `TestRunDnsDefaultOptions` - `TestRunDnsOptionsBasedOnHostResolvConf` - `TestRunResolvconfUpdater` - `TestRunVolumesNotRecreatedOnStart` Signed-off-by: Ahmet Alp Balkan Upstream-commit: b686b65c9b5f5eabc7a618faf0055aff06e4c0c4 Component: engine --- .../integration-cli/docker_cli_build_test.go | 4 ++++ .../integration-cli/docker_cli_cp_test.go | 2 ++ .../integration-cli/docker_cli_create_test.go | 1 + .../integration-cli/docker_cli_rm_test.go | 1 + .../integration-cli/docker_cli_run_test.go | 22 ++++++++++++++++--- 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/components/engine/integration-cli/docker_cli_build_test.go b/components/engine/integration-cli/docker_cli_build_test.go index f29eb8652b..738df91a21 100644 --- a/components/engine/integration-cli/docker_cli_build_test.go +++ b/components/engine/integration-cli/docker_cli_build_test.go @@ -2140,6 +2140,8 @@ func TestBuildEnv(t *testing.T) { } func TestBuildContextCleanup(t *testing.T) { + testRequires(t, SameHostDaemon) + name := "testbuildcontextcleanup" defer deleteImages(name) entries, err := ioutil.ReadDir("/var/lib/docker/tmp") @@ -2165,6 +2167,8 @@ func TestBuildContextCleanup(t *testing.T) { } func TestBuildContextCleanupFailedBuild(t *testing.T) { + testRequires(t, SameHostDaemon) + name := "testbuildcontextcleanup" defer deleteImages(name) defer deleteAllContainers() diff --git a/components/engine/integration-cli/docker_cli_cp_test.go b/components/engine/integration-cli/docker_cli_cp_test.go index 2b88b62bf6..ecda53526a 100644 --- a/components/engine/integration-cli/docker_cli_cp_test.go +++ b/components/engine/integration-cli/docker_cli_cp_test.go @@ -384,6 +384,8 @@ func TestCpUnprivilegedUser(t *testing.T) { } func TestCpVolumePath(t *testing.T) { + testRequires(t, SameHostDaemon) + tmpDir, err := ioutil.TempDir("", "cp-test-volumepath") if err != nil { t.Fatal(err) diff --git a/components/engine/integration-cli/docker_cli_create_test.go b/components/engine/integration-cli/docker_cli_create_test.go index 3ce8b2d258..92cd460335 100644 --- a/components/engine/integration-cli/docker_cli_create_test.go +++ b/components/engine/integration-cli/docker_cli_create_test.go @@ -228,6 +228,7 @@ func TestCreateEchoStdout(t *testing.T) { func TestCreateVolumesCreated(t *testing.T) { defer deleteAllContainers() + testRequires(t, SameHostDaemon) name := "test_create_volume" if out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "create", "--name", name, "-v", "/foo", "busybox")); err != nil { diff --git a/components/engine/integration-cli/docker_cli_rm_test.go b/components/engine/integration-cli/docker_cli_rm_test.go index c4c60f3856..50eda08195 100644 --- a/components/engine/integration-cli/docker_cli_rm_test.go +++ b/components/engine/integration-cli/docker_cli_rm_test.go @@ -9,6 +9,7 @@ import ( func TestRmContainerWithRemovedVolume(t *testing.T) { defer deleteAllContainers() + testRequires(t, SameHostDaemon) cmd := exec.Command(dockerBinary, "run", "--name", "losemyvolumes", "-v", "/tmp/testing:/test", "busybox", "true") if _, err := runCommand(cmd); err != nil { diff --git a/components/engine/integration-cli/docker_cli_run_test.go b/components/engine/integration-cli/docker_cli_run_test.go index e864276bd0..1051ac3114 100644 --- a/components/engine/integration-cli/docker_cli_run_test.go +++ b/components/engine/integration-cli/docker_cli_run_test.go @@ -1361,6 +1361,7 @@ func TestRunAddingOptionalDevices(t *testing.T) { func TestRunModeHostname(t *testing.T) { defer deleteAllContainers() + testRequires(t, SameHostDaemon) cmd := exec.Command(dockerBinary, "run", "-h=testhostname", "busybox", "cat", "/etc/hostname") out, _, err := runCommandWithOutput(cmd) @@ -1429,6 +1430,7 @@ func TestRunDisallowBindMountingRootToRoot(t *testing.T) { // Verify that a container gets default DNS when only localhost resolvers exist func TestRunDnsDefaultOptions(t *testing.T) { defer deleteAllContainers() + testRequires(t, SameHostDaemon) // preserve original resolv.conf for restoring after test origResolvConf, err := ioutil.ReadFile("/etc/resolv.conf") @@ -1500,8 +1502,7 @@ func TestRunDnsOptions(t *testing.T) { func TestRunDnsOptionsBasedOnHostResolvConf(t *testing.T) { defer deleteAllContainers() - - var out string + testRequires(t, SameHostDaemon) origResolvConf, err := ioutil.ReadFile("/etc/resolv.conf") if os.IsNotExist(err) { @@ -1511,8 +1512,8 @@ func TestRunDnsOptionsBasedOnHostResolvConf(t *testing.T) { hostNamservers := resolvconf.GetNameservers(origResolvConf) hostSearch := resolvconf.GetSearchDomains(origResolvConf) + var out string cmd := exec.Command(dockerBinary, "run", "--dns=127.0.0.1", "busybox", "cat", "/etc/resolv.conf") - if out, _, err = runCommandWithOutput(cmd); err != nil { t.Fatal(err, out) } @@ -1600,6 +1601,7 @@ func TestRunDnsOptionsBasedOnHostResolvConf(t *testing.T) { // stopped and have an unmodified copy of resolv.conf, as well as // marking running containers as requiring an update on next restart func TestRunResolvconfUpdater(t *testing.T) { + testRequires(t, SameHostDaemon) tmpResolvConf := []byte("search pommesfrites.fr\nnameserver 12.34.56.78") tmpLocalhostResolvConf := []byte("nameserver 127.0.0.1") @@ -2355,6 +2357,7 @@ func TestRunInspectMacAddress(t *testing.T) { func TestRunDeallocatePortOnMissingIptablesRule(t *testing.T) { defer deleteAllContainers() + testRequires(t, SameHostDaemon) cmd := exec.Command(dockerBinary, "run", "-d", "-p", "23:23", "busybox", "top") out, _, err := runCommandWithOutput(cmd) @@ -2386,6 +2389,7 @@ func TestRunDeallocatePortOnMissingIptablesRule(t *testing.T) { func TestRunPortInUse(t *testing.T) { defer deleteAllContainers() + testRequires(t, SameHostDaemon) port := "1234" l, err := net.Listen("tcp", ":"+port) @@ -2407,6 +2411,8 @@ func TestRunPortInUse(t *testing.T) { // https://github.com/docker/docker/issues/8428 func TestRunPortProxy(t *testing.T) { + testRequires(t, SameHostDaemon) + defer deleteAllContainers() port := "12345" @@ -2441,6 +2447,7 @@ func TestRunPortProxy(t *testing.T) { // Regression test for #7792 func TestRunMountOrdering(t *testing.T) { defer deleteAllContainers() + testRequires(t, SameHostDaemon) tmpDir, err := ioutil.TempDir("", "docker_nested_mount_test") if err != nil { @@ -2484,6 +2491,7 @@ func TestRunMountOrdering(t *testing.T) { // Regression test for https://github.com/docker/docker/issues/8259 func TestRunReuseBindVolumeThatIsSymlink(t *testing.T) { defer deleteAllContainers() + testRequires(t, SameHostDaemon) tmpDir, err := ioutil.TempDir(os.TempDir(), "testlink") if err != nil { @@ -2579,6 +2587,8 @@ func TestVolumesNoCopyData(t *testing.T) { } func TestRunVolumesNotRecreatedOnStart(t *testing.T) { + testRequires(t, SameHostDaemon) + // Clear out any remnants from other tests deleteAllContainers() info, err := ioutil.ReadDir(volumesConfigPath) @@ -2779,6 +2789,7 @@ func TestRunUnknownCommand(t *testing.T) { func TestRunModeIpcHost(t *testing.T) { defer deleteAllContainers() + testRequires(t, SameHostDaemon) hostIpc, err := os.Readlink("/proc/1/ns/ipc") if err != nil { @@ -2812,6 +2823,7 @@ func TestRunModeIpcHost(t *testing.T) { func TestRunModeIpcContainer(t *testing.T) { defer deleteAllContainers() + testRequires(t, SameHostDaemon) cmd := exec.Command(dockerBinary, "run", "-d", "busybox", "top") out, _, err := runCommandWithOutput(cmd) @@ -2851,6 +2863,7 @@ func TestRunModeIpcContainer(t *testing.T) { func TestContainerNetworkMode(t *testing.T) { defer deleteAllContainers() + testRequires(t, SameHostDaemon) cmd := exec.Command(dockerBinary, "run", "-d", "busybox", "top") out, _, err := runCommandWithOutput(cmd) @@ -2886,6 +2899,7 @@ func TestContainerNetworkMode(t *testing.T) { func TestRunModePidHost(t *testing.T) { defer deleteAllContainers() + testRequires(t, SameHostDaemon) hostPid, err := os.Readlink("/proc/1/ns/pid") if err != nil { @@ -3029,6 +3043,8 @@ func TestRunNonLocalMacAddress(t *testing.T) { } func TestRunNetHost(t *testing.T) { + testRequires(t, SameHostDaemon) + defer deleteAllContainers() hostNet, err := os.Readlink("/proc/1/ns/net") if err != nil {