diff --git a/server/src/__tests__/execution-control-work.test.ts b/server/src/__tests__/execution-control-work.test.ts index 9166c7f1da1..584eeafb6af 100644 --- a/server/src/__tests__/execution-control-work.test.ts +++ b/server/src/__tests__/execution-control-work.test.ts @@ -11,6 +11,7 @@ import { resolveExternalTestDatabaseUrl } from "./helpers/external-test-database import { createDeliveryWorkCoordinator } from "../services/delivery-work-coordinator.js"; import { DELIVERY_QUEUES, notifyDeliveryWork } from "../services/delivery-work-notifications.js"; import { executionControlSchedule, registerExecutionControlWork } from "../services/execution-control-work.js"; +import { EXECUTION_RECONCILIATION_INTERVAL_MS } from "../services/execution-control-deadline.js"; import { deliverExecutionStatuses } from "../services/execution-status-delivery.js"; import { terminalizeLegacyExecution } from "../services/legacy-execution-recovery.js"; import { reconcileAbandonedExecutionControl } from "../services/execution-control-reconciliation.js"; @@ -252,7 +253,7 @@ describe.skipIf(!support.supported)("execution-control durable work", () => { }); it("visits a newly committed earlier Retry during a busy recovered-source pass, then becomes quiet", async () => { - const sources = []; + const sources: Awaited>[] = []; for (let index = 0; index < 3; index++) { sources.push(await pausedRecoveredSource(`ffffffff-000${index}-4000-8000-${randomUUID().slice(-12)}`)); } @@ -272,9 +273,11 @@ describe.skipIf(!support.supported)("execution-control durable work", () => { const earlier = await pausedRecoveredSource(`00000000-0000-4000-8000-${randomUUID().slice(-12)}`); sources.push(earlier); release(); - for (let pass = 0; pass < 10 && sources.some(({ run }) => - !resume.mock.calls.some(([visited]) => visited.id === run.id)); pass++) await settle(); - expect(resume.mock.calls.map(([run]) => run.id)).toContain(earlier.run.id); + await vi.waitFor(async () => { + await vi.advanceTimersByTimeAsync(EXECUTION_RECONCILIATION_INTERVAL_MS); + expect(sources.every(({ run }) => resume.mock.calls.some(([visited]) => visited.id === run.id))).toBe(true); + expect(idleWorkSnapshot().active).toBe(0); + }, { timeout: 10_000, interval: 50 }); await quiet(c); for (const { run, retry } of sources) { expect(resume.mock.calls.map(([visited]) => visited.id)).toContain(run.id);