Skip to content

Commit

Permalink
Add retry checks to TestSwarmPublishAdd
Browse files Browse the repository at this point in the history
Signed-off-by: Tonis Tiigi <[email protected]>
(cherry picked from commit 7bd1c11)
Signed-off-by: Tibor Vass <[email protected]>
  • Loading branch information
tonistiigi authored and Tibor Vass committed Aug 16, 2016
1 parent 651c53f commit f21cdf4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
14 changes: 14 additions & 0 deletions integration-cli/daemon_swarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,3 +311,17 @@ func (d *SwarmDaemon) checkControlAvailable(c *check.C) (interface{}, check.Comm
c.Assert(info.LocalNodeState, checker.Equals, swarm.LocalNodeStateActive)
return info.ControlAvailable, nil
}

func (d *SwarmDaemon) cmdRetryOutOfSequence(args ...string) (string, error) {
for i := 0; ; i++ {
out, err := d.Cmd(args[0], args[1:]...)
if err != nil {
if strings.Contains(err.Error(), "update out of sequence") {
if i < 10 {
continue
}
}
}
return out, err
}
}
6 changes: 3 additions & 3 deletions integration-cli/docker_cli_swarm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f21cdf4

Please sign in to comment.