test(ha-single-leader-role): sweep all COMMITTING fixtures to direct-PRIMARY contract (task 5.1)

This commit is contained in:
Rongsong Shen 2026-06-13 13:59:42 +00:00
parent 71ce41f486
commit 7f974e766b
11 changed files with 138 additions and 169 deletions

View file

@ -79,7 +79,6 @@ static ha_config_t g_cfg = {
.max_promotion_retries = 5,
.election_jitter_max_ms = 0,
.election_priority_step_ms = 500,
.committing_timeout_ms = 10000,
};
/* ── Stubs for production hooks ─────────────────────────────────────────── */
@ -176,11 +175,11 @@ static void test_dispatcher_electing_calls_vote_reply_hook(void)
printf("test_dispatcher_electing_calls_vote_reply_hook: PASS\n");
}
/* ── Test 2 (dispatcher CTRL_PRIMARY_COMMITTING → repl_ack count) DELETED ─────
/* ── Test 2 (dispatcher transitional-leader → repl_ack count) DELETED ─────────
* ha-single-leader-role task 4.1. Subject was the deleted ack-counting
* promotion machinery (replCatchUpDone incrementing repl_ack_count to drive
* COMMITTING → PRIMARY). That path is gone — nothing left to verify. No shim
* (design §"Transitional-State Deletions").
* promotion machinery (replCatchUpDone incrementing repl_ack_count to drive a
* transitional leader state to PRIMARY). That path is gone — nothing left to
* verify. No shim (design §"Transitional-State Deletions").
*/
/* ── Test 3: dispatcher drops packet for CTRL_STANDBY ───────────────────── */
@ -346,7 +345,7 @@ static void test_err_handler_removes_promoted_ep_from_standby(void)
ha_state_t ha;
init_ha_with_standby_eps(&ha);
ha.n_peers = 2;
atomic_store_explicit(&ha.role, (int32_t)CTRL_PRIMARY_COMMITTING,
atomic_store_explicit(&ha.role, (int32_t)CTRL_PRIMARY,
memory_order_release);
/* Populate standby_endpoints with a heap-allocated mock ep pointer */
@ -368,7 +367,7 @@ static void test_err_handler_removes_promoted_ep_from_standby(void)
TEST_ASSERT_EQUAL_INT_MESSAGE(0, rc, "err_handler must return 0");
TEST_ASSERT_EQUAL_INT_MESSAGE(0, ha.standby_endpoints->count,
"err_handler: ep must be removed from standby_endpoints when role=COMMITTING (Req 4.2)");
"err_handler: ep must be removed from standby_endpoints when role=CTRL_PRIMARY (Req 4.2)");
free(ep->data);
free(ep);
@ -481,7 +480,8 @@ static void test_follower_passive_no_outbound_connect(void)
/* ── Test 10 (Task 7.3: promoted ep repl_ack promotes to PRIMARY) DELETED ─────
* ha-single-leader-role task 4.1. Subject was the deleted ack-counting
* promotion machinery (replCatchUpDone incrementing repl_ack_count until the
* majority threshold drives COMMITTING → CTRL_PRIMARY via ha_promote_to_primary).
* majority threshold promoted a transitional leader state to CTRL_PRIMARY via
* ha_promote_to_primary).
* The mechanism is gone — promotion is now the heartbeat decision loop +
* per-entry majority ack. Nothing left to verify; no shim (design
* §"Transitional-State Deletions").