]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[rt46602] Assign block of ports for each test
authorStephen Morris <stephen@isc.org>
Thu, 23 Nov 2017 09:58:57 +0000 (09:58 +0000)
committerEvan Hunt <each@isc.org>
Sun, 25 Feb 2018 17:22:30 +0000 (09:22 -0800)
Some tests use more ports than just the query and control ports.
Each test that can run in parallel with other tests is now assigned
a unique block of 10 ports.

(cherry picked from commit e0ff77f9d3178d09eb60cf39733ae0c5018ce29d)
(cherry picked from commit df1348ad2bc0a97a79c8b8089dbec8bb4b395f4a)
(cherry picked from commit c64af8abe58855e52bc5fb2e3add42274af8d01f)

bin/tests/system/Makefile.in
bin/tests/system/getopts.sh
bin/tests/system/run.sh

index d87c89de4ebe42f0ea5812bd485e7bfdc28939ec..58c32d19bae67c6b055dee2fc506a691c2767ae3 100644 (file)
@@ -58,19 +58,20 @@ feature-test@EXEEXT@: feature-test.@O@
 PARALLEL = allow_query serve-stale rpzrecurse
 
 # Produce intermediate makefile that assigns unique port numbers to each
-# parallel test.
+# parallel test.  The sequential tests all use ports 5300 (for queries) and
+# 9953 (for control).  For this reason, the parallel tests start at port
+# # 10,000
 
 parallel.mk:
        @echo ".PHONY: $(PARALLEL)" > $@ ; \
        echo "" >> $@ ; \
        echo "check: $(PARALLEL)" >> $@ ; \
-       port=5299 ; \
+       port=9990 ; \
        for directory in $(PARALLEL) ; do \
-               port=$$(($$port + 2)) ; \
-               controlport=$$(($$port + 1)) ; \
+               port=$$(($$port + 10)) ; \
                echo "" >> $@ ; \
                echo "$$directory:" >> $@ ; \
-               echo "  @$(SHELL) ./run.sh -p $$port -c $$controlport $$directory" >> $@ ; \
+               echo "  @$(SHELL) ./run.sh -p $$port $$directory" >> $@ ; \
        done
 
 # Targets to run the tests that can be done in parallel (which have unique
@@ -78,10 +79,10 @@ parallel.mk:
 # they all use query port 5300 and control port 9953).
 
 parallel: parallel.mk
-       $(MAKE) -f parallel.mk
+       @$(MAKE) -f parallel.mk
 
 sequential:
-       if test -f ./runall.sh; then $(SHELL) ./runall.sh; fi
+       @if test -f ./runall.sh; then $(SHELL) ./runall.sh; fi
 
 # Standard targets.
 
index fd615a4ef146e4c4fe9030ed6518d8b8f087bea0..b3ac264b63c12c4596a2841d6deb6acf49cdf594 100644 (file)
@@ -5,25 +5,76 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-# Shell script snippet, must be sourced
+# Shell script snippet, must be sourced.
+#
+# Most system tests require use of at least two ports: the nameserver query
+# port and a port for RNDC access.  In addition, some tests require additional
+# ports (e.g. for tests of transfers between nameservers).
+#
+# To allow tests to run in parallel, each test must be allocated a unique set
+# ports to use.
+#
+# This script is used during testing to parse the "-p" option on the command
+# line invoking scripts used during the test.  The option sets the base of
+# a block of 10 ports used by the test.  A shell symbol is set for each port:
+#
+# port         Port used for queries (default to 5300)
+# aport1       First additional port (set to $port + 1)
+#   :
+# aport8       Eighth additional port (set to $port + 8)
+# controlport  Port used for RNDC (set to $port + 9)
+#
+# The fiule also defines a simple shell function to
 
 port=5300
-controlport=9953
 
-while getopts ":p:c:" flag; do
+while getopts ":p:" flag; do
     case "$flag" in
        p) port=$OPTARG ;;
-       c) controlport=$OPTARG ;;
        -) break ;;
        *) exit 1 ;;
     esac
 done
-
 shift $(($OPTIND - 1))
 OPTIND=1
 
