Browse code

Last three tests skip on lxc.

Now we can scale lxc tests to all PRs.

Docker-DCO-1.1-Signed-off-by: Jessie Frazelle <princess@docker.com> (github: jfrazelle)

Docker-DCO-1.1-Signed-off-by: Jessie Frazelle <hugs@docker.com> (github: jfrazelle)

Docker-DCO-1.1-Signed-off-by: Jessie Frazelle <jess@docker.com> (github: jfrazelle)

Jessica Frazelle authored on 2015/02/26 13:16:44
Showing 6 changed files
... ...
@@ -2,11 +2,12 @@ package main
2 2
 
3 3
 import (
4 4
 	"encoding/json"
5
-	"github.com/docker/docker/nat"
6 5
 	"os"
7 6
 	"os/exec"
8 7
 	"testing"
9 8
 	"time"
9
+
10
+	"github.com/docker/docker/nat"
10 11
 )
11 12
 
12 13
 // Make sure we can create a simple container with some args
... ...
@@ -227,8 +228,8 @@ func TestCreateEchoStdout(t *testing.T) {
227 227
 }
228 228
 
229 229
 func TestCreateVolumesCreated(t *testing.T) {
230
-	defer deleteAllContainers()
231 230
 	testRequires(t, SameHostDaemon)
231
+	defer deleteAllContainers()
232 232
 
233 233
 	name := "test_create_volume"
234 234
 	if out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "create", "--name", name, "-v", "/foo", "busybox")); err != nil {
... ...
@@ -30,9 +30,8 @@ func TestLinksEtcHostsRegularFile(t *testing.T) {
30 30
 }
31 31
 
32 32
 func TestLinksEtcHostsContentMatch(t *testing.T) {
33
-	defer deleteAllContainers()
34
-
35 33
 	testRequires(t, SameHostDaemon)
34
+	defer deleteAllContainers()
36 35
 
37 36
 	runCmd := exec.Command(dockerBinary, "run", "--net=host", "busybox", "cat", "/etc/hosts")
38 37
 	out, _, _, err := runCommandWithStdoutStderr(runCmd)
... ...
@@ -124,9 +123,8 @@ func TestLinksPingLinkedContainersAfterRename(t *testing.T) {
124 124
 }
125 125
 
126 126
 func TestLinksIpTablesRulesWhenLinkAndUnlink(t *testing.T) {
127
-	defer deleteAllContainers()
128
-
129 127
 	testRequires(t, SameHostDaemon)
128
+	defer deleteAllContainers()
130 129
 
131 130
 	dockerCmd(t, "run", "-d", "--name", "child", "--publish", "8080:80", "busybox", "sleep", "10")
132 131
 	dockerCmd(t, "run", "-d", "--name", "parent", "--link", "child:http", "busybox", "sleep", "10")
... ...
@@ -9,7 +9,7 @@ import (
9 9
 )
10 10
 
11 11
 func TestNetworkNat(t *testing.T) {
12
-	testRequires(t, SameHostDaemon)
12
+	testRequires(t, SameHostDaemon, NativeExecDriver)
13 13
 	defer deleteAllContainers()
14 14
 
15 15
 	iface, err := net.InterfaceByName("eth0")
... ...
@@ -8,8 +8,8 @@ import (
8 8
 )
9 9
 
10 10
 func TestRmContainerWithRemovedVolume(t *testing.T) {
11
-	defer deleteAllContainers()
12 11
 	testRequires(t, SameHostDaemon)
12
+	defer deleteAllContainers()
13 13
 
14 14
 	cmd := exec.Command(dockerBinary, "run", "--name", "losemyvolumes", "-v", "/tmp/testing:/test", "busybox", "true")
15 15
 	if _, err := runCommand(cmd); err != nil {
... ...
@@ -1348,8 +1348,8 @@ func TestRunAddingOptionalDevices(t *testing.T) {
1348 1348
 }
1349 1349
 
1350 1350
 func TestRunModeHostname(t *testing.T) {
1351
-	defer deleteAllContainers()
1352 1351
 	testRequires(t, SameHostDaemon)
1352
+	defer deleteAllContainers()
1353 1353
 
1354 1354
 	cmd := exec.Command(dockerBinary, "run", "-h=testhostname", "busybox", "cat", "/etc/hostname")
1355 1355
 	out, _, err := runCommandWithOutput(cmd)
... ...
@@ -2764,6 +2764,7 @@ func TestRunExposePort(t *testing.T) {
2764 2764
 }
2765 2765
 
2766 2766
 func TestRunUnknownCommand(t *testing.T) {
2767
+	testRequires(t, NativeExecDriver)
2767 2768
 	defer deleteAllContainers()
2768 2769
 	runCmd := exec.Command(dockerBinary, "create", "busybox", "/bin/nada")
2769 2770
 	cID, _, _, err := runCommandWithStdoutStderr(runCmd)
... ...
@@ -2791,8 +2792,8 @@ func TestRunUnknownCommand(t *testing.T) {
2791 2791
 }
2792 2792
 
2793 2793
 func TestRunModeIpcHost(t *testing.T) {
2794
-	defer deleteAllContainers()
2795 2794
 	testRequires(t, SameHostDaemon)
2795
+	defer deleteAllContainers()
2796 2796
 
2797 2797
 	hostIpc, err := os.Readlink("/proc/1/ns/ipc")
2798 2798
 	if err != nil {
... ...
@@ -2901,8 +2902,8 @@ func TestContainerNetworkMode(t *testing.T) {
2901 2901
 }
2902 2902
 
2903 2903
 func TestRunModePidHost(t *testing.T) {
2904
+	testRequires(t, NativeExecDriver, SameHostDaemon)
2904 2905
 	defer deleteAllContainers()
2905
-	testRequires(t, SameHostDaemon)
2906 2906
 
2907 2907
 	hostPid, err := os.Readlink("/proc/1/ns/pid")
2908 2908
 	if err != nil {
... ...
@@ -3047,8 +3048,8 @@ func TestRunNonLocalMacAddress(t *testing.T) {
3047 3047
 
3048 3048
 func TestRunNetHost(t *testing.T) {
3049 3049
 	testRequires(t, SameHostDaemon)
3050
-
3051 3050
 	defer deleteAllContainers()
3051
+
3052 3052
 	hostNet, err := os.Readlink("/proc/1/ns/net")
3053 3053
 	if err != nil {
3054 3054
 		t.Fatal(err)
... ...
@@ -3157,7 +3158,9 @@ func TestRunContainerWithWritableRootfs(t *testing.T) {
3157 3157
 }
3158 3158
 
3159 3159
 func TestRunContainerWithReadonlyRootfs(t *testing.T) {
3160
+	testRequires(t, NativeExecDriver)
3160 3161
 	defer deleteAllContainers()
3162
+
3161 3163
 	out, err := exec.Command(dockerBinary, "run", "--read-only", "--rm", "busybox", "touch", "/file").CombinedOutput()
3162 3164
 	if err == nil {
3163 3165
 		t.Fatal("expected container to error on run with read only error")
... ...
@@ -1,8 +1,11 @@
1 1
 package main
2 2
 
3 3
 import (
4
+	"encoding/json"
4 5
 	"fmt"
6
+	"log"
5 7
 	"os/exec"
8
+	"strings"
6 9
 	"testing"
7 10
 )
8 11
 
... ...
@@ -15,6 +18,8 @@ type TestRequirement struct {
15 15
 
16 16
 // List test requirements
17 17
 var (
18
+	daemonExecDriver string
19
+
18 20
 	SameHostDaemon = TestRequirement{
19 21
 		func() bool { return isLocalDaemon },
20 22
 		"Test requires docker daemon to runs on the same machine as CLI",
... ...
@@ -37,6 +42,30 @@ var (
37 37
 		},
38 38
 		fmt.Sprintf("Test requires an environment that can host %s in the same host", v2binary),
39 39
 	}
40
+	NativeExecDriver = TestRequirement{
41
+		func() bool {
42
+			if daemonExecDriver == "" {
43
+				// get daemon info
44
+				body, err := sockRequest("GET", "/info", nil)
45
+				if err != nil {
46
+					log.Fatalf("sockRequest failed for /info: %v", err)
47
+				}
48
+
49
+				type infoJSON struct {
50
+					ExecutionDriver string
51
+				}
52
+				var info infoJSON
53
+				if err = json.Unmarshal(body, &info); err != nil {
54
+					log.Fatalf("unable to unmarshal body: %v", err)
55
+				}
56
+
57
+				daemonExecDriver = info.ExecutionDriver
58
+			}
59
+
60
+			return strings.HasPrefix(daemonExecDriver, "native")
61
+		},
62
+		"Test requires the native (libcontainer) exec driver.",
63
+	}
40 64
 )
41 65
 
42 66
 // testRequires checks if the environment satisfies the requirements