Skip to content

Commit 13b5200

Browse files
os-muskclaude
andauthored
test(driver-sql): give the seven unconditionally-live hooks an explicit 60_000 budget (#14629)
A per-site AST walk over all 160 test files in packages/drivers/driver-sql/src (111 hooks that construct a SqlDriver) classifies each site by READING its `new SqlDriver(...)` argument rather than by filename. Seven hooks take an unconditionally live cell argument (`PG_CELL.config()` / `MYSQL_CELL.config()`, not a parametrised `cell.config()`) and carried no explicit budget. Each now takes the third argument, matching the precedent set in sql-driver-backend-fault-envelope.test.ts. A hook inherits `hookTimeout`, NOT `testTimeout`. This package's config sets neither, so both are vitest's own defaults: an unbudgeted hook dies at 10000ms, not at the 5000ms an unbudgeted it() gets. The comments at each site record that measured figure. No existing prose needed correcting: the only "5000ms" mention already in these four files describes an it() site, where 5000ms is the correct number. The `declareDialectCell(...)` hook population is deliberately untouched: those take a parametrised `cell.config()` and budgeting them trades against keeping the sqlite path fast. Claude-Session: https://claude.ai/code/session_0112hMx9hjJ9BgB28X97DS68 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 8225248 commit 13b5200

4 files changed

Lines changed: 75 additions & 7 deletions

File tree

packages/drivers/driver-sql/src/sql-driver-datetime-mysql-storage.test.ts

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,27 @@ describe.skipIf(!URL)('Field.datetime on MySQL (#3942)', () => {
6161
await probe.disconnect();
6262
});
6363

64+
// ── Why this beforeEach carries an explicit 60_000 budget (#14213) ──
65+
// The driver argument here is `MYSQL_CELL.config()` — unconditionally LIVE,
66+
// not a parametrised `cell.config()` that would be SQLite for the sqlite
67+
// cell — so every test in this suite pays a fresh live connect, a
68+
// `drop table` and `initObjects(...)` schema-sync DDL against the cell's
69+
// MySQL server. A beforeEach is the heaviest shape in this class: the cost is
70+
// paid PER TEST, not once.
71+
// ⚠️ A hook inherits `hookTimeout`, NOT `testTimeout`. Measured in this
72+
// package's config (which sets neither, so both are vitest's own defaults):
73+
// an unbudgeted hook dies at 10000ms ("Hook timed out in 10000ms"), not at
74+
// the 5000ms an unbudgeted it() gets. Ten seconds is still a ceiling nobody
75+
// chose for live work, and the third argument does lift it (measured).
76+
// ⛔ NOT a claim that this hook is known to time out: it was found by a
77+
// per-site AST walk over the package, never by a measured red.
6478
beforeEach(async () => {
6579
driver = new SqlDriver(MYSQL_CELL.config());
6680
await driver.execute(`drop table if exists ${TABLE}`);
6781
await driver.initObjects([
6882
{ name: TABLE, fields: { label: { type: 'string' }, at: { type: 'datetime' } } },
6983
]);
70-
});
84+
}, 60_000);
7185

