Repository navigation
ADR 0099 H2: convert the live-PG suite to engram-testkit; run the CI PG lane deeply parallel - #696
Merged
Merged
Conversation
…ases New dev-only crate engram-testkit with pg::fresh_db(): clone each test's database from a migrated template (~100-300ms vs replaying the full migration chain). The template name fingerprints the embedded migrator's (version, checksum) pairs so a migration change mints a new template automatically; bootstrap publishes via CREATE-as-wip + ALTER RENAME so a crash mid-migrate never leaves a half-built template looking valid; bootstrap and clones are serialized under a session-scoped advisory lock (concurrent CREATE DATABASE ... TEMPLATE fails on 'source database is being accessed', and nextest is process-per-test so an in-process guard is not enough). Per-test DBs are leaked (CI Postgres is ephemeral); template bootstrap sweeps testkit-named databases older than 3h on long-lived dev instances. Convert the three proof tests: - ha_listener.rs (all four tests) — the binary that forced the CI PG lane to --test-threads=1: both LISTEN/NOTIFY tests cross-talked on the shared database's session_events channel. NOTIFY is per-database, so private clones make the class impossible. - admin_evac_live_pg.rs / enable_reuse_live_pg.rs — replace their bespoke CREATE DATABASE blocks (the pattern this crate generalizes). migration_0037 schema assertions now inspect the rig's own database instead of the shared admin database (which nothing migrates anymore). Verified: 16 tests across the three binaries pass under default nextest parallelism 5x consecutively against local PG; skip path (env unset) intact; just check green (1678 passed). The remaining ~19 live_pg files convert in the follow-up (H2), which then drops --test-threads=1 from ci.yml. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…PG lane deeply parallel Convert the remaining 19 coordinator live-PG test files to engram_testkit::pg::fresh_db() — every test now runs against its own template-cloned database. queue_scanner_live_pg threads the per-test URL through its connect() helper so its AppStates, raw pools, and PgListeners all point at the test's private database (previously three tests re-read the admin env var mid-test). admin_chunk_gc retires its wipe_pin_set_state helper — scrubbing leaked shared-DB state is dead code under per-test clones. Stale shared-database comments updated throughout. CI (ci.yml test-linux): - Postgres moves from a services: container to plain docker run with -c max_connections=300 (service containers can't override CMD — same reason fake-gcs-server already uses docker run). Readiness wait forces TCP (-h 127.0.0.1): initdb's temporary bootstrap server listens on the unix socket only, so a socket pg_isready can report ready prematurely. - The Postgres-gated step drops --test-threads=1 for --test-threads=16: the tests are PG-IO-bound, so oversubscribe the 4 vcpus; 16 threads x worst-case ~17 connections stays under 300. - The dev compose postgres gets the same max_connections=300 so local runs can go equally deep. Verified: the full 22-binary lane (143 tests) passes at --test-threads=16 against local PG 3x consecutively, ~12-22s wall (previously fully serial); just check green (1678 passed); ci.yml + compose validated with yaml.safe_load, actionlint delta clean (only pre-existing custom runner-label warnings). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest Buf updates on your PR. Results from workflow CI / buf (pull_request).
|
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.
Stacked on #695 (H1). Completes the per-test Postgres isolation arc of ADR 0099.
What
Tests — the remaining 19 coordinator live-PG files convert to
engram_testkit::pg::fresh_db()(net −248 lines):queue_scanner_live_pg.rsthreads the per-test URL through itsconnect()helper so its AppStates, raw assertion pools, andPgListeners all point at the test's private database — previously three tests re-read the admin env var mid-test, which would now target an unmigrated database.admin_chunk_gc_live_pg.rsretires itswipe_pin_set_statescrub helper: cleaning leaked shared-DB state is dead code under per-test clones.ENGRAM_TEST_DATABASE_URLunset) unchanged.CI (
test-linux) — this is the "parallelize deeply" half:services:to plaindocker runwith-c max_connections=300— service containers can't override the image CMD (same reason fake-gcs-server already usesdocker run), and connection headroom is what actually gates deep parallelism: each test'sPostgresStoreholds up to an 8-connection pool.pg_isready -h 127.0.0.1): initdb's temporary bootstrap server listens on the unix socket only, so a socket probe can report ready prematurely.--test-threads=1→--test-threads=16(PG-IO-bound tests; oversubscribing the 4 vcpus; 16 × worst-case ~17 connections < 300).deploy/docker-compose.dev.ymlpostgres gets the samemax_connections=300so local runs go equally deep.Verification
--test-threads=16against local PG: green 3× consecutively, ~12–22 s wall — previously fully serial. (One intermittent nextestleakyinfo-flag: a spawned listener task outliving its test process; pre-existing behavior, passes.)just checkgreen (1678 passed).ci.yml+ compose validated withyaml.safe_load; actionlint delta clean (only pre-existing custom runner-label warnings).Follow-on ceilings (not this PR)
Template cloning is serialized under an advisory lock (~100–300 ms/test ⇒ a few seconds of serial floor at current suite size); after that, the runner size itself is the next lever.
🤖 Generated with Claude Code