Repository navigation
test(db): run the Postgres package's suites in parallel on free ports - #713
Merged
Merged
Conversation
The Backend Postgres Tests job failed on main (run 40973235887): the internal/db/postgres package hit go test's default 10-minute timeout. Its ~107 tests each boot an embedded PostgreSQL and run every migration, almost all of them one after another, for ~624s of serial time. Green runs had already crept from 413s to 566s; nothing in the failing commit touched it. Every test now asks testsupport.FreePort for a kernel-assigned port (deduped in-process) instead of a hand-numbered constant that same-file tests shared, and calls t.Parallel(). The "pwfile extraction" reason on the old nolint:paralleltest directives no longer holds: embeddedpg gives each instance its own runtime directory. The five headroom tests that swap the global slog default stay serial. Locally the package now runs in 78s at -parallel 4, with no skips. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (70.58%) is below the target coverage (87.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #713 +/- ##
==========================================
- Coverage 89.76% 89.75% -0.01%
==========================================
Files 1296 1297 +1
Lines 132198 132215 +17
==========================================
+ Hits 118672 118676 +4
- Misses 13517 13530 +13
Partials 9 9
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the red Backend Postgres Tests job on main (run 40973235887).
Cause
internal/db/postgreshitgo test's default 10-minute per-package timeout. Its ~107 tests each boot an embedded PostgreSQL and run every migration, almost all of them serially (~624s total). Green runs had already crept up from 413s to 566s. The failing commit didn't touch this package; it just tipped it over the limit.Fix
testsupport.FreePort(t): a port assigned by the kernel and deduplicated in-process. It comes from the ephemeral range, so it can't clash with the 14xxx/15xxx fixed ports other packages use.t.Parallel().nolint:paralleltestreason ("pwfile extraction race") no longer holds:embeddedpggives each instance its own runtime dir.slogdefault, and the subtests ofTestGetLastSignalForChecks_Postgres, which share one instance in order.Verification
SP_TEST_REQUIRE_POSTGRES=1 go test -parallel 4 ./internal/db/postgres/passes in 78s, 0 skips.golangci-lint runon the touched packages: 0 issues.🤖 Generated with Claude Code