Skip to content

Commit

Permalink
Fix unstable test TestReplication_FederationStates()
Browse files Browse the repository at this point in the history
  • Loading branch information
pierresouchay committed Apr 3, 2020
1 parent 09e638a commit 9771dfa
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions agent/consul/federation_state_replication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func TestReplication_FederationStates(t *testing.T) {
require.NoError(t, err)

require.Len(t, local, len(remote))
for i, _ := range remote {
for i := range remote {
// zero out the raft data for future comparisons
remote[i].RaftIndex = structs.RaftIndex{}
local[i].RaftIndex = structs.RaftIndex{}
Expand Down Expand Up @@ -121,8 +121,12 @@ func TestReplication_FederationStates(t *testing.T) {
require.NoError(t, s1.RPC("FederationState.Apply", &arg, &out))
}

nTimesWithDelay := func() *retry.Counter {
return &retry.Counter{Count: 30, Wait: 750 * time.Millisecond}
}

// Wait for the replica to converge.
retry.Run(t, func(r *retry.R) {
retry.RunWith(nTimesWithDelay(), t, func(r *retry.R) {
checkSame(r)
})

Expand All @@ -138,7 +142,7 @@ func TestReplication_FederationStates(t *testing.T) {
}

// Wait for the replica to converge.
retry.Run(t, func(r *retry.R) {
retry.RunWith(nTimesWithDelay(), t, func(r *retry.R) {
checkSame(r)
})
}

0 comments on commit 9771dfa

Please sign in to comment.