1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

TestAPISwarmLeaderElection: add some debug

......

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin 2018-09-12 19:30:09 -07:00
parent 24cbb98971
commit 06afc2d1e6
3 changed files with 9 additions and 3 deletions

View file

@ -332,6 +332,7 @@ func (s *DockerSwarmSuite) TestAPISwarmLeaderElection(c *check.C) {
}
// wait for an election to occur
c.Logf("Waiting for election to occur...")
waitAndAssert(c, defaultReconciliationTimeout, checkLeader(d2, d3), checker.True)
// 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
d1.Start(c)
// TODO(stevvooe): may need to wait for rejoin here
// wait for possible election
c.Logf("Waiting for possible election...")
waitAndAssert(c, defaultReconciliationTimeout, checkLeader(d1, d2, d3), checker.True)
// pick out the leader and the followers again

View file

@ -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{}) {
t1 := time.Now()
defer func() {
t2 := time.Now()
c.Logf("waited for %v (out of %v)", t2.Sub(t1), timeout)
}()
after := time.After(timeout)
for {
v, comment := f(c)

View file

@ -23,7 +23,7 @@ func (d *Daemon) GetNode(t assert.TestingT, id string) *swarm.Node {
defer cli.Close()
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)
return &node
}