7286
afterEach(async () => {
7387
await driver.execute(`drop table if exists ${TABLE}`).catch(() => {});
@@ -155,6 +169,12 @@ describe.skipIf(!URL)('MySQL TIMESTAMP → DATETIME(3) migration (#3942)', () =>
155169
const GOOD = '2026-03-20T12:34:56.000Z';
156170
let driver: SqlDriver;
157171

172+
// ── Why this beforeEach carries an explicit 60_000 budget (#14213) ──
173+
// Same live-cell reasoning as the #3942 suite's beforeEach above, and this
174+
// one is heavier: it opens a SECOND live connection (`rawDriver()`) to build
175+
// the legacy fixture — raw DDL plus an insert — before constructing the
176+
// driver under test, all per test. A hook inherits `hookTimeout` (measured
177+
// 10000ms), not `testTimeout` (5000ms); the third argument lifts it.
158178
beforeEach(async () => {
159179
// Build the table the way a pre-#3942 build did: TIMESTAMP columns, rows in
160180
// it. The legacy connection is pinned to UTC so the fixture's instants are
@@ -178,7 +198,7 @@ describe.skipIf(!URL)('MySQL TIMESTAMP → DATETIME(3) migration (#3942)', () =>
178198
await legacy.disconnect();
179199

180200
driver = new SqlDriver(MYSQL_CELL.config());
181-
});
201+
}, 60_000);
182202

183203
afterEach(async () => {
184204
await driver.execute(`drop table if exists ${LEGACY}`).catch(() => {});
@@ -234,6 +254,12 @@ describe.skipIf(!URL)('os migrate plan lists the MySQL widening (#3954)', () =>
234254
const SHAPE = { name: LEGACY, fields: { label: { type: 'string' }, at: { type: 'datetime' } } };
235255
let driver: SqlDriver;
236256

257+
// ── Why this beforeEach carries an explicit 60_000 budget (#14213) ──
258+
// Same live-cell reasoning as the two beforeEach hooks above. Heaviest of the
259+
// three: a second live connection builds the legacy fixture with raw DDL and
260+
// FIVE inserts before the driver under test is constructed — per test.
261+
// A hook inherits `hookTimeout` (measured 10000ms), not `testTimeout`
262+
// (5000ms); the third argument lifts it.
237263
beforeEach(async () => {
238264
const legacy = rawDriver();
239265
await legacy.execute(`drop table if exists ${LEGACY}`);
@@ -254,7 +280,7 @@ describe.skipIf(!URL)('os migrate plan lists the MySQL widening (#3954)', () =>
254280
}
255281
await legacy.disconnect();
256282
driver = new SqlDriver(MYSQL_CELL.config());
257-
});
283+
}, 60_000);
258284

259285
afterEach(async () => {
260286
await driver.execute(`drop table if exists ${LEGACY}`).catch(() => {});

packages/drivers/driver-sql/src/sql-driver-datetime-postgres-timezone.test.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,36 @@ describe.skipIf(!URL)('Field.datetime on Postgres is timezone-independent (#3912
4949
let driver: SqlDriver;
5050
let serverTimeZone = '';
5151

52+
// ── Why this beforeAll carries an explicit 60_000 budget (#14213) ──
53+
// The driver argument here is `PG_CELL.config()` — unconditionally LIVE, not
54+
// a parametrised `cell.config()` that would be SQLite for the sqlite cell —
55+
// so this hook pays a full connect cycle against the cell's Postgres server,
56+
// a `current_setting('TimeZone')` round trip and a disconnect.
57+
// ⚠️ A hook inherits `hookTimeout`, NOT `testTimeout`. Measured in this
58+
// package's config (which sets neither, so both are vitest's own defaults):
59+
// an unbudgeted hook dies at 10000ms ("Hook timed out in 10000ms"), not at
60+
// the 5000ms an unbudgeted it() gets. Ten seconds is still a ceiling nobody
61+
// chose for live work, and the third argument does lift it (measured).
62+
// ⛔ NOT a claim that this hook is known to time out: it was found by a
63+
// per-site AST walk over the package, never by a measured red.
5264
beforeAll(async () => {
5365
const probe = new SqlDriver(PG_CELL.config());
5466
const res: any = await probe.execute(`select current_setting('TimeZone') as tz`);
5567
serverTimeZone = ((res?.rows ?? res)[0] as any).tz;
5668
await probe.disconnect();
57-
});
69+
}, 60_000);
5870

71+
// ── Why this beforeEach carries an explicit 60_000 budget (#14213) ──
72+
// Same live-cell reasoning as the beforeAll above, except this one is paid
73+
// PER TEST rather than once: a fresh live connect, a `drop table ... cascade`
74+
// and `initObjects(...)` schema-sync DDL, for every it() in this suite.
5975
beforeEach(async () => {
6076
driver = new SqlDriver(PG_CELL.config());
6177
await driver.execute(`drop table if exists "${TABLE}" cascade`);
6278
await driver.initObjects([
6379
{ name: TABLE, fields: { label: { type: 'string' }, at: { type: 'datetime' } } },
6480
]);
65-
});
81+
}, 60_000);
6682

6783
afterEach(async () => {
6884
await driver.execute(`drop table if exists "${TABLE}" cascade`).catch(() => {});

packages/drivers/driver-sql/src/sql-driver-json-binding-without-ddl.test.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,27 @@ describe.skipIf(!PG_URL)('#10995 — live Postgres, driver told about the object
9898
let driver: SqlDriver;
9999
const TABLE = 'os10995_pref';
100100

101+
// ── Why this beforeAll carries an explicit 60_000 budget (#14213) ──
102+
// §1–§3 deliberately reuse the connection this hook opens, so the live cost
103+
// of the whole suite is concentrated HERE: a full connect cycle against the
104+
// cell's Postgres server plus the out-of-band `create table` in
105+
// `migrateOutOfBand(...)`. (The §3 it() below is budgeted separately under
106+
// #14100 because it builds a SECOND driver inside its own body.)
107+
// ⚠️ A hook inherits `hookTimeout`, NOT `testTimeout`. Measured in this
108+
// package's config (which sets neither, so both are vitest's own defaults):
109+
// an unbudgeted hook dies at 10000ms ("Hook timed out in 10000ms"), not at
110+
// the 5000ms an unbudgeted it() gets — so the 5000ms figure in §3's note
111+
// below is correct for that it() and would be wrong for this hook.
112+
// ⛔ NOT a claim that this hook is known to time out: it was found by a
113+
// per-site AST walk over the package, never by a measured red.
101114
beforeAll(async () => {
102115
driver = new SqlDriver(PG_CELL.config());
103116
await migrateOutOfBand(driver, TABLE);
104117
// THE LINE UNDER TEST: the object's field types reach the driver with no
105118
// CREATE TABLE, no ALTER TABLE and no round-trip — what a `skipSchemaSync`
106119
// boot now does in place of doing nothing.
107120
driver.registerObjectMetadata([prefObject(TABLE)]);
108-
});
121+
}, 60_000);
109122

110123
afterAll(async () => {
111124
await driver?.disconnect();

packages/drivers/driver-sql/src/sql-driver-time-live-dialects.test.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,19 @@ describe.skipIf(!MY_URL)('MySQL TIME → TIME(3) widening (#3994)', () => {
151151
const LEGACY = 'os3994_legacy';
152152
let driver: SqlDriver;
153153

154+
// ── Why this beforeEach carries an explicit 60_000 budget (#14213) ──
155+
// Both driver arguments here are `MYSQL_CELL.config()` — unconditionally
156+
// LIVE, not the parametrised `cell.config()` the dialect sweep above uses —
157+
// so this hook opens TWO live connections per test: one to build the legacy
158+
// fixture with raw DDL and an insert, then the driver under test. A
159+
// beforeEach pays that PER TEST, not once.
160+
// ⚠️ A hook inherits `hookTimeout`, NOT `testTimeout`. Measured in this
161+
// package's config (which sets neither, so both are vitest's own defaults):
162+
// an unbudgeted hook dies at 10000ms ("Hook timed out in 10000ms"), not at
163+
// the 5000ms an unbudgeted it() gets. Ten seconds is still a ceiling nobody
164+
// chose for live work, and the third argument does lift it (measured).
165+
// ⛔ NOT a claim that this hook is known to time out: it was found by a
166+
// per-site AST walk over the package, never by a measured red.
154167
beforeEach(async () => {
155168
// Build the table the way a pre-#3994 build did: a bare TIME column.
156169
const legacy = new SqlDriver(MYSQL_CELL.config());
@@ -168,7 +181,7 @@ describe.skipIf(!MY_URL)('MySQL TIME → TIME(3) widening (#3994)', () => {
168181
await legacy.disconnect();
169182

170183
driver = new SqlDriver(MYSQL_CELL.config());
171-
});
184+
}, 60_000);
172185

173186
afterEach(async () => {
174187
await driver.execute(`drop table if exists ${LEGACY}`).catch(() => {});

0 commit comments

Comments
 (0)