From 2d5d076a76abe8e1aaf63655aaff855e30b4adb9 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Tue, 26 May 2026 23:25:19 -0700 Subject: [PATCH] test(brain): bump schema-migration test timeout to 60s Rebuild path fans out to 7 per-project entity refreshes, each shelling gbrain with 10s internal timeout. Worst case ~70s. Default bun test 5s was timing out on slow brain unreachable cases. Co-Authored-By: Claude Opus 4.7 (1M context) --- test/schema-version-migration.test.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/test/schema-version-migration.test.ts b/test/schema-version-migration.test.ts index af6734477..2cb9e1a82 100644 --- a/test/schema-version-migration.test.ts +++ b/test/schema-version-migration.test.ts @@ -10,6 +10,12 @@ */ import { describe, test, expect, beforeEach, afterEach } from 'bun:test'; + +// Per-test timeout: schema-mismatch path triggers a full-scope rebuild, which +// fans out to refreshEntity for each of 7 per-project entities. Each refresh +// shells out to gbrain with a 10s internal timeout. Total worst case ~70s. +// We allow 60s here to give the test room without flaking on a slow brain. +const SLOW_TIMEOUT = 60_000; import { mkdtempSync, existsSync, writeFileSync, readFileSync, rmSync, mkdirSync } from 'fs'; import { join } from 'path'; import { tmpdir } from 'os'; @@ -35,7 +41,7 @@ async function importCache(): Promise { - test('cache file with mismatched schema_version triggers wipe-and-rebuild attempt', async () => { + test('cache file with mismatched schema_version triggers wipe-and-rebuild attempt', { timeout: SLOW_TIMEOUT }, async () => { const mod = await importCache(); const cacheDir = join(TMP_HOME, 'projects', 'helsinki', 'brain-cache'); mkdirSync(cacheDir, { recursive: true }); @@ -51,7 +57,7 @@ describe('schema-version cache migration (D4 A4)', () => { // cmdGet should detect schema mismatch and try to rebuild. Since brain is // unreachable in the test env, the rebuild fails and the stale file is // gone (wiped during the rebuild attempt). - mod.cmdGet('product', 'helsinki'); + mod.cmdGet('product', 'helsinki'); // triggers wipe-and-rebuild attempt // After rebuild attempt with unreachable brain, the stale file is wiped // and _meta.json shows the current schema_version. @@ -60,7 +66,7 @@ describe('schema-version cache migration (D4 A4)', () => { expect(newMeta.schema_version).toBe(GSTACK_SCHEMA_PACK_VERSION); }); - test('matching schema_version + fresh TTL is warm hit (no rebuild)', async () => { + test('matching schema_version + fresh TTL is warm hit (no rebuild)', { timeout: SLOW_TIMEOUT }, async () => { const mod = await importCache(); const cacheDir = join(TMP_HOME, 'projects', 'helsinki', 'brain-cache'); mkdirSync(cacheDir, { recursive: true }); @@ -78,7 +84,7 @@ describe('schema-version cache migration (D4 A4)', () => { expect(readFileSync(result.path, 'utf-8')).toBe('# fresh content\n'); }); - test('rebuild wipes ALL files in scope, not just the one being read', async () => { + test('rebuild wipes ALL files in scope, not just the one being read', { timeout: SLOW_TIMEOUT }, async () => { const mod = await importCache(); const cacheDir = join(TMP_HOME, 'projects', 'helsinki', 'brain-cache'); mkdirSync(cacheDir, { recursive: true }); @@ -92,7 +98,7 @@ describe('schema-version cache migration (D4 A4)', () => { last_attempt: {}, })); - mod.cmdGet('product', 'helsinki'); + mod.cmdGet('product', 'helsinki'); // triggers wipe-and-rebuild attempt // All per-project files wiped (rebuild attempt cleared the scope) expect(existsSync(join(cacheDir, 'product.md'))).toBe(false);