feat: add persistence/HA system constants to config.h with tests (P0-A)
Adds 17 compile-time constants covering WAL format, HA topology, snapshot sizing, and operational defaults. test_persistence_constants in test_config.c validates every constant value; all 6 config tests pass (4 pre-existing unrelated failures unchanged).
This commit is contained in:
parent
dffa44d59b
commit
e0e2f56c81
2 changed files with 44 additions and 0 deletions
|
|
@ -71,4 +71,26 @@ typedef uint64_t jobid_t;
|
|||
#define REGEX_JOBARRAY_ID \
|
||||
"[ \t]*([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)\\[([0-9]+)\\][ \t]*"
|
||||
|
||||
/* ======================================================
|
||||
* Persistence & HA system constants (Part 2.6, Appendix A.10)
|
||||
* ====================================================== */
|
||||
#define MAX_STANDBYS 3
|
||||
#define MAX_HA_CANDIDATES 4
|
||||
#define WAL_FORMAT_VERSION 1
|
||||
#define WAL_ENTRY_TYPE_MAX 100 /* WAL_CHECKPOINT = 100, highest known type */
|
||||
#define MAX_WAL_PAYLOAD_BYTES (1 << 20) /* 1 MB per replication entry */
|
||||
#define MAX_SNAPSHOT_BYTES (256 * 1024 * 1024) /* 256 MB max snapshot size */
|
||||
#define WAL_HDR_CRC_SIZE 32 /* sizeof(wal_entry_hdr_t) - 2*sizeof(uint32_t) */
|
||||
#define WAL_CRC_NONE 0xFFFFFFFFu /* sentinel: no predecessor in chain */
|
||||
|
||||
#define DEFAULT_WAL_SYNC_MS 10
|
||||
#define DEFAULT_SNAP_INTERVAL_S 60
|
||||
#define DEFAULT_SNAP_WAL_SIZE_MB 64
|
||||
#define DEFAULT_SNAP_KEEP_N 2
|
||||
#define DEFAULT_TRANSIENT_JOB_TIMEOUT_S 300
|
||||
#define DEFAULT_FINISHED_RETAIN_S 3600
|
||||
#define DEFAULT_WORKER_RETAIN_S 86400
|
||||
#define DEFAULT_SYNC_TIMEOUT_MS 50
|
||||
#define DEFAULT_HB_INTERVAL_MS 3000
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -27,6 +27,27 @@ static void test_array(void)
|
|||
TEST_ASSERT_TRUE(MAX_ARRAY_IDX == 32767);
|
||||
}
|
||||
|
||||
static void test_persistence_constants(void)
|
||||
{
|
||||
TEST_ASSERT_TRUE(MAX_STANDBYS == 3);
|
||||
TEST_ASSERT_TRUE(MAX_HA_CANDIDATES == 4);
|
||||
TEST_ASSERT_TRUE(WAL_FORMAT_VERSION == 1);
|
||||
TEST_ASSERT_TRUE(WAL_ENTRY_TYPE_MAX == 100);
|
||||
TEST_ASSERT_TRUE(MAX_WAL_PAYLOAD_BYTES == (1 << 20));
|
||||
TEST_ASSERT_TRUE(MAX_SNAPSHOT_BYTES == (256 * 1024 * 1024));
|
||||
TEST_ASSERT_TRUE(DEFAULT_WAL_SYNC_MS == 10);
|
||||
TEST_ASSERT_TRUE(DEFAULT_SNAP_INTERVAL_S == 60);
|
||||
TEST_ASSERT_TRUE(DEFAULT_SNAP_WAL_SIZE_MB == 64);
|
||||
TEST_ASSERT_TRUE(DEFAULT_SNAP_KEEP_N == 2);
|
||||
TEST_ASSERT_TRUE(DEFAULT_FINISHED_RETAIN_S == 3600);
|
||||
TEST_ASSERT_TRUE(DEFAULT_WORKER_RETAIN_S == 86400);
|
||||
TEST_ASSERT_TRUE(DEFAULT_SYNC_TIMEOUT_MS == 50);
|
||||
TEST_ASSERT_TRUE(DEFAULT_HB_INTERVAL_MS == 3000);
|
||||
TEST_ASSERT_TRUE(DEFAULT_TRANSIENT_JOB_TIMEOUT_S == 300);
|
||||
TEST_ASSERT_TRUE(WAL_HDR_CRC_SIZE == 32);
|
||||
TEST_ASSERT_TRUE(WAL_CRC_NONE == 0xFFFFFFFFu);
|
||||
}
|
||||
|
||||
void test_config(void)
|
||||
{
|
||||
printf("\n>> config test\n\n");
|
||||
|
|
@ -36,4 +57,5 @@ void test_config(void)
|
|||
RUN_TEST(test_timestamp);
|
||||
RUN_TEST(test_tag);
|
||||
RUN_TEST(test_array);
|
||||
RUN_TEST(test_persistence_constants);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue