Skip to content

Commit

Permalink
bugfix: reduce flakiness in follower node test (#5355)
Browse files Browse the repository at this point in the history
  • Loading branch information
tzaffi committed May 5, 2023
1 parent c5e57c3 commit d939705
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions node/follower_node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package node
import (
"context"
"testing"
"time"

"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus/hooks/test"
Expand Down Expand Up @@ -206,8 +207,21 @@ func TestSyncRoundWithRemake(t *testing.T) {
}

followNode, _ = remakeableFollowNode(t, tempDir, maxAcctLookback)
status, err := followNode.Status()
require.NoError(t, err)

// Wait for follower to catch up. This rarely is needed, but can happen
// and cause flakey test failures. Timing out can still occur, but is less
// likely than the being caught behind a few rounds.
var status *StatusReport
require.Eventually(t, func() bool {
st, err := followNode.Status()
require.NoError(t, err)
if st.LastRound >= newRound {
status = &st
return true
}
return false
}, 10*time.Second, 500*time.Millisecond, "failed to reach newRound within the allowed time")

require.Equal(t, newRound, status.LastRound)

// syncRound should be at
Expand Down

0 comments on commit d939705

Please sign in to comment.