feat(ha-heartbeat-liveness): add last_activity and last_push_time state fields (task 1.1)
Add time_t last_activity to ha_state_t for standby liveness timestamp tracking. Add time_t last_push_time to standby_ep_ctx_t for primary idle NOP suppression. Zero-initialize last_activity in ha_init(); last_push_time zeroed by calloc. Add test_ha_init_last_activity_is_zero to test_ha_startup.c.
This commit is contained in:
parent
e85100d761
commit
bcb45e59d2
4 changed files with 141 additions and 2 deletions
|
|
@ -589,6 +589,24 @@ static void test_dispatch_gate_committing_allows_repl_ops(void)
|
|||
printf("test_dispatch_gate_committing_allows_repl_ops: PASS\n");
|
||||
}
|
||||
|
||||
/* ── Task 1.1 (ha-heartbeat-liveness): ha_init() zero-initializes last_activity ─
|
||||
*
|
||||
* Req 1.1, 1.3, 3.1: ha_state_t must carry a `time_t last_activity` field that
|
||||
* is zero-initialized by ha_init(). Later tasks (2.1) write to this field via
|
||||
* ha_on_heartbeat_received(); task 3.1 reads it for liveness polling.
|
||||
*/
|
||||
static void test_ha_init_last_activity_is_zero(void)
|
||||
{
|
||||
ha_state_t ha;
|
||||
ha_init(&ha, &g_dispatch_cfg, 0);
|
||||
|
||||
TEST_ASSERT_EQUAL_INT_MESSAGE(0, (int)ha.last_activity,
|
||||
"ha_init must zero-initialize last_activity (liveness field)");
|
||||
|
||||
ha_fini(&ha);
|
||||
printf("test_ha_init_last_activity_is_zero: PASS\n");
|
||||
}
|
||||
|
||||
/* ── Task 5.1: myapp_run startup sequence ────────────────────────────────
|
||||
*
|
||||
* Req 1.1, 9.3, 9.4: myapp_run must call ha_start_election_async (non-blocking)
|
||||
|
|
@ -744,4 +762,7 @@ void test_ha_startup(void)
|
|||
RUN_TEST(test_nonblocking_single_node_election_sets_n_peers);
|
||||
RUN_TEST(test_nonblocking_single_node_election_enters_committing);
|
||||
RUN_TEST(test_nonblocking_election_returns_in_under_10ms);
|
||||
|
||||
/* Task 1.1 (ha-heartbeat-liveness) — ha_init zero-initializes last_activity */
|
||||
RUN_TEST(test_ha_init_last_activity_is_zero);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue