mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Migrate TestKillDifferentUserContainer to api test
This fix migrates TestKillDifferentUserContainer to api test Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
parent
7e7f8160fc
commit
0855922cd3
2 changed files with 18 additions and 25 deletions
|
@ -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"))
|
||||
|
||||
}
|
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue