Browse Source

Merge pull request #32099 from dnephin/fix-test-stack-remove

Fix flaky TestStackRemove test
Tõnis Tiigi 8 years ago
parent
commit
773d3bb5a0

+ 19 - 12
integration-cli/docker_cli_stack_test.go

@@ -11,6 +11,7 @@ import (
 
 
 	"github.com/docker/docker/api/types/swarm"
 	"github.com/docker/docker/api/types/swarm"
 	"github.com/docker/docker/integration-cli/checker"
 	"github.com/docker/docker/integration-cli/checker"
+	icmd "github.com/docker/docker/pkg/testutil/cmd"
 	"github.com/go-check/check"
 	"github.com/go-check/check"
 )
 )
 
 
@@ -111,18 +112,24 @@ func (s *DockerSwarmSuite) TestStackRemove(c *check.C) {
 		"--compose-file", "fixtures/deploy/remove.yaml",
 		"--compose-file", "fixtures/deploy/remove.yaml",
 		stackName,
 		stackName,
 	}
 	}
-	out, err := d.Cmd(stackArgs...)
-	c.Assert(err, checker.IsNil, check.Commentf(out))
-
-	out, err = d.Cmd("stack", "ps", stackName)
-	c.Assert(err, checker.IsNil)
-	c.Assert(strings.Split(strings.TrimSpace(out), "\n"), checker.HasLen, 2)
-
-	out, err = d.Cmd("stack", "rm", stackName)
-	c.Assert(err, checker.IsNil, check.Commentf(out))
-	c.Assert(out, checker.Contains, "Removing service testdeploy_web")
-	c.Assert(out, checker.Contains, "Removing network testdeploy_default")
-	c.Assert(out, checker.Contains, "Removing secret testdeploy_special")
+	result := icmd.RunCmd(d.Command(stackArgs...))
+	result.Assert(c, icmd.Expected{
+		Err: icmd.None,
+		Out: "Creating service testdeploy_web",
+	})
+
+	result = icmd.RunCmd(d.Command("service", "ls"))
+	result.Assert(c, icmd.Success)
+	c.Assert(
+		strings.Split(strings.TrimSpace(result.Stdout()), "\n"),
+		checker.HasLen, 2)
+
+	result = icmd.RunCmd(d.Command("stack", "rm", stackName))
+	result.Assert(c, icmd.Success)
+	stderr := result.Stderr()
+	c.Assert(stderr, checker.Contains, "Removing service testdeploy_web")
+	c.Assert(stderr, checker.Contains, "Removing network testdeploy_default")
+	c.Assert(stderr, checker.Contains, "Removing secret testdeploy_special")
 }
 }
 
 
 type sortSecrets []swarm.SecretReference
 type sortSecrets []swarm.SecretReference

+ 1 - 1
integration-cli/fixtures/deploy/remove.yaml

@@ -2,7 +2,7 @@
 version: "3.1"
 version: "3.1"
 services:
 services:
   web:
   web:
-    image: busybox@sha256:e4f93f6ed15a0cdd342f5aae387886fba0ab98af0a102da6276eaf24d6e6ade0
+    image: busybox:latest
     command: top
     command: top
     secrets:
     secrets:
       - special
       - special