[rt46602] Assign block of ports for each test

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.
This commit is contained in:
Stephen Morris
2017-11-23 09:58:57 +00:00
parent 07341693e1
commit e0ff77f9d3
3 changed files with 78 additions and 34 deletions

View File

@@ -50,19 +50,20 @@ feature-test@EXEEXT@: feature-test.@O@
PARALLEL = allow_query catz 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
@@ -70,10 +71,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.

View 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
}

View File

@@ -15,30 +15,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; }
@@ -47,6 +37,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
@@ -55,14 +48,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
@@ -97,15 +90,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