Skip to content

Commit

Permalink
improve readability
Browse files Browse the repository at this point in the history
Signed-off-by: Clement <[email protected]>
  • Loading branch information
clement2026 committed Sep 13, 2024
1 parent b51d3cb commit 6336424
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions server/etcdserver/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1598,11 +1598,14 @@ func TestIsActive(t *testing.T) {
}
}

// newDummyPutReqReady creates a dummy raft.Ready.
// newDummyPutReqReady creates a raft.Ready.
//
// In unit tests, EtcdServer doesn't append raft log entries upon start like the full-featured etcd does.
// This can crash the program when creating a raft log snapshot due to no available entries.
// To append raft log entries, we can send a newDummyPutReqReady() to raft.Node's readyc after the server starts.
// In unit tests, a manually created EtcdServer doesn't append raft log
// entries on startup like the full-featured etcd does in bootstrap.
// This can crash the program when creating a raft log snapshot if there
// are no available entries.
// To work around this, we can send a newDummyPutReqReady() to raft.Node's readyc
// after the server starts to ensure the entries are appended.
func newDummyPutReqReady() raft.Ready {
req := &pb.InternalRaftRequest{
Header: &pb.RequestHeader{ID: 1},
Expand Down

0 comments on commit 6336424

Please sign in to comment.