Add retry checks to TestSwarmPublishAdd

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi 2016-08-16 10:39:05 -07:00
parent d7753dceb8
commit 7bd1c11959
2 changed files with 17 additions and 3 deletions

View file

@ -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
}
}

View file

@ -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)