Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)
| ... | ... |
@@ -3,6 +3,8 @@ package main |
| 3 | 3 |
import ( |
| 4 | 4 |
"io/ioutil" |
| 5 | 5 |
"os" |
| 6 |
+ "strings" |
|
| 7 |
+ "time" |
|
| 6 | 8 |
|
| 7 | 9 |
"github.com/docker/docker/integration-cli/checker" |
| 8 | 10 |
"github.com/docker/docker/integration-cli/cli/build" |
| ... | ... |
@@ -93,6 +95,17 @@ func (s *DockerSuite) TestRmRestartingContainer(c *check.C) {
|
| 93 | 93 |
dockerCmd(c, "run", "--name", name, "--restart=always", "busybox", "date") |
| 94 | 94 |
|
| 95 | 95 |
res, _, err := dockerCmdWithError("rm", name)
|
| 96 |
+ |
|
| 97 |
+ for strings.Contains(res, "cannot remove a running container") {
|
|
| 98 |
+ // The `date` command hasn't exited yet. It should end |
|
| 99 |
+ // up in a "restarting" state if we wait a bit, though |
|
| 100 |
+ // it is possible that it might be running again by |
|
| 101 |
+ // that time. The wait period between each restart |
|
| 102 |
+ // increases though so we just loop in this condition. |
|
| 103 |
+ time.Sleep(100 * time.Millisecond) |
|
| 104 |
+ res, _, err = dockerCmdWithError("rm", name)
|
|
| 105 |
+ } |
|
| 106 |
+ |
|
| 96 | 107 |
c.Assert(err, checker.NotNil, check.Commentf("Expected error on rm a restarting container, got none"))
|
| 97 | 108 |
c.Assert(res, checker.Contains, "cannot remove a restarting container") |
| 98 | 109 |
c.Assert(res, checker.Contains, "Stop the container before attempting removal or force remove") |