-# Convenience function to copy configuration file, replacing the port numbers
-# during the copy - more readable than embedding a "sed" command in the script.
+# Ensure port is numeric, above 1024 (limit of privileged port) and that
+# the upper of the 10 ports notionally assigned does not exceed 65535.
+
+if [ "$((${port}+0))" != "${port}" ] || [ "${port}" -le 1024 ] || [ "${port}" -gt 65520 ]; then
+    echo "Specified port '$port' must be numeric and in the range 1025 to 65520" >&2
+    exit 1
+fi
+
+aport1=$(($port + 1))
+aport2=$(($port + 2))
+aport3=$(($port + 3))
+aport4=$(($port + 4))
+aport5=$(($port + 5))
+aport6=$(($port + 6))
+aport7=$(($port + 7))
+aport8=$(($port + 8))
+controlport=$(($port + 9))
+
+
+# copy_setports - Copy Configuration File and Replace Ports
+#
+# Convenience function to copy a configuration file, replacing the symbols
+# PORT, CONTROLPORT and APORT[1-8] with the port numbers set by the "-p"
+# option passed to the script.
+#
+# Usage:
+#   copy_setports infile outfile
+
 copy_setports() {
-    sed -e "s/@PORT@/${port}/g" -e "s/@CONTROLPORT@/${controlport}/g" < $1 > $2
+    sed -e "s/@PORT@/${port}/g" \
+        -e "s/@APORT1@/${aport1}/g" \
+        -e "s/@APORT2@/${aport1}/g" \
+        -e "s/@APORT3@/${aport1}/g" \
+        -e "s/@APORT4@/${aport1}/g" \
+        -e "s/@APORT5@/${aport1}/g" \
+        -e "s/@APORT6@/${aport1}/g" \
+        -e "s/@APORT7@/${aport1}/g" \
+        -e "s/@APORT8@/${aport1}/g" \
+        -e "s/@CONTROLPORT@/${controlport}/g" < $1 > $2
 }
index 13e12bafefcf36092288c9ef62aaa2b5ef08eda9..5043126911f17b72a4ca2fd8569edcda13173583 100644 (file)
@@ -24,30 +24,20 @@ SYSTEMTESTTOP=.
 
 stopservers=true
 clean=true
-port=5300
-controlport=9953
+baseport=5300
 dateargs="-R"
 
-while getopts "knp:d:c:" flag; do
+while getopts "knp:d:" flag; do
     case "$flag" in
        k) stopservers=false ;;
        n) clean=false ;;
-       p) port=$OPTARG ;;
-       c) controlport=$OPTARG ;;
+       p) baseport=$OPTARG ;;
        d) dateargs=$OPTARG ;;
        *) exit 1 ;;
     esac
 done
-
-if [ "$((${port}+0))" -ne "${port}" ] || [ "${port}" -le 1024 ] || [ "${port}" -gt 65535 ]; then
-    echo "Specified port '$port' must be numeric (1024,65535>" >&2; exit 1;
-fi
-
-if [ "$((${controlport}+0))" -ne "${controlport}" ] || [ "${controlport}" -le 1024 ] || [ "${controlport}" -gt 65535 ]; then
-    echo "Specified control port '$controlport' must be numeric (1024,65535>" >&2; exit 1;
-fi
-
 shift $(($OPTIND - 1))
+OPTIND=1
 
 test $# -gt 0 || { echo "usage: $0 [-k|-n|-p <PORT>] test-directory" >&2; exit 1; }
 
@@ -56,6 +46,9 @@ shift
 
 test -d $test || { echofail "$0: $test: no such test" >&2; exit 1; }
 
+# Validate the port number and obtain other port numbers.
+. $SYSTEMTESTTOP/getopts.sh -p "$baseport"
+
 echoinfo "S:$test:`date $dateargs`" >&2
 echoinfo "T:$test:1:A" >&2
 echoinfo "A:$test:System test $test" >&2
@@ -64,14 +57,14 @@ echoinfo "I:$test:CONTROLPORT:${controlport}" >&2
 
 if [ x${PERL:+set} = x ]
 then
-    echowarn "I:Perl not available.  Skipping test." >&2
+    echowarn "I:$test:Perl not available.  Skipping test." >&2
     echowarn "R:$test:UNTESTED" >&2
     echoinfo "E:$test:`date $dateargs`" >&2
     exit 0;
 fi
 
 # Check for test-specific prerequisites.
-test ! -f $test/prereq.sh || ( cd $test && $SHELL prereq.sh -c "$controlport" -p "$port" -- "$@" )
+test ! -f $test/prereq.sh || ( cd $test && $SHELL prereq.sh -p "$port" -- "$@" )
 result=$?
 
 if [ $result -eq 0 ]; then
@@ -106,15 +99,14 @@ fi
 # Set up any dynamically generated test data
 if test -f $test/setup.sh
 then
-   ( cd $test && $SHELL setup.sh -c "$controlport" -p "$port" -- "$@" )
+   ( cd $test && $SHELL setup.sh -p "$port" -- "$@" )
 fi
 
 # Start name servers running
 $PERL start.pl -p $port $test || { echofail "R:$test:FAIL"; echoinfo "E:$test:`date $dateargs`"; exit 1; }
 
 # Run the tests
-( cd $test ; $SHELL tests.sh -c "$controlport" -p "$port" -- "$@" )
-
+( cd $test ; $SHELL tests.sh -p "$port" -- "$@" )
 status=$?
 
 if $stopservers