fix(test): keep int gate under Postgres connection ceiling

Cap vitest workers and raise Docker max_connections so high-core laptops
stop failing the suite with cascading "too many clients" / QueryError noise.
This commit is contained in:
Francisco Solla 2026-08-05 20:29:14 -03:00
parent 3c6b3c4b4c
commit 1a3084a6ee
2 changed files with 12 additions and 3 deletions

View file

@ -13,6 +13,10 @@ services:
POSTGRES_DB: teqo
ports:
- '5432:5432'
# Default max_connections=100 is tight for vitest forks (≈CPUs × pg pool)
# plus a leftover `next start` from local repro. Raise the ceiling so the
# int gate fails on real assertions, not "too many clients already".
command: ['postgres', '-c', 'max_connections=200']
volumes:
- pgdata:/var/lib/postgresql/data
# Runs only on first initialization of the volume. Creates the dedicated

View file

@ -15,9 +15,14 @@ export default defineConfig({
environment: 'jsdom',
setupFiles: ['./vitest.setup.ts'],
include: ['tests/int/**/*.int.spec.ts'],
// Int specs hit a real Postgres under a ~48-way parallel suite, so wall
// time is dominated by pool contention, not by the code under test. The
// 5s default made legitimately heavy RSC-composition tests flake as the
// Cap forks so each worker's Payload pg pool stays under Docker Postgres
// max_connections=100 on high-core laptops (default worker count ≈ CPUs;
// 16× pool-max-10 ≈ 160 clients → "too many clients already", which then
// cascades into unrelated QueryError noise). CI runners have fewer CPUs.
maxWorkers: 8,
// Int specs hit a real Postgres under a parallel suite, so wall time is
// dominated by pool contention, not by the code under test. The 5s
// default made legitimately heavy RSC-composition tests flake as the
// suite grew (municipalityPageData was the first); one global budget
// beats per-test overrides. Genuinely hung tests still fail — just 10s
// later. The unit suite keeps the 5s default.