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>
| ... | ... |
@@ -20,6 +20,10 @@ func (s *DockerSuite) TestRestartStoppedContainer(c *check.C) {
|
| 20 | 20 |
|
| 21 | 21 |
dockerCmd(c, "restart", cleanedContainerID) |
| 22 | 22 |
|
| 23 |
+ // Wait until the container has stopped |
|
| 24 |
+ err = waitInspect(cleanedContainerID, "{{.State.Running}}", "false", 20*time.Second)
|
|
| 25 |
+ c.Assert(err, checker.IsNil) |
|
| 26 |
+ |
|
| 23 | 27 |
out, _ = dockerCmd(c, "logs", cleanedContainerID) |
| 24 | 28 |
c.Assert(out, checker.Equals, "foobar\nfoobar\n") |
| 25 | 29 |
} |