mirror of
https://github.com/docker/docs.git
synced 2026-03-27 14:28:47 +07:00
Add retry checks to TestSwarmPublishAdd
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com> (cherry picked from commit 7bd1c1195998c10c732ccfa67c568e634d58166e) Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user