Browse Source

TestAPISwarmLeaderElection: add some debug

......

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Kir Kolyshkin 6 years ago
parent
commit
06afc2d1e6

+ 2 - 2
integration-cli/docker_api_swarm_test.go

@@ -332,6 +332,7 @@ func (s *DockerSwarmSuite) TestAPISwarmLeaderElection(c *check.C) {
 	}
 	}
 
 
 	// wait for an election to occur
 	// wait for an election to occur
+	c.Logf("Waiting for election to occur...")
 	waitAndAssert(c, defaultReconciliationTimeout, checkLeader(d2, d3), checker.True)
 	waitAndAssert(c, defaultReconciliationTimeout, checkLeader(d2, d3), checker.True)
 
 
 	// assert that we have a new leader
 	// assert that we have a new leader
@@ -343,9 +344,8 @@ func (s *DockerSwarmSuite) TestAPISwarmLeaderElection(c *check.C) {
 	// add the d1, the initial leader, back
 	// add the d1, the initial leader, back
 	d1.Start(c)
 	d1.Start(c)
 
 
-	// TODO(stevvooe): may need to wait for rejoin here
-
 	// wait for possible election
 	// wait for possible election
+	c.Logf("Waiting for possible election...")
 	waitAndAssert(c, defaultReconciliationTimeout, checkLeader(d1, d2, d3), checker.True)
 	waitAndAssert(c, defaultReconciliationTimeout, checkLeader(d1, d2, d3), checker.True)
 	// pick out the leader and the followers again
 	// pick out the leader and the followers again
 
 

+ 6 - 0
integration-cli/docker_utils_test.go

@@ -419,6 +419,12 @@ func getErrorMessage(c *check.C, body []byte) string {
 }
 }
 
 
 func waitAndAssert(c *check.C, timeout time.Duration, f checkF, checker check.Checker, args ...interface{}) {
 func waitAndAssert(c *check.C, timeout time.Duration, f checkF, checker check.Checker, args ...interface{}) {
+	t1 := time.Now()
+	defer func() {
+		t2 := time.Now()
+		c.Logf("waited for %v (out of %v)", t2.Sub(t1), timeout)
+	}()
+
 	after := time.After(timeout)
 	after := time.After(timeout)
 	for {
 	for {
 		v, comment := f(c)
 		v, comment := f(c)

+ 1 - 1
internal/test/daemon/node.go

@@ -23,7 +23,7 @@ func (d *Daemon) GetNode(t assert.TestingT, id string) *swarm.Node {
 	defer cli.Close()
 	defer cli.Close()
 
 
 	node, _, err := cli.NodeInspectWithRaw(context.Background(), id)
 	node, _, err := cli.NodeInspectWithRaw(context.Background(), id)
-	assert.NilError(t, err)
+	assert.NilError(t, err, "[%s] (*Daemon).GetNode: NodeInspectWithRaw(%q) failed", d.id, id)
 	assert.Check(t, node.ID == id)
 	assert.Check(t, node.ID == id)
 	return &node
 	return &node
 }
 }