TestAPISwarmLeaderElection: add some debug

......

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 06afc2d1e6f8c5052af71e8815266d30e29ed664)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 2b498de10422c4d887c37ff1d51ac320e88151c8
Component: engine
This commit is contained in:
Kir Kolyshkin
2018-09-12 19:30:09 -07:00
committed by Sebastiaan van Stijn
parent 3a2688e1e5
commit de3e7fdf71
3 changed files with 9 additions and 3 deletions

View File

@ -340,6 +340,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
@ -351,9 +352,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

@ -413,6 +413,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
}