mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Fixes some integration/container test to run on remote daemon
``` docker build -f Dockerfile.e2e -t moby-e2e . docker run -v /var/run/docker.sock:/var/run/docker.sock \ -e TEST_INTEGRATION_DIR=/tests/integration/container \ -e DOCKER_API_VERSION=1.36 moby-e2e ``` Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
parent
135f815fb4
commit
18dd1d9aba
11 changed files with 36 additions and 22 deletions
|
@ -85,7 +85,7 @@ type DockerSuite struct {
|
|||
}
|
||||
|
||||
func (s *DockerSuite) OnTimeout(c *check.C) {
|
||||
if !testEnv.IsLocalDaemon() {
|
||||
if testEnv.IsRemoteDaemon() {
|
||||
return
|
||||
}
|
||||
path := filepath.Join(os.Getenv("DEST"), "docker.pid")
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/integration-cli/daemon"
|
||||
"github.com/docker/docker/integration/internal/container"
|
||||
"github.com/gotestyourself/gotestyourself/skip"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
@ -26,6 +27,7 @@ import (
|
|||
// the container process, then start dockerd back up and attempt to start the
|
||||
// container again.
|
||||
func TestContainerStartOnDaemonRestart(t *testing.T) {
|
||||
skip.If(t, testEnv.IsRemoteDaemon(), "cannot start daemon on remote test run")
|
||||
t.Parallel()
|
||||
|
||||
d := daemon.New(t, "", "dockerd", daemon.Config{})
|
||||
|
|
|
@ -20,7 +20,7 @@ import (
|
|||
)
|
||||
|
||||
func TestLinksEtcHostsContentMatch(t *testing.T) {
|
||||
skip.If(t, !testEnv.IsLocalDaemon())
|
||||
skip.If(t, testEnv.IsRemoteDaemon())
|
||||
|
||||
hosts, err := ioutil.ReadFile("/etc/hosts")
|
||||
skip.If(t, os.IsNotExist(err))
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
)
|
||||
|
||||
func TestContainerShmNoLeak(t *testing.T) {
|
||||
skip.If(t, testEnv.IsRemoteDaemon(), "cannot start daemon on remote test run")
|
||||
t.Parallel()
|
||||
d := daemon.New(t, "docker", "dockerd", daemon.Config{})
|
||||
client, err := d.NewClient()
|
||||
|
@ -94,7 +95,7 @@ func TestContainerShmNoLeak(t *testing.T) {
|
|||
|
||||
func TestContainerNetworkMountsNoChown(t *testing.T) {
|
||||
// chown only applies to Linux bind mounted volumes; must be same host to verify
|
||||
skip.If(t, testEnv.DaemonInfo.OSType != "linux" || !testEnv.IsLocalDaemon())
|
||||
skip.If(t, testEnv.DaemonInfo.OSType != "linux" || testEnv.IsRemoteDaemon())
|
||||
|
||||
defer setupTest(t)()
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import (
|
|||
)
|
||||
|
||||
func TestNetworkNat(t *testing.T) {
|
||||
skip.If(t, !testEnv.IsLocalDaemon())
|
||||
skip.If(t, testEnv.IsRemoteDaemon())
|
||||
|
||||
defer setupTest(t)()
|
||||
|
||||
|
@ -40,7 +40,7 @@ func TestNetworkNat(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestNetworkLocalhostTCPNat(t *testing.T) {
|
||||
skip.If(t, !testEnv.IsLocalDaemon())
|
||||
skip.If(t, testEnv.IsRemoteDaemon())
|
||||
|
||||
defer setupTest(t)()
|
||||
|
||||
|
@ -57,7 +57,7 @@ func TestNetworkLocalhostTCPNat(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestNetworkLoopbackNat(t *testing.T) {
|
||||
skip.If(t, !testEnv.IsLocalDaemon())
|
||||
skip.If(t, testEnv.IsRemoteDaemon())
|
||||
|
||||
msg := "it works"
|
||||
startServerContainer(t, msg, 8080)
|
||||
|
|
|
@ -25,20 +25,19 @@ func TestPause(t *testing.T) {
|
|||
client := request.NewAPIClient(t)
|
||||
ctx := context.Background()
|
||||
|
||||
name := "testeventpause"
|
||||
cID := container.Run(t, ctx, client, container.WithName(name))
|
||||
cID := container.Run(t, ctx, client)
|
||||
poll.WaitOn(t, container.IsInState(ctx, client, cID, "running"), poll.WithDelay(100*time.Millisecond))
|
||||
|
||||
since := request.DaemonUnixTime(ctx, t, client, testEnv)
|
||||
|
||||
err := client.ContainerPause(ctx, name)
|
||||
err := client.ContainerPause(ctx, cID)
|
||||
require.NoError(t, err)
|
||||
|
||||
inspect, err := client.ContainerInspect(ctx, cID)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, inspect.State.Paused, true)
|
||||
|
||||
err = client.ContainerUnpause(ctx, name)
|
||||
err = client.ContainerUnpause(ctx, cID)
|
||||
require.NoError(t, err)
|
||||
|
||||
until := request.DaemonUnixTime(ctx, t, client, testEnv)
|
||||
|
@ -46,7 +45,7 @@ func TestPause(t *testing.T) {
|
|||
messages, errs := client.Events(ctx, types.EventsOptions{
|
||||
Since: since,
|
||||
Until: until,
|
||||
Filters: filters.NewArgs(filters.Arg("container", name)),
|
||||
Filters: filters.NewArgs(filters.Arg("container", cID)),
|
||||
})
|
||||
assert.Equal(t, getEventActions(t, messages, errs), []string{"pause", "unpause"})
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ func getPrefixAndSlashFromDaemonPlatform() (prefix, slash string) {
|
|||
|
||||
// Test case for #5244: `docker rm` fails if bind dir doesn't exist anymore
|
||||
func TestRemoveContainerWithRemovedVolume(t *testing.T) {
|
||||
skip.If(t, !testEnv.IsLocalDaemon())
|
||||
skip.If(t, testEnv.IsRemoteDaemon())
|
||||
|
||||
defer setupTest(t)()
|
||||
ctx := context.Background()
|
||||
|
|
|
@ -55,7 +55,7 @@ func TestRenameStoppedContainer(t *testing.T) {
|
|||
|
||||
inspect, err := client.ContainerInspect(ctx, cID)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, inspect.Name, "/"+oldName)
|
||||
assert.Equal(t, "/"+oldName, inspect.Name)
|
||||
|
||||
newName := "new_name" + stringid.GenerateNonCryptoID()
|
||||
err = client.ContainerRename(ctx, oldName, newName)
|
||||
|
@ -63,7 +63,7 @@ func TestRenameStoppedContainer(t *testing.T) {
|
|||
|
||||
inspect, err = client.ContainerInspect(ctx, cID)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, inspect.Name, "/"+newName)
|
||||
assert.Equal(t, "/"+newName, inspect.Name)
|
||||
}
|
||||
|
||||
func TestRenameRunningContainerAndReuse(t *testing.T) {
|
||||
|
@ -81,7 +81,7 @@ func TestRenameRunningContainerAndReuse(t *testing.T) {
|
|||
|
||||
inspect, err := client.ContainerInspect(ctx, cID)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, inspect.Name, "/"+newName)
|
||||
assert.Equal(t, "/"+newName, inspect.Name)
|
||||
|
||||
_, err = client.ContainerInspect(ctx, oldName)
|
||||
testutil.ErrorContains(t, err, "No such container: "+oldName)
|
||||
|
@ -91,7 +91,7 @@ func TestRenameRunningContainerAndReuse(t *testing.T) {
|
|||
|
||||
inspect, err = client.ContainerInspect(ctx, cID)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, inspect.Name, "/"+oldName)
|
||||
assert.Equal(t, "/"+oldName, inspect.Name)
|
||||
}
|
||||
|
||||
func TestRenameInvalidName(t *testing.T) {
|
||||
|
@ -108,7 +108,7 @@ func TestRenameInvalidName(t *testing.T) {
|
|||
|
||||
inspect, err := client.ContainerInspect(ctx, oldName)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, inspect.ID, cID)
|
||||
assert.Equal(t, cID, inspect.ID)
|
||||
}
|
||||
|
||||
// Test case for GitHub issue 22466
|
||||
|
@ -133,6 +133,10 @@ func TestRenameAnonymousContainer(t *testing.T) {
|
|||
})
|
||||
err = client.ContainerRename(ctx, cID, "container1")
|
||||
require.NoError(t, err)
|
||||
// Stop/Start the container to get registered
|
||||
// FIXME(vdemeester) this is a really weird behavior as it fails otherwise
|
||||
err = client.ContainerStop(ctx, "container1", nil)
|
||||
require.NoError(t, err)
|
||||
err = client.ContainerStart(ctx, "container1", types.ContainerStartOptions{})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
@ -152,7 +156,7 @@ func TestRenameAnonymousContainer(t *testing.T) {
|
|||
|
||||
inspect, err := client.ContainerInspect(ctx, cID)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, inspect.State.ExitCode, 0)
|
||||
assert.Equal(t, 0, inspect.State.ExitCode, "container %s exited with the wrong exitcode: %+v", cID, inspect)
|
||||
}
|
||||
|
||||
// TODO: should be a unit test
|
||||
|
@ -175,7 +179,7 @@ func TestRenameContainerWithSameName(t *testing.T) {
|
|||
// of the linked container should be updated so that the other
|
||||
// container could still reference to the container that is renamed.
|
||||
func TestRenameContainerWithLinkedContainer(t *testing.T) {
|
||||
skip.If(t, !testEnv.IsLocalDaemon())
|
||||
skip.If(t, testEnv.IsRemoteDaemon())
|
||||
|
||||
defer setupTest(t)()
|
||||
ctx := context.Background()
|
||||
|
@ -192,5 +196,5 @@ func TestRenameContainerWithLinkedContainer(t *testing.T) {
|
|||
|
||||
inspect, err := client.ContainerInspect(ctx, "app2/mysql")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, inspect.ID, db1ID)
|
||||
assert.Equal(t, db1ID, inspect.ID)
|
||||
}
|
||||
|
|
|
@ -9,9 +9,11 @@ import (
|
|||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/integration-cli/daemon"
|
||||
"github.com/gotestyourself/gotestyourself/skip"
|
||||
)
|
||||
|
||||
func TestDaemonRestartKillContainers(t *testing.T) {
|
||||
skip.If(t, testEnv.IsRemoteDaemon(), "cannot start daemon on remote test run")
|
||||
type testCase struct {
|
||||
desc string
|
||||
config *container.Config
|
||||
|
|
|
@ -18,7 +18,7 @@ import (
|
|||
)
|
||||
|
||||
func TestInspect(t *testing.T) {
|
||||
skip.IfCondition(t, !testEnv.IsLocalDaemon())
|
||||
skip.IfCondition(t, testEnv.IsRemoteDaemon())
|
||||
defer setupTest(t)()
|
||||
d := swarm.NewSwarm(t, testEnv)
|
||||
defer d.Stop(t)
|
||||
|
|
|
@ -96,7 +96,7 @@ func toSlash(path string) string {
|
|||
}
|
||||
|
||||
// IsLocalDaemon is true if the daemon under test is on the same
|
||||
// host as the CLI.
|
||||
// host as the test process.
|
||||
//
|
||||
// Deterministically working out the environment in which CI is running
|
||||
// to evaluate whether the daemon is local or remote is not possible through
|
||||
|
@ -115,6 +115,12 @@ func (e *Execution) IsLocalDaemon() bool {
|
|||
return os.Getenv("DOCKER_REMOTE_DAEMON") == ""
|
||||
}
|
||||
|
||||
// IsRemoteDaemon is true if the daemon under test is on different host
|
||||
// as the test process.
|
||||
func (e *Execution) IsRemoteDaemon() bool {
|
||||
return !e.IsLocalDaemon()
|
||||
}
|
||||
|
||||
// Print the execution details to stdout
|
||||
// TODO: print everything
|
||||
func (e *Execution) Print() {
|
||||
|
|
Loading…
Reference in a new issue