From 77e6bad77df46746ee1fc0f3a01f43d8e2eaf5f0 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 16:46:51 +0000 Subject: [PATCH] test(service-knowledge): give the multi-node sync-state cases measured timeouts The rebuild-through-node-A case boots four kernels over one file, seeds three records, runs two rebuilds and restarts both nodes inside vitest's default 5000 ms; under the merge queue's full-suite load it timed out. Each multi-node case in the file now carries an explicit budget of 20x its worst locally measured duration under doubled suite load. No case is skipped and no assertion or waitFor changes. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP --- .../src/__tests__/sync-state.test.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/services/service-knowledge/src/__tests__/sync-state.test.ts b/packages/services/service-knowledge/src/__tests__/sync-state.test.ts index a2778da3b10..1623c8aa835 100644 --- a/packages/services/service-knowledge/src/__tests__/sync-state.test.ts +++ b/packages/services/service-knowledge/src/__tests__/sync-state.test.ts @@ -317,6 +317,7 @@ async function seedArticles(n: Node): Promise { } describe('one record per source, the same on every node', () => { + // Four kernel boots over one file, three seeded syncs, two rebuilds: 1.28 s worst measured under doubled suite load, x20 headroom. it('a rebuild through node A reads identically on node B while it runs and after it ends — an index already current included — and after both restart', async () => { const file = freshFile(); const store = makeStore(); @@ -375,8 +376,9 @@ describe('one record per source, the same on every node', () => { expect((await a2.status()).build).toEqual(current); expect((await b2.status()).build).toEqual(current); expect(await a2.stateRows()).toHaveLength(1); - }); + }, 26_000); + // Two kernel boots over one file, three seeded syncs, a rebuild and a restart: 0.77 s worst measured under doubled suite load, x20 headroom. it('a build whose node stopped mid-walk reads running until the next boot, then interrupted', async () => { const file = freshFile(); const store = makeStore(); @@ -392,8 +394,9 @@ describe('one record per source, the same on every node', () => { expect(after.build).toMatchObject({ status: 'interrupted', trigger: 'operator' }); expect(after.build?.finishedAt).toBeDefined(); expect(after.build?.message).toContain('stopped before it ended'); - }); + }, 16_000); + // Three kernel boots over one file, three seeded syncs, a rebuild: 0.81 s worst measured under doubled suite load, x20 headroom. it("over a cluster lock: a boot leaves a build whose lease another node holds; once its lease runs out the next boot or the next lease holder closes it interrupted", async () => { const file = freshFile(); const store = makeStore(); @@ -414,8 +417,9 @@ describe('one record per source, the same on every node', () => { expect((await c.status()).build).toMatchObject({ status: 'interrupted', startedAt }); expect((await b.status()).build).toMatchObject({ status: 'interrupted', startedAt }); expect(cluster.held.size).toBe(0); - }); + }, 17_000); + // Two kernel boots over one file, three seeded syncs, three rebuild calls: 0.46 s worst measured under doubled suite load, x20 headroom. it('the next lease holder closes the build a stopped node left running before it starts its own', async () => { const file = freshFile(); const store = makeStore(); @@ -447,7 +451,7 @@ describe('one record per source, the same on every node', () => { expect((await a.status()).build).toMatchObject({ status: 'running', startedAt: takenAt }); release(); await vi.waitFor(async () => expect((await a.status()).build?.status).toBe('done'), { timeout: 5000, interval: 20 }); - }); + }, 10_000); }); describe('sync failures: one per dead letter, cleared by the reconcile that repairs them', () => {