This fix migrates TestKillDifferentUserContainer to api test
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
| 1 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,25 +0,0 @@ |
| 1 |
-package main |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "strings" |
|
| 5 |
- "time" |
|
| 6 |
- |
|
| 7 |
- "github.com/docker/docker/integration-cli/checker" |
|
| 8 |
- "github.com/docker/docker/integration-cli/cli" |
|
| 9 |
- "github.com/go-check/check" |
|
| 10 |
-) |
|
| 11 |
- |
|
| 12 |
-func (s *DockerSuite) TestKillDifferentUserContainer(c *check.C) {
|
|
| 13 |
- // TODO Windows: Windows does not yet support -u (Feb 2016). |
|
| 14 |
- testRequires(c, DaemonIsLinux) |
|
| 15 |
- out := cli.DockerCmd(c, "run", "-u", "daemon", "-d", "busybox", "top").Combined() |
|
| 16 |
- cleanedContainerID := strings.TrimSpace(out) |
|
| 17 |
- cli.WaitRun(c, cleanedContainerID) |
|
| 18 |
- |
|
| 19 |
- cli.DockerCmd(c, "kill", cleanedContainerID) |
|
| 20 |
- cli.WaitExited(c, cleanedContainerID, 10*time.Second) |
|
| 21 |
- |
|
| 22 |
- out = cli.DockerCmd(c, "ps", "-q").Combined() |
|
| 23 |
- c.Assert(out, checker.Not(checker.Contains), cleanedContainerID, check.Commentf("killed container is still running"))
|
|
| 24 |
- |
|
| 25 |
-} |
| ... | ... |
@@ -175,3 +175,21 @@ func TestKillStoppedContainerAPIPre120(t *testing.T) {
|
| 175 | 175 |
err = client.ContainerKill(ctx, c.ID, "SIGKILL") |
| 176 | 176 |
require.NoError(t, err) |
| 177 | 177 |
} |
| 178 |
+ |
|
| 179 |
+func TestKillDifferentUserContainer(t *testing.T) {
|
|
| 180 |
+ // TODO Windows: Windows does not yet support -u (Feb 2016). |
|
| 181 |
+ skip.If(t, testEnv.OSType != "linux", "User containers (container.Config.User) are not yet supported on %q platform", testEnv.OSType) |
|
| 182 |
+ |
|
| 183 |
+ defer setupTest(t)() |
|
| 184 |
+ ctx := context.Background() |
|
| 185 |
+ client := request.NewAPIClient(t, client.WithVersion("1.19"))
|
|
| 186 |
+ |
|
| 187 |
+ cID := runSimpleContainer(ctx, t, client, "", func(config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig) {
|
|
| 188 |
+ config.User = "daemon" |
|
| 189 |
+ }) |
|
| 190 |
+ poll.WaitOn(t, containerIsInState(ctx, client, cID, "running"), poll.WithDelay(100*time.Millisecond)) |
|
| 191 |
+ |
|
| 192 |
+ err := client.ContainerKill(ctx, cID, "SIGKILL") |
|
| 193 |
+ require.NoError(t, err) |
|
| 194 |
+ poll.WaitOn(t, containerIsInState(ctx, client, cID, "exited"), poll.WithDelay(100*time.Millisecond)) |
|
| 195 |
+} |