mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-20 09:50:48 +01:00
Respect dispatch-hint coalescing in the handover test
The first replacement hint can arrive before the test samples its wake counter. A skipped dispatch inside the existing hint cooldown then emits no new notification, so waiting for a second hint without another dispatch fails even though the handover works. Make the cooldown observable, wait for the initial hint, and retry the old server's skipped dispatch within the existing wait. Keep proving that the old server refuses the run and the replacement claims it exactly once. Verification: the controlled cooldown case reproduced CI's expected-1-to- be-greater-than-1 failure before the change. All 19 handover tests pass after the change. The original suite also passed in local isolation. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
77778da28a
commit
afee630120
1 file changed
+6
-2
@@ -110,7 +110,7 @@ suite("run start hand-over between an old and a new server during a deploy overl
|
||||
|
||||
it("the old server stops starting runs once the new one starts them, and the new one starts the queued run", async () => {
|
||||
// The old server booted alone long ago: it recorded its own start and holds no hand-over.
|
||||
const old = await bootServer("old");
|
||||
const old = await bootServer("old", { timing: { skipHintMinMs: 500 } });
|
||||
await old.handover.begin();
|
||||
expect(old.handover.isHandingOver()).toBe(false);
|
||||
const before = await queueRun();
|
||||
@@ -126,12 +126,16 @@ suite("run start hand-over between an old and a new server during a deploy overl
|
||||
expect(next.handover.isHandingOver()).toBe(true);
|
||||
expect(await marker(next)).toMatchObject({ live: true });
|
||||
await vi.waitFor(() => expect(old.handover.isActive()).toBe(true), { timeout: 10_000 });
|
||||
await vi.waitFor(() => expect(next.dispatchHints).toBeGreaterThan(0), { timeout: 10_000 });
|
||||
|
||||
const handedOver = await queueRun();
|
||||
const hintsBefore = next.dispatchHints;
|
||||
expect(await dispatch(old, handedOver)).toBe(false);
|
||||
// The skipped start wakes the new server's queued-run dispatch instead of waiting for a sweep.
|
||||
await vi.waitFor(() => expect(next.dispatchHints).toBeGreaterThan(hintsBefore), { timeout: 10_000 });
|
||||
await vi.waitFor(async () => {
|
||||
expect(await dispatch(old, handedOver)).toBe(false);
|
||||
expect(next.dispatchHints).toBeGreaterThan(hintsBefore);
|
||||
}, { timeout: 10_000 });
|
||||
expect(await dispatch(next, handedOver)).toBe(true);
|
||||
expect(claims.filter(claim => claim.runId === handedOver)).toEqual([{ server: "new", runId: handedOver }]);
|
||||
|
||||
|
||||
Reference in new issue
Block a user