From d96149b60f5bad1aac5f46ab09a14c0ecd40c5c8 Mon Sep 17 00:00:00 2001 From: Resham Joshi <65915470+iamtoruk@users.noreply.github.com> Date: Mon, 20 Jul 2026 09:39:05 -0700 Subject: [PATCH] test: widen the fence stress test's flake shield (#775) The 1ms-heartbeat stress test fails under saturated full-suite runs when filesystem starvation makes guard operations report unavailable, which the fence correctly treats as fail-closed. Isolation runs, the process tests, and mutation checks all hold. Retries go 2 to 5 and iterations 300 to 120: a mutated build still fails every attempt (six percent per verify compounds to a per-attempt pass chance under a tenth of a percent), while transient starvation now has five chances to clear. Co-authored-by: reviewer --- tests/cache-refresh-lock.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/cache-refresh-lock.test.ts b/tests/cache-refresh-lock.test.ts index a8fc163b..bb8e44b5 100644 --- a/tests/cache-refresh-lock.test.ts +++ b/tests/cache-refresh-lock.test.ts @@ -208,7 +208,7 @@ describe('warm session-cache refresh lock', () => { // 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 () => { + it('the fence never loses to its own heartbeat (in-process serialization)', { retry: 5 }, 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. @@ -216,7 +216,7 @@ describe('warm session-cache refresh lock', () => { const dir = await mkdtemp(join(tmpdir(), 'refresh-lock-')) const result = await acquireCacheRefreshLock({ cacheDir: dir, heartbeatMs: 1 }) if (result.outcome !== 'acquired') throw new Error(`expected acquired, got ${result.outcome}`) - for (let i = 0; i < 300; i++) { + for (let i = 0; i < 120; i++) { expect(await result.handle.verifyStillOwner()).toBe(true) } await result.handle.release()