From 78f2b9ca01143dd20b543a8ea360338f28c4ba78 Mon Sep 17 00:00:00 2001 From: Stephen Morris Date: Fri, 17 Nov 2017 17:29:21 +0000 Subject: [PATCH] [rt46602] Miscellaneous changes to existing parallelised tests Currently these tests are allow_query, rpzrecurse and serve-stale 1. Function to copy files and set port numbers renamed from copy_config to copy_setports, as this is used to change the ports in Perl and Python test scripts as well. 2. Changes to rpzrecurse/tests.sh to handle two calls to getopts (one to parse port numbers, the other to parse rpzrecurse-specific options). Also fixed various commands to use correct ports. 3. Updates to "clean.sh" scripts to ensure that all files created in the test are removed. --- bin/tests/system/allow_query/clean.sh | 1 + bin/tests/system/allow_query/setup.sh | 4 +- bin/tests/system/allow_query/tests.sh | 62 +++++++++++++-------------- bin/tests/system/conf.sh.in | 8 +++- bin/tests/system/getopts.sh | 5 ++- bin/tests/system/rpzrecurse/clean.sh | 13 ++++-- bin/tests/system/rpzrecurse/setup.sh | 24 +++++++---- bin/tests/system/run.sh | 6 +-- bin/tests/system/serve-stale/clean.sh | 1 + bin/tests/system/serve-stale/setup.sh | 6 +-- bin/tests/system/serve-stale/tests.sh | 2 +- 11 files changed, 77 insertions(+), 55 deletions(-) diff --git a/bin/tests/system/allow_query/clean.sh b/bin/tests/system/allow_query/clean.sh index 15c4ee833a..0301c3d1e2 100644 --- a/bin/tests/system/allow_query/clean.sh +++ b/bin/tests/system/allow_query/clean.sh @@ -12,6 +12,7 @@ # Clean up after allow query tests. # +rm -f test.output rm -f dig.out.* rm -f ns2/named.conf ns2/named.port ns2/controls.conf rm -f */named.memstats diff --git a/bin/tests/system/allow_query/setup.sh b/bin/tests/system/allow_query/setup.sh index 53f030681b..3e14f3533a 100644 --- a/bin/tests/system/allow_query/setup.sh +++ b/bin/tests/system/allow_query/setup.sh @@ -10,6 +10,6 @@ . ../getopts.sh -copy_config ../common/controls.conf.in ns2/controls.conf -copy_config ns2/named01.conf.in ns2/named.conf +copy_setports ../common/controls.conf.in ns2/controls.conf +copy_setports ns2/named01.conf.in ns2/named.conf echo "${port}" > ns2/named.port diff --git a/bin/tests/system/allow_query/tests.sh b/bin/tests/system/allow_query/tests.sh index b8a7ea2749..58a4c37369 100644 --- a/bin/tests/system/allow_query/tests.sh +++ b/bin/tests/system/allow_query/tests.sh @@ -75,7 +75,7 @@ status=`expr $status + $ret` # Test 2 - explicit any, query allowed n=`expr $n + 1` -copy_config ns2/named02.conf.in ns2/named.conf +copy_setports ns2/named02.conf.in ns2/named.conf rndc_reload sleep 5 @@ -89,7 +89,7 @@ status=`expr $status + $ret` # Test 3 - none, query refused n=`expr $n + 1` -copy_config ns2/named03.conf.in ns2/named.conf +copy_setports ns2/named03.conf.in ns2/named.conf rndc_reload sleep 5 @@ -103,7 +103,7 @@ status=`expr $status + $ret` # Test 4 - address allowed, query allowed n=`expr $n + 1` -copy_config ns2/named04.conf.in ns2/named.conf +copy_setports ns2/named04.conf.in ns2/named.conf rndc_reload sleep 5 @@ -117,7 +117,7 @@ status=`expr $status + $ret` # Test 5 - address not allowed, query refused n=`expr $n + 1` -copy_config ns2/named05.conf.in ns2/named.conf +copy_setports ns2/named05.conf.in ns2/named.conf rndc_reload sleep 5 @@ -131,7 +131,7 @@ status=`expr $status + $ret` # Test 6 - address disallowed, query refused n=`expr $n + 1` -copy_config ns2/named06.conf.in ns2/named.conf +copy_setports ns2/named06.conf.in ns2/named.conf rndc_reload sleep 5 @@ -145,7 +145,7 @@ status=`expr $status + $ret` # Test 7 - acl allowed, query allowed n=`expr $n + 1` -copy_config ns2/named07.conf.in ns2/named.conf +copy_setports ns2/named07.conf.in ns2/named.conf rndc_reload sleep 5 @@ -159,7 +159,7 @@ status=`expr $status + $ret` # Test 8 - acl not allowed, query refused n=`expr $n + 1` -copy_config ns2/named08.conf.in ns2/named.conf +copy_setports ns2/named08.conf.in ns2/named.conf rndc_reload sleep 5 @@ -174,7 +174,7 @@ status=`expr $status + $ret` # Test 9 - acl disallowed, query refused n=`expr $n + 1` -copy_config ns2/named09.conf.in ns2/named.conf +copy_setports ns2/named09.conf.in ns2/named.conf rndc_reload sleep 5 @@ -188,7 +188,7 @@ status=`expr $status + $ret` # Test 10 - key allowed, query allowed n=`expr $n + 1` -copy_config ns2/named10.conf.in ns2/named.conf +copy_setports ns2/named10.conf.in ns2/named.conf rndc_reload sleep 5 @@ -202,7 +202,7 @@ status=`expr $status + $ret` # Test 11 - key not allowed, query refused n=`expr $n + 1` -copy_config ns2/named11.conf.in ns2/named.conf +copy_setports ns2/named11.conf.in ns2/named.conf rndc_reload sleep 5 @@ -216,7 +216,7 @@ status=`expr $status + $ret` # Test 12 - key disallowed, query refused n=`expr $n + 1` -copy_config ns2/named12.conf.in ns2/named.conf +copy_setports ns2/named12.conf.in ns2/named.conf rndc_reload sleep 5 @@ -233,7 +233,7 @@ status=`expr $status + $ret` n=20 # Test 21 - views default, query allowed n=`expr $n + 1` -copy_config ns2/named21.conf.in ns2/named.conf +copy_setports ns2/named21.conf.in ns2/named.conf rndc_reload sleep 5 @@ -247,7 +247,7 @@ status=`expr $status + $ret` # Test 22 - views explicit any, query allowed n=`expr $n + 1` -copy_config ns2/named22.conf.in ns2/named.conf +copy_setports ns2/named22.conf.in ns2/named.conf rndc_reload sleep 5 @@ -261,7 +261,7 @@ status=`expr $status + $ret` # Test 23 - views none, query refused n=`expr $n + 1` -copy_config ns2/named23.conf.in ns2/named.conf +copy_setports ns2/named23.conf.in ns2/named.conf rndc_reload sleep 5 @@ -275,7 +275,7 @@ status=`expr $status + $ret` # Test 24 - views address allowed, query allowed n=`expr $n + 1` -copy_config ns2/named24.conf.in ns2/named.conf +copy_setports ns2/named24.conf.in ns2/named.conf rndc_reload sleep 5 @@ -289,7 +289,7 @@ status=`expr $status + $ret` # Test 25 - views address not allowed, query refused n=`expr $n + 1` -copy_config ns2/named25.conf.in ns2/named.conf +copy_setports ns2/named25.conf.in ns2/named.conf rndc_reload sleep 5 @@ -303,7 +303,7 @@ status=`expr $status + $ret` # Test 26 - views address disallowed, query refused n=`expr $n + 1` -copy_config ns2/named26.conf.in ns2/named.conf +copy_setports ns2/named26.conf.in ns2/named.conf rndc_reload sleep 5 @@ -317,7 +317,7 @@ status=`expr $status + $ret` # Test 27 - views acl allowed, query allowed n=`expr $n + 1` -copy_config ns2/named27.conf.in ns2/named.conf +copy_setports ns2/named27.conf.in ns2/named.conf rndc_reload sleep 5 @@ -331,7 +331,7 @@ status=`expr $status + $ret` # Test 28 - views acl not allowed, query refused n=`expr $n + 1` -copy_config ns2/named28.conf.in ns2/named.conf +copy_setports ns2/named28.conf.in ns2/named.conf rndc_reload sleep 5 @@ -345,7 +345,7 @@ status=`expr $status + $ret` # Test 29 - views acl disallowed, query refused n=`expr $n + 1` -copy_config ns2/named29.conf.in ns2/named.conf +copy_setports ns2/named29.conf.in ns2/named.conf rndc_reload sleep 5 @@ -359,7 +359,7 @@ status=`expr $status + $ret` # Test 30 - views key allowed, query allowed n=`expr $n + 1` -copy_config ns2/named30.conf.in ns2/named.conf +copy_setports ns2/named30.conf.in ns2/named.conf rndc_reload sleep 5 @@ -373,7 +373,7 @@ status=`expr $status + $ret` # Test 31 - views key not allowed, query refused n=`expr $n + 1` -copy_config ns2/named31.conf.in ns2/named.conf +copy_setports ns2/named31.conf.in ns2/named.conf rndc_reload sleep 5 @@ -387,7 +387,7 @@ status=`expr $status + $ret` # Test 32 - views key disallowed, query refused n=`expr $n + 1` -copy_config ns2/named32.conf.in ns2/named.conf +copy_setports ns2/named32.conf.in ns2/named.conf rndc_reload sleep 5 @@ -401,7 +401,7 @@ status=`expr $status + $ret` # Test 33 - views over options, views allow, query allowed n=`expr $n + 1` -copy_config ns2/named33.conf.in ns2/named.conf +copy_setports ns2/named33.conf.in ns2/named.conf rndc_reload sleep 5 @@ -415,7 +415,7 @@ status=`expr $status + $ret` # Test 34 - views over options, views disallow, query refused n=`expr $n + 1` -copy_config ns2/named34.conf.in ns2/named.conf +copy_setports ns2/named34.conf.in ns2/named.conf rndc_reload sleep 5 @@ -433,7 +433,7 @@ n=40 # Test 41 - zone default, query allowed n=`expr $n + 1` -copy_config ns2/named40.conf.in ns2/named.conf +copy_setports ns2/named40.conf.in ns2/named.conf rndc_reload sleep 5 @@ -557,7 +557,7 @@ status=`expr $status + $ret` # Test 53 - zones over options, zones allow, query allowed n=`expr $n + 1` -copy_config ns2/named53.conf.in ns2/named.conf +copy_setports ns2/named53.conf.in ns2/named.conf rndc_reload sleep 5 @@ -571,7 +571,7 @@ status=`expr $status + $ret` # Test 54 - zones over options, zones disallow, query refused n=`expr $n + 1` -copy_config ns2/named54.conf.in ns2/named.conf +copy_setports ns2/named54.conf.in ns2/named.conf rndc_reload sleep 5 @@ -585,7 +585,7 @@ status=`expr $status + $ret` # Test 55 - zones over views, zones allow, query allowed n=`expr $n + 1` -copy_config ns2/named55.conf.in ns2/named.conf +copy_setports ns2/named55.conf.in ns2/named.conf rndc_reload sleep 5 @@ -599,7 +599,7 @@ status=`expr $status + $ret` # Test 56 - zones over views, zones disallow, query refused n=`expr $n + 1` -copy_config ns2/named56.conf.in ns2/named.conf +copy_setports ns2/named56.conf.in ns2/named.conf rndc_reload sleep 5 @@ -613,7 +613,7 @@ status=`expr $status + $ret` # Test 57 - zones over views, zones disallow, query refused (allow-query-on) n=`expr $n + 1` -copy_config ns2/named57.conf.in ns2/named.conf +copy_setports ns2/named57.conf.in ns2/named.conf rndc_reload sleep 5 diff --git a/bin/tests/system/conf.sh.in b/bin/tests/system/conf.sh.in index 9bbfe2ceb1..2c65b721d7 100644 --- a/bin/tests/system/conf.sh.in +++ b/bin/tests/system/conf.sh.in @@ -160,6 +160,7 @@ if test -t 1 && type tput > /dev/null 2>&1 ; then COLOR_FAIL=`tput setaf 1` # red COLOR_WARN=`tput setaf 3` # yellow COLOR_PASS=`tput setaf 2` # green + COLOR_STEN=`tput setaf 4` # blue COLOR_INFO=`tput bold` # bold COLOR_NONE=`tput sgr0` else @@ -167,6 +168,7 @@ else COLOR_FAIL='' COLOR_WARN='' COLOR_PASS='' + COLOR_STEN='' COLOR_INFO='' COLOR_NONE='' fi @@ -183,7 +185,11 @@ then printf "${COLOR_PASS}%s${COLOR_NONE}\n" "$*" } echoinfo () { - printf "${COLOR_INFO}%s${COLOR_NONE}\n" "$*" + COLOR=$COLOR_INFO + case "$1" in + S:*|E:*) COLOR=${COLOR}${COLOR_STEN} ;; # Start/end messages + esac + printf "${COLOR}%s${COLOR_NONE}\n" "$*" } else echofail () { diff --git a/bin/tests/system/getopts.sh b/bin/tests/system/getopts.sh index cdb0922a53..fd615a4ef1 100644 --- a/bin/tests/system/getopts.sh +++ b/bin/tests/system/getopts.sh @@ -5,7 +5,7 @@ # 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 port=5300 controlport=9953 @@ -18,11 +18,12 @@ while getopts ":p:c:" flag; do *) 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. -copy_config() { +copy_setports() { sed -e "s/@PORT@/${port}/g" -e "s/@CONTROLPORT@/${controlport}/g" < $1 > $2 } diff --git a/bin/tests/system/rpzrecurse/clean.sh b/bin/tests/system/rpzrecurse/clean.sh index ea04f0b879..d339d67e30 100644 --- a/bin/tests/system/rpzrecurse/clean.sh +++ b/bin/tests/system/rpzrecurse/clean.sh @@ -6,15 +6,22 @@ # Clean up after rpz tests. +rm -f test.output rm -f dig.out.* + rm -f ns*/named.lock rm -f ns*/named.memstats rm -f ns*/*.run +rm -f ns*/named.port +rm -f ns*/*core *core +rm -f ns*/named.conf + rm -f ns2/*.local rm -f ns2/*.queries rm -f ns2/named.[0-9]*.conf -rm -f ns2/named.conf -rm -f ns3/named.conf -rm -f ns*/*core *core +rm -f ns2/named.conf.header + +rm -f ans4/ans.pl + rm -f dnsrps*.conf dnsrpzd* rm -f ns*/session.key diff --git a/bin/tests/system/rpzrecurse/setup.sh b/bin/tests/system/rpzrecurse/setup.sh index dba93e35d2..a1c890d5ff 100644 --- a/bin/tests/system/rpzrecurse/setup.sh +++ b/bin/tests/system/rpzrecurse/setup.sh @@ -12,15 +12,14 @@ set -e SYSTEMTESTTOP=.. . $SYSTEMTESTTOP/conf.sh - -. ../getopts.sh +. $SYSTEMTESTTOP/getopts.sh USAGE="$0: [-xD]" DEBUG= while getopts "xD" c; do case $c in x) set -x; DEBUG=-x;; - D) TEST_DNSRPS="-D";; + D) TEST_DNSRPS="-D";; N) NOCLEAN=set;; *) echo "$USAGE" 1>&2; exit 1;; esac @@ -30,20 +29,27 @@ if test "$#" -ne 0; then echo "$USAGE" 1>&2 exit 1 fi +OPTIND=1 [ ${NOCLEAN:-unset} = unset ] && $SHELL clean.sh $DEBUG $PERL testgen.pl -$SEDPORTS < ns1/named.conf.in > ns1/named.conf + +copy_setports ns1/named.conf.in ns1/named.conf echo "${port}" > ns1/named.port -$SEDPORTS < ns2/named.conf.header.in > ns2/named.conf.header + +copy_setports ns2/named.conf.header.in ns2/named.conf.header echo "${port}" > ns2/named.port -cp -f ns2/named.default.conf ns2/named.conf -$SEDPORTS < ns3/named1.conf.in > ns3/named.conf + +copy_setports ns2/named.default.conf ns2/named.conf + +copy_setports ns3/named1.conf.in ns3/named.conf echo "${port}" > ns3/named.port -$SEDPORTS < ns4/named.conf.in > ns4/named.conf + +copy_setports ns4/named.conf.in ns4/named.conf echo "${port}" > ns4/named.port -$SEDPORTS < ans5/ans.pl.in > ans5/ans.pl + +copy_setports ans5/ans.pl.in ans5/ans.pl # decide whether to test DNSRPS $SHELL ../rpz/ckdnsrps.sh $TEST_DNSRPS $DEBUG diff --git a/bin/tests/system/run.sh b/bin/tests/system/run.sh index f26743cf4a..e30e120227 100644 --- a/bin/tests/system/run.sh +++ b/bin/tests/system/run.sh @@ -68,7 +68,7 @@ result=$? if [ $result -eq 0 ]; then : prereqs ok else - echowarn "I:Prerequisites for $test missing, skipping test." >&2 + echowarn "I:$test:Prerequisites missing, skipping test." >&2 [ $result -eq 255 ] && echowarn "R:$test:SKIPPED" || echowarn "R:$test:UNTESTED" echoinfo "E:$test:`date $dateargs`" >&2 exit 0 @@ -76,7 +76,7 @@ fi # Test sockets after the prerequisites has been setup $PERL testsock.pl -p "${port}" || { - echowarn "I:Network interface aliases not set up. Skipping test." >&2; + echowarn "I:$test:Network interface aliases not set up. Skipping test." >&2; echowarn "R:$test:UNTESTED" >&2; echoinfo "E:$test:`date $dateargs`" >&2; exit 0; @@ -88,7 +88,7 @@ if then : pkcs11 ok else - echowarn "I:Need PKCS#11 for $test, skipping test." >&2 + echowarn "I:$test:Need PKCS#11, skipping test." >&2 echowarn "R:$test:PKCS11ONLY" >&2 echoinfo "E:$test:`date $dateargs`" >&2 exit 0 diff --git a/bin/tests/system/serve-stale/clean.sh b/bin/tests/system/serve-stale/clean.sh index 5d073079d3..e2efb77bf2 100644 --- a/bin/tests/system/serve-stale/clean.sh +++ b/bin/tests/system/serve-stale/clean.sh @@ -4,6 +4,7 @@ # 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/. +rm -f test.output rm -f dig.out.test* rm -f ns1/named.conf ns1/named.port rm -f ans2/ans.pl ans2/named.port diff --git a/bin/tests/system/serve-stale/setup.sh b/bin/tests/system/serve-stale/setup.sh index 5526340990..1e05053348 100644 --- a/bin/tests/system/serve-stale/setup.sh +++ b/bin/tests/system/serve-stale/setup.sh @@ -7,11 +7,11 @@ . ../getopts.sh -copy_config ns1/named1.conf.in ns1/named.conf +copy_setports ns1/named1.conf.in ns1/named.conf echo "${port}" > ns1/named.port -copy_config ans2/ans.pl.in ans2/ans.pl +copy_setports ans2/ans.pl.in ans2/ans.pl echo "${port}" > ans2/named.port -copy_config ns3/named.conf.in ns3/named.conf +copy_setports ns3/named.conf.in ns3/named.conf echo "${port}" > ns3/named.port diff --git a/bin/tests/system/serve-stale/tests.sh b/bin/tests/system/serve-stale/tests.sh index c7e2d0f30c..7985433326 100755 --- a/bin/tests/system/serve-stale/tests.sh +++ b/bin/tests/system/serve-stale/tests.sh @@ -335,7 +335,7 @@ status=`expr $status + $ret` n=`expr $n + 1` echo_i "updating ns1/named.conf ($n)" ret=0 -$SEDPORTS < ns1/named2.conf.in > ns1/named.conf +copy_setports ns1/named2.conf.in ns1/named.conf if [ $ret != 0 ]; then echo_i "failed"; fi status=`expr $status + $ret`