Skip to content

Add extension upgrade template regression test#2364

Open
jrgemignani wants to merge 1 commit intoapache:masterfrom
jrgemignani:upgrade-regression-test
Open

Add extension upgrade template regression test#2364
jrgemignani wants to merge 1 commit intoapache:masterfrom
jrgemignani:upgrade-regression-test

Conversation

@jrgemignani
Copy link
Copy Markdown
Contributor

@jrgemignani jrgemignani commented Apr 2, 2026

Note: This PR was created with AI tools and a human.

Add a version-agnostic regression test (age_upgrade) that validates the upgrade template (age----y.y.y.sql) works correctly by simulating a full extension version upgrade within "make installcheck".

Add full upgrade scripts to the install path (DATA) in the Makefile, excluding template upgrade files. This enables the install to copy all version upgrade files into the PG AGE install. This is needed for ALTER EXTENSION

Adjusted installcheck.yaml to allow git commit history for this test.

Makefile infrastructure:

  • Build the install SQL (age--.sql) from the initial version-bump commit in git history, so CREATE EXTENSION installs "day-one" SQL while the .so comes from current HEAD — implicitly testing backward compat.
  • Build a synthetic "next" version (age--.sql) from HEAD and stamp the upgrade template to produce age----.sql.
  • Add an installcheck prerequisite that temporarily installs both synthetic files into the PG extension directory; a generated cleanup script removes them at the end of the test via ! shell escape. EXTRA_CLEAN catches stragglers on "make clean".
  • Skip the test automatically when: (a) no git history (tarball builds), (b) no upgrade template exists, or (c) a real upgrade script from the current version is already committed (detected via git ls-files).o

Regression test (regress/sql/age_upgrade.sql):

  • Creates 3 graphs (company, network, routes) with 8 vertex labels, 8 edge labels, 23 vertices, 28 edges, and 4 GIN indexes.
  • Records integrity checksums (agtype sums), vertex/edge counts, and label counts before the upgrade; repeats all checks after ALTER EXTENSION UPDATE to the synthetic next version.
  • Verifies structural queries: VLE management chains, circular follow chains, flight distances with edge properties.
  • Verifies all 4 GIN indexes survive the upgrade via pg_indexes.
  • Uses ORDER BY on all multi-row queries for deterministic output.
  • Returns agtype natively (no ::numeric casts) for portability.
  • Avoids version-dependent output (checks boolean IS NOT NULL instead of printing the version string).
  • Uses JOIN-based label counts to avoid NULL comparison bugs with the internal _ag_catalog graph.
  • Cleans up all 3 graphs and restores the default AGE version.

modified: Makefile
new file: regress/expected/age_upgrade.out
new file: regress/sql/age_upgrade.sql
modified: .github/workflows/installcheck.yaml

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new regression test that simulates an in-place Apache AGE extension upgrade (via the upgrade template) during make installcheck, and updates build/install infrastructure to make upgrade scripts available to ALTER EXTENSION ... UPDATE.

Changes:

  • Add age_upgrade regression test (regress/sql/age_upgrade.sql) with expected output (regress/expected/age_upgrade.out) to validate upgrade-template correctness and post-upgrade data/index integrity.
  • Update the Makefile to install real upgrade scripts into $(SHAREDIR)/extension/, generate synthetic “next” version SQL + stamped upgrade SQL for testing, and conditionally include the new regression test.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
Makefile Adds conditional upgrade-test infrastructure, installs upgrade scripts, and stages synthetic upgrade artifacts for installcheck.
regress/sql/age_upgrade.sql New upgrade regression test that creates graphs/indexes, upgrades the extension, and validates data/index survival.
regress/expected/age_upgrade.out Expected output for the new age_upgrade test.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jrgemignani jrgemignani force-pushed the upgrade-regression-test branch from 8d51ffa to 9d7d7ea Compare April 2, 2026 08:38
Note: This PR was created with AI tools and a human.

Add a version-agnostic regression test (age_upgrade) that validates the
upgrade template (age--<VER>--y.y.y.sql) works correctly by simulating a
full extension version upgrade within "make installcheck".

Add full upgrade scripts to the install path (DATA) in the Makefile,
excluding template upgrade files. This enables the install to copy all
version upgrade files into the PG AGE install. This is needed for
ALTER EXTENSION

Adjusted installcheck.yaml to allow git commit history for this test.

Makefile infrastructure:
- Build the install SQL (age--<CURR>.sql) from the initial version-bump
  commit in git history, so CREATE EXTENSION installs "day-one" SQL while
  the .so comes from current HEAD — implicitly testing backward compat.
- Build a synthetic "next" version (age--<NEXT>.sql) from HEAD and stamp
  the upgrade template to produce age--<CURR>--<NEXT>.sql.
- Add an installcheck prerequisite that temporarily installs both synthetic
  files into the PG extension directory; a generated cleanup script removes
  them at the end of the test via \! shell escape. EXTRA_CLEAN catches
  stragglers on "make clean".
- Skip the test automatically when: (a) no git history (tarball builds),
  (b) no upgrade template exists, or (c) a real upgrade script from the
  current version is already committed (detected via git ls-files).o

Regression test (regress/sql/age_upgrade.sql):
- Creates 3 graphs (company, network, routes) with 8 vertex labels,
  8 edge labels, 23 vertices, 28 edges, and 4 GIN indexes.
- Records integrity checksums (agtype sums), vertex/edge counts, and
  label counts before the upgrade; repeats all checks after ALTER
  EXTENSION UPDATE to the synthetic next version.
- Verifies structural queries: VLE management chains, circular follow
  chains, flight distances with edge properties.
- Verifies all 4 GIN indexes survive the upgrade via pg_indexes.
- Uses ORDER BY on all multi-row queries for deterministic output.
- Returns agtype natively (no ::numeric casts) for portability.
- Avoids version-dependent output (checks boolean IS NOT NULL instead
  of printing the version string).
- Uses JOIN-based label counts to avoid NULL comparison bugs with the
  internal _ag_catalog graph.
- Cleans up all 3 graphs and restores the default AGE version.

modified:   Makefile
new file:   regress/expected/age_upgrade.out
new file:   regress/sql/age_upgrade.sql
modified:   .github/workflows/installcheck.yaml
@jrgemignani jrgemignani force-pushed the upgrade-regression-test branch from 9d7d7ea to 2b5c485 Compare April 2, 2026 17:25
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.

2 participants