mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #10785 from ahmetalpbalkan/win-cli/TestLinks-skip
integration-cli: add const to skip daemon-requiring cli tests
This commit is contained in:
commit
306bb28569
5 changed files with 56 additions and 0 deletions
|
@ -31,6 +31,8 @@ func TestLinksEtcHostsRegularFile(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestLinksEtcHostsContentMatch(t *testing.T) {
|
||||
testRequires(t, SameHostDaemon)
|
||||
|
||||
runCmd := exec.Command(dockerBinary, "run", "--net=host", "busybox", "cat", "/etc/hosts")
|
||||
out, _, _, err := runCommandWithStdoutStderr(runCmd)
|
||||
if err != nil {
|
||||
|
@ -109,6 +111,8 @@ func TestLinksPingLinkedContainersAfterRename(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestLinksIpTablesRulesWhenLinkAndUnlink(t *testing.T) {
|
||||
testRequires(t, SameHostDaemon)
|
||||
|
||||
dockerCmd(t, "run", "-d", "--name", "child", "--publish", "8080:80", "busybox", "sleep", "10")
|
||||
dockerCmd(t, "run", "-d", "--name", "parent", "--link", "child:http", "busybox", "sleep", "10")
|
||||
|
||||
|
@ -213,6 +217,8 @@ func TestLinksNotStartedParentNotFail(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestLinksHostsFilesInject(t *testing.T) {
|
||||
testRequires(t, SameHostDaemon)
|
||||
|
||||
defer deleteAllContainers()
|
||||
|
||||
out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "run", "-itd", "--name", "one", "busybox", "top"))
|
||||
|
@ -265,6 +271,8 @@ func TestLinksNetworkHostContainer(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestLinksUpdateOnRestart(t *testing.T) {
|
||||
testRequires(t, SameHostDaemon)
|
||||
|
||||
defer deleteAllContainers()
|
||||
|
||||
if out, err := exec.Command(dockerBinary, "run", "-d", "--name", "one", "busybox", "top").CombinedOutput(); err != nil {
|
||||
|
|
|
@ -9,6 +9,8 @@ import (
|
|||
)
|
||||
|
||||
func TestNetworkNat(t *testing.T) {
|
||||
testRequires(t, SameHostDaemon)
|
||||
|
||||
iface, err := net.InterfaceByName("eth0")
|
||||
if err != nil {
|
||||
t.Skipf("Test not running with `make test`. Interface eth0 not found: %s", err)
|
||||
|
|
8
integration-cli/docker_test_vars_cli.go
Normal file
8
integration-cli/docker_test_vars_cli.go
Normal file
|
@ -0,0 +1,8 @@
|
|||
// +build !daemon
|
||||
|
||||
package main
|
||||
|
||||
const (
|
||||
// tests should not assume daemon runs on the same machine as CLI
|
||||
isLocalDaemon = false
|
||||
)
|
8
integration-cli/docker_test_vars_daemon.go
Normal file
8
integration-cli/docker_test_vars_daemon.go
Normal file
|
@ -0,0 +1,8 @@
|
|||
// +build daemon
|
||||
|
||||
package main
|
||||
|
||||
const (
|
||||
// tests can assume daemon runs on the same machine as CLI
|
||||
isLocalDaemon = true
|
||||
)
|
30
integration-cli/requirements.go
Normal file
30
integration-cli/requirements.go
Normal file
|
@ -0,0 +1,30 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
type TestCondition func() bool
|
||||
|
||||
type TestRequirement struct {
|
||||
Condition TestCondition
|
||||
SkipMessage string
|
||||
}
|
||||
|
||||
// List test requirements
|
||||
var (
|
||||
SameHostDaemon = TestRequirement{
|
||||
func() bool { return isLocalDaemon },
|
||||
"Test requires docker daemon to runs on the same machine as CLI",
|
||||
}
|
||||
)
|
||||
|
||||
// testRequires checks if the environment satisfies the requirements
|
||||
// for the test to run or skips the tests.
|
||||
func testRequires(t *testing.T, requirements ...TestRequirement) {
|
||||
for _, r := range requirements {
|
||||
if !r.Condition() {
|
||||
t.Skip(r.SkipMessage)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue