The standing test's runs last 0.6 of failingAfterMs of clock as well as two attempts, so a success that does not reset a run is caught; the addition test holds a thousand stable passes, so 'first pass' is proved (review of the standing test races)

This commit is contained in:
2026-10-26 21:49:03 +01:00
parent 36ae0c691b
commit cf930388f9
2 changed files with 8 additions and 7 deletions
+6 -5
View File
@@ -38,7 +38,7 @@ interface World {
async function world(
names: string[],
opts: { retire?: boolean; held?: string[]; del?: boolean; reenable?: boolean; stableForMs?: number } = {},
opts: { retire?: boolean; held?: string[]; del?: boolean; reenable?: boolean; stableForMs?: number; stablePasses?: number } = {},
): Promise<World> {
const dir = await mkdtemp(join(tmpdir(), "retire-"));
const receives = join(dir, "postgres-database.json");
@@ -64,6 +64,7 @@ async function world(
};
w.p = runProviderLoop("postgres-database", adapter, {
receives, everyMs: EVERY, node: "anchor", stableForMs: opts.stableForMs ?? 0,
...(opts.stablePasses ? { stablePasses: opts.stablePasses } : {}),
// Only retirement is these tests'; the standing (provisioner.failing, .recovered) is standing.test.ts's.
announce: (event, body) => { if (event === RETIREMENT_EVENT) w.events.push(body); },
});
@@ -302,13 +303,13 @@ test("delete refuses an active consumer and deletes only the named retired one",
});
test("an addition acts on the first pass", async () => {
// Not gated by the stability a retirement waits for: with a hold of a minute, only a pass that acts at once creates b
// in the time the test waits. A deadline of three intervals, as before, was a race with the scheduler under load.
const w = await world(["a"], { stableForMs: 60_000 });
// Not gated by the stability a retirement waits for: with a hold of a minute and a thousand passes, only a pass that
// acts at once creates b. The deadline is a few passes, not three intervals of 10 ms: a scheduler stall must not fail it.
const w = await world(["a"], { stableForMs: 60_000, stablePasses: 1000 });
try {
const before = w.created.length;
await w.ask(["a", "b"]);
await until(() => w.created.length > before);
await until(() => w.created.length > before, 1000);
assert.equal(w.created.at(-1), "b");
} finally {
w.done();