From 57294ecb248f098defce08e5f667f40e6d163791 Mon Sep 17 00:00:00 2001 From: Sean Evans Date: Wed, 20 May 2026 11:20:19 -0400 Subject: [PATCH] Split test suites into core, integration, and performance groups --- .github/workflows/ci.yml | 20 +++++++++++++++++-- README.md | 19 +++++++++++++++++- makefile | 42 ++++++++++++++++++++++++++++++++-------- 3 files changed, 70 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c56ea6f..34b62bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,9 +5,12 @@ on: branches: [ main ] pull_request: branches: [ main ] + workflow_dispatch: + schedule: + - cron: "0 6 * * 0" jobs: - test: + test-core: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -15,6 +18,19 @@ jobs: run: | make sudo make install - - name: Run tests + - name: Run core tests run: | docker compose up --abort-on-container-exit --exit-code-from test test + + test-slow-suites: + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Build and install extension + run: | + make + sudo make install + - name: Run integration and performance suites + run: | + docker compose run --rm -e RUN_INTEGRATION=1 -e RUN_PERF=1 test make test-all diff --git a/README.md b/README.md index e9057b7..de0c19d 100644 --- a/README.md +++ b/README.md @@ -111,8 +111,25 @@ CREATE EXTENSION pg_git; ## Testing +Test suites are split by speed and external dependencies: + +- `test-core` (default): deterministic SQL tests for local logic. **Expected runtime:** ~10-30 seconds in Docker on a modern laptop. **Prerequisites:** running PostgreSQL test database. +- `test-integration` (opt-in): HTTPS transport checks in `test/sql/https_fetch_test.sql`. **Expected runtime:** ~30-90 seconds depending on network/container startup. **Prerequisites:** set `RUN_INTEGRATION=1`; `plpython3u` available; outbound HTTPS/network available. +- `test-performance` (opt-in): GC performance regression checks in `test/sql/gc_performance_test.sql`. **Expected runtime:** ~1-5+ minutes depending on machine load. **Prerequisites:** set `RUN_PERF=1`; stable CPU/IO for consistent measurements. +- `test-all`: runs `test-core` and then conditionally runs integration/performance suites when their flags are enabled. + ```bash -make test +# Fast default suite (also what `make test` runs) +make test-core + +# Explicitly include HTTPS/integration tests +RUN_INTEGRATION=1 make test-integration + +# Explicitly include performance tests +RUN_PERF=1 make test-performance + +# Run everything (slow suites run only when flags are set) +RUN_INTEGRATION=1 RUN_PERF=1 make test-all ``` ## Development diff --git a/makefile b/makefile index f26ac2b..70d8dde 100644 --- a/makefile +++ b/makefile @@ -14,8 +14,8 @@ DATA = \ $(wildcard sql/schema/*.sql) \ $(wildcard sql/functions/*.sql) -# Register new SQL tests here in execution order (add matching test/sql/*.sql files to this list). -TESTS := \ +# Deterministic, fast SQL tests that run on every change. +CORE_TESTS := \ test/sql/init.sql \ test/sql/add_test.sql \ test/sql/branch_test.sql \ @@ -25,11 +25,17 @@ TESTS := \ test/sql/remote_test.sql \ test/sql/advanced_test.sql \ test/sql/gc_test.sql \ - test/sql/https_fetch_test.sql \ - test/sql/optimize_indexes_test.sql \ - test/sql/gc_performance_test.sql + test/sql/optimize_indexes_test.sql + +# Slower/less deterministic suites are opt-in. +INTEGRATION_TESTS := \ + test/sql/https_fetch_test.sql +PERFORMANCE_TESTS := \ + test/sql/gc_performance_test.sql +# Backward-compatible aggregate for PGXS regress helpers. +TESTS := $(CORE_TESTS) $(INTEGRATION_TESTS) $(PERFORMANCE_TESTS) # Derive the target names from the TESTS list to keep them in sync. REGRESS := $(notdir $(basename $(TESTS))) @@ -37,6 +43,26 @@ REGRESS_OPTS = --inputdir=test include $(PGXS) -.PHONY: test -test: - pg_prove -d postgres $(TESTS) +.PHONY: test test-core test-integration test-performance test-all + +# Keep `make test` as fast default. +test: test-core + +test-core: + pg_prove -d postgres $(CORE_TESTS) + +test-integration: + @if [ "$(RUN_INTEGRATION)" != "1" ]; then \ + echo "Skipping integration tests. Set RUN_INTEGRATION=1 to run them."; \ + exit 0; \ + fi + pg_prove -d postgres $(INTEGRATION_TESTS) + +test-performance: + @if [ "$(RUN_PERF)" != "1" ]; then \ + echo "Skipping performance tests. Set RUN_PERF=1 to run them."; \ + exit 0; \ + fi + pg_prove -d postgres $(PERFORMANCE_TESTS) + +test-all: test-core test-integration test-performance