Skip to content

Commit

Permalink
Only run Test_RecoverCluster 3 times
Browse files Browse the repository at this point in the history
We really only care about 3 cases, so make that explicit
  • Loading branch information
dnephin committed May 14, 2021
1 parent df671c7 commit e60cb68
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions raft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,12 @@ func TestRaft_RecoverCluster_NoState(t *testing.T) {
}

func TestRaft_RecoverCluster(t *testing.T) {
// Run with different number of applies which will cover no snapshot and
// snapshot + log scenarios. By sweeping through the trailing logs value
// we will also hit the case where we have a snapshot only.
var err error
snapshotThreshold := 5
runRecover := func(t *testing.T, applies int) {
var err error
conf := inmemConfig(t)
conf.TrailingLogs = 10
conf.SnapshotThreshold = uint64(snapshotThreshold)
c := MakeCluster(3, t, conf)
defer c.Close()

Expand Down Expand Up @@ -212,11 +211,16 @@ func TestRaft_RecoverCluster(t *testing.T) {
c.EnsureSame(t)
c.EnsureSamePeers(t)
}
for applies := 0; applies < 10; applies++ {
t.Run(fmt.Sprintf("%d applies", applies), func(t *testing.T) {
runRecover(t, applies)
})
}

t.Run("no snapshot, no trailing logs", func(t *testing.T) {
runRecover(t, 0)
})
t.Run("snapshot", func(t *testing.T) {
runRecover(t, snapshotThreshold)
})
t.Run("snapshot, with trailing logs", func(t *testing.T) {
runRecover(t, snapshotThreshold+20)
})
}

func TestRaft_HasExistingState(t *testing.T) {
Expand Down

0 comments on commit e60cb68

Please sign in to comment.