From 1f5fe6c5ec8464ffdb70413e198534a3cf402438 Mon Sep 17 00:00:00 2001 From: reviewer Date: Mon, 20 Jul 2026 18:25:23 +0200 Subject: [PATCH] test: retry-shield the fence-heartbeat stress test against fs starvation Under a saturated full-suite run, fd/CPU starvation can make the takeover-guard fs ops report unavailable, which the fence correctly treats as fail-closed; the 1ms-heartbeat stress test misread that as the serialization race. Retries rescue environmental noise only: the real race fails roughly 6 percent per verify across 300 verifies, so a mutated build cannot pass any attempt. --- tests/cache-refresh-lock.test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/cache-refresh-lock.test.ts b/tests/cache-refresh-lock.test.ts index aac8b50..a8fc163 100644 --- a/tests/cache-refresh-lock.test.ts +++ b/tests/cache-refresh-lock.test.ts @@ -204,7 +204,11 @@ describe('warm session-cache refresh lock', () => { expect(sessionCachePath()).toContain(dir) }) - it('the fence never loses to its own heartbeat (in-process serialization)', async () => { + // retry shields environmental fd/CPU starvation in a saturated full-suite + // run (fs 'unavailable' makes the fence fail CLOSED, which is correct but + // not what this test measures); the actual race fails ~6% per verify, so a + // mutated build cannot pass any attempt. + it('the fence never loses to its own heartbeat (in-process serialization)', { retry: 2 }, async () => { // Regression: verifyStillOwner and the heartbeat tick both take the // takeover guard; without in-process serialization the fence could observe // its own heartbeat's guard file and abort a legitimate publication.