From 28daf1a648a22195603c638ff872535352f0cddb Mon Sep 17 00:00:00 2001 From: Hanefi Onaldi Date: Sat, 6 Aug 2022 02:34:32 +0300 Subject: [PATCH] Pass source directory in env to regression tests PostgreSQL 15 dropped usage of .source files that are used to generate .sql and .out files by replacing some placeholders with the actual values before test runs. Instead, the information is passed from pg_regress to the .sql and .out files directly via env variables. Those variables are read via \getenv psql command in relevant test files. PostgreSQL 15 commit d1029bb5a26cb84b116b0dee4dde312291359f2a introduced some changes to pg_regress binary that allowed this to happen. However this change is not backported to earlier versions of PG, and thus we come up with a similar mechanism in pg_regress_multi that works in all available PG versions. --- src/test/regress/Makefile | 7 +------ src/test/regress/pg_regress_multi.pl | 3 +++ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/test/regress/Makefile b/src/test/regress/Makefile index 0c3d05b4d..9689e7570 100644 --- a/src/test/regress/Makefile +++ b/src/test/regress/Makefile @@ -24,7 +24,7 @@ export PGISOLATIONTIMEOUT = 20 ## Citus regression support ## MULTI_INSTALLDIR=$(CURDIR)/tmp_check/install -pg_regress_multi_check = $(PERL) $(citus_abs_srcdir)/pg_regress_multi.pl --pgxsdir="$(pgxsdir)" --bindir="$(bindir)" --libdir="$(libdir)" --majorversion="$(MAJORVERSION)" --postgres-builddir="$(postgres_abs_builddir)" --postgres-srcdir="$(postgres_abs_srcdir)" +pg_regress_multi_check = $(PERL) $(citus_abs_srcdir)/pg_regress_multi.pl --pgxsdir="$(pgxsdir)" --bindir="$(bindir)" --libdir="$(libdir)" --majorversion="$(MAJORVERSION)" --postgres-builddir="$(postgres_abs_builddir)" --postgres-srcdir="$(postgres_abs_srcdir)" --citus_abs_srcdir="$(citus_abs_srcdir)" MULTI_REGRESS_OPTS = --inputdir=$(citus_abs_srcdir) $(pg_regress_locale_flags) --launcher="$(citus_abs_srcdir)/log_test_times" pg_upgrade_check = $(citus_abs_srcdir)/citus_tests/upgrade/pg_upgrade_test.py @@ -34,11 +34,6 @@ arbitrary_config_check = $(citus_abs_srcdir)/citus_tests/arbitrary_configs/citus template_isolation_files = $(shell find $(citus_abs_srcdir)/spec/ -name '*.spec') generated_isolation_files = $(patsubst $(citus_abs_srcdir)/spec/%,$(citus_abs_srcdir)/build/specs/%,$(template_isolation_files)) -# Test input and expected files. These are created by pg_regress itself, so we -# don't have a rule to create them. We do need rules to clean them however. -input_files := $(patsubst $(citus_abs_srcdir)/input/%.source,sql/%.sql, $(wildcard $(citus_abs_srcdir)/input/*.source)) -output_files := $(patsubst $(citus_abs_srcdir)/output/%.source,expected/%.out, $(wildcard $(citus_abs_srcdir)/output/*.source)) - # have make check actually run all tests, but keep check-full as an # intermediate, for muscle memory backward compatibility. check: check-full check-enterprise-full diff --git a/src/test/regress/pg_regress_multi.pl b/src/test/regress/pg_regress_multi.pl index 23b5d8033..61c2193b9 100755 --- a/src/test/regress/pg_regress_multi.pl +++ b/src/test/regress/pg_regress_multi.pl @@ -66,6 +66,7 @@ my $bindir = ""; my $libdir = undef; my $pgxsdir = ""; my $postgresBuilddir = ""; +my $citusAbsSrcdir = ""; my $postgresSrcdir = ""; my $majorversion = ""; my $synchronousReplication = ""; @@ -104,6 +105,7 @@ GetOptions( 'pgxsdir=s' => \$pgxsdir, 'postgres-builddir=s' => \$postgresBuilddir, 'postgres-srcdir=s' => \$postgresSrcdir, + 'citus_abs_srcdir=s' => \$citusAbsSrcdir, 'majorversion=s' => \$majorversion, 'load-extension=s' => \@extensions, 'server-option=s' => \@userPgOptions, @@ -640,6 +642,7 @@ print $fh "--variable=worker_2_proxy_port=$mitmPort "; print $fh "--variable=follower_master_port=$followerCoordPort "; print $fh "--variable=default_user=$user "; print $fh "--variable=SHOW_CONTEXT=always "; +print $fh "--variable=abs_srcdir=$citusAbsSrcdir "; for my $workeroff (0 .. $#workerPorts) { my $port = $workerPorts[$workeroff];