Skip to content

Commit 973ca00

Browse files
committed
reduce flakiness of TestSwarmLockUnlockCluster and TestSwarmJoinPromoteLocked
I noticed that this test failed, because the node was in status "pending". The test checks for the node's status immediately after it was restarted, so possibly it needs some time to unlock. 14:07:10 FAIL: docker_cli_swarm_test.go:1128: DockerSwarmSuite.TestSwarmLockUnlockCluster ... 14:07:10 docker_cli_swarm_test.go:1168: 14:07:10 checkSwarmLockedToUnlocked(c, d) 14:07:10 docker_cli_swarm_test.go:1017: 14:07:10 c.Assert(getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateActive) 14:07:10 ... obtained swarm.LocalNodeState = "pending" 14:07:10 ... expected swarm.LocalNodeState = "active" This patch adds a `waitAndAssert` for the node's status, with a 1 second timeout. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent ad2765b commit 973ca00

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

integration-cli/docker_cli_swarm_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,15 +1014,15 @@ func checkSwarmLockedToUnlocked(c *check.C, d *daemon.Daemon) {
10141014
waitAndAssert(c, defaultReconciliationTimeout, checkKeyIsEncrypted(d), checker.Equals, false)
10151015

10161016
d.RestartNode(c)
1017-
c.Assert(getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateActive)
1017+
waitAndAssert(c, time.Second, d.CheckLocalNodeState, checker.Equals, swarm.LocalNodeStateActive)
10181018
}
10191019

10201020
func checkSwarmUnlockedToLocked(c *check.C, d *daemon.Daemon) {
10211021
// Wait for the PEM file to become encrypted
10221022
waitAndAssert(c, defaultReconciliationTimeout, checkKeyIsEncrypted(d), checker.Equals, true)
10231023

10241024
d.RestartNode(c)
1025-
c.Assert(getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateLocked)
1025+
waitAndAssert(c, time.Second, d.CheckLocalNodeState, checker.Equals, swarm.LocalNodeStateLocked)
10261026
}
10271027

10281028
func (s *DockerSwarmSuite) TestUnlockEngineAndUnlockedSwarm(c *check.C) {
@@ -1197,7 +1197,7 @@ func (s *DockerSwarmSuite) TestSwarmJoinPromoteLocked(c *check.C) {
11971197
// joined workers start off unlocked
11981198
d2 := s.AddDaemon(c, true, false)
11991199
d2.RestartNode(c)
1200-
c.Assert(getNodeStatus(c, d2), checker.Equals, swarm.LocalNodeStateActive)
1200+
waitAndAssert(c, time.Second, d2.CheckLocalNodeState, checker.Equals, swarm.LocalNodeStateActive)
12011201

12021202
// promote worker
12031203
outs, err = d1.Cmd("node", "promote", d2.NodeID())
@@ -1242,7 +1242,7 @@ func (s *DockerSwarmSuite) TestSwarmJoinPromoteLocked(c *check.C) {
12421242

12431243
// by now, it should *never* be locked on restart
12441244
d3.RestartNode(c)
1245-
c.Assert(getNodeStatus(c, d3), checker.Equals, swarm.LocalNodeStateActive)
1245+
waitAndAssert(c, time.Second, d3.CheckLocalNodeState, checker.Equals, swarm.LocalNodeStateActive)
12461246
}
12471247

12481248
func (s *DockerSwarmSuite) TestSwarmRotateUnlockKey(c *check.C) {

0 commit comments

Comments
 (0)