Repository navigation
Add real-Postgres driver smoke tests + CI job (TODO A5) - #69
Merged
Merged
Conversation
PGlite covers all SQL for the core/journal/digest Postgres adapters, but none of the three -pg packages had any test exercising the actual node-postgres driver: real connection pooling, node-pg-migrate migrations against a live server, transaction commit/rollback, and LISTEN/NOTIFY. Add one *.smoke.test.ts per package, wired the same way as the -pglite packages (jest.config.js + test script). Each suite creates its own throwaway database in beforeAll and drops it in afterAll so the three suites' node-pg-migrate migration-tracking tables never collide, and skips entirely (describe.skip) when PG_TEST_URL/DATABASE_URL isn't set so local `pnpm test` and the existing CI `check` job stay dependency-free. Add a `pg-smoke` job to check-pr.yml that runs only these three suites against a postgres:16-alpine service container. Fixes found by actually running against real Postgres: - pg's Pool/Client give `connectionString` priority over a co-supplied `database` field, so the per-suite database override was silently ignored; the test helper now parses the connection string into discrete fields instead. - turbo's default strict env mode stripped PG_TEST_URL/DATABASE_URL from the test task; declared them in turbo.json. - PostgresDigestPersistenceAdapter.connect() never released the pool client it opened to warm the connection, which made pool.end() (and therefore disconnect()) hang forever for any real caller.
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.
What
Completes Track A. The
-pgpackages had zero tests; after #64/#66/#67 all shared SQL is covered by the PGlite suites, leaving only the driver layer uncovered. This adds small real-Postgres smoke suites forcore-pg,journal-pg, anddigest-pg, plus apg-smokeCI job.Details
PG_TEST_URL ?? DATABASE_URLanddescribe.skipthemselves when unset — localpnpm testand the existingcheckjob stay dependency-free (verified: 8 skipped, tasks green).xjog_<pkg>_smoke_<uuid>, runs the adapter'sconnect()(migrations) against it, and drops it inafterAll— nonode-pg-migratetracking-table collisions between suites on a shared server. Connection strings are parsed into discretePoolConfigfields becausepgsilently ignores adatabaseoverride whenconnectionStringis present.withTransactioncommit and rollback,destroyChart; journal-pg + digest-pg — connect + migrations and a realpg-listen→pg_notifyLISTEN/NOTIFY round trip each.pg-smokejob incheck-pr.ymlwith apostgres:16-alpineservice container (health-checked), building first (adapters loadlib/migrations/*.sql), then running only the three-pgsuites serialized. The existingcheckjob is unchanged.turbo.jsondeclaresPG_TEST_URL/DATABASE_URLin the test task'senvso turbo doesn't serve stale cached results across env changes.🐛 Real bug found and fixed by these tests
digest-pg'sconnect()didawait pool.connect()and discarded the client without releasing it — permanently occupying a pool slot, sodisconnect()→pool.end()hangs forever. Fixed with(await pool.connect()).release(). The hang was reproduced before the fix and confirmed resolved after (the digest suite's teardown is the regression test — it hangs without the fix). Changeset:patchfor@telia-oss/xjog-digest-pg.Verification
All 8 tests run green against real Postgres 16 on two independent local setups (a Homebrew postgres@16 server and a
postgres:16-alpineDocker container), including both LISTEN/NOTIFY round trips. Skip path verified with env unset. Full-repo build (15/15) + test (16/16) +lintclean.Implements TODO item A5 — Track A complete.