Provide a way to run the parallel regression tests with a user-specified
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 2 Nov 2003 21:56:15 +0000 (21:56 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 2 Nov 2003 21:56:15 +0000 (21:56 +0000)
limit on the number of simultaneous connections.  Andrew Dunstan, with
review by Tom Lane.

doc/src/sgml/regress.sgml
src/test/regress/GNUmakefile
src/test/regress/pg_regress.sh

index 768f0cf6ea05871bd32e314bdb0c8fbeacc740b0..693a758373550605d67b211a396a0d4d8b114c9c 100644 (file)
@@ -1,4 +1,4 @@
-<!-- $Header: /cvsroot/pgsql/doc/src/sgml/regress.sgml,v 1.34 2003/09/12 22:17:23 tgl Exp $ -->
+<!-- $Header: /cvsroot/pgsql/doc/src/sgml/regress.sgml,v 1.35 2003/11/02 21:56:14 tgl Exp $ -->
 
  <chapter id="regress">
   <title id="regress-title">Regression Tests</title>
@@ -52,18 +52,18 @@ gmake check
 <screen>
 <computeroutput>
 ======================
- All 77 tests passed.
+ All 93 tests passed.
 ======================
 </computeroutput>
 </screen>
-   or otherwise a note about what tests failed.  See <xref
+   or otherwise a note about which tests failed.  See <xref
    linkend="regress-evaluation"> below for more.
   </para>
 
   <note>
    <para>
     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
    <para>
     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 <application>psql</>,
-    and usually a shell parent process for the <application>psql</> for each test script.
+    scripts, which means sixty processes: there's a server process, a
+    <application>psql</>, and usually a shell parent process for the
+    <application>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
-    <filename>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 <literal>MAX_CONNECTIONS</> parameter.  For example,
+<screen>
+gmake MAX_CONNECTIONS=10 check
+</screen>
+    runs no more than ten tests concurrently.
    </para>
   </tip>
 
@@ -109,8 +113,8 @@ gmake check
 <screen>
 gmake SHELL=/bin/ksh check
 </screen>
-    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.
    </para>
   </tip>
 
@@ -177,7 +181,7 @@ gmake installcheck
 
     <para>
      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
      <literal><replaceable>testname</>_<replaceable>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 <xref linkend="regress-platform">
      should be used instead.
     </para>
@@ -245,7 +249,7 @@ env TZ=PST8PDT date
 </screen>
      The command above should have returned the current system time in
      the <literal>PST8PDT</literal> time zone. If the <literal>PST8PDT</literal> 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
      <literal>PST8PDT</literal> time zone is missing, you can set the time zone
      rules explicitly:
 <programlisting>
@@ -364,7 +368,7 @@ diff results/random.out expected/random.out
     which comparison file to use.  So, to eliminate bogus test
     <quote>failures</quote> for a particular platform, you must choose
     or make a variant result file, and then add a line to the mapping
-    file, which is <filename>resultmap</filename>.
+    file, which is <filename>src/test/regress/resultmap</filename>.
    </para>
 
    <para>
index 5279204b3b622540be0d3539ec53490e670bad62..eb54dce64b600dbd773763e209b020cc34fea994 100644 (file)
@@ -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
 
 
 ##
index 89eca9586657247eb75f9fdde5fb671cc2f55cd3..dfa57467c104f04469e7f18b4073f2c1798a3624 100644 (file)
@@ -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=