Skip to content

Add live PostgreSQL integration suite and PG18 fixes#4

Merged
ahstn merged 2 commits into
mainfrom
feat/ci-postgres-tests
Mar 7, 2026
Merged

Add live PostgreSQL integration suite and PG18 fixes#4
ahstn merged 2 commits into
mainfrom
feat/ci-postgres-tests

Conversation

@ahstn

@ahstn ahstn commented Mar 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • add a Docker-backed live PostgreSQL integration test suite for analyze and workload
  • cover PostgreSQL 14 and 18 in local workflows and CI
  • fix the PostgreSQL/runtime issues that the live runs exposed so the suite passes end-to-end

Why

The existing tests were pure Rust and did not verify the CLI against a real PostgreSQL instance. That left several important paths unvalidated:

  • loading the real SQL fixtures used by this repo
  • pg_stat_statements availability, visibility, and eviction behavior
  • JSON output stability from the actual binary
  • PostgreSQL version-specific catalog/statistics differences

Running the new live suite surfaced real compatibility problems on PostgreSQL 18, so this PR includes the fixes required to make the suite and the product behavior correct against current PostgreSQL releases.

How

Live test harness

  • add testcontainers, assert_cmd, insta, and related dev dependencies
  • add tests/support/mod.rs to start PostgreSQL containers, seed databases, clone fresh test databases, run workload setup, and invoke the postgreat binary
  • seed the base template database through the Postgres container init path so the existing pg_dump-style fixture with COPY ... FROM stdin loads correctly
  • add stable JSON snapshot summaries for live assertions under tests/snapshots/

New integration scenarios

  • it_analyze: seeded analyze --format json run with table/index-health findings
  • it_workload: happy-path workload analysis with pg_stat_statements
  • it_workload_unavailable: extension missing and installed-but-not-preloaded behavior
  • it_workload_visibility: limited query-text visibility without pg_read_all_stats
  • it_workload_dealloc: pg_stat_statements eviction/deallocation warnings under a constrained statement budget

Fixture and product fixes from live verification

  • remove the FK-unsafe delete from tests/_data/2-bloat-and-indexes.sql
  • send tracing logs to stderr so JSON stdout remains parseable
  • support PostgreSQL 17+/18 checkpoint stats via pg_stat_checkpointer with fallback to pg_stat_bgwriter
  • use indpred IS NOT NULL instead of indispartial when checking for partial indexes
  • cast seconds_since_reset to double precision in workload metadata collection
  • widen pg_stat_statements preload-error detection to handle the quoted PostgreSQL 18 error text
  • use an accepted low pg_stat_statements.max value in the deallocation test profile

CI and docs

  • add a GitHub Actions workflow for unit/lint checks plus the PostgreSQL 14/18 live matrix
  • document the live suite, scenarios, and run commands in README.md
  • record the new testing layer in PROGRESS.md

Verification

  • cargo test
  • cargo clippy --all-targets --all-features -- -D warnings
  • POSTGREAT_TEST_PG_VERSION=18 cargo test --test it_analyze -- --ignored --test-threads=1
  • POSTGREAT_TEST_PG_VERSION=18 cargo test --test it_workload -- --ignored --test-threads=1
  • POSTGREAT_TEST_PG_VERSION=18 cargo test --test it_workload_unavailable -- --ignored --test-threads=1
  • POSTGREAT_TEST_PG_VERSION=18 cargo test --test it_workload_visibility -- --ignored --test-threads=1
  • POSTGREAT_TEST_PG_VERSION=18 cargo test --test it_workload_dealloc -- --ignored --test-threads=1
  • the same five ignored live tests with POSTGREAT_TEST_PG_VERSION=14

ahstn and others added 2 commits March 5, 2026 19:50
Add workload metadata, coverage accounting, richer candidate evidence, and reporter regression tests so the workload command explains its scope and confidence more clearly.

Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
@ahstn ahstn merged commit 64338ef into main Mar 7, 2026
2 of 3 checks passed
@ahstn ahstn deleted the feat/ci-postgres-tests branch March 7, 2026 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant