test(ha-single-leader-role): RED lifecycle tests for direct promotion + own-term gate (task 2.1)

This commit is contained in:
Rongsong Shen 2026-06-13 08:31:42 +00:00
parent e6abd7c8af
commit b7a69afa0b
2 changed files with 598 additions and 1 deletions

View file

@ -18,7 +18,7 @@
- _Requirements: 2.1_
- [ ] 2. Promotion rewrite: direct PRIMARY + own-term gate
- [ ] 2.1 Write RED lifecycle tests for direct promotion and the own-term gate
- [x] 2.1 Write RED lifecycle tests for direct promotion and the own-term gate
- Tests in `test_ha_role_lifecycle.c`: driving the become-leader path yields `ha->role == CTRL_PRIMARY` directly (no intermediate value observable; `ha_is_primary()` true immediately); `ha_should_redirect()` returns 0 the instant promotion returns, before any standby ACK; persistence hooks are registered by promotion (hooksys observes the three persist hook fns; `hooks_registered == 1`); promotion arms NO delaymgr watchdog (delaymgr task-count seam unchanged across promotion); with a real engine (n_peers=3, stub registry): promotion appends WAL_NOOP at lsn=N, registers it RETAIN, and `commit_set_writable_lsn(N)` is in effect — a `commit_submit(WAIT)` for entry N+1 does NOT complete while ACKs cover N+1 but not N, and completes once `committed_lsn >= N`; with the gate unmet a WAIT submission resolves only as barrier success, `-ETIMEDOUT`, or `-XCE_ERR_NOT_READY` — never via any promotion-side path; n_peers=1: gate opens immediately at promotion (noop self-committed), WAIT returns 0 as before
- Observable completion: new cases FAIL (red) against the current COMMITTING-entering `raft_cb_become_leader`
- _Requirements: 1.1, 1.3, 1.4, 1.5, 2.1, 2.2, 2.3_