test(ha-config-bootstrap): RED phase tests for quorum election logic (task 4.1)

- 21 test functions covering all 12 acceptance criteria (req 2.1-2.12)
- Tests: 2/3 quorum wins, 1/3 loses, voted_for enforcement, freshness gate,
  single-node self-elects, split-vote retry, in_catch_up denial, jitter
- Build fails with undefined reference to handle_request_vote,
  ha_elect_evaluate_and_signal, am_i_primary_quorum (expected RED proof)
This commit is contained in:
Rongsong Shen 2026-05-28 07:10:02 +00:00
parent f0029bf000
commit 403dd17f8b
4 changed files with 860 additions and 1 deletions

View file

@ -86,7 +86,7 @@ Dependency order: startup validation (D) unblocks vtaskmgr before election (A);
- _Boundary: Controller FSM (ha.c)_
- [ ] 4. Change B: Quorum-based controller election (replaces am_i_primary)
- [ ] 4.1 Write failing tests for quorum election logic
- [x] 4.1 Write failing tests for quorum election logic
- In `src/controller/testsuite/test_ha_election.c`: test 2/3 votes → `CTRL_PRIMARY`; test only 1/3 vote → `CTRL_STANDBY`; test `voted_for` enforcement (deny second candidate in same term); test freshness gate (higher peer tag yields to peer → `CTRL_STANDBY`); test fresher candidate wins over stale peer; test split vote triggers retry with incremented term; test single-node self-elects immediately without network; test `in_catch_up=1` standby votes are denied
- `make test` fails
- _Requirements: 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 2.10, 2.11, 2.12_