mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
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)
This commit is contained in:
parent
df7ba57f5f
commit
321874f376
6 changed files with 43 additions and 12 deletions
|
@ -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 {
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
)
|
||||
|
||||
func TestNetworkNat(t *testing.T) {
|
||||
testRequires(t, SameHostDaemon)
|
||||
testRequires(t, SameHostDaemon, NativeExecDriver)
|
||||
defer deleteAllContainers()
|
||||
|
||||
iface, err := net.InterfaceByName("eth0")
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue