浏览代码

Merge pull request #25765 from tonistiigi/publish-add

Add retry checks to TestSwarmPublishAdd
Tibor Vass 9 年之前
父节点
当前提交
1225e3e621
共有 2 个文件被更改,包括 17 次插入3 次删除
  1. 14 0
      integration-cli/daemon_swarm.go
  2. 3 3
      integration-cli/docker_cli_swarm_test.go

+ 14 - 0
integration-cli/daemon_swarm.go

@@ -354,3 +354,17 @@ func (d *SwarmDaemon) checkLeader(c *check.C) (interface{}, check.CommentInterfa
 	}
 	return fmt.Errorf("no leader"), check.Commentf("could not find leader")
 }
+
+func (d *SwarmDaemon) cmdRetryOutOfSequence(args ...string) (string, error) {
+	for i := 0; ; i++ {
+		out, err := d.Cmd(args...)
+		if err != nil {
+			if strings.Contains(err.Error(), "update out of sequence") {
+				if i < 10 {
+					continue
+				}
+			}
+		}
+		return out, err
+	}
+}

+ 3 - 3
integration-cli/docker_cli_swarm_test.go

@@ -207,13 +207,13 @@ func (s *DockerSwarmSuite) TestSwarmPublishAdd(c *check.C) {
 	out, err = d.Cmd("service", "update", "--publish-add", "80:80", name)
 	c.Assert(err, checker.IsNil)
 
-	out, err = d.Cmd("service", "update", "--publish-add", "80:80", name)
+	out, err = d.cmdRetryOutOfSequence("service", "update", "--publish-add", "80:80", name)
 	c.Assert(err, checker.IsNil)
 
-	out, err = d.Cmd("service", "update", "--publish-add", "80:80", "--publish-add", "80:20", name)
+	out, err = d.cmdRetryOutOfSequence("service", "update", "--publish-add", "80:80", "--publish-add", "80:20", name)
 	c.Assert(err, checker.NotNil)
 
-	out, err = d.Cmd("service", "update", "--publish-add", "80:20", name)
+	out, err = d.cmdRetryOutOfSequence("service", "update", "--publish-add", "80:20", name)
 	c.Assert(err, checker.IsNil)
 
 	out, err = d.Cmd("service", "inspect", "--format", "{{ .Spec.EndpointSpec.Ports }}", name)