[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> Upstream-commit: fd32d49c490126d830be6c1008ab20f6ffcee56c Component: engine
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user