Browse code

Fix TestSwarmClusterRotateUnlockKey

TestSwarmClusterRotateUnlockKey had been identified as a flaky test. It
turns out that the test code was wrong: where we should have been
checking the string output of a command, we were instead checking the
value of the error. This means that the error case we were expecting was
not being matched, and the test was failing when it should have just
retried.

Signed-off-by: Drew Erny <drew.erny@docker.com>

Drew Erny authored on 2019/07/27 03:05:00
Showing 1 changed files
... ...
@@ -1312,7 +1312,7 @@ func (s *DockerSwarmSuite) TestSwarmRotateUnlockKey(c *check.C) {
1312 1312
 			// an issue sometimes prevents leader to be available right away
1313 1313
 			outs, err = d.Cmd("node", "ls")
1314 1314
 			if err != nil && retry < 5 {
1315
-				if strings.Contains(err.Error(), "swarm does not have a leader") {
1315
+				if strings.Contains(outs, "swarm does not have a leader") {
1316 1316
 					retry++
1317 1317
 					time.Sleep(3 * time.Second)
1318 1318
 					continue
... ...
@@ -1404,7 +1404,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterRotateUnlockKey(c *check.C) {
1404 1404
 				// an issue sometimes prevents leader to be available right away
1405 1405
 				outs, err = d.Cmd("node", "ls")
1406 1406
 				if err != nil && retry < 5 {
1407
-					if strings.Contains(err.Error(), "swarm does not have a leader") {
1407
+					if strings.Contains(outs, "swarm does not have a leader") {
1408 1408
 						retry++
1409 1409
 						time.Sleep(3 * time.Second)
1410 1410
 						continue