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) <noreply@anthropic.com>
This commit is contained in:
Garry Tan 2026-05-26 23:25:19 -07:00
parent 373023555c
commit 2d5d076a76
No known key found for this signature in database
GPG Key ID: C1F69E85C74EFE1D
1 changed files with 11 additions and 5 deletions

View File

@ -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<typeof import('../bin/gstack-brain-cache')
}
describe('schema-version cache migration (D4 A4)', () => {
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);