feat(ha-repl-hardening): audit unit tests for decision loop and WAL catch-up (tasks 6.1, 6.2)
6.1: Add missing test_evaluate_repl_action_stream_wal_fresh_system (tag=T, lsn=0, oldest_wal_lsn=0 → STREAM_WAL in fresh system); 5 other required test cases already existed from tasks 3.1/3.2/5.2/2.3 6.2: Add test_wal_catchup_batch_256_entries (max batch size boundary) and test_wal_catchup_batch_applied_lsn_only_after_full_batch (Req 5.5); 4 other required test cases already existed from tasks 2.1/2.2
This commit is contained in:
parent
5defe7cc01
commit
d41cfc5813
3 changed files with 160 additions and 2 deletions
|
|
@ -766,6 +766,30 @@ static void test_evaluate_repl_action_stream_wal(void)
|
|||
printf("test_evaluate_repl_action_stream_wal: PASS\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Test: (tag=T, lsn=0) with oldest_wal_lsn=0 (fresh system, no WAL entries yet)
|
||||
* → STREAM_WAL (lsn=0 >= oldest_wal_lsn=0, so not in snapshot territory;
|
||||
* lsn=0 < committed_lsn → stream WAL from the beginning).
|
||||
*
|
||||
* This is the canonical Task 6.1 case: a standby that has caught up on config
|
||||
* (tag matches) but has no WAL applied yet on a fresh system. When there is no
|
||||
* WAL retention window to worry about (oldest_wal_lsn == 0), the correct action
|
||||
* is STREAM_WAL, not SEND_SNAPSHOT.
|
||||
*
|
||||
* Requirements: 1.1, 1.2, 2.2, 2.3 (ha-repl-hardening)
|
||||
*/
|
||||
static void test_evaluate_repl_action_stream_wal_fresh_system(void)
|
||||
{
|
||||
ha_repl_action_t action = ha_evaluate_repl_action(
|
||||
/*standby_tag=*/5, /*standby_lsn=*/0,
|
||||
/*committed_tag=*/5, /*committed_lsn=*/100,
|
||||
/*oldest_wal_lsn=*/0);
|
||||
/* lsn=0 >= oldest_wal_lsn=0 → NOT snapshot; lsn=0 < committed → STREAM_WAL */
|
||||
TEST_ASSERT_EQUAL_INT_MESSAGE(HA_REPL_STREAM_WAL, action,
|
||||
"(tag=T, lsn=0) with oldest_wal_lsn=0 must route to STREAM_WAL (Req 1.1, 1.2)");
|
||||
printf("test_evaluate_repl_action_stream_wal_fresh_system: PASS\n");
|
||||
}
|
||||
|
||||
/* ── Task 5.3: committing timeout default value and degraded-mode WARN ───────
|
||||
*
|
||||
* Requirements: 6.4, 7.5 (ha-repl-hardening)
|
||||
|
|
@ -922,6 +946,8 @@ void test_ha_role(void)
|
|||
RUN_TEST(test_evaluate_repl_action_converged);
|
||||
RUN_TEST(test_evaluate_repl_action_send_snapshot);
|
||||
RUN_TEST(test_evaluate_repl_action_stream_wal);
|
||||
/* Task 6.1: (tag=T, lsn=0) with oldest_wal_lsn=0 → STREAM_WAL */
|
||||
RUN_TEST(test_evaluate_repl_action_stream_wal_fresh_system);
|
||||
/* Task 3.3: ha_dispatch_repl_action_for_standby PUSH_CONFIG wiring */
|
||||
RUN_TEST(test_dispatch_repl_action_push_config_when_tag_behind);
|
||||
RUN_TEST(test_dispatch_repl_action_no_push_when_converged);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue