Переглянути джерело

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 <yong.tang.github@outlook.com>
Yong Tang 9 роки тому
батько
коміт
48ccdd46ae
1 змінених файлів з 4 додано та 0 видалено
  1. 4 0
      integration-cli/docker_cli_restart_test.go

+ 4 - 0
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")
 }