Skip to content

Test the update path with pgxntool's fresh/update pattern - #10

Open
jnasbyupgrade wants to merge 5 commits into
masterfrom
update-testing
Open

jnasbyupgrade wants to merge 5 commits into
masterfrom
update-testing

Conversation

@jnasbyupgrade

@jnasbyupgrade jnasbyupgrade commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

test/install/load.sql installs the extension once, committed, before the suite runs. TEST_LOAD_SOURCE=update runs the same suite and expected output against an install created at TEST_UPDATE_FROM (0.2.0) and then updated with ALTER EXTENSION trunklet UPDATE. make test-update runs that suite, then bin/compare_fresh_vs_update, which diffs every extension member's definition, comments and ACL against a fresh install. CI runs make verify-results, then make test-update, on every PostgreSQL version in the matrix.

In update mode, test/helpers/update_with_data.sql stores a test language and one template, 'test template' with versions 1 and 2, under the old version before the update. After the update it checks that the template still processes by name and by template_id. It then removes the language with template_language__remove(), which drops the language functions the old version created. The run fails if any language function or row is left behind, and the sequences are reset, so the suite's expected output is the same in both modes. A failure of any check in the helper surfaces at load on PG16+; on PG 9.5-15 it surfaces through the downstream tests such as all and search_path, since pg_regress reports the test/install file itself as ok. test/helpers/language_factory.sql defines the language and template setup functions, and both the suite and the helper load it. The helper also checks that trunklet is at default_version right after ALTER EXTENSION UPDATE, so a wrong version fails the run.

The build test is test/build/build.sql, which pgxntool runs in its isolated test-build pass before the main suite. It has no committed install to drop, so it doesn't fight test/install. test/sql/search_path.sql still drops the committed install inside its rolled-back test. There is no existing mode and no TEST_UPDATE_TO.

Updating from 0.2.0 or 0.2.1 changes the caller's search_path. The 0.2.0--0.2.1 and 0.2.1--0.3.0 scripts save it from inside the script, where Postgres has already overridden it, and SET that value back. The helper schema-qualifies everything after the update instead of relying on search_path. This PR does not change those scripts.

The extension is now installed once, committed, by
`test/install/load.sql`. `TEST_LOAD_SOURCE=update` (`make test-update`)
runs the same suite and expected output against an install updated from
`TEST_UPDATE_FROM` (0.2.0), and `bin/compare_fresh_vs_update` diffs every
extension member against a fresh install; CI runs both.

In update mode, `test/helpers/update_with_data.sql` stores a test
language and templates under the old version, runs the update, checks
that they still process by name and by `template_id`, and removes the
language, leaving nothing behind. The language and template setup moves
from `test/core/functions.sql` to `test/helpers/language_factory.sql` so
the suite and the helper share it.
@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 885f20e2-ffbf-4322-a588-61eb759e335b
Commits

Reviewing files that changed from the base of the PR and between 40e4b89 and da8dce5.

Files ignored due to path filters: 1
  • test/build/expected/build.out is excluded by !**/*.out
Files selected for processing: 10
  • .github/workflows/ci.yml
  • Makefile
  • bin/compare_fresh_vs_update
  • test/build/build.sql
  • test/core/functions.sql
  • test/helpers/language_factory.sql
  • test/helpers/setup.sql
  • test/helpers/update_with_data.sql
  • test/install/load.sql
  • test/sql/search_path.sql

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The PostgreSQL test workflow now runs both fresh-install and update-mode tests. The test loader selects the install mode from PGOPTIONS. Update-mode SQL checks extension version, template processing, and cleanup behavior. A comparison script checks snapshots from fresh and upgraded installations. Shared language and template helpers are now in a separate SQL file.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Other

Possibly related issues

  • Issue 6 — The update-mode test covers preserving existing language and template data through an extension update, but the changes do not add the proposed public API.
Merge Risk: Minimal · up to da8dc

The update-mode suite and comparison are wired into CI, with no established issue requiring a change before merge.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: testing the extension update path with the fresh/update pattern.
Description check Passed The description directly explains the update-mode test flow, comparison checks, CI changes, and related implementation details.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 0 files. (9 skipped: 9 unsupported.)

Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks the fresh install,
Then hops through updates, testing still.
It compares each snapshot pair,
And checks the templates are still there.
The carrots pass; the logs say “OK!”

Comment @coderabbitai help to get the list of available commands.

test/build/build.sql runs in pgxntool's isolated test-build pass, so it no
longer drops the committed install or fights test/install.

Check the post-update version in update_with_data.sql right after ALTER
EXTENSION UPDATE, so a wrong version fails the run on every PG version. Assert
that the test language's functions exist before template_language__remove().
Fix header and comment wording, and gate compare-fresh-vs-update's install
dependency on PGXNTOOL_ENABLE_FS_INSTALL.
Comment thread Makefile Outdated
@jnasbyupgrade
jnasbyupgrade marked this pull request as ready for review October 29, 2026 15:43
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