Skip to content

Commit

Permalink
add wait loop to test
Browse files Browse the repository at this point in the history
  • Loading branch information
dhiaayachi committed Sep 22, 2021
1 parent 702e286 commit fb6efb9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions raft_test.go
Expand Up @@ -760,6 +760,11 @@ func TestRaft_RemovedFollower_Vote(t *testing.T) {
time.Sleep(c.propagateTimeout)

// wait for the remaining follower to trigger an election
count := 0
for follower.getState() != Candidate && count < 1000 {
count++
time.Sleep(1 * time.Millisecond)
}
require.Equal(t, Candidate, follower.getState())

// send a vote request from the removed follower to the Candidate follower
Expand Down
2 changes: 1 addition & 1 deletion testing.go
Expand Up @@ -165,7 +165,7 @@ func newTestLogger(t *testing.T) hclog.Logger {
// the logs only appear when a test fails.
func newTestLoggerWithPrefix(t *testing.T, prefix string) hclog.Logger {
if testing.Verbose() {
return hclog.New(&hclog.LoggerOptions{Name: prefix})
return hclog.New(&hclog.LoggerOptions{Name: prefix, Level: 2})
}

return hclog.New(&hclog.LoggerOptions{
Expand Down

0 comments on commit fb6efb9

Please sign in to comment.