Skip to content

Commit 3325b31

Browse files
committed
test(daemon): skip the build-fingerprint hash in tests (root-cause fix)
Every spawned worker/daemon re-hashes the entire executable image for the exact-build fingerprint; for the ASan test-runner (hundreds of MB) that is tens of seconds per spawn on constrained CI runners and was the sole cause of the whole daemon-family readiness-timeout flake class (index_supervisor, daemon_frontend, cli, and much of the Windows daemon surface). Add a test-only seam under CBM_CLI_ENABLE_TEST_API: when CBM_TEST_BUILD_FINGERPRINT holds a valid stub the hash is skipped. test_main.c sets it once; every forked child and re-exec'd worker inherits it, so exact-build match AND mismatch behaviour is preserved (a mismatch test still passes a different fingerprint via argv). Never compiled into production. Local mac run: index_supervisor 6/6, the four daemon suites 111/0, exact-build test green. The generous frontend catastrophic-alarm values are kept as backstops. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent f420e1a commit 3325b31

3 files changed

Lines changed: 33 additions & 3 deletions

File tree

‎src/mcp/index_supervisor.c‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,30 @@ size_t cbm_index_worker_memory_budget_bytes(void) {
8484
return g_worker_memory_budget_bytes;
8585
}
8686

87+
static bool worker_fingerprint_valid(const char *fingerprint);
88+
8789
bool cbm_index_supervisor_capture_build_fingerprint(void) {
8890
if (g_build_fingerprint_capture_attempted) {
8991
return g_build_fingerprint[0] != '\0';
9092
}
9193
g_build_fingerprint_capture_attempted = true;
94+
#if defined(CBM_CLI_ENABLE_TEST_API)
95+
/* Test-only seam: computing the real fingerprint hashes the ENTIRE
96+
* executable image, which for the ASan test-runner (hundreds of MB) takes
97+
* tens of seconds per spawned worker/daemon on constrained CI runners and
98+
* is the sole cause of the daemon-family readiness-timeout flakes. When a
99+
* valid stub is provided the hash is skipped; every process in the test
100+
* (parent, forked children, re-exec'd workers) inherits the same stub via
101+
* the environment, so exact-build match/mismatch behaviour is preserved
102+
* while startup becomes instant. Never compiled into production. */
103+
char test_fingerprint[CBM_INDEX_WORKER_BUILD_FINGERPRINT_SIZE];
104+
const char *test_value = cbm_safe_getenv("CBM_TEST_BUILD_FINGERPRINT", test_fingerprint,
105+
sizeof(test_fingerprint), NULL);
106+
if (test_value && worker_fingerprint_valid(test_value)) {
107+
(void)snprintf(g_build_fingerprint, sizeof(g_build_fingerprint), "%s", test_value);
108+
return true;
109+
}
110+
#endif
92111
char captured[CBM_INDEX_WORKER_BUILD_FINGERPRINT_SIZE] = {0};
93112
if (!cbm_daemon_runtime_process_build_fingerprint((uint64_t)worker_getpid(), captured)) {
94113
return false;

‎tests/test_daemon_frontend.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ enum {
6969
* seconds for frontend/daemon startup paths that finish instantly on a
7070
* dev machine (see the index-supervisor calibration). */
7171
FRONTEND_EOF_TEST_REQUEST_TIMEOUT_MS = 30000,
72-
FRONTEND_EOF_TEST_CATASTROPHIC_TIMEOUT_S = 30,
72+
FRONTEND_EOF_TEST_CATASTROPHIC_TIMEOUT_S = 90,
7373
FRONTEND_BACKPRESSURE_MESSAGE_BYTES = 2 * 1024 * 1024,
74-
FRONTEND_BACKPRESSURE_FRONTEND_TIMEOUT_S = 12,
75-
FRONTEND_BACKPRESSURE_DAEMON_TIMEOUT_S = 20,
74+
FRONTEND_BACKPRESSURE_FRONTEND_TIMEOUT_S = 90,
75+
FRONTEND_BACKPRESSURE_DAEMON_TIMEOUT_S = 90,
7676
FRONTEND_BACKPRESSURE_RUNTIME_TIMEOUT_MS = 90000,
7777
FRONTEND_BACKPRESSURE_CLEANUP_TIMEOUT_MS = 30000,
7878
/* The production queue is deliberately bounded below this count. Keep the

‎tests/test_main.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,17 @@ extern void suite_dump_verify_io(void);
648648
extern void cbm_kind_in_set_free_cache(void);
649649

650650
int main(int argc, char **argv) {
651+
/* Skip the multi-hundred-MB executable-image hash that computes the exact
652+
* build fingerprint: it is tens of seconds per spawned worker/daemon under
653+
* ASan on constrained CI runners and the sole cause of the daemon-family
654+
* readiness-timeout flakes. Set once here; every forked child and re-exec'd
655+
* worker inherits it, so exact-build match/mismatch still works (a
656+
* mismatch test still passes a DIFFERENT fingerprint via argv). Honoured
657+
* only under CBM_CLI_ENABLE_TEST_API — never in a production binary. */
658+
if (!getenv("CBM_TEST_BUILD_FINGERPRINT")) {
659+
(void)cbm_setenv("CBM_TEST_BUILD_FINGERPRINT",
660+
"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 1);
661+
}
651662
int blocking_git_rc = tf_maybe_run_blocking_git_probe(argc, argv);
652663
if (blocking_git_rc >= 0) {
653664
return blocking_git_rc;

0 commit comments

Comments
 (0)