Skip to content

Add extension testing conventions: schema/search_path isolation - #5

Merged
jnasbyupgrade merged 9 commits into
Postgres-Extensions:mainfrom
jnasbyupgrade:schema-flexibility-testing
Aug 9, 2026
Merged

Add extension testing conventions: schema/search_path isolation#5
jnasbyupgrade merged 9 commits into
Postgres-Extensions:mainfrom
jnasbyupgrade:schema-flexibility-testing

Conversation

@jnasbyupgrade

@jnasbyupgrade jnasbyupgrade commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

test/CLAUDE.md (new, linked from CLAUDE.md's Related docs): the universal principle — an extension's own schema(s) must be absent from search_path for the entire test run, for every extension, including fixed-schema ones. A pinned schema only means the install location can't change; it says nothing about whether the extension's own code correctly qualifies its own references, so the same unqualified-reference bug can hide in a fixed-schema extension just as easily. Cross-references pgxntool's own test/install feature and CLAUDE.md, and asks for a re-check at the end of the suite (framed as a practical compromise for file-based suites, plus a suggestion to add an automated check that search_path is mentioned in exactly the two legitimate places).

test/RANDOM_SCHEMA_TESTING.md (new, deliberately not linked from anywhere): randomly-named-schema installs to catch hardcoded schema references in non-fixed-schema extensions, plus the cheaper two-random-schema move verification for relocatable extensions. Repos that don't use a fixed schema should reference this explicitly from their own test/CLAUDE.md — companion PRs do that where it applies.

Neither doc names a specific sibling repo as an example or citation — that kind of reference is a maintenance burden that goes stale the moment the cited repo's code changes.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a1b8a1bf-dda9-461b-ad84-57b0b5dfb332

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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

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

@jnasbyupgrade jnasbyupgrade changed the title Add schema-flexibility testing methodology, generalized from extension_tools/cat_tools Add extension testing conventions: schema/search_path isolation Aug 9, 2026
…n_tools/cat_tools

Found extension_tools's CLAUDE.md pointing at container-local docs
(~/advanced-extension-testing.md, ~/test-fixes.md) that nothing outside
that one session could resolve. The substance -- check schema= not
relocatable= before building a custom-schema test dimension, and how to
actually prove search_path-independence when one applies -- is general
methodology, not extension_tools-specific: test-fixes.md's own account of
it describes a costly mistake made in cat_tools from getting this wrong.

Companion PR trims extension_tools's CLAUDE.md to its own specific facts
and points here for the methodology.
…opt-in doc for random-schema testing

Moves the schema-flexibility content out of CLAUDE.md entirely and
reframes the core lesson: the critical, universal thing to get right is
that an extension's own schema(s) must be absent from search_path during
testing -- for EVERY extension, including fixed-schema ones, not just
flexible ones. A pinned schema only means the install location can't
change; it says nothing about whether the extension's own code correctly
qualifies its own references. Adds the end-of-suite re-check as an
explicit, separate ask, since a start-of-suite-only check misses
mid-suite search_path leaks.

test/CLAUDE.md carries only that universal principle, linked from
CLAUDE.md's Related docs.

RANDOM_SCHEMA_TESTING.md is new and deliberately unlinked from either:
randomly-named-schema installs to catch hardcoded schema references (for
non-fixed-schema extensions), and the cheaper two-random-schema move
verification for relocatable extensions (none exist in this org yet, but
worth documenting). Repos that don't use a fixed schema should reference
it explicitly from their own test/CLAUDE.md.
…ble=true

Checked rather than assumed -- found it while surveying repos for the
random-schema-testing PRs. Note it doesn't obviously need the pattern
applied, since it doesn't create any schema-dependent objects of its own.
…ce burden

Docs in this repo describe general policy for the whole org -- naming a
specific sibling repo as "the example" or "the current instance of X"
just creates a dangling reference the moment that repo's code changes,
gets renamed, or the property being cited no longer holds. Rephrased the
relocatable-extension caveat generically instead of naming
trunklet-format specifically, and dropped a specific pgxntool issue-link
URL in favor of stating the gap without a link that can go stale if the
issue closes without a doc update.
… run, not "at least part" of it

"At least part of the test run" allows windows where the schema is back
on search_path, during which an unqualified reference can resolve by
accident and go undetected -- exactly what this doc exists to prevent.
Also reframes the start/end double-check section so it reads as
verifying the entire-run requirement, not as a softer alternative to it.
If you explicitly SET search_path yourself before assertions, checking it
right after tells you nothing you didn't already know. The end-of-run
check is what actually matters -- it's the one that can catch a test
putting the schema back on search_path partway through.
…mplement

Continuous checking throughout the run would be ideal but isn't
practical for file-based test suites. A static grep for search_path
across the suite's own files -- expecting exactly two matches, the
setup and the end-check -- catches a leak at review time instead of only
at the mercy of whether the end-check's specific assertion happens to
notice it.
…gxntool cross-ref, move RANDOM_SCHEMA_TESTING.md under test/

- Drop "The one thing to get right" heading -- this doc is about one
  aspect of testing (schema/search_path isolation), not testing overall.
- The search_path-mention-count check should be an automated,
  checked-in test, not a suggestion to have an agent manually re-grep.
- pgxntool's own test/install feature (files that run once, committed,
  before the suite) is the natural place to put the explicit
  `SET search_path` step -- cross-referenced from "How to exclude."
- Moved RANDOM_SCHEMA_TESTING.md under test/ alongside CLAUDE.md, since
  it's testing-specific rather than a general top-level doc. Still not
  linked from CLAUDE.md or test/CLAUDE.md on purpose.
@jnasbyupgrade
jnasbyupgrade force-pushed the schema-flexibility-testing branch from 1dd0715 to 652bb24 Compare August 9, 2026 22:28
@jnasbyupgrade
jnasbyupgrade merged commit 772a4bd into Postgres-Extensions:main Aug 9, 2026
1 check passed
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