Skip to content

Commit

Permalink
WaitForLeader: Also wait for a non-zero index.
Browse files Browse the repository at this point in the history
On my laptop, I'm currently seeing a huge number of intermittent test
failures all related to WaitForLeader returning after the test node has
become a leader, but before it has actually finished starting up, in
particular, performing the serf/Raft reconciliation.

Waiting for the index to become nonzero makes the tests pass reliably,
by also blocking until the new leader has started committing state.
  • Loading branch information
nelhage committed May 26, 2014
1 parent 8af424f commit 2080122
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion testutil/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func WaitForLeader(t *testing.T, rpc rpcFn, dc string) structs.IndexedNodes {
Datacenter: dc,
}
err := rpc("Catalog.ListNodes", args, &out)
return out.QueryMeta.KnownLeader, err
return out.QueryMeta.KnownLeader && out.Index > 0, err
}, func(err error) {
t.Fatalf("failed to find leader: %v", err)
})
Expand Down

0 comments on commit 2080122

Please sign in to comment.