mirror of https://github.com/docker/compose.git
Add test for ACI start
This commit is contained in:
parent
1a3182fb7f
commit
aa8bf1daaa
|
@ -30,7 +30,7 @@ import (
|
|||
"github.com/docker/api/client"
|
||||
)
|
||||
|
||||
// StartCommand deletes containers
|
||||
// StartCommand starts containers
|
||||
func StartCommand() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "start",
|
||||
|
|
|
@ -385,8 +385,18 @@ func TestContainerRunAttached(t *testing.T) {
|
|||
assert.Assert(t, is.Len(out, 2))
|
||||
})
|
||||
|
||||
t.Run("start container", func(t *testing.T) {
|
||||
res := c.RunDockerCmd("start", container)
|
||||
res.Assert(t, icmd.Expected{Out: container})
|
||||
waitForStatus(t, c, container, "Running")
|
||||
})
|
||||
|
||||
t.Run("rm stopped container", func(t *testing.T) {
|
||||
res := c.RunDockerCmd("rm", container)
|
||||
res := c.RunDockerCmd("stop", container)
|
||||
res.Assert(t, icmd.Expected{Out: container})
|
||||
waitForStatus(t, c, container, "Terminated")
|
||||
|
||||
res = c.RunDockerCmd("rm", container)
|
||||
res.Assert(t, icmd.Expected{Out: container})
|
||||
})
|
||||
}
|
||||
|
@ -653,3 +663,15 @@ func getContainerName(stdout string) string {
|
|||
out := strings.Split(strings.TrimSpace(stdout), "\n")
|
||||
return strings.TrimSpace(out[len(out)-1])
|
||||
}
|
||||
|
||||
func waitForStatus(t *testing.T, c *E2eCLI, containerID string, status string) {
|
||||
checkStopped := func(t poll.LogT) poll.Result {
|
||||
res := c.RunDockerCmd("inspect", containerID)
|
||||
if strings.Contains(res.Stdout(), status) {
|
||||
return poll.Success()
|
||||
}
|
||||
return poll.Continue("waiting for container to stop")
|
||||
}
|
||||
|
||||
poll.WaitOn(t, checkStopped, poll.WithDelay(5*time.Second), poll.WithTimeout(60*time.Second))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue