From eeaf5f04ae3fca446b43851fb9a612fe0c980994 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 2 Nov 2003 21:56:15 +0000 Subject: [PATCH] Provide a way to run the parallel regression tests with a user-specified limit on the number of simultaneous connections. Andrew Dunstan, with review by Tom Lane. --- doc/src/sgml/regress.sgml | 34 +++++++++-------- src/test/regress/GNUmakefile | 12 ++++-- src/test/regress/pg_regress.sh | 69 +++++++++++++++++++++++++--------- 3 files changed, 80 insertions(+), 35 deletions(-) diff --git a/doc/src/sgml/regress.sgml b/doc/src/sgml/regress.sgml index 768f0cf6ea0..693a7583735 100644 --- a/doc/src/sgml/regress.sgml +++ b/doc/src/sgml/regress.sgml @@ -1,4 +1,4 @@ - + Regression Tests @@ -52,18 +52,18 @@ gmake check ====================== - All 77 tests passed. + All 93 tests passed. ====================== - or otherwise a note about what tests failed. See below for more. Because this test method runs a temporary server, it will not work - when you are the root user (the server will not start as root). + when you are the root user (since the server will not start as root). If you already did the build as root, you do not have to start all over. Instead, make the regression test directory writable by some other user, log in as that user, and restart the tests. @@ -88,14 +88,18 @@ gmake check The parallel regression test starts quite a few processes under your user ID. Presently, the maximum concurrency is twenty parallel test - scripts, which means sixty processes: there's a server process, a psql, - and usually a shell parent process for the psql for each test script. + scripts, which means sixty processes: there's a server process, a + psql, and usually a shell parent process for the + psql for each test script. So if your system enforces a per-user limit on the number of processes, make sure this limit is at least seventy-five or so, else you may get random-seeming failures in the parallel test. If you are not in - a position to raise the limit, you can edit the file - src/test/regress/parallel_schedule to split the - larger concurrent test sets into more manageable groups. + a position to raise the limit, you can cut down the degree of parallelism + by setting the MAX_CONNECTIONS parameter. For example, + +gmake MAX_CONNECTIONS=10 check + + runs no more than ten tests concurrently. @@ -109,8 +113,8 @@ gmake check gmake SHELL=/bin/ksh check - If no non-broken shell is available, you can alter the parallel test - schedule as suggested above. + If no non-broken shell is available, you may be able to work around the + problem by limiting the number of connections, as shown above. @@ -177,7 +181,7 @@ gmake installcheck If you run the tests against an already-installed server that was - initialized with a collation order locale different than C then + initialized with a collation-order locale other than C, then there may be differences due to sort order and follow-up failures. The regression test suite is set up to handle this problem by providing alternative result files that together are @@ -199,7 +203,7 @@ gmake installcheck testname_digit.out. The actual digit is not significant. Remember that the regression test driver will consider all such files to be equally - valid test results. If the test results are platform-dependent, + valid test results. If the test results are platform-specific, the technique described in should be used instead. @@ -245,7 +249,7 @@ env TZ=PST8PDT date The command above should have returned the current system time in the PST8PDT time zone. If the PST8PDT time zone is not available, - then your system may have returned the time in GMT. If the + then your system may have returned the time in UTC. If the PST8PDT time zone is missing, you can set the time zone rules explicitly: @@ -364,7 +368,7 @@ diff results/random.out expected/random.out which comparison file to use. So, to eliminate bogus test failures for a particular platform, you must choose or make a variant result file, and then add a line to the mapping - file, which is resultmap. + file, which is src/test/regress/resultmap. diff --git a/src/test/regress/GNUmakefile b/src/test/regress/GNUmakefile index 5279204b3b6..eb54dce64b6 100644 --- a/src/test/regress/GNUmakefile +++ b/src/test/regress/GNUmakefile @@ -7,7 +7,7 @@ # # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/test/regress/GNUmakefile,v 1.42 2003/03/21 17:18:34 petere Exp $ +# $Header: /cvsroot/pgsql/src/test/regress/GNUmakefile,v 1.43 2003/11/02 21:56:15 tgl Exp $ # #------------------------------------------------------------------------- @@ -25,6 +25,12 @@ SHLIB_LINK = $(BE_DLLLIBS) # default encoding MULTIBYTE = SQL_ASCII +# maximum simultaneous connections for parallel tests +MAXCONNOPT := +ifdef MAX_CONNECTIONS +MAXCONNOPT += --max-connections=$(MAX_CONNECTIONS) +endif + ## ## Prepare for tests @@ -113,7 +119,7 @@ all-spi: ## check: all - $(SHELL) ./pg_regress --temp-install --top-builddir=$(top_builddir) --schedule=$(srcdir)/parallel_schedule --multibyte=$(MULTIBYTE) + $(SHELL) ./pg_regress --temp-install --top-builddir=$(top_builddir) --schedule=$(srcdir)/parallel_schedule --multibyte=$(MULTIBYTE) $(MAXCONNOPT) installcheck: all $(SHELL) ./pg_regress --schedule=$(srcdir)/serial_schedule --multibyte=$(MULTIBYTE) @@ -128,7 +134,7 @@ bigtest: $(SHELL) ./pg_regress --schedule=$(srcdir)/serial_schedule --multibyte=$(MULTIBYTE) numeric_big bigcheck: - $(SHELL) ./pg_regress --temp-install --top-builddir=$(top_builddir) --schedule=$(srcdir)/parallel_schedule --multibyte=$(MULTIBYTE) numeric_big + $(SHELL) ./pg_regress --temp-install --top-builddir=$(top_builddir) --schedule=$(srcdir)/parallel_schedule --multibyte=$(MULTIBYTE) $(MAXCONNOPT) numeric_big ## diff --git a/src/test/regress/pg_regress.sh b/src/test/regress/pg_regress.sh index 89eca958665..dfa57467c10 100644 --- a/src/test/regress/pg_regress.sh +++ b/src/test/regress/pg_regress.sh @@ -1,5 +1,5 @@ #! /bin/sh -# $Header: /cvsroot/pgsql/src/test/regress/Attic/pg_regress.sh,v 1.35 2003/08/07 14:36:31 tgl Exp $ +# $Header: /cvsroot/pgsql/src/test/regress/Attic/pg_regress.sh,v 1.36 2003/11/02 21:56:15 tgl Exp $ me=`basename $0` : ${TMPDIR=/tmp} @@ -13,6 +13,8 @@ Usage: $me [options...] [extra tests...] Options: --debug turn on debug mode in programs that are run --inputdir=DIR take input files from DIR (default \`.') + --max-connections=N maximum number of concurrent connections + (default is 0 meaning unlimited) --multibyte=ENCODING use ENCODING as the multibyte encoding, and also run a test by the same name --outputdir=DIR place output files in DIR (default \`.') @@ -92,6 +94,7 @@ unset multibyte dbname=regression hostname=localhost +maxconnections=0 : ${GMAKE='@GMAKE@'} @@ -124,6 +127,9 @@ do --temp-install=*) temp_install=`expr "x$1" : "x--temp-install=\(.*\)"` shift;; + --max-connections=*) + maxconnections=`expr "x$1" : "x--max-connections=\(.*\)"` + shift;; --outputdir=*) outputdir=`expr "x$1" : "x--outputdir=\(.*\)"` shift;; @@ -156,6 +162,26 @@ do esac done +# ---------- +# warn of Cygwin likely failure if maxconnections = 0 +# and we are running parallel tests +# ---------- + +case $host_platform in + *-*-cygwin*) + case "$schedule" in + *parallel_schedule*) + if [ $maxconnections -eq 0 ] ; then + echo Using unlimited parallel connections is likely to fail or hang on Cygwin. + echo Try \"$me --max-connections=n\" or \"gmake MAX_CONNECTIONS=n check\" + echo with n = 5 or 10 if this happens. + echo + fi + ;; + esac + ;; +esac + # ---------- # When on QNX or BeOS, don't use Unix sockets. @@ -248,15 +274,15 @@ if [ -f "$inputdir/resultmap" ] then while read LINE do - HOSTPAT=`expr "$LINE" : '.*/\(.*\)='` - if [ `expr "$host_platform:$compiler" : "$HOSTPAT"` -ne 0 ] - then - # remove hostnamepattern from line so that there are no shell - # wildcards in SUBSTLIST; else later 'for' could expand them! - TESTNAME=`expr "$LINE" : '\(.*\)/'` - SUBST=`echo "$LINE" | sed 's/^.*=//'` - echo "$TESTNAME=$SUBST" >> $TMPFILE - fi + HOSTPAT=`expr "$LINE" : '.*/\(.*\)='` + if [ `expr "$host_platform:$compiler" : "$HOSTPAT"` -ne 0 ] + then + # remove hostnamepattern from line so that there are no shell + # wildcards in SUBSTLIST; else later 'for' could expand them! + TESTNAME=`expr "$LINE" : '\(.*\)/'` + SUBST=`echo "$LINE" | sed 's/^.*=//'` + echo "$TESTNAME=$SUBST" >> $TMPFILE + fi done <"$inputdir/resultmap" fi SUBSTLIST=`cat $TMPFILE` @@ -309,10 +335,11 @@ then # Windows needs shared libraries in PATH. (Only those linked into # executables, not dlopen'ed ones) # ---------- - case $host_platform in *-*-cygwin*) - PATH=$libdir:$PATH - export PATH - ;; + case $host_platform in + *-*-cygwin*) + PATH=$libdir:$PATH + export PATH + ;; esac if [ -d "$temp_install" ]; then @@ -556,11 +583,19 @@ do else # Start a parallel group $ECHO_N "parallel group ($# tests): $ECHO_C" + if [ $maxconnections -gt 0 ] ; then + connnum=0 + test $# -gt $maxconnections && $ECHO_N "(in groups of $maxconnections) $ECHO_C" + fi for name do ( - $PSQL -d "$dbname" <"$inputdir/sql/$name.sql" >"$outputdir/results/$name.out" 2>&1 + $PSQL -d "$dbname" <"$inputdir/sql/$name.sql" >"$outputdir/results/$name.out" 2>&1 $ECHO_N " $name$ECHO_C" ) & + if [ $maxconnections -gt 0 ] ; then + connnum=`expr \( $connnum + 1 \) % $maxconnections` + test $connnum -eq 0 && wait + fi done wait echo @@ -593,8 +628,8 @@ do fi done - # If there are multiple equally valid result file, loop to get the right one. - # If none match, diff against the closet one. + # If there are multiple equally valid result files, loop to get the right one. + # If none match, diff against the closest one. bestfile= bestdiff= -- 2.39.5