Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit eeaf5f0

Browse files
committed
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.
1 parent 4593531 commit eeaf5f0

File tree

3 files changed

+80
-35
lines changed

3 files changed

+80
-35
lines changed

doc/src/sgml/regress.sgml

+19-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/regress.sgml,v 1.34 2003/09/12 22:17:23 tgl Exp $ -->
1+
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/regress.sgml,v 1.35 2003/11/02 21:56:14 tgl Exp $ -->
22

33
<chapter id="regress">
44
<title id="regress-title">Regression Tests</title>
@@ -52,18 +52,18 @@ gmake check
5252
<screen>
5353
<computeroutput>
5454
======================
55-
All 77 tests passed.
55+
All 93 tests passed.
5656
======================
5757
</computeroutput>
5858
</screen>
59-
or otherwise a note about what tests failed. See <xref
59+
or otherwise a note about which tests failed. See <xref
6060
linkend="regress-evaluation"> below for more.
6161
</para>
6262

6363
<note>
6464
<para>
6565
Because this test method runs a temporary server, it will not work
66-
when you are the root user (the server will not start as root).
66+
when you are the root user (since the server will not start as root).
6767
If you already did the build as root, you do not have to start all
6868
over. Instead, make the regression test directory writable by
6969
some other user, log in as that user, and restart the tests.
@@ -88,14 +88,18 @@ gmake check
8888
<para>
8989
The parallel regression test starts quite a few processes under your
9090
user ID. Presently, the maximum concurrency is twenty parallel test
91-
scripts, which means sixty processes: there's a server process, a <application>psql</>,
92-
and usually a shell parent process for the <application>psql</> for each test script.
91+
scripts, which means sixty processes: there's a server process, a
92+
<application>psql</>, and usually a shell parent process for the
93+
<application>psql</> for each test script.
9394
So if your system enforces a per-user limit on the number of processes,
9495
make sure this limit is at least seventy-five or so, else you may get
9596
random-seeming failures in the parallel test. If you are not in
96-
a position to raise the limit, you can edit the file
97-
<filename>src/test/regress/parallel_schedule</> to split the
98-
larger concurrent test sets into more manageable groups.
97+
a position to raise the limit, you can cut down the degree of parallelism
98+
by setting the <literal>MAX_CONNECTIONS</> parameter. For example,
99+
<screen>
100+
gmake MAX_CONNECTIONS=10 check
101+
</screen>
102+
runs no more than ten tests concurrently.
99103
</para>
100104
</tip>
101105

@@ -109,8 +113,8 @@ gmake check
109113
<screen>
110114
gmake SHELL=/bin/ksh check
111115
</screen>
112-
If no non-broken shell is available, you can alter the parallel test
113-
schedule as suggested above.
116+
If no non-broken shell is available, you may be able to work around the
117+
problem by limiting the number of connections, as shown above.
114118
</para>
115119
</tip>
116120

@@ -177,7 +181,7 @@ gmake installcheck
177181

178182
<para>
179183
If you run the tests against an already-installed server that was
180-
initialized with a collation order locale different than C then
184+
initialized with a collation-order locale other than C, then
181185
there may be differences due to sort order and follow-up
182186
failures. The regression test suite is set up to handle this
183187
problem by providing alternative result files that together are
@@ -199,7 +203,7 @@ gmake installcheck
199203
<literal><replaceable>testname</>_<replaceable>digit</>.out</>.
200204
The actual digit is not significant. Remember that the
201205
regression test driver will consider all such files to be equally
202-
valid test results. If the test results are platform-dependent,
206+
valid test results. If the test results are platform-specific,
203207
the technique described in <xref linkend="regress-platform">
204208
should be used instead.
205209
</para>
@@ -245,7 +249,7 @@ env TZ=PST8PDT date
245249
</screen>
246250
The command above should have returned the current system time in
247251
the <literal>PST8PDT</literal> time zone. If the <literal>PST8PDT</literal> time zone is not available,
248-
then your system may have returned the time in GMT. If the
252+
then your system may have returned the time in UTC. If the
249253
<literal>PST8PDT</literal> time zone is missing, you can set the time zone
250254
rules explicitly:
251255
<programlisting>
@@ -364,7 +368,7 @@ diff results/random.out expected/random.out
364368
which comparison file to use. So, to eliminate bogus test
365369
<quote>failures</quote> for a particular platform, you must choose
366370
or make a variant result file, and then add a line to the mapping
367-
file, which is <filename>resultmap</filename>.
371+
file, which is <filename>src/test/regress/resultmap</filename>.
368372
</para>
369373

370374
<para>

src/test/regress/GNUmakefile

+9-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
#
99
# IDENTIFICATION
10-
# $Header: /cvsroot/pgsql/src/test/regress/GNUmakefile,v 1.42 2003/03/21 17:18:34 petere Exp $
10+
# $Header: /cvsroot/pgsql/src/test/regress/GNUmakefile,v 1.43 2003/11/02 21:56:15 tgl Exp $
1111
#
1212
#-------------------------------------------------------------------------
1313

@@ -25,6 +25,12 @@ SHLIB_LINK = $(BE_DLLLIBS)
2525
# default encoding
2626
MULTIBYTE = SQL_ASCII
2727

28+
# maximum simultaneous connections for parallel tests
29+
MAXCONNOPT :=
30+
ifdef MAX_CONNECTIONS
31+
MAXCONNOPT += --max-connections=$(MAX_CONNECTIONS)
32+
endif
33+
2834

2935
##
3036
## Prepare for tests
@@ -113,7 +119,7 @@ all-spi:
113119
##
114120

115121
check: all
116-
$(SHELL) ./pg_regress --temp-install --top-builddir=$(top_builddir) --schedule=$(srcdir)/parallel_schedule --multibyte=$(MULTIBYTE)
122+
$(SHELL) ./pg_regress --temp-install --top-builddir=$(top_builddir) --schedule=$(srcdir)/parallel_schedule --multibyte=$(MULTIBYTE) $(MAXCONNOPT)
117123

118124
installcheck: all
119125
$(SHELL) ./pg_regress --schedule=$(srcdir)/serial_schedule --multibyte=$(MULTIBYTE)
@@ -128,7 +134,7 @@ bigtest:
128134
$(SHELL) ./pg_regress --schedule=$(srcdir)/serial_schedule --multibyte=$(MULTIBYTE) numeric_big
129135

130136
bigcheck:
131-
$(SHELL) ./pg_regress --temp-install --top-builddir=$(top_builddir) --schedule=$(srcdir)/parallel_schedule --multibyte=$(MULTIBYTE) numeric_big
137+
$(SHELL) ./pg_regress --temp-install --top-builddir=$(top_builddir) --schedule=$(srcdir)/parallel_schedule --multibyte=$(MULTIBYTE) $(MAXCONNOPT) numeric_big
132138

133139

134140
##

src/test/regress/pg_regress.sh

+52-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#! /bin/sh
2-
# $Header: /cvsroot/pgsql/src/test/regress/Attic/pg_regress.sh,v 1.35 2003/08/07 14:36:31 tgl Exp $
2+
# $Header: /cvsroot/pgsql/src/test/regress/Attic/pg_regress.sh,v 1.36 2003/11/02 21:56:15 tgl Exp $
33

44
me=`basename $0`
55
: ${TMPDIR=/tmp}
@@ -13,6 +13,8 @@ Usage: $me [options...] [extra tests...]
1313
Options:
1414
--debug turn on debug mode in programs that are run
1515
--inputdir=DIR take input files from DIR (default \`.')
16+
--max-connections=N maximum number of concurrent connections
17+
(default is 0 meaning unlimited)
1618
--multibyte=ENCODING use ENCODING as the multibyte encoding, and
1719
also run a test by the same name
1820
--outputdir=DIR place output files in DIR (default \`.')
@@ -92,6 +94,7 @@ unset multibyte
9294

9395
dbname=regression
9496
hostname=localhost
97+
maxconnections=0
9598

9699
: ${GMAKE='@GMAKE@'}
97100

@@ -124,6 +127,9 @@ do
124127
--temp-install=*)
125128
temp_install=`expr "x$1" : "x--temp-install=\(.*\)"`
126129
shift;;
130+
--max-connections=*)
131+
maxconnections=`expr "x$1" : "x--max-connections=\(.*\)"`
132+
shift;;
127133
--outputdir=*)
128134
outputdir=`expr "x$1" : "x--outputdir=\(.*\)"`
129135
shift;;
@@ -156,6 +162,26 @@ do
156162
esac
157163
done
158164

165+
# ----------
166+
# warn of Cygwin likely failure if maxconnections = 0
167+
# and we are running parallel tests
168+
# ----------
169+
170+
case $host_platform in
171+
*-*-cygwin*)
172+
case "$schedule" in
173+
*parallel_schedule*)
174+
if [ $maxconnections -eq 0 ] ; then
175+
echo Using unlimited parallel connections is likely to fail or hang on Cygwin.
176+
echo Try \"$me --max-connections=n\" or \"gmake MAX_CONNECTIONS=n check\"
177+
echo with n = 5 or 10 if this happens.
178+
echo
179+
fi
180+
;;
181+
esac
182+
;;
183+
esac
184+
159185

160186
# ----------
161187
# When on QNX or BeOS, don't use Unix sockets.
@@ -248,15 +274,15 @@ if [ -f "$inputdir/resultmap" ]
248274
then
249275
while read LINE
250276
do
251-
HOSTPAT=`expr "$LINE" : '.*/\(.*\)='`
252-
if [ `expr "$host_platform:$compiler" : "$HOSTPAT"` -ne 0 ]
253-
then
254-
# remove hostnamepattern from line so that there are no shell
255-
# wildcards in SUBSTLIST; else later 'for' could expand them!
256-
TESTNAME=`expr "$LINE" : '\(.*\)/'`
257-
SUBST=`echo "$LINE" | sed 's/^.*=//'`
258-
echo "$TESTNAME=$SUBST" >> $TMPFILE
259-
fi
277+
HOSTPAT=`expr "$LINE" : '.*/\(.*\)='`
278+
if [ `expr "$host_platform:$compiler" : "$HOSTPAT"` -ne 0 ]
279+
then
280+
# remove hostnamepattern from line so that there are no shell
281+
# wildcards in SUBSTLIST; else later 'for' could expand them!
282+
TESTNAME=`expr "$LINE" : '\(.*\)/'`
283+
SUBST=`echo "$LINE" | sed 's/^.*=//'`
284+
echo "$TESTNAME=$SUBST" >> $TMPFILE
285+
fi
260286
done <"$inputdir/resultmap"
261287
fi
262288
SUBSTLIST=`cat $TMPFILE`
@@ -309,10 +335,11 @@ then
309335
# Windows needs shared libraries in PATH. (Only those linked into
310336
# executables, not dlopen'ed ones)
311337
# ----------
312-
case $host_platform in *-*-cygwin*)
313-
PATH=$libdir:$PATH
314-
export PATH
315-
;;
338+
case $host_platform in
339+
*-*-cygwin*)
340+
PATH=$libdir:$PATH
341+
export PATH
342+
;;
316343
esac
317344

318345
if [ -d "$temp_install" ]; then
@@ -556,11 +583,19 @@ do
556583
else
557584
# Start a parallel group
558585
$ECHO_N "parallel group ($# tests): $ECHO_C"
586+
if [ $maxconnections -gt 0 ] ; then
587+
connnum=0
588+
test $# -gt $maxconnections && $ECHO_N "(in groups of $maxconnections) $ECHO_C"
589+
fi
559590
for name do
560591
(
561-
$PSQL -d "$dbname" <"$inputdir/sql/$name.sql" >"$outputdir/results/$name.out" 2>&1
592+
$PSQL -d "$dbname" <"$inputdir/sql/$name.sql" >"$outputdir/results/$name.out" 2>&1
562593
$ECHO_N " $name$ECHO_C"
563594
) &
595+
if [ $maxconnections -gt 0 ] ; then
596+
connnum=`expr \( $connnum + 1 \) % $maxconnections`
597+
test $connnum -eq 0 && wait
598+
fi
564599
done
565600
wait
566601
echo
@@ -593,8 +628,8 @@ do
593628
fi
594629
done
595630

596-
# If there are multiple equally valid result file, loop to get the right one.
597-
# If none match, diff against the closet one.
631+
# If there are multiple equally valid result files, loop to get the right one.
632+
# If none match, diff against the closest one.
598633

599634
bestfile=
600635
bestdiff=

0 commit comments

Comments
 (0)