diff --git a/cli/cmd/start.go b/cli/cmd/start.go index 1f1e65650..87fdc7df4 100644 --- a/cli/cmd/start.go +++ b/cli/cmd/start.go @@ -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", diff --git a/tests/aci-e2e/e2e-aci_test.go b/tests/aci-e2e/e2e-aci_test.go index 9dbdab4d9..91f624af2 100644 --- a/tests/aci-e2e/e2e-aci_test.go +++ b/tests/aci-e2e/e2e-aci_test.go @@ -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)) +}