瀏覽代碼

[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 7 年之前
父節點
當前提交
fd32d49c49
共有 1 個文件被更改,包括 6 次插入2 次删除
  1. 6 2
      integration-cli/docker_api_swarm_test.go

+ 6 - 2
integration-cli/docker_api_swarm_test.go

@@ -370,8 +370,12 @@ func (s *DockerSwarmSuite) TestAPISwarmRaftQuorum(c *check.C) {
 	cli, err := d1.NewClient()
 	c.Assert(err, checker.IsNil)
 	defer cli.Close()
-	_, err = cli.ServiceCreate(context.Background(), service.Spec, types.ServiceCreateOptions{})
-	c.Assert(err.Error(), checker.Contains, "deadline exceeded")
+
+	// d1 will eventually step down from leader because there is no longer an active quorum, wait for that to happen
+	waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {
+		_, err = cli.ServiceCreate(context.Background(), service.Spec, types.ServiceCreateOptions{})
+		return err.Error(), nil
+	}, checker.Contains, "Make sure more than half of the managers are online.")
 
 	d2.Start(c)