Browse code

[integration-cli] fix flaky raft test

Fixes previously flaky TestAPISwarmRaftQuorum.

In the test we are shutting down 2 of 3 nodes, all of which are managers.
When this happens the remaining node prepares to step down from being
a leader because there is no longer an active quorum. This test was
written before that change was implemented, and assumes that the
remaining node can still handle requests to create a service (it can't)

There was further flakiness depending on whether or not the node has
stepped down or was in the process of doing so. Fix this by waiting
for the node to completely step down and checking to see if it errors
out like it should.

Signed-off-by: Christopher Jones <tophj@linux.vnet.ibm.com>

Christopher Jones authored on 2017/10/12 03:23:55
Showing 1 changed files
... ...
@@ -370,8 +370,12 @@ func (s *DockerSwarmSuite) TestAPISwarmRaftQuorum(c *check.C) {
370 370
 	cli, err := d1.NewClient()
371 371
 	c.Assert(err, checker.IsNil)
372 372
 	defer cli.Close()
373
-	_, err = cli.ServiceCreate(context.Background(), service.Spec, types.ServiceCreateOptions{})
374
-	c.Assert(err.Error(), checker.Contains, "deadline exceeded")
373
+
374
+	// d1 will eventually step down from leader because there is no longer an active quorum, wait for that to happen
375
+	waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {
376
+		_, err = cli.ServiceCreate(context.Background(), service.Spec, types.ServiceCreateOptions{})
377
+		return err.Error(), nil
378
+	}, checker.Contains, "Make sure more than half of the managers are online.")
375 379
 
376 380
 	d2.Start(c)
377 381