diff --git a/doc/idle-gateway-credential-expiry.md b/doc/idle-gateway-credential-expiry.md index 04c48991e65..14c0a6a01ce 100644 --- a/doc/idle-gateway-credential-expiry.md +++ b/doc/idle-gateway-credential-expiry.md @@ -111,3 +111,10 @@ behavioral evidence; combined-stack and fresh remote checks remain required. The full local test:run remains unverified because of embedded PostgreSQL startup/capacity limits; the two real gateway suites used separate migrated, task-owned disposable PostgreSQL databases. + +A later combined run exposed a test-clock overshoot: repeated blind 30-second +advances could expire the future session before its intermediate assertion. +The settlement helper now lets real SQL settle and advances only to an actually +armed follow-up within the coalescing window. All 12 credential expiry tests pass +on the owning gateway branch with the existing exact-deadline and transaction +assertions intact. This follow-up changes the test fixture only. diff --git a/server/src/__tests__/gateway-credential-expiry.test.ts b/server/src/__tests__/gateway-credential-expiry.test.ts index 39e3590f9ad..da1619aea42 100644 --- a/server/src/__tests__/gateway-credential-expiry.test.ts +++ b/server/src/__tests__/gateway-credential-expiry.test.ts @@ -60,8 +60,15 @@ describe.skipIf(!supported)("gateway credential expiry", () => { async function settle(ms = 60_000) { await vi.advanceTimersByTimeAsync(ms); if (!draining) await vi.waitFor(async () => { - // SQL may finish after the clock jump and arm a coalesced follow-up pass. - if (idleWorkSnapshot().active > 0) await vi.advanceTimersByTimeAsync(30_000); + // Let real SQL settle before advancing only to an actually armed follow-up. + // Repeated blind clock jumps can expire the future credential under test. + if (idleWorkSnapshot().active > 0) { + await db.execute(sql`select pg_sleep(0.01)`); + const next = coordinator!.nextWakeAt(); + if (next !== null && next <= Date.now() + 30_000) { + await vi.advanceTimersByTimeAsync(Math.max(0, next - Date.now())); + } + } expect(idleWorkSnapshot().active).toBe(0); }, { timeout: 5000 }); }