Skip to content

Commit 773b545

Browse files
committed
test(core): observe live lock renewal deterministically
1 parent 0db6b68 commit 773b545

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

packages/core/src/ops/trusted-config-queue-lock.test.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,27 @@ describe("trusted configuration retained-budget lock", () => {
376376

377377
it("does not reclaim a live multiprocess holder beyond its original expiry", async () => {
378378
const root = directory();
379-
const child = await liveHolder(root);
380-
await delay(250);
379+
const holderTtlMs = 1_000;
380+
const child = await liveHolder(root, holderTtlMs);
381+
const heartbeatPath = join(root, OPS_TRUSTED_CONFIG_QUEUE_LOCK_NAME, "heartbeat.json");
382+
const initialHeartbeat = JSON.parse(readFileSync(heartbeatPath, "utf8")) as {
383+
expiresAtMs: number;
384+
sequence: number;
385+
};
386+
await expect
387+
.poll(
388+
() => {
389+
const current = JSON.parse(readFileSync(heartbeatPath, "utf8")) as {
390+
sequence: number;
391+
};
392+
return (
393+
Date.now() > initialHeartbeat.expiresAtMs &&
394+
current.sequence > initialHeartbeat.sequence
395+
);
396+
},
397+
{ interval: 25, timeout: 5_000 },
398+
)
399+
.toBe(true);
381400
expect(child.exitCode).toBeNull();
382401
let recovered: Awaited<ReturnType<typeof acquireTrustedConfigurationQueueLock>> | undefined;
383402
try {

0 commit comments

Comments
 (0)