Skip to content

Commit eee2d2f

Browse files
committed
raft: add test case to check maybeCommit()
1 parent 9d39ce1 commit eee2d2f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pkg/raft/raft_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2597,21 +2597,29 @@ func TestLeaderAppResp(t *testing.T) {
25972597
// There is no storage access for term in the maybeCommit() code path
25982598
{2, false, 2, 7, 1, 2, 0, 2},
25992599

2600+
// Follower 2 responds to leader, indicating log index 3 is replicated.
2601+
// Leader tries to commit, but commit index doesn't advance since the index
2602+
// is from a previous term. Same as above.
2603+
{3, false, 3, 7, 1, 3, 0, 1},
2604+
26002605
// NB: For the following tests, we are skipping the MsgAppResp for the first
26012606
// 3 entries, by directly processing MsgAppResp for later entries.
26022607
//
26032608
// Follower 2 is StateProbing at 4, it sends MsgAppResp for 4, and is moved
26042609
// to StateReplicate and as many entries as possible are sent to it (5, 6).
26052610
// Correspondingly the Next is then 7 (entry 7 does not exist, indicating
26062611
// the follower will be up to date should it process the emitted MsgApp).
2607-
// accept resp; leader commits; respond with commit index
2612+
// accept resp; leader commits; respond with commit index.
2613+
// maybeCommit() is successful.
26082614
{4, false, 4, 7, 1, 4, 4, 1},
26092615

26102616
// Follower 2 says term2, index5 is already replicated.
26112617
// The leader responds with the updated commit index to follower 2.
2618+
// maybeCommit() is successful.
26122619
{5, false, 5, 7, 1, 5, 5, 1},
26132620
// Follower 2 says term2, index6 is already replicated.
26142621
// The leader responds with the updated commit index to follower 2.
2622+
// maybeCommit() is successful.
26152623
{6, false, 6, 7, 1, 6, 6, 1},
26162624
} {
26172625
t.Run("", func(t *testing.T) {

0 commit comments

Comments
 (0)