-
Notifications
You must be signed in to change notification settings - Fork 259
fix: raft HA production hardening — leader fencing, log compaction, election timeout, audit log #3230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: raft HA production hardening — leader fencing, log compaction, election timeout, audit log #3230
Changes from 16 commits
2d28b20
857b44b
2106f04
52d7cda
b8471f0
c6b1a5f
4cdfc54
266c61f
cc39c9a
135b5af
465203e
84b70d4
30ef514
3d94b75
9ed4946
a2a2599
4d105a2
fc023b8
2d3dc8e
40b7251
bf6bb50
f90c600
7e09507
0f6818f
84ec0d0
5897ef3
03e33c3
f61de99
a434761
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this test does not look necessary
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done — deleted in bf6bb50. The test was validating an implementation detail (that Stop() calls SetApplyCallback(nil)) rather than observable behaviour. The stubRaftNode helper it defined has been moved to syncer_test.go where it's still needed by TestSyncer_Stop_CallsRaftRetrieverStop. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| package syncing | ||
|
|
||
| import ( | ||
| "context" | ||
| "sync" | ||
| "testing" | ||
|
|
||
| "github.com/rs/zerolog" | ||
| "github.com/stretchr/testify/require" | ||
|
|
||
| "github.com/evstack/ev-node/pkg/genesis" | ||
| pkgraft "github.com/evstack/ev-node/pkg/raft" | ||
| ) | ||
|
|
||
| type stubRaftNode struct { | ||
| mu sync.Mutex | ||
| callbacks []chan<- pkgraft.RaftApplyMsg | ||
| } | ||
|
|
||
| func (s *stubRaftNode) IsLeader() bool { return false } | ||
|
|
||
| func (s *stubRaftNode) HasQuorum() bool { return false } | ||
|
|
||
| func (s *stubRaftNode) GetState() *pkgraft.RaftBlockState { return nil } | ||
|
|
||
| func (s *stubRaftNode) Broadcast(context.Context, *pkgraft.RaftBlockState) error { return nil } | ||
|
|
||
| func (s *stubRaftNode) SetApplyCallback(ch chan<- pkgraft.RaftApplyMsg) { | ||
| s.mu.Lock() | ||
| defer s.mu.Unlock() | ||
| s.callbacks = append(s.callbacks, ch) | ||
| } | ||
|
|
||
| func (s *stubRaftNode) recordedCallbacks() []chan<- pkgraft.RaftApplyMsg { | ||
| s.mu.Lock() | ||
| defer s.mu.Unlock() | ||
| out := make([]chan<- pkgraft.RaftApplyMsg, len(s.callbacks)) | ||
| copy(out, s.callbacks) | ||
| return out | ||
| } | ||
|
|
||
| func TestRaftRetrieverStopClearsApplyCallback(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| raftNode := &stubRaftNode{} | ||
| retriever := newRaftRetriever( | ||
| raftNode, | ||
| genesis.Genesis{}, | ||
| zerolog.Nop(), | ||
| nil, | ||
| func(context.Context, *pkgraft.RaftBlockState) error { return nil }, | ||
| ) | ||
|
|
||
| require.NoError(t, retriever.Start(t.Context())) | ||
| retriever.Stop() | ||
|
|
||
| callbacks := raftNode.recordedCallbacks() | ||
| require.Len(t, callbacks, 2) | ||
| require.NotNil(t, callbacks[0]) | ||
| require.Nil(t, callbacks[1]) | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.