1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Fix flaky TestExec

The container started with `-d` as part of the test requires a `waitRun`
to ensure it is actually running before attempting any other operation.

Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
This commit is contained in:
Arnaud Porterie 2016-02-23 09:46:13 -08:00
parent 0f18fa939c
commit 0a7755ab4e

View file

@ -21,9 +21,10 @@ import (
func (s *DockerSuite) TestExec(c *check.C) {
testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "-d", "--name", "testing", "busybox", "sh", "-c", "echo test > /tmp/file && top")
out, _ := dockerCmd(c, "run", "-d", "--name", "testing", "busybox", "sh", "-c", "echo test > /tmp/file && top")
c.Assert(waitRun(strings.TrimSpace(out)), check.IsNil)
out, _ := dockerCmd(c, "exec", "testing", "cat", "/tmp/file")
out, _ = dockerCmd(c, "exec", "testing", "cat", "/tmp/file")
out = strings.Trim(out, "\r\n")
c.Assert(out, checker.Equals, "test")
@ -67,7 +68,7 @@ func (s *DockerSuite) TestExecInteractive(c *check.C) {
func (s *DockerSuite) TestExecAfterContainerRestart(c *check.C) {
testRequires(c, DaemonIsLinux)
out, _ := runSleepingContainer(c, "-d")
out, _ := runSleepingContainer(c)
cleanedContainerID := strings.TrimSpace(out)
c.Assert(waitRun(cleanedContainerID), check.IsNil)
dockerCmd(c, "restart", cleanedContainerID)