You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pg-tle-test: extend to the 0.9.6 -> current update path via DESTDIR sandboxing
pgxntool 2.3.0's installcheck-ordering fix (pgxntool#83) made `installcheck`
(and so `make test`) unconditionally depend on `install`, which writes a real
.control file to disk - defeating the whole point of a pg_tle-only-deployment
proof, and with no upstream fix yet (pgxntool#90). bin/test_existing's
run_suite gains a TEST_EXISTING_DEPLOY=pgtle mode that instead redirects
`make test`'s install step through a scratch DESTDIR (harmless here since a
pg_tle-deployed database never needs those files), pre-seeding a stub
pgtap.control at the DESTDIR-prefixed path pgxntool's `pgtap` prerequisite
checks for - otherwise its DESTDIR-blind recipe (`pgxn install pgtap --sudo`)
would trigger a real, unwanted reinstall against the scratch dir.
Also fixes test/install/load.sql's existing-mode assertion, which cross-checks
the installed version against pg_available_extensions.default_version -
that view never sees pg_tle registrations (it only reads .control files off
disk), so it would return NULL under a pg_tle deployment even though CREATE
EXTENSION resolves correctly through pg_tle's own catalog. A new
count_nulls.test_existing_deploy GUC (driven by the same TEST_EXISTING_DEPLOY
var, Makefile-exported like TEST_SCHEMA/TEST_LOAD_SOURCE) selects
pgtle.available_extensions() instead when deploy=pgtle.
The pg-tle-test CI job now installs count_nulls at 0.9.6 into a second
scratch database (inheriting the job's template1 pg_tle registration),
plants + proves the dependency guard, ALTER EXTENSION UPDATEs to current,
then runs the real pgTAP suite against it via the new mode - with
bin/assert_fs_clean verify checked after every one of those steps, not just
at the end, since that's what actually proves the DESTDIR sandboxing worked.
Verified locally (no real pg_tle in this container): confirmed via
mtime comparison that the real count_nulls.control and pgtap.control are
untouched by a full prepare-old/update/run-suite(pgtle) cycle, that the
scratch DESTDIR is cleaned up on both success and a forced regression
failure (EXIT trap surviving `set -e`), and exercised the
count_nulls.test_existing_deploy branch in load.sql against a stubbed
pgtle.available_extensions() function. The genuine pg_tle-registered
version needs a real CI run to confirm end to end.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
# then runs the suite via --use-existing so pg_regress does NOT drop/recreate
180
243
# the database.
181
244
run_suite() {
182
-
local db=$1 schema=$2
245
+
local db=$1 schema=$2 deploy=${TEST_EXISTING_DEPLOY:-filesystem}
246
+
case"$deploy"in
247
+
filesystem|pgtle) ;;
248
+
*)
249
+
echo"FAIL: TEST_EXISTING_DEPLOY must be 'filesystem' or 'pgtle', got '$deploy'">&2
250
+
exit 1
251
+
;;
252
+
esac
253
+
183
254
assert_version "$db" current
184
255
assert_drop_blocked "$db"
185
256
drop_guard "$db"
257
+
258
+
# See TEST_EXISTING_DEPLOY in the file header. Only 'pgtle' changes
259
+
# anything here; a scratch DESTDIR is created and baked into a trap so it
260
+
# is cleaned up regardless of how this function/script exits (a RETURN
261
+
# trap would NOT fire under `set -e` if `make test` below reports a
262
+
# regression - EXIT does, for any exit reason).
263
+
local destdir_opt=()
264
+
if [ "$deploy"= pgtle ];then
265
+
local scratch
266
+
scratch=$(mktemp -d)
267
+
trap"rm -rf '$scratch'" EXIT
268
+
seed_pgtap_stub "$scratch"
269
+
destdir_opt=(DESTDIR="$scratch")
270
+
fi
271
+
186
272
# In existing mode pg_regress runs against $db via --use-existing and must
187
273
# NOT create/drop its own database. `make test` (not just `make
188
274
# verify-results`) is a real gate as of pgxntool 2.3.0 - it now exits
189
275
# non-zero on regression failures instead of always exiting 0 regardless
190
276
# of pg_regress's result (see this repo's pgxntool 2.3.0 bump).
191
-
make test TEST_LOAD_SOURCE=existing TEST_SCHEMA="$schema" CONTRIB_TESTDB="$db" EXTRA_REGRESS_OPTS=--use-existing
277
+
# TEST_EXISTING_DEPLOY is passed through explicitly (not left to
278
+
# environment inheritance) so test/install/load.sql's existing-mode
279
+
# assertion (via the count_nulls.test_existing_deploy GUC - see the
280
+
# Makefile) picks the right source regardless of how this function is
281
+
# invoked.
282
+
make test TEST_LOAD_SOURCE=existing TEST_SCHEMA="$schema" CONTRIB_TESTDB="$db" EXTRA_REGRESS_OPTS=--use-existing TEST_EXISTING_DEPLOY="$deploy""${destdir_opt[@]}"
0 commit comments