Sfoglia il codice sorgente

Merge pull request #11030 from jfrazelle/skip-lxc-remaining-tests

Last three tests skip on lxc.
Tibor Vass 10 anni fa
parent
commit
ffc738225d

+ 3 - 2
integration-cli/docker_cli_create_test.go

@@ -2,11 +2,12 @@ package main
 
 import (
 	"encoding/json"
-	"github.com/docker/docker/nat"
 	"os"
 	"os/exec"
 	"testing"
 	"time"
+
+	"github.com/docker/docker/nat"
 )
 
 // Make sure we can create a simple container with some args
@@ -227,8 +228,8 @@ func TestCreateEchoStdout(t *testing.T) {
 }
 
 func TestCreateVolumesCreated(t *testing.T) {
-	defer deleteAllContainers()
 	testRequires(t, SameHostDaemon)
+	defer deleteAllContainers()
 
 	name := "test_create_volume"
 	if out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "create", "--name", name, "-v", "/foo", "busybox")); err != nil {

+ 2 - 4
integration-cli/docker_cli_links_test.go

@@ -30,9 +30,8 @@ func TestLinksEtcHostsRegularFile(t *testing.T) {
 }
 
 func TestLinksEtcHostsContentMatch(t *testing.T) {
-	defer deleteAllContainers()
-
 	testRequires(t, SameHostDaemon)
+	defer deleteAllContainers()
 
 	runCmd := exec.Command(dockerBinary, "run", "--net=host", "busybox", "cat", "/etc/hosts")
 	out, _, _, err := runCommandWithStdoutStderr(runCmd)
@@ -124,9 +123,8 @@ func TestLinksPingLinkedContainersAfterRename(t *testing.T) {
 }
 
 func TestLinksIpTablesRulesWhenLinkAndUnlink(t *testing.T) {
-	defer deleteAllContainers()
-
 	testRequires(t, SameHostDaemon)
+	defer deleteAllContainers()
 
 	dockerCmd(t, "run", "-d", "--name", "child", "--publish", "8080:80", "busybox", "sleep", "10")
 	dockerCmd(t, "run", "-d", "--name", "parent", "--link", "child:http", "busybox", "sleep", "10")

+ 1 - 1
integration-cli/docker_cli_nat_test.go

@@ -9,7 +9,7 @@ import (
 )
 
 func TestNetworkNat(t *testing.T) {
-	testRequires(t, SameHostDaemon)
+	testRequires(t, SameHostDaemon, NativeExecDriver)
 	defer deleteAllContainers()
 
 	iface, err := net.InterfaceByName("eth0")

+ 1 - 1
integration-cli/docker_cli_rm_test.go

@@ -8,8 +8,8 @@ import (
 )
 
 func TestRmContainerWithRemovedVolume(t *testing.T) {
-	defer deleteAllContainers()
 	testRequires(t, SameHostDaemon)
+	defer deleteAllContainers()
 
 	cmd := exec.Command(dockerBinary, "run", "--name", "losemyvolumes", "-v", "/tmp/testing:/test", "busybox", "true")
 	if _, err := runCommand(cmd); err != nil {

+ 7 - 4
integration-cli/docker_cli_run_test.go

@@ -1348,8 +1348,8 @@ func TestRunAddingOptionalDevices(t *testing.T) {
 }
 
 func TestRunModeHostname(t *testing.T) {
-	defer deleteAllContainers()
 	testRequires(t, SameHostDaemon)
+	defer deleteAllContainers()
 
 	cmd := exec.Command(dockerBinary, "run", "-h=testhostname", "busybox", "cat", "/etc/hostname")
 	out, _, err := runCommandWithOutput(cmd)
@@ -2764,6 +2764,7 @@ func TestRunExposePort(t *testing.T) {
 }
 
 func TestRunUnknownCommand(t *testing.T) {
+	testRequires(t, NativeExecDriver)
 	defer deleteAllContainers()
 	runCmd := exec.Command(dockerBinary, "create", "busybox", "/bin/nada")
 	cID, _, _, err := runCommandWithStdoutStderr(runCmd)
@@ -2791,8 +2792,8 @@ func TestRunUnknownCommand(t *testing.T) {
 }
 
 func TestRunModeIpcHost(t *testing.T) {
-	defer deleteAllContainers()
 	testRequires(t, SameHostDaemon)
+	defer deleteAllContainers()
 
 	hostIpc, err := os.Readlink("/proc/1/ns/ipc")
 	if err != nil {
@@ -2901,8 +2902,8 @@ func TestContainerNetworkMode(t *testing.T) {
 }
 
 func TestRunModePidHost(t *testing.T) {
+	testRequires(t, NativeExecDriver, SameHostDaemon)
 	defer deleteAllContainers()
-	testRequires(t, SameHostDaemon)
 
 	hostPid, err := os.Readlink("/proc/1/ns/pid")
 	if err != nil {
@@ -3047,8 +3048,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 {
 		t.Fatal(err)
@@ -3157,7 +3158,9 @@ func TestRunContainerWithWritableRootfs(t *testing.T) {
 }
 
 func TestRunContainerWithReadonlyRootfs(t *testing.T) {
+	testRequires(t, NativeExecDriver)
 	defer deleteAllContainers()
+
 	out, err := exec.Command(dockerBinary, "run", "--read-only", "--rm", "busybox", "touch", "/file").CombinedOutput()
 	if err == nil {
 		t.Fatal("expected container to error on run with read only error")

+ 29 - 0
integration-cli/requirements.go

@@ -1,8 +1,11 @@
 package main
 
 import (
+	"encoding/json"
 	"fmt"
+	"log"
 	"os/exec"
+	"strings"
 	"testing"
 )
 
@@ -15,6 +18,8 @@ type TestRequirement struct {
 
 // List test requirements
 var (
+	daemonExecDriver string
+
 	SameHostDaemon = TestRequirement{
 		func() bool { return isLocalDaemon },
 		"Test requires docker daemon to runs on the same machine as CLI",
@@ -37,6 +42,30 @@ var (
 		},
 		fmt.Sprintf("Test requires an environment that can host %s in the same host", v2binary),
 	}
+	NativeExecDriver = TestRequirement{
+		func() bool {
+			if daemonExecDriver == "" {
+				// get daemon info
+				body, err := sockRequest("GET", "/info", nil)
+				if err != nil {
+					log.Fatalf("sockRequest failed for /info: %v", err)
+				}
+
+				type infoJSON struct {
+					ExecutionDriver string
+				}
+				var info infoJSON
+				if err = json.Unmarshal(body, &info); err != nil {
+					log.Fatalf("unable to unmarshal body: %v", err)
+				}
+
+				daemonExecDriver = info.ExecutionDriver
+			}
+
+			return strings.HasPrefix(daemonExecDriver, "native")
+		},
+		"Test requires the native (libcontainer) exec driver.",
+	}
 )
 
 // testRequires checks if the environment satisfies the requirements