From f21cdf48f98b164c2a0ea52c7404e4227eebd1e0 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Tue, 16 Aug 2016 10:39:05 -0700 Subject: [PATCH] Add retry checks to TestSwarmPublishAdd Signed-off-by: Tonis Tiigi (cherry picked from commit 7bd1c1195998c10c732ccfa67c568e634d58166e) Signed-off-by: Tibor Vass --- integration-cli/daemon_swarm.go | 14 ++++++++++++++ integration-cli/docker_cli_swarm_test.go | 6 +++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/integration-cli/daemon_swarm.go b/integration-cli/daemon_swarm.go index 9194fc05e8..43f16d23ed 100644 --- a/integration-cli/daemon_swarm.go +++ b/integration-cli/daemon_swarm.go @@ -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 + } +} diff --git a/integration-cli/docker_cli_swarm_test.go b/integration-cli/docker_cli_swarm_test.go index f454baee7c..bf9cfb72b4 100644 --- a/integration-cli/docker_cli_swarm_test.go +++ b/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)