Browse code

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 <ahmetalpbalkan@gmail.com>

Ahmet Alp Balkan authored on 2015/02/19 13:06:23
Showing 5 changed files
... ...
@@ -2140,6 +2140,8 @@ func TestBuildEnv(t *testing.T) {
2140 2140
 }
2141 2141
 
2142 2142
 func TestBuildContextCleanup(t *testing.T) {
2143
+	testRequires(t, SameHostDaemon)
2144
+
2143 2145
 	name := "testbuildcontextcleanup"
2144 2146
 	defer deleteImages(name)
2145 2147
 	entries, err := ioutil.ReadDir("/var/lib/docker/tmp")
... ...
@@ -2165,6 +2167,8 @@ func TestBuildContextCleanup(t *testing.T) {
2165 2165
 }
2166 2166
 
2167 2167
 func TestBuildContextCleanupFailedBuild(t *testing.T) {
2168
+	testRequires(t, SameHostDaemon)
2169
+
2168 2170
 	name := "testbuildcontextcleanup"
2169 2171
 	defer deleteImages(name)
2170 2172
 	defer deleteAllContainers()
... ...
@@ -384,6 +384,8 @@ func TestCpUnprivilegedUser(t *testing.T) {
384 384
 }
385 385
 
386 386
 func TestCpVolumePath(t *testing.T) {
387
+	testRequires(t, SameHostDaemon)
388
+
387 389
 	tmpDir, err := ioutil.TempDir("", "cp-test-volumepath")
388 390
 	if err != nil {
389 391
 		t.Fatal(err)
... ...
@@ -228,6 +228,7 @@ func TestCreateEchoStdout(t *testing.T) {
228 228
 
229 229
 func TestCreateVolumesCreated(t *testing.T) {
230 230
 	defer deleteAllContainers()
231
+	testRequires(t, SameHostDaemon)
231 232
 
232 233
 	name := "test_create_volume"
233 234
 	if out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "create", "--name", name, "-v", "/foo", "busybox")); err != nil {
... ...
@@ -9,6 +9,7 @@ import (
9 9
 
10 10
 func TestRmContainerWithRemovedVolume(t *testing.T) {
11 11
 	defer deleteAllContainers()
12
+	testRequires(t, SameHostDaemon)
12 13
 
13 14
 	cmd := exec.Command(dockerBinary, "run", "--name", "losemyvolumes", "-v", "/tmp/testing:/test", "busybox", "true")
14 15
 	if _, err := runCommand(cmd); err != nil {
... ...
@@ -1361,6 +1361,7 @@ func TestRunAddingOptionalDevices(t *testing.T) {
1361 1361
 
1362 1362
 func TestRunModeHostname(t *testing.T) {
1363 1363
 	defer deleteAllContainers()
1364
+	testRequires(t, SameHostDaemon)
1364 1365
 
1365 1366
 	cmd := exec.Command(dockerBinary, "run", "-h=testhostname", "busybox", "cat", "/etc/hostname")
1366 1367
 	out, _, err := runCommandWithOutput(cmd)
... ...
@@ -1429,6 +1430,7 @@ func TestRunDisallowBindMountingRootToRoot(t *testing.T) {
1429 1429
 // Verify that a container gets default DNS when only localhost resolvers exist
1430 1430
 func TestRunDnsDefaultOptions(t *testing.T) {
1431 1431
 	defer deleteAllContainers()
1432
+	testRequires(t, SameHostDaemon)
1432 1433
 
1433 1434
 	// preserve original resolv.conf for restoring after test
1434 1435
 	origResolvConf, err := ioutil.ReadFile("/etc/resolv.conf")
... ...
@@ -1500,8 +1502,7 @@ func TestRunDnsOptions(t *testing.T) {
1500 1500
 
1501 1501
 func TestRunDnsOptionsBasedOnHostResolvConf(t *testing.T) {
1502 1502
 	defer deleteAllContainers()
1503
-
1504
-	var out string
1503
+	testRequires(t, SameHostDaemon)
1505 1504
 
1506 1505
 	origResolvConf, err := ioutil.ReadFile("/etc/resolv.conf")
1507 1506
 	if os.IsNotExist(err) {
... ...
@@ -1511,8 +1512,8 @@ func TestRunDnsOptionsBasedOnHostResolvConf(t *testing.T) {
1511 1511
 	hostNamservers := resolvconf.GetNameservers(origResolvConf)
1512 1512
 	hostSearch := resolvconf.GetSearchDomains(origResolvConf)
1513 1513
 
1514
+	var out string
1514 1515
 	cmd := exec.Command(dockerBinary, "run", "--dns=127.0.0.1", "busybox", "cat", "/etc/resolv.conf")
1515
-
1516 1516
 	if out, _, err = runCommandWithOutput(cmd); err != nil {
1517 1517
 		t.Fatal(err, out)
1518 1518
 	}
... ...
@@ -1600,6 +1601,7 @@ func TestRunDnsOptionsBasedOnHostResolvConf(t *testing.T) {
1600 1600
 // stopped and have an unmodified copy of resolv.conf, as well as
1601 1601
 // marking running containers as requiring an update on next restart
1602 1602
 func TestRunResolvconfUpdater(t *testing.T) {
1603
+	testRequires(t, SameHostDaemon)
1603 1604
 
1604 1605
 	tmpResolvConf := []byte("search pommesfrites.fr\nnameserver 12.34.56.78")
1605 1606
 	tmpLocalhostResolvConf := []byte("nameserver 127.0.0.1")
... ...
@@ -2355,6 +2357,7 @@ func TestRunInspectMacAddress(t *testing.T) {
2355 2355
 
2356 2356
 func TestRunDeallocatePortOnMissingIptablesRule(t *testing.T) {
2357 2357
 	defer deleteAllContainers()
2358
+	testRequires(t, SameHostDaemon)
2358 2359
 
2359 2360
 	cmd := exec.Command(dockerBinary, "run", "-d", "-p", "23:23", "busybox", "top")
2360 2361
 	out, _, err := runCommandWithOutput(cmd)
... ...
@@ -2386,6 +2389,7 @@ func TestRunDeallocatePortOnMissingIptablesRule(t *testing.T) {
2386 2386
 
2387 2387
 func TestRunPortInUse(t *testing.T) {
2388 2388
 	defer deleteAllContainers()
2389
+	testRequires(t, SameHostDaemon)
2389 2390
 
2390 2391
 	port := "1234"
2391 2392
 	l, err := net.Listen("tcp", ":"+port)
... ...
@@ -2407,6 +2411,8 @@ func TestRunPortInUse(t *testing.T) {
2407 2407
 
2408 2408
 // https://github.com/docker/docker/issues/8428
2409 2409
 func TestRunPortProxy(t *testing.T) {
2410
+	testRequires(t, SameHostDaemon)
2411
+
2410 2412
 	defer deleteAllContainers()
2411 2413
 
2412 2414
 	port := "12345"
... ...
@@ -2441,6 +2447,7 @@ func TestRunPortProxy(t *testing.T) {
2441 2441
 // Regression test for #7792
2442 2442
 func TestRunMountOrdering(t *testing.T) {
2443 2443
 	defer deleteAllContainers()
2444
+	testRequires(t, SameHostDaemon)
2444 2445
 
2445 2446
 	tmpDir, err := ioutil.TempDir("", "docker_nested_mount_test")
2446 2447
 	if err != nil {
... ...
@@ -2484,6 +2491,7 @@ func TestRunMountOrdering(t *testing.T) {
2484 2484
 // Regression test for https://github.com/docker/docker/issues/8259
2485 2485
 func TestRunReuseBindVolumeThatIsSymlink(t *testing.T) {
2486 2486
 	defer deleteAllContainers()
2487
+	testRequires(t, SameHostDaemon)
2487 2488
 
2488 2489
 	tmpDir, err := ioutil.TempDir(os.TempDir(), "testlink")
2489 2490
 	if err != nil {
... ...
@@ -2579,6 +2587,8 @@ func TestVolumesNoCopyData(t *testing.T) {
2579 2579
 }
2580 2580
 
2581 2581
 func TestRunVolumesNotRecreatedOnStart(t *testing.T) {
2582
+	testRequires(t, SameHostDaemon)
2583
+
2582 2584
 	// Clear out any remnants from other tests
2583 2585
 	deleteAllContainers()
2584 2586
 	info, err := ioutil.ReadDir(volumesConfigPath)
... ...
@@ -2779,6 +2789,7 @@ func TestRunUnknownCommand(t *testing.T) {
2779 2779
 
2780 2780
 func TestRunModeIpcHost(t *testing.T) {
2781 2781
 	defer deleteAllContainers()
2782
+	testRequires(t, SameHostDaemon)
2782 2783
 
2783 2784
 	hostIpc, err := os.Readlink("/proc/1/ns/ipc")
2784 2785
 	if err != nil {
... ...
@@ -2812,6 +2823,7 @@ func TestRunModeIpcHost(t *testing.T) {
2812 2812
 
2813 2813
 func TestRunModeIpcContainer(t *testing.T) {
2814 2814
 	defer deleteAllContainers()
2815
+	testRequires(t, SameHostDaemon)
2815 2816
 
2816 2817
 	cmd := exec.Command(dockerBinary, "run", "-d", "busybox", "top")
2817 2818
 	out, _, err := runCommandWithOutput(cmd)
... ...
@@ -2851,6 +2863,7 @@ func TestRunModeIpcContainer(t *testing.T) {
2851 2851
 
2852 2852
 func TestContainerNetworkMode(t *testing.T) {
2853 2853
 	defer deleteAllContainers()
2854
+	testRequires(t, SameHostDaemon)
2854 2855
 
2855 2856
 	cmd := exec.Command(dockerBinary, "run", "-d", "busybox", "top")
2856 2857
 	out, _, err := runCommandWithOutput(cmd)
... ...
@@ -2886,6 +2899,7 @@ func TestContainerNetworkMode(t *testing.T) {
2886 2886
 
2887 2887
 func TestRunModePidHost(t *testing.T) {
2888 2888
 	defer deleteAllContainers()
2889
+	testRequires(t, SameHostDaemon)
2889 2890
 
2890 2891
 	hostPid, err := os.Readlink("/proc/1/ns/pid")
2891 2892
 	if err != nil {
... ...
@@ -3029,6 +3043,8 @@ func TestRunNonLocalMacAddress(t *testing.T) {
3029 3029
 }
3030 3030
 
3031 3031
 func TestRunNetHost(t *testing.T) {
3032
+	testRequires(t, SameHostDaemon)
3033
+
3032 3034
 	defer deleteAllContainers()
3033 3035
 	hostNet, err := os.Readlink("/proc/1/ns/net")
3034 3036
 	if err != nil {