From fb6efb95edc5a22e58311699042c8925efcc2ef6 Mon Sep 17 00:00:00 2001 From: Dhia Ayachi Date: Wed, 22 Sep 2021 11:36:27 -0400 Subject: [PATCH] add wait loop to test --- raft_test.go | 5 +++++ testing.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/raft_test.go b/raft_test.go index 1e7a2452d..1fee1adb7 100644 --- a/raft_test.go +++ b/raft_test.go @@ -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 diff --git a/testing.go b/testing.go index 1dd61b94c..9620311da 100644 --- a/testing.go +++ b/testing.go @@ -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{