From e7429b124bd3d0fcce107eaf790ece4ba332eccd Mon Sep 17 00:00:00 2001 From: Stephen Morris Date: Fri, 17 Nov 2017 13:21:05 +0000 Subject: [PATCH] [rt46602] Ensure that tests running in parallel use unique ports Via an intermediate make file, tests that have been modified to be able to run in parallel are assigned unique query and control port numbers (other than 5300 and 9953 respectively). Tests that have not yet been modified all use ports 5300 and 9953, so must be run sequentially. --- bin/tests/system/Makefile.in | 52 +++++++++++++++++++++++++--------- bin/tests/system/conf.sh.in | 18 +++++++++++- bin/tests/system/conf.sh.win32 | 13 ++++++++- bin/tests/system/runall.sh | 6 +++- 4 files changed, 72 insertions(+), 17 deletions(-) diff --git a/bin/tests/system/Makefile.in b/bin/tests/system/Makefile.in index 8af2b5d8a9..ebae70b96f 100644 --- a/bin/tests/system/Makefile.in +++ b/bin/tests/system/Makefile.in @@ -40,26 +40,52 @@ feature-test@EXEEXT@: feature-test.@O@ ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ feature-test.@O@ ${ISCLIBS} ${LIBS} -# Running the scripts below is bypassed when a separate -# build directory is used. +# Running the scripts below is bypassed when a separate # build directory is +# used. + +# Define the tests that can be run in parallel. This should be identical to +# the definition of PARALLELDIRS in conf.sh. These tests do not use query +# port 5300 or control port 9953. + +PARALLEL = allow_query serve-stale rpzrecurse + +# Produce intermediate makefile that assigns unique port numbers to each +# parallel test. + +parallel.mk: + @echo ".PHONY: $(PARALLEL)" > $@ ; \ + echo "" >> $@ ; \ + echo "check: $(PARALLEL)" >> $@ ; \ + port=5299 ; \ + for directory in $(PARALLEL) ; do \ + port=$$(($$port + 2)) ; \ + controlport=$$(($$port + 1)) ; \ + echo "" >> $@ ; \ + echo "$$directory:" >> $@ ; \ + echo " @$(SHELL) ./run.sh -p $$port -c $$controlport $$directory" >> $@ ; \ + done + +# Targets to run the tests that can be done in parallel (which have unique +# ports assigned to them) and the tests which must be run sequentially (because +# they all use query port 5300 and control port 9953). + +parallel: parallel.mk + $(MAKE) -f parallel.mk + +sequential: + if test -f ./runall.sh; then $(SHELL) ./runall.sh; fi + +# Standard targets. check: test -TESTS = allow_query serve-stale rpzrecurse alltests - -test: subdirs $(TESTS) - -alltests: - if test -f ./runall.sh; then $(SHELL) ./runall.sh; fi - -$(TESTS): - PORT=$$((32767+$$RANDOM)); \ - $(SHELL) ./run.sh -p $$(($$PORT)) -c $$(($$PORT+1)) $@ +test: parallel sequential testclean clean distclean:: if test -f ./cleanall.sh; then sh ./cleanall.sh; fi rm -f systests.output rm -f random.data + rm -f parallel.mk rm -f ${TARGETS} rm -f ${OBJS} @@ -71,5 +97,3 @@ installdirs: install:: uninstall:: - -.PHONY: $(TESTS) diff --git a/bin/tests/system/conf.sh.in b/bin/tests/system/conf.sh.in index bc553905c8..9bbfe2ceb1 100644 --- a/bin/tests/system/conf.sh.in +++ b/bin/tests/system/conf.sh.in @@ -72,7 +72,10 @@ KRB5_CONFIG=/dev/null # The "stress" test is not run by default since it creates enough # load on the machine to make it unusable to other users. # v6synth -SUBDIRS="acl additional addzone auth autosign builtin +# +# List of tests that use ports 5300 and 9953. For this reason, these must +# be run sequentially. +SEQUENTIALDIRS="acl additional addzone auth autosign builtin cacheclean case catz cds chain checkconf @CHECKDS@ checknames checkzone cookie @COVERAGE@ database digdelv dlv dlz dlzexternal @@ -88,6 +91,15 @@ SUBDIRS="acl additional addzone auth autosign builtin tsig tsiggss unknown upforwd verify views wildcard xfer xferquota zero zonechecks" +# List of tests that use unique ports (other than 5300 and 9953). These +# tests can be run in parallel. +# +# This symbol must be kept in step with the PARALLEL macro in Makefile.in +PARALLELDIRS="allow_query rps-recurse serve-stale" + +SUBDIRS="$SEQUENTIALDIRS $PARALLELDIRS" + + # Things that are different on Windows KILL=kill DIFF=diff @@ -191,6 +203,10 @@ fi TESTNAME="`basename $PWD`" echo_i() { + # Without formatting + echo "I:$TESTNAME:$@" >> test.output + + # With formatting echoinfo "I:$TESTNAME:$@" } diff --git a/bin/tests/system/conf.sh.win32 b/bin/tests/system/conf.sh.win32 index 492fbb81d2..2fd9fafa1d 100644 --- a/bin/tests/system/conf.sh.win32 +++ b/bin/tests/system/conf.sh.win32 @@ -79,7 +79,10 @@ KRB5_CONFIG=NUL # The "stress" test is not run by default since it creates enough # load on the machine to make it unusable to other users. # v6synth -SUBDIRS="acl additional addzone autosign builtin +# +# List of tests that use ports 5300 and 9953. For this reason, these must +# be run sequentially. +SEQUENTIALDIRS="acl additional addzone autosign builtin cacheclean case catz checkconf @CHECKDS@ checknames checkzone cookie @COVERAGE@ database digdelv dlv dlvauto dlz dlzexternal dname @@ -95,6 +98,14 @@ SUBDIRS="acl additional addzone autosign builtin tsiggss unknown upforwd verify views wildcard xfer xferquota zero zonechecks" +# List of tests that use unique ports (other than 5300 and 9953). These +# tests can be run in parallel. +# +# This symbol must be kept in step with the PARALLEL macro in Makefile.in +PARALLELDIRS="allow_query rpzrecurse serve-stale" + +SUBDIRS="$SEQUENTIALDIRS $PARALLELDIRS" + # missing: chain integrity # extra: dname ednscompliance forward diff --git a/bin/tests/system/runall.sh b/bin/tests/system/runall.sh index a03166978e..315caf67c0 100644 --- a/bin/tests/system/runall.sh +++ b/bin/tests/system/runall.sh @@ -9,6 +9,10 @@ # # Run all the system tests. # +# Note: Use "make check" to run all the system tests. This script will just +# run those tests that require that each of their nameservers is the only one +# running on an IP address. +# SYSTEMTESTTOP=. . $SYSTEMTESTTOP/conf.sh @@ -16,7 +20,7 @@ SYSTEMTESTTOP=. status=0 { - for d in $SUBDIRS + for d in $SEQUENTIALDIRS do $SHELL run.sh "${@}" $d || status=1 done