fix flaky TestRunContainerWithRmFlag tests (take 2)
This is a new attempt on making these tests less flaky. The previous attempt in
commit 585c147b7a
assumed that the test was failing
if the test-daemon still had unrelated containers present from other tests, but
it appears that the actual reason for the tests to be flaky may be that the `--rm`
option was moved to the daemon side and an asynchronous operation. As a result,
the container may not yet be removed once the `docker run` completes, which happens
frequently on Windows (likely be- cause removing containers is somewhat slower
on Windows).
This patch adds a retry-loop (using `poll.WaitOn()`) to wait for the container
to be removed.
make DOCKER_GRAPHDRIVER=vfs TEST_FILTER='TestRunContainerWithRmFlag' test-integration
INFO: Testing against a local daemon
=== RUN TestDockerSuite
=== RUN TestDockerSuite/TestRunContainerWithRmFlagCannotStartContainer
=== RUN TestDockerSuite/TestRunContainerWithRmFlagExitCodeNotEqualToZero
--- PASS: TestDockerSuite (1.00s)
--- PASS: TestDockerSuite/TestRunContainerWithRmFlagCannotStartContainer (0.50s)
--- PASS: TestDockerSuite/TestRunContainerWithRmFlagExitCodeNotEqualToZero (0.49s)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
74286cba8c
commit
f1c111b176
1 changed files with 17 additions and 10 deletions
|
@ -34,6 +34,7 @@ import (
|
|||
"github.com/moby/sys/mountinfo"
|
||||
"gotest.tools/v3/assert"
|
||||
"gotest.tools/v3/icmd"
|
||||
"gotest.tools/v3/poll"
|
||||
"gotest.tools/v3/skip"
|
||||
)
|
||||
|
||||
|
@ -2750,11 +2751,7 @@ func (s *DockerSuite) TestRunContainerWithRmFlagExitCodeNotEqualToZero(c *testin
|
|||
ExitCode: 1,
|
||||
})
|
||||
|
||||
cli.Docker(cli.Args("container", "inspect", name)).Assert(c, icmd.Expected{
|
||||
ExitCode: 1,
|
||||
Out: "[]\n",
|
||||
Err: "o such container", // (N|n)o such container
|
||||
})
|
||||
poll.WaitOn(c, containerRemoved(name))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestRunContainerWithRmFlagCannotStartContainer(c *testing.T) {
|
||||
|
@ -2763,11 +2760,21 @@ func (s *DockerSuite) TestRunContainerWithRmFlagCannotStartContainer(c *testing.
|
|||
ExitCode: 127,
|
||||
})
|
||||
|
||||
cli.Docker(cli.Args("container", "inspect", name)).Assert(c, icmd.Expected{
|
||||
ExitCode: 1,
|
||||
Out: "[]\n",
|
||||
Err: "o such container", // (N|n)o such container
|
||||
})
|
||||
poll.WaitOn(c, containerRemoved(name))
|
||||
}
|
||||
|
||||
func containerRemoved(name string) poll.Check {
|
||||
return func(l poll.LogT) poll.Result {
|
||||
err := cli.Docker(cli.Args("container", "inspect", "--format='{{.ID}}'", name)).Compare(icmd.Expected{
|
||||
ExitCode: 1,
|
||||
Out: "",
|
||||
Err: "o such container", // (N|n)o such container
|
||||
})
|
||||
if err != nil {
|
||||
return poll.Continue("waiting for container '%s' to be removed", name)
|
||||
}
|
||||
return poll.Success()
|
||||
}
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestRunPIDHostWithChildIsKillable(c *testing.T) {
|
||||
|
|
Loading…
Add table
Reference in a new issue