Add retry checks to TestSwarmPublishAdd

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 7bd1c11959)
Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
Tonis Tiigi 2016-08-16 10:39:05 -07:00 committed by Tibor Vass
parent 651c53f020
commit f21cdf48f9
2 changed files with 17 additions and 3 deletions

View file

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

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)