Skip to content

Commit b8b9893

Browse files
committed
fix(raftadmin): fakeEngine implements RegisterLeaderAcquiredCallback
CI failure on PR #723 (test (ubuntu-latest)): TestServerMapsEngineAdminMethods returned "add voter is not supported by this raft engine" because the type-assertion at internal/raftadmin/server.go:21 (any(engine).(raftengine.Admin)) silently fell back to admin=nil after Phase 3.D PR 4-B-3b extended the Admin interface with RegisterLeaderAcquiredCallback. The test stub fakeEngine never gained the method, so it stopped satisfying the interface — and every admin RPC mapped through NewServer returned Unimplemented. This is exactly the "semantic-change-without-full-caller-audit" miss the recent lessons-learned discipline targets. PR #723's audit grep was on the production resolver helpers, not on the Admin interface itself; raftadmin's stub slipped through. Fix: add the missing method on the stub. Returns a no-op deregister — raftadmin doesn't exercise the leader-acquired observer (PR 4-B-3b's SQS leadership-refusal lives in main_sqs_leadership_refusal.go), the stub's only obligation is to satisfy the type assertion. go test -race ./... and golangci-lint clean.
1 parent 634fbcf commit b8b9893

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

internal/raftadmin/server_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,18 @@ func (f *fakeEngine) TransferLeadership(context.Context) error {
137137
return nil
138138
}
139139

140+
func (f *fakeEngine) RegisterLeaderAcquiredCallback(fn func()) func() {
141+
// raftadmin doesn't exercise the leader-acquired observer (PR
142+
// 4-B-3b's SQS leadership-refusal hook lives in main_sqs_*).
143+
// The stub satisfies the raftengine.Admin interface so the
144+
// type-assertion in NewServer succeeds; without this method
145+
// the assertion would silently fall back to admin=nil and every
146+
// admin RPC would return Unimplemented (regression caught by
147+
// TestServerMapsEngineAdminMethods after Phase 3.D PR 4-B-3b
148+
// extended the Admin interface).
149+
return func() {}
150+
}
151+
140152
func (f *fakeEngine) TransferLeadershipToServer(_ context.Context, id string, address string) error {
141153
f.mu.Lock()
142154
defer f.mu.Unlock()

0 commit comments

Comments
 (0)