From 48ccdd46aea4bb16925d0a333f792a712f1c11dc Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Wed, 16 Mar 2016 03:10:49 +0000 Subject: [PATCH] Fix flaky test of TestRestartStoppedContainer (#21211). This fix addressed the issue of test TestRestartStoppedContainer in #21211. Inside the test, a `docker restart` command is followed by a `docker logs` command. However, `docker restart` returns immediately so there is no guarantee that `docker logs` will wait until the restarted container completes the command `echo foobar`. This fix use the check of `{{.State.Running}} = false` to make sure that the restarted container has already finished, before invoking the `docker logs` command. The timeout is set to 20s to make sure it passes WindowsTP4 check. This fixes #21211. Signed-off-by: Yong Tang --- integration-cli/docker_cli_restart_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/integration-cli/docker_cli_restart_test.go b/integration-cli/docker_cli_restart_test.go index 2de3d12d93..297e16a169 100644 --- a/integration-cli/docker_cli_restart_test.go +++ b/integration-cli/docker_cli_restart_test.go @@ -20,6 +20,10 @@ func (s *DockerSuite) TestRestartStoppedContainer(c *check.C) { dockerCmd(c, "restart", cleanedContainerID) + // Wait until the container has stopped + err = waitInspect(cleanedContainerID, "{{.State.Running}}", "false", 20*time.Second) + c.Assert(err, checker.IsNil) + out, _ = dockerCmd(c, "logs", cleanedContainerID) c.Assert(out, checker.Equals, "foobar\nfoobar\n") }