diff --git a/test/cycle-consolidate.test.ts b/test/cycle-consolidate.test.ts index 812bffcad..fe3462bc5 100644 --- a/test/cycle-consolidate.test.ts +++ b/test/cycle-consolidate.test.ts @@ -10,6 +10,7 @@ import { describe, test, expect, beforeAll, afterAll, beforeEach } from 'bun:test'; import { PGLiteEngine } from '../src/core/pglite-engine.ts'; +import { configureGateway } from '../src/core/ai/gateway.ts'; import { runPhaseConsolidate } from '../src/core/cycle/phases/consolidate.ts'; let engine: PGLiteEngine; @@ -17,6 +18,20 @@ let engine: PGLiteEngine; beforeAll(async () => { engine = new PGLiteEngine(); await engine.connect({}); + // initSchema() bakes the facts.embedding dim from the gateway's configured + // embedding model; the default is now 1280-d (ZE). This file's fixtures are + // 1536-d, so pin the legacy 1536-d OpenAI config (matching + // test/helpers/legacy-embedding-preload.ts) right before initSchema. The + // global preload sets this, but a co-sharded test that calls resetGateway() + // in its teardown nulls it, leaving initSchema to fall back to the 1280-d + // default and build a halfvec(1280) column the 1536-d inserts can't fill. + // Re-pinning here makes the schema deterministic regardless of shard + // neighbors (surfaced when #1972's new test files reshuffled the shards). + configureGateway({ + embedding_model: 'openai:text-embedding-3-large', + embedding_dimensions: 1536, + env: { ...process.env }, + }); await engine.initSchema(); }); diff --git a/test/db-lock-heartbeat-takeover.test.ts b/test/db-lock-heartbeat-takeover.test.ts index fff0d4381..a4f479547 100644 --- a/test/db-lock-heartbeat-takeover.test.ts +++ b/test/db-lock-heartbeat-takeover.test.ts @@ -16,6 +16,7 @@ import { describe, test, expect, beforeAll, afterAll, beforeEach } from 'bun:test'; import { hostname } from 'os'; import { PGLiteEngine } from '../src/core/pglite-engine.ts'; +import { withEnv } from './helpers/with-env.ts'; import { tryAcquireDbLock, resolveStealGraceSeconds, @@ -81,22 +82,16 @@ describe('resolveStealGraceSeconds', () => { expect(resolveStealGraceSeconds(1)).toBe(60); }); - test('env override wins', () => { - process.env.GBRAIN_LOCK_STEAL_GRACE_SECONDS = '123'; - try { + test('env override wins', async () => { + await withEnv({ GBRAIN_LOCK_STEAL_GRACE_SECONDS: '123' }, async () => { expect(resolveStealGraceSeconds(30)).toBe(123); - } finally { - delete process.env.GBRAIN_LOCK_STEAL_GRACE_SECONDS; - } + }); }); - test('bad env override falls back to derived', () => { - process.env.GBRAIN_LOCK_STEAL_GRACE_SECONDS = 'nope'; - try { + test('bad env override falls back to derived', async () => { + await withEnv({ GBRAIN_LOCK_STEAL_GRACE_SECONDS: 'nope' }, async () => { expect(resolveStealGraceSeconds(30)).toBe(600); - } finally { - delete process.env.GBRAIN_LOCK_STEAL_GRACE_SECONDS; - } + }); }); });