Commit dcae5fac authored by Peter Eisentraut's avatar Peter Eisentraut

Improve speed of make check-world

Before, make check-world would create a new temporary installation for
each test suite, which is slow and wasteful.  Instead, we now create one
test installation that is used by all test suites that are part of a
make run.

The management of the temporary installation is removed from pg_regress
and handled in the makefiles.  This allows for better control, and
unifies the code with that of test suites not run through pg_regress.

review and msvc support by Michael Paquier <michael.paquier@gmail.com>

more review by Fabien Coelho <coelho@cri.ensmp.fr>
parent 50a16e30
......@@ -36,3 +36,4 @@ lib*.pc
/pgsql.sln.cache
/Debug/
/Release/
/tmp_install/
......@@ -47,6 +47,7 @@ $(call recurse,distprep,doc src config contrib)
# it's not built by default
$(call recurse,clean,doc contrib src config)
clean:
rm -rf tmp_install/
# Garbage from autoconf:
@rm -rf autom4te.cache/
......
......@@ -7,7 +7,7 @@ DATA = earthdistance--1.0.sql earthdistance--unpackaged--1.0.sql
PGFILEDESC = "earthdistance - calculate distances on the surface of the Earth"
REGRESS = earthdistance
REGRESS_OPTS = --extra-install=contrib/cube
EXTRA_INSTALL = contrib/cube
LDFLAGS_SL += $(filter -lm, $(LIBS))
......
......@@ -39,35 +39,33 @@ submake-test_decoding:
REGRESSCHECKS=ddl rewrite toast permissions decoding_in_xact decoding_into_rel binary prepared
regresscheck: all | submake-regress submake-test_decoding
regresscheck: all | submake-regress submake-test_decoding temp-install
$(MKDIR_P) regression_output
$(pg_regress_check) \
--temp-config $(top_srcdir)/contrib/test_decoding/logical.conf \
--temp-install=./tmp_check \
--extra-install=contrib/test_decoding \
--temp-instance=./tmp_check \
--outputdir=./regression_output \
$(REGRESSCHECKS)
regresscheck-install-force: | submake-regress submake-test_decoding
regresscheck-install-force: | submake-regress submake-test_decoding temp-install
$(pg_regress_installcheck) \
--extra-install=contrib/test_decoding \
$(REGRESSCHECKS)
ISOLATIONCHECKS=mxact delayed_startup ondisk_startup concurrent_ddl_dml
isolationcheck: all | submake-isolation submake-test_decoding
isolationcheck: all | submake-isolation submake-test_decoding temp-install
$(MKDIR_P) isolation_output
$(pg_isolation_regress_check) \
--temp-config $(top_srcdir)/contrib/test_decoding/logical.conf \
--extra-install=contrib/test_decoding \
--outputdir=./isolation_output \
$(ISOLATIONCHECKS)
isolationcheck-install-force: all | submake-isolation submake-test_decoding
isolationcheck-install-force: all | submake-isolation submake-test_decoding temp-install
$(pg_isolation_regress_installcheck) \
--extra-install=contrib/test_decoding \
$(ISOLATIONCHECKS)
PHONY: submake-test_decoding submake-regress check \
regresscheck regresscheck-install-force \
isolationcheck isolationcheck-install-force
temp-install: EXTRA_INSTALL=contrib/test_decoding
......@@ -43,6 +43,7 @@ MAJORVERSION = @PG_MAJORVERSION@
# (PGXS VPATH support is handled separately in pgxs.mk)
ifndef PGXS
vpath_build = @vpath_build@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ifneq ($(vpath_build),yes)
......@@ -301,6 +302,17 @@ BZIP2 = bzip2
# Testing
check: temp-install
.PHONY: temp-install
temp-install:
ifeq ($(MAKELEVEL),0)
rm -rf '$(abs_top_builddir)'/tmp_install
$(MKDIR_P) '$(abs_top_builddir)'/tmp_install/log
$(MAKE) -C '$(top_builddir)' DESTDIR='$(abs_top_builddir)'/tmp_install install >'$(abs_top_builddir)'/tmp_install/log/install.log 2>&1
endif
for extra in $(EXTRA_INSTALL); do $(MAKE) -C '$(top_builddir)'/$$extra DESTDIR='$(abs_top_builddir)'/tmp_install install >>'$(abs_top_builddir)'/tmp_install/log/install.log 2>&1 || exit; done
PROVE = @PROVE@
PG_PROVE_FLAGS = -I $(top_srcdir)/src/test/perl/
PROVE_FLAGS = --verbose
......@@ -315,6 +327,10 @@ define ld_library_path_var
$(if $(filter $(PORTNAME),darwin),DYLD_LIBRARY_PATH,$(if $(filter $(PORTNAME),aix),LIBPATH,LD_LIBRARY_PATH))
endef
define with_temp_install
PATH="$(abs_top_builddir)/tmp_install$(bindir):$$PATH" $(call add_to_path,$(ld_library_path_var),$(abs_top_builddir)/tmp_install$(libdir))
endef
ifeq ($(enable_tap_tests),yes)
define prove_installcheck
......@@ -322,9 +338,7 @@ cd $(srcdir) && TESTDIR='$(CURDIR)' PATH="$(bindir):$$PATH" PGPORT='6$(DEF_PGPOR
endef
define prove_check
$(MKDIR_P) tmp_check/log
$(MAKE) -C $(top_builddir) DESTDIR='$(CURDIR)'/tmp_check/install install >'$(CURDIR)'/tmp_check/log/install.log 2>&1
cd $(srcdir) && TESTDIR='$(CURDIR)' PATH="$(CURDIR)/tmp_check/install$(bindir):$$PATH" $(call add_to_path,$(ld_library_path_var),$(CURDIR)/tmp_check/install$(libdir)) top_builddir='$(CURDIR)/$(top_builddir)' PGPORT='6$(DEF_PGPORT)' $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) t/*.pl
cd $(srcdir) && TESTDIR='$(CURDIR)' $(with_temp_install) PGPORT='6$(DEF_PGPORT)' top_builddir='$(CURDIR)/$(top_builddir)' $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) t/*.pl
endef
else
......@@ -495,13 +509,13 @@ endif
pg_regress_locale_flags = $(if $(ENCODING),--encoding=$(ENCODING)) $(NOLOCALE)
pg_regress_check = $(top_builddir)/src/test/regress/pg_regress --inputdir=$(srcdir) --temp-install=./tmp_check --top-builddir=$(top_builddir) $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS)
pg_regress_installcheck = $(top_builddir)/src/test/regress/pg_regress --inputdir=$(srcdir) --psqldir='$(PSQLDIR)' $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS)
pg_regress_check = $(with_temp_install) $(top_builddir)/src/test/regress/pg_regress --inputdir=$(srcdir) --temp-instance=./tmp_check --bindir= $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS)
pg_regress_installcheck = $(top_builddir)/src/test/regress/pg_regress --inputdir=$(srcdir) --bindir='$(bindir)' $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS)
pg_regress_clean_files = results/ regression.diffs regression.out tmp_check/ log/
pg_isolation_regress_check = $(top_builddir)/src/test/isolation/pg_isolation_regress --inputdir=$(srcdir) --temp-install=./tmp_check --top-builddir=$(top_builddir) $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS)
pg_isolation_regress_installcheck = $(top_builddir)/src/test/isolation/pg_isolation_regress --inputdir=$(srcdir) --top-builddir=$(top_builddir) $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS)
pg_isolation_regress_check = $(with_temp_install) $(top_builddir)/src/test/isolation/pg_isolation_regress --inputdir=$(srcdir) --temp-instance=./tmp_check --bindir= $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS)
pg_isolation_regress_installcheck = $(top_builddir)/src/test/isolation/pg_isolation_regress --inputdir=$(srcdir) $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS)
##########################################################################
#
......@@ -683,7 +697,7 @@ endif
define _create_recursive_target
.PHONY: $(1)-$(2)-recurse
$(1): $(1)-$(2)-recurse
$(1)-$(2)-recurse:
$(1)-$(2)-recurse: $(if $(filter check, $(3)), temp-install)
$$(MAKE) -C $(2) $(3)
endef
# Note that the use of $$ on the last line above is important; we want
......
......@@ -86,7 +86,7 @@ if [ "$1" = '--install' ]; then
# use psql from the proper installation directory, which might
# be outdated or missing. But don't override anything else that's
# already in EXTRA_REGRESS_OPTS.
EXTRA_REGRESS_OPTS="$EXTRA_REGRESS_OPTS --psqldir='$bindir'"
EXTRA_REGRESS_OPTS="$EXTRA_REGRESS_OPTS --bindir='$bindir'"
export EXTRA_REGRESS_OPTS
fi
......
......@@ -11,14 +11,10 @@ override CPPFLAGS := \
'-I$(top_builddir)/src/port' \
'-I$(top_srcdir)/src/test/regress' \
'-DHOST_TUPLE="$(host_tuple)"' \
'-DMAKEPROG="$(MAKE)"' \
'-DSHELLPROG="$(SHELL)"' \
'-DDLSUFFIX="$(DLSUFFIX)"' \
$(CPPFLAGS)
# where to find psql for testing an existing installation
PSQLDIR = $(bindir)
# default encoding for regression tests
ENCODING = SQL_ASCII
......@@ -82,11 +78,11 @@ endif
REGRESS_OPTS = --dbname=regress1,connectdb --create-role=connectuser,connectdb $(EXTRA_REGRESS_OPTS)
check: all
./pg_regress $(REGRESS_OPTS) --top-builddir=$(top_builddir) --temp-install=./tmp_check $(pg_regress_locale_flags) $(THREAD) --schedule=$(srcdir)/ecpg_schedule
$(with_temp_install) ./pg_regress $(REGRESS_OPTS) --temp-instance=./tmp_check --bindir= $(pg_regress_locale_flags) $(THREAD) --schedule=$(srcdir)/ecpg_schedule
# the same options, but with --listen-on-tcp
checktcp: all
./pg_regress $(REGRESS_OPTS) --top-builddir=$(top_builddir) --temp-install=./tmp_check $(pg_regress_locale_flags) $(THREAD) --schedule=$(srcdir)/ecpg_schedule_tcp --host=localhost
$(with_temp_install) ./pg_regress $(REGRESS_OPTS) --temp-instance=./tmp_check --bindir= $(pg_regress_locale_flags) $(THREAD) --schedule=$(srcdir)/ecpg_schedule_tcp --host=localhost
installcheck: all
./pg_regress $(REGRESS_OPTS) --psqldir='$(PSQLDIR)' --top-builddir=$(top_builddir) $(pg_regress_locale_flags) $(THREAD) --schedule=$(srcdir)/ecpg_schedule
./pg_regress $(REGRESS_OPTS) --bindir='$(bindir)' $(pg_regress_locale_flags) $(THREAD) --schedule=$(srcdir)/ecpg_schedule
......@@ -258,9 +258,6 @@ else
REGRESS_OPTS += --dbname=$(CONTRIB_TESTDB)
endif
# where to find psql for running the tests
PSQLDIR = $(bindir)
# When doing a VPATH build, must copy over the data files so that the
# driver script can find them. We have to use an absolute path for
# the targets, because otherwise make will try to locate the missing
......@@ -295,7 +292,9 @@ check:
@echo 'Do "$(MAKE) install", then "$(MAKE) installcheck" instead.'
else
check: all submake $(REGRESS_PREP)
$(pg_regress_check) --extra-install=$(subdir) $(REGRESS_OPTS) $(REGRESS)
$(pg_regress_check) $(REGRESS_OPTS) $(REGRESS)
temp-install: EXTRA_INSTALL=$(subdir)
endif
endif # REGRESS
......
......@@ -69,8 +69,6 @@ ifeq ($(shell $(PERL) -V:usemultiplicity), usemultiplicity='define';)
REGRESS += plperl_plperlu
endif
endif
# where to find psql for running the tests
PSQLDIR = $(bindir)
# where to find xsubpp for building XS.
XSUBPPDIR = $(shell $(PERL) -e 'use List::Util qw(first); print first { -r "$$_/ExtUtils/xsubpp" } @INC')
......
......@@ -115,9 +115,6 @@ REGRESS = \
REGRESS_PLPYTHON3_MANGLE := $(REGRESS)
# where to find psql for running the tests
PSQLDIR = $(bindir)
include $(top_srcdir)/src/Makefile.shlib
all: all-lib
......
......@@ -45,8 +45,6 @@ DATA = pltcl.control pltcl--1.0.sql pltcl--unpackaged--1.0.sql \
REGRESS_OPTS = --dbname=$(PL_TESTDB) --load-extension=pltcl
REGRESS = pltcl_setup pltcl_queries
# where to find psql for running the tests
PSQLDIR = $(bindir)
# Tcl on win32 ships with import libraries only for Microsoft Visual C++,
# which are not compatible with mingw gcc. Therefore we need to build a
......
......@@ -9,9 +9,6 @@ subdir = src/test/isolation
top_builddir = ../../..
include $(top_builddir)/src/Makefile.global
# where to find psql for testing an existing installation
PSQLDIR = $(bindir)
override CPPFLAGS := -I$(srcdir) -I$(libpq_srcdir) -I$(srcdir)/../regress $(CPPFLAGS)
OBJS = specparse.o isolationtester.o $(WIN32RES)
......@@ -55,17 +52,17 @@ maintainer-clean: distclean
rm -f specparse.c specscanner.c
installcheck: all
./pg_isolation_regress --psqldir='$(PSQLDIR)' $(EXTRA_REGRESS_OPTS) --inputdir=$(srcdir) --schedule=$(srcdir)/isolation_schedule
./pg_isolation_regress --bindir='$(bindir)' $(EXTRA_REGRESS_OPTS) --inputdir=$(srcdir) --schedule=$(srcdir)/isolation_schedule
check: all
./pg_isolation_regress --temp-install=./tmp_check --inputdir=$(srcdir) --top-builddir=$(top_builddir) $(EXTRA_REGRESS_OPTS) --schedule=$(srcdir)/isolation_schedule
$(with_temp_install) ./pg_isolation_regress --temp-instance=./tmp_check --inputdir=$(srcdir) --bindir= $(EXTRA_REGRESS_OPTS) --schedule=$(srcdir)/isolation_schedule
# Versions of the check tests that include the prepared_transactions test
# It only makes sense to run these if set up to use prepared transactions,
# via TEMP_CONFIG for the check case, or via the postgresql.conf for the
# installcheck case.
installcheck-prepared-txns: all
./pg_isolation_regress --psqldir='$(PSQLDIR)' $(EXTRA_REGRESS_OPTS) --inputdir=$(srcdir) --schedule=$(srcdir)/isolation_schedule prepared-transactions
installcheck-prepared-txns: all temp-install
./pg_isolation_regress --bindir='$(bindir)' $(EXTRA_REGRESS_OPTS) --inputdir=$(srcdir) --schedule=$(srcdir)/isolation_schedule prepared-transactions
check-prepared-txns: all
./pg_isolation_regress --temp-install=./tmp_check $(EXTRA_REGRESS_OPTS) --inputdir=$(srcdir) --top-builddir=$(top_builddir) --schedule=$(srcdir)/isolation_schedule prepared-transactions
check-prepared-txns: all temp-install
./pg_isolation_regress --temp-instance=./tmp_check $(EXTRA_REGRESS_OPTS) --inputdir=$(srcdir) --schedule=$(srcdir)/isolation_schedule prepared-transactions
......@@ -23,9 +23,6 @@ ifdef TEMP_CONFIG
TEMP_CONF += --temp-config=$(TEMP_CONFIG)
endif
# where to find psql for testing an existing installation
PSQLDIR = $(bindir)
# maximum simultaneous connections for parallel tests
MAXCONNOPT =
ifdef MAX_CONNECTIONS
......@@ -34,7 +31,6 @@ endif
# stuff to pass into build of pg_regress
EXTRADEFS = '-DHOST_TUPLE="$(host_tuple)"' \
'-DMAKEPROG="$(MAKE)"' \
'-DSHELLPROG="$(SHELL)"' \
'-DDLSUFFIX="$(DLSUFFIX)"'
......
This diff is collapsed.
......@@ -43,12 +43,6 @@ extern char *inputdir;
extern char *outputdir;
extern char *launcher;
/*
* This should not be global but every module should be able to read command
* line parameters.
*/
extern char *psqldir;
extern const char *basic_diff_opts;
extern const char *pretty_diff_opts;
......
......@@ -65,8 +65,8 @@ psql_start_test(const char *testname,
snprintf(psql_cmd + offset, sizeof(psql_cmd) - offset,
"\"%s%spsql\" -X -a -q -d \"%s\" < \"%s\" > \"%s\" 2>&1",
psqldir ? psqldir : "",
psqldir ? "/" : "",
bindir ? bindir : "",
bindir ? "/" : "",
dblist->str,
infile,
outfile);
......
......@@ -16,6 +16,7 @@ my $startdir = getcwd();
chdir "../../.." if (-d "../../../src/tools/msvc");
my $topdir = getcwd();
my $tmp_installdir = "$topdir/tmp_install";
require 'src/tools/msvc/config_default.pl';
require 'src/tools/msvc/config.pl' if (-f 'src/tools/msvc/config.pl');
......@@ -95,7 +96,7 @@ sub installcheck
my @args = (
"../../../$Config/pg_regress/pg_regress",
"--dlpath=.",
"--psqldir=../../../$Config/psql",
"--bindir=../../../$Config/psql",
"--schedule=${schedule}_schedule",
"--encoding=SQL_ASCII",
"--no-locale");
......@@ -107,15 +108,19 @@ sub installcheck
sub check
{
chdir $startdir;
InstallTemp();
chdir "${topdir}/src/test/regress";
my @args = (
"../../../$Config/pg_regress/pg_regress",
"${tmp_installdir}/bin/pg_regress",
"--dlpath=.",
"--psqldir=../../../$Config/psql",
"--bindir=${tmp_installdir}/bin",
"--schedule=${schedule}_schedule",
"--encoding=SQL_ASCII",
"--no-locale",
"--temp-install=./tmp_check",
"--top-builddir=\"$topdir\"");
"--temp-instance=./tmp_check");
push(@args, $maxconn) if $maxconn;
push(@args, $temp_config) if $temp_config;
system(@args);
......@@ -129,18 +134,20 @@ sub ecpgcheck
system("msbuild ecpg_regression.proj /p:config=$Config");
my $status = $? >> 8;
exit $status if $status;
InstallTemp();
chdir "$topdir/src/interfaces/ecpg/test";
$ENV{PATH} = "${tmp_installdir}/bin;${tmp_installdir}/lib;$ENV{PATH}";
$schedule = "ecpg";
my @args = (
"../../../../$Config/pg_regress_ecpg/pg_regress_ecpg",
"--psqldir=../../../$Config/psql",
"${tmp_installdir}/bin/pg_regress_ecpg",
"--bindir=",
"--dbname=regress1,connectdb",
"--create-role=connectuser,connectdb",
"--schedule=${schedule}_schedule",
"--encoding=SQL_ASCII",
"--no-locale",
"--temp-install=./tmp_chk",
"--top-builddir=\"$topdir\"");
"--temp-instance=./tmp_chk");
push(@args, $maxconn) if $maxconn;
system(@args);
$status = $? >> 8;
......@@ -149,12 +156,14 @@ sub ecpgcheck
sub isolationcheck
{
chdir "../isolation";
copy("../../../$Config/isolationtester/isolationtester.exe",
"../../../$Config/pg_isolation_regress");
chdir $startdir;
InstallTemp();
chdir "${topdir}/src/test/isolation";
my @args = (
"../../../$Config/pg_isolation_regress/pg_isolation_regress",
"--psqldir=../../../$Config/psql",
"${tmp_installdir}/bin/pg_isolation_regress",
"--bindir=${tmp_installdir}/bin",
"--inputdir=.",
"--schedule=./isolation_schedule");
push(@args, $maxconn) if $maxconn;
......@@ -165,7 +174,10 @@ sub isolationcheck
sub plcheck
{
chdir "../../pl";
chdir $startdir;
InstallTemp();
chdir "${topdir}/src/pl";
foreach my $pl (glob("*"))
{
......@@ -202,8 +214,8 @@ sub plcheck
"============================================================\n";
print "Checking $lang\n";
my @args = (
"../../../$Config/pg_regress/pg_regress",
"--psqldir=../../../$Config/psql",
"${tmp_installdir}/bin/pg_regress",
"--bindir=${tmp_installdir}/bin",
"--dbname=pl_regression", @lang_args, @tests);
system(@args);
my $status = $? >> 8;
......@@ -233,8 +245,8 @@ sub subdircheck
my @tests = fetchTests();
my @opts = fetchRegressOpts();
my @args = (
"$topdir/$Config/pg_regress/pg_regress",
"--psqldir=$topdir/$Config/psql",
"${tmp_installdir}/bin/pg_regress",
"--bindir=${tmp_installdir}/bin",
"--dbname=contrib_regression", @opts, @tests);
system(@args);
my $status = $? >> 8;
......@@ -273,8 +285,8 @@ sub modulescheck
sub standard_initdb
{
return (
system('initdb', '-N') == 0 and system(
"$topdir/$Config/pg_regress/pg_regress", '--config-auth',
system("${tmp_installdir}/bin/initdb", '-N') == 0 and system(
"${tmp_installdir}/bin/pg_regress", '--config-auth',
$ENV{PGDATA}) == 0);
}
......@@ -293,14 +305,13 @@ sub upgradecheck
$ENV{PGPORT} ||= 50432;
my $tmp_root = "$topdir/src/bin/pg_upgrade/tmp_check";
(mkdir $tmp_root || die $!) unless -d $tmp_root;
my $tmp_install = "$tmp_root/install";
print "Setting up temp install\n\n";
Install($tmp_install, "all", $config);
InstallTemp();
# Install does a chdir, so change back after that
chdir $cwd;
my ($bindir, $libdir, $oldsrc, $newsrc) =
("$tmp_install/bin", "$tmp_install/lib", $topdir, $topdir);
("$tmp_installdir/bin", "$tmp_installdir/lib", $topdir, $topdir);
$ENV{PATH} = "$bindir;$ENV{PATH}";
my $data = "$tmp_root/data";
$ENV{PGDATA} = "$data.old";
......@@ -435,6 +446,12 @@ sub GetTests
return "";
}
sub InstallTemp
{
print "Setting up temp install\n\n";
Install("$tmp_installdir", "all", $config);
}
sub usage
{
print STDERR
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment