mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
fix flaky TestRunContainerWithRmFlag tests
This attempts to fix CI flakiness on the TestRunContainerWithRmFlagCannotStartContainer and TestRunContainerWithRmFlagExitCodeNotEqualToZero tests. These tests; - get a list of all container ID's - run a container with `--rm` - wait for it to exit - checks that the list of all container IDs is empty The last step assumes that no other tests are running on the same daemon; if another test is running, there may be other containers present (unrelated to the test). This patch updates the tests to use a `docker inspect` to verify the container no longer exists afterwards. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
fbcdc6a980
commit
585c147b7a
1 changed files with 11 additions and 12 deletions
|
@ -2745,30 +2745,29 @@ func (s *DockerSuite) TestRunVolumesFromRestartAfterRemoved(c *testing.T) {
|
||||||
|
|
||||||
// run container with --rm should remove container if exit code != 0
|
// run container with --rm should remove container if exit code != 0
|
||||||
func (s *DockerSuite) TestRunContainerWithRmFlagExitCodeNotEqualToZero(c *testing.T) {
|
func (s *DockerSuite) TestRunContainerWithRmFlagExitCodeNotEqualToZero(c *testing.T) {
|
||||||
existingContainers := ExistingContainerIDs(c)
|
|
||||||
name := "flowers"
|
name := "flowers"
|
||||||
cli.Docker(cli.Args("run", "--name", name, "--rm", "busybox", "ls", "/notexists")).Assert(c, icmd.Expected{
|
cli.Docker(cli.Args("run", "--name", name, "--rm", "busybox", "ls", "/notexists")).Assert(c, icmd.Expected{
|
||||||
ExitCode: 1,
|
ExitCode: 1,
|
||||||
})
|
})
|
||||||
|
|
||||||
out := cli.DockerCmd(c, "ps", "-q", "-a").Combined()
|
cli.Docker(cli.Args("container", "inspect", name)).Assert(c, icmd.Expected{
|
||||||
out = RemoveOutputForExistingElements(out, existingContainers)
|
ExitCode: 1,
|
||||||
if out != "" {
|
Out: "[]\n",
|
||||||
c.Fatal("Expected not to have containers", out)
|
Err: "o such container", // (N|n)o such container
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DockerSuite) TestRunContainerWithRmFlagCannotStartContainer(c *testing.T) {
|
func (s *DockerSuite) TestRunContainerWithRmFlagCannotStartContainer(c *testing.T) {
|
||||||
existingContainers := ExistingContainerIDs(c)
|
|
||||||
name := "sparkles"
|
name := "sparkles"
|
||||||
cli.Docker(cli.Args("run", "--name", name, "--rm", "busybox", "commandNotFound")).Assert(c, icmd.Expected{
|
cli.Docker(cli.Args("run", "--name", name, "--rm", "busybox", "commandNotFound")).Assert(c, icmd.Expected{
|
||||||
ExitCode: 127,
|
ExitCode: 127,
|
||||||
})
|
})
|
||||||
out := cli.DockerCmd(c, "ps", "-q", "-a").Combined()
|
|
||||||
out = RemoveOutputForExistingElements(out, existingContainers)
|
cli.Docker(cli.Args("container", "inspect", name)).Assert(c, icmd.Expected{
|
||||||
if out != "" {
|
ExitCode: 1,
|
||||||
c.Fatal("Expected not to have containers", out)
|
Out: "[]\n",
|
||||||
}
|
Err: "o such container", // (N|n)o such container
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DockerSuite) TestRunPIDHostWithChildIsKillable(c *testing.T) {
|
func (s *DockerSuite) TestRunPIDHostWithChildIsKillable(c *testing.T) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue