TestDaemonRestartIpcMode: modernize

Move the test case from integration-cli to integration.

The test logic itself has not changed, except these
two things:

* the new test sets default-ipc-mode via command line
  rather than via daemon.json (less code);
* the new test uses current API version.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 9fd765f07cc08ccc2ea991d21835bf50ece9318b)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: b228a498d55fcd47c741d51a510a7f5eab0794f7
Component: engine
This commit is contained in:
Kir Kolyshkin
2019-04-17 23:09:51 +02:00
committed by Sebastiaan van Stijn
parent 51a09b5116
commit aa5b904041
2 changed files with 44 additions and 41 deletions
@@ -13,6 +13,7 @@ import (
"github.com/docker/docker/internal/test/daemon"
"golang.org/x/sys/unix"
"gotest.tools/assert"
is "gotest.tools/assert/cmp"
"gotest.tools/skip"
)
@@ -76,3 +77,46 @@ func getContainerdShimPid(t *testing.T, c types.ContainerJSON) int {
assert.Check(t, ppid != 1, "got unexpected ppid")
return ppid
}
// TestDaemonRestartIpcMode makes sure a container keeps its ipc mode
// (derived from daemon default) even after the daemon is restarted
// with a different default ipc mode.
func TestDaemonRestartIpcMode(t *testing.T) {
skip.If(t, testEnv.IsRemoteDaemon, "cannot start daemon on remote test run")
skip.If(t, testEnv.DaemonInfo.OSType == "windows")
t.Parallel()
d := daemon.New(t)
d.StartWithBusybox(t, "--iptables=false", "--default-ipc-mode=private")
defer d.Stop(t)
c := d.NewClientT(t)
ctx := context.Background()
// check the container is created with private ipc mode as per daemon default
cID := container.Run(t, ctx, c,
container.WithCmd("top"),
container.WithRestartPolicy("always"),
)
defer c.ContainerRemove(ctx, cID, types.ContainerRemoveOptions{Force: true})
inspect, err := c.ContainerInspect(ctx, cID)
assert.NilError(t, err)
assert.Check(t, is.Equal(string(inspect.HostConfig.IpcMode), "private"))
// restart the daemon with shareable default ipc mode
d.Restart(t, "--iptables=false", "--default-ipc-mode=shareable")
// check the container is still having private ipc mode
inspect, err = c.ContainerInspect(ctx, cID)
assert.NilError(t, err)
assert.Check(t, is.Equal(string(inspect.HostConfig.IpcMode), "private"))
// check a new container is created with shareable ipc mode as per new daemon default
cID = container.Run(t, ctx, c)
defer c.ContainerRemove(ctx, cID, types.ContainerRemoveOptions{Force: true})
inspect, err = c.ContainerInspect(ctx, cID)
assert.NilError(t, err)
assert.Check(t, is.Equal(string(inspect.HostConfig.IpcMode), "shareable"))
}