From 0855922cd3cd1e9d846fd85ef968653ff8649a44 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Fri, 9 Feb 2018 12:46:38 +0000 Subject: [PATCH] Migrate TestKillDifferentUserContainer to api test This fix migrates TestKillDifferentUserContainer to api test Signed-off-by: Yong Tang --- integration-cli/docker_cli_kill_test.go | 25 ------------------------- integration/container/kill_test.go | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 25 deletions(-) delete mode 100644 integration-cli/docker_cli_kill_test.go diff --git a/integration-cli/docker_cli_kill_test.go b/integration-cli/docker_cli_kill_test.go deleted file mode 100644 index e2e510fcaa..0000000000 --- a/integration-cli/docker_cli_kill_test.go +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "strings" - "time" - - "github.com/docker/docker/integration-cli/checker" - "github.com/docker/docker/integration-cli/cli" - "github.com/go-check/check" -) - -func (s *DockerSuite) TestKillDifferentUserContainer(c *check.C) { - // TODO Windows: Windows does not yet support -u (Feb 2016). - testRequires(c, DaemonIsLinux) - out := cli.DockerCmd(c, "run", "-u", "daemon", "-d", "busybox", "top").Combined() - cleanedContainerID := strings.TrimSpace(out) - cli.WaitRun(c, cleanedContainerID) - - cli.DockerCmd(c, "kill", cleanedContainerID) - cli.WaitExited(c, cleanedContainerID, 10*time.Second) - - out = cli.DockerCmd(c, "ps", "-q").Combined() - c.Assert(out, checker.Not(checker.Contains), cleanedContainerID, check.Commentf("killed container is still running")) - -} diff --git a/integration/container/kill_test.go b/integration/container/kill_test.go index 57343942da..2bef7e4e96 100644 --- a/integration/container/kill_test.go +++ b/integration/container/kill_test.go @@ -175,3 +175,21 @@ func TestKillStoppedContainerAPIPre120(t *testing.T) { err = client.ContainerKill(ctx, c.ID, "SIGKILL") require.NoError(t, err) } + +func TestKillDifferentUserContainer(t *testing.T) { + // TODO Windows: Windows does not yet support -u (Feb 2016). + skip.If(t, testEnv.OSType != "linux", "User containers (container.Config.User) are not yet supported on %q platform", testEnv.OSType) + + defer setupTest(t)() + ctx := context.Background() + client := request.NewAPIClient(t, client.WithVersion("1.19")) + + cID := runSimpleContainer(ctx, t, client, "", func(config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig) { + config.User = "daemon" + }) + poll.WaitOn(t, containerIsInState(ctx, client, cID, "running"), poll.WithDelay(100*time.Millisecond)) + + err := client.ContainerKill(ctx, cID, "SIGKILL") + require.NoError(t, err) + poll.WaitOn(t, containerIsInState(ctx, client, cID, "exited"), poll.WithDelay(100*time.Millisecond)) +}