TEST_SCHEMA switching in test/install - #28
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
Code reviewFound 2 high-signal issues: 1. CLAUDE.md violation —
|
90fad56 to
c07d4ca
Compare
fecdde5 to
c48f176
Compare
bb72303 to
6e33854
Compare
cdace49 to
32e3429
Compare
32e3429 to
4a2f3c4
Compare
test/install/load.sql now reads the count_nulls.test_schema GUC (set via
the Makefile's TEST_SCHEMA var, propagated via PGOPTIONS) to decide whether
to CREATE SCHEMA/SET search_path before installing - empty means no
targeting at all, non-empty explicitly targets that schema, matching
TEST_SCHEMA=Quoted locally.
test/sql/extension_tests.sql's test__check_ncs and test__shutdown__drop_all
gain a schema_hint parameter (defaulted from the same GUC) so they can
assert against a known target when TEST_SCHEMA is non-empty, and skip the
schema-drop when it's empty (nothing to drop). This relies on
test/core/functions.sql already producing schema-invariant assertion
descriptions (see the prior PR) so a single test/expected/extension_tests.out
still matches both legs.
One unavoidable, genuine exception: test__shutdown__drop_all drops the
schema TEST_SCHEMA created - real, different, correct behavior between
"there's a schema to clean up" and "there isn't". Handled via pg_regress's
native numbered-alternate mechanism - test/expected/extension_tests_1.out,
captured from a real TEST_SCHEMA=Quoted run - documented in
test/README.md's scenario writeup.
Crossed the `test` CI job with TEST_SCHEMA={"", Quoted}.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Per a review pass against Postgres-Extensions/cat_tools' own experience (test-fixes.md item 6, found while syncing that repo to pgxntool 2.3.0): a schema name is just an input value the SAME assertions run against in the SAME environment, not a real isolation/environment boundary (unlike PostgreSQL major - different binaries, different container - or pg_tle deployment, which must never share a runner with a filesystem install). Crossing it into the CI matrix only multiplies job count for zero added confidence per dollar. Added test-schema-all: loops TEST_SCHEMA through every value via sequential recursive $(MAKE) calls (same pattern test-update already uses for the load-mode axis), exit 1 on the first failure so a later iteration can't mask an earlier one, each iteration echoed so a failure's TEST_SCHEMA value is still directly attributable without a separate CI check name per value. The `test` CI job now calls this once per PostgreSQL major instead of crossing pg x schema - job count for this job drops back to one per PG major. Verified locally against PG17: both TEST_SCHEMA values pass via `make test-schema-all`. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…nches Per review: we either expect the schema count_nulls is installed into to be in search_path, or we don't - and in this file we never do, in either leg. functions.sql unconditionally sets search_path to exclude count_nulls' own schema (see the header comment above), whether that's the empty leg's 'public' or the TEST_SCHEMA leg's known target - so the membership check's expected value is unconditionally false, not conditional on schema_hint at all. Drops the previous skip()-based two-branch design (which only ran a real assertion in the TEST_SCHEMA leg and skipped it entirely in the empty leg) and the is(ncs(), s) check (a separate "did TEST_SCHEMA target correctly" concern, not a "is it in search_path" concern). s is still real, independently-determined content (via ncs() when there's no fixed target, via schema_hint when there is), so this isn't a tautology - it fails for real if functions.sql's search_path exclusion or load.sql's schema targeting ever breaks. Regenerated test/expected/extension_tests.out and _1.out via make results for both TEST_SCHEMA legs (empty, Quoted) - verified via make test-schema-all. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Document why these two search_path checks aren't redundant: this one doesn't guard against some other test mutating search_path mid-suite. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…raph The prior cross-reference was folded into the end of an existing sentence, easy to miss when skimming the block; call it out as its own labeled paragraph instead. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
deps.sql now carries a fuller explanation of why it's empty and kept; avoid duplicating that here. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
4a2f3c4 to
0b3a607
Compare
The schema drop was a lives_ok()/skip() branch purely to make the TAP output type-check across both TEST_SCHEMA legs, forcing a second pg_regress expected-output file (extension_tests_1.out) whose only difference was that one row. Dropping the schema is teardown, not a behavior under test, so make it plain EXECUTE'd SQL with no pgTAP-visible output - both legs now produce byte-identical TAP output, so the numbered alternate is gone and test/README.md's description of it is updated to match.
…sion) Comments described the schema matrix mechanically (install into schema A vs schema B) without stating the actual load-bearing requirement: at least one leg must have its schema verifiably off search_path, or an extension full of unqualified references would pass every leg anyway. Clarify in the Makefile's TEST_SCHEMA/TEST_SCHEMA_VALUES comments, test/README.md's TEST_SCHEMA section, and extension_tests.sql's header that excluding search_path in every leg (this suite's actual behavior) is a stronger-than-necessary, deliberate choice, not evidence that every leg must exclude it.
…path CREATE EXTENSION ... WITH SCHEMA targets a schema directly with no session-level side effect, so this file's own bare connection never needs to mutate its own search_path to land count_nulls in TEST_SCHEMA. Compute the WITH SCHEMA clause once (right after count_nulls_has_schema) so both CREATE EXTENSION call sites can reuse it without duplicating the has-schema branch.
…pe style test/install/load.sql's TEST_SCHEMA comment claimed the file skips mutating search_path because a one-shot bare connection wouldn't need it set later - that's not why. The real reason: mutating search_path before CREATE EXTENSION would let the install succeed via a coincidentally arranged search_path, masking the extension's own install script secretly depending on unqualified name resolution. WITH SCHEMA avoids that by targeting the schema directly without touching search_path at all - the same qualification-correctness principle the whole TEST_SCHEMA axis is built on, applied to the install step itself. Also lowercase NULLIF/COALESCE calls in test/sql/extension_tests.sql to match the rest of the suite's function-call casing convention, and switch the 'count_nulls'' schema...' description to dollar-quoting to avoid the doubled single-quote escape.
test/install/load.sql now reads the count_nulls.test_schema GUC (set via the Makefile's TEST_SCHEMA var, propagated via PGOPTIONS) to decide whether to CREATE SCHEMA/SET search_path before installing - empty means no targeting at all, non-empty explicitly targets that schema, matching TEST_SCHEMA=Quoted locally.
test/sql/extension_tests.sql's test__check_ncs and test__shutdown__drop_all gain a schema_hint parameter (defaulted from the same GUC) so they can assert against a known target when TEST_SCHEMA is non-empty, and skip the schema-drop when it's empty (nothing to drop). This relies on test/core/functions.sql already producing schema-invariant assertion descriptions (see #46) so a single test/expected/extension_tests.out still matches both legs.
test__check_ncs runs a single unconditional assertion rather than two skip()'d branches: we either expect count_nulls' own schema to be in search_path, or we don't - and in this file we never do, in either leg, since functions.sql unconditionally excludes it from search_path regardless of TEST_SCHEMA. The expected value is unconditionally false; the schema being checked (s) is still real, independently-determined content, so this isn't a tautology.
One unavoidable, genuine exception: test__shutdown__drop_all drops the schema TEST_SCHEMA created - real, different, correct behavior between "there's a schema to clean up" and "there isn't". Handled via pg_regress's native numbered-alternate mechanism - test/expected/extension_tests_1.out, captured from a real TEST_SCHEMA=Quoted run - documented in test/README.md's scenario writeup.
Crossed the
testCI job with TEST_SCHEMA={"", Quoted}, then collapsed that back out of the CI matrix into a make-level loop (test-schema-all) since a schema name is just an input value the same assertions run against in the same environment, not a real isolation boundary.Verified via make test-schema-all for both TEST_SCHEMA legs against PG17.