mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
tests: reproduce raft panic
Signed-off-by: Clement <gh.2lgqz@aleeas.com>
This commit is contained in:
parent
8947d9aff1
commit
ba4bc88f78
@ -42,7 +42,7 @@ func TestMustPanic(t *testing.T) {
|
||||
t.Logf("elected lead: %v", clus.Members[lead].Server.MemberID())
|
||||
time.Sleep(2 * time.Second)
|
||||
|
||||
// send 500 put request to [member-1, member 2], resulting at least 400 compaction in raft log
|
||||
// send 500 put request to [member-1, member 2], resulting at least 400 compactions in raft log
|
||||
for i := 0; i < 500; i++ {
|
||||
_, err := clus.Client(1).Put(context.TODO(), "foo", "bar")
|
||||
if err != nil {
|
||||
@ -53,7 +53,7 @@ func TestMustPanic(t *testing.T) {
|
||||
expectMemberLog(t, clus.Members[lead], 5*time.Second, "compacted Raft logs", 400)
|
||||
expectMemberLog(t, clus.Members[lead], 5*time.Second, "\"compact-index\": 400", 1)
|
||||
|
||||
// member-0 rejoins the cluster. Since its appliedIndex is very low (less than 10),
|
||||
// member-0 rejoins the cluster. Since its appliedIndex is very low (less than 10, not in leader raft log's range),
|
||||
// the leader decides to send a snapshot to member-0.
|
||||
clus.Members[0].RecoverPartition(t, clus.Members[1:]...)
|
||||
|
||||
@ -93,8 +93,9 @@ func TestMustNotPanic(t *testing.T) {
|
||||
_, err := clus.Members[lead].LogObserver.Expect(ctx, "compacted Raft logs", 1)
|
||||
assert.ErrorIs(t, err, context.DeadlineExceeded)
|
||||
|
||||
// member-0 rejoins the cluster. Since its appliedIndex is within the leader raft log's range,
|
||||
// no snapshot should be sent
|
||||
// member-0 rejoins the cluster.
|
||||
// Since member-0's appliedIndex is within the leader raft log's range,
|
||||
// the leader won't send a snapshot. So, no panic should happen here.
|
||||
clus.Members[0].RecoverPartition(t, clus.Members[1:]...)
|
||||
|
||||
// No errors should occur during this wait
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user