]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Light refactoring of the fetchlimit system test
authorAram Sargsyan <aram@isc.org>
Mon, 29 May 2023 17:34:13 +0000 (17:34 +0000)
committerAram Sargsyan <aram@isc.org>
Tue, 6 Jun 2023 12:45:00 +0000 (12:45 +0000)
Prepare the fetchlimit system test for adding a clients-per-query
check. Change some functions and commands to accept a destination
NS IP address instead of using the hardcoded 10.53.0.3.

(cherry picked from commit 7ebd055c7849f190fdfba99a6e8697f80f917136)

bin/tests/system/fetchlimit/tests.sh

index 0e3aadd4062b32f975e5a757059671004375f432..e1b74e44c8ef1cced328e816de492bce27cd635d 100644 (file)
 . ../conf.sh
 
 DIGCMD="$DIG @10.53.0.3 -p ${PORT} +tcp +tries=1 +time=1"
-RNDCCMD="$RNDC -p ${CONTROLPORT} -s 10.53.0.3 -c ../common/rndc.conf"
+
+rndccmd() (
+    "$RNDC" -c ../common/rndc.conf -p "${CONTROLPORT}" -s "$@"
+)
 
 burst() {
-    num=${3:-20}
+    server=${1}
+    num=${4:-20}
     rm -f burst.input.$$
     while [ $num -gt 0 ]; do
         num=$((num-1))
-        echo "${num}${1}${2}.lamesub.example A" >> burst.input.$$
+        if [ "${5}" == "dup" ]; then
+            # burst with duplicate queries
+            echo "${2}${3}.lamesub.example A" >> burst.input.$$
+        else
+            # burst with unique queries
+            echo "${num}${2}${3}.lamesub.example A" >> burst.input.$$
+        fi
     done
-    $PERL ../ditch.pl -p ${PORT} -s 10.53.0.3 burst.input.$$
+    $PERL ../ditch.pl -p ${PORT} -s ${server} burst.input.$$
     rm -f burst.input.$$
 }
 
 stat() {
-    clients=`$RNDCCMD status | grep "recursive clients" | 
+    clients=`rndccmd ${1} status | grep "recursive clients" | 
             sed 's;.*: \([^/][^/]*\)/.*;\1;'`
     echo_i "clients: $clients"
     [ "$clients" = "" ] && return 1
-    [ "$clients" -ge $1 ] || return 1
-    [ "$clients" -le $2 ] || return 1
+    [ "$clients" -ge $2 ] || return 1
+    [ "$clients" -le $3 ] || return 1
     return 0
 }
 
@@ -44,15 +54,15 @@ n=$((n + 1))
 echo_i "checking recursing clients are dropped at the per-server limit ($n)"
 ret=0
 # make the server lame and restart
-$RNDCCMD flush
+rndccmd 10.53.0.3 flush
 touch ans4/norespond
 for try in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
-    burst a $try
+    burst 10.53.0.3 a $try
     # fetches-per-server is at 400, but at 20qps against a lame server,
     # we'll reach 200 at the tenth second, and the quota should have been
     # tuned to less than that by then.
     [ $try -le 5 ] && low=$((try*10))
-    stat 20 200 || ret=1
+    stat 10.53.0.3 20 200 || ret=1
     [ $ret -eq 1 ] && break
     sleep 1
 done
@@ -62,7 +72,7 @@ status=$((status+ret))
 n=$((n + 1))
 echo_i "dumping ADB data ($n)"
 ret=0
-$RNDCCMD dumpdb -adb
+rndccmd 10.53.0.3 dumpdb -adb
 info=`grep '10.53.0.4' ns3/named_dump.db | sed 's/.*\(atr [.0-9]*\).*\(quota [0-9]*\).*/\1 \2/'`
 echo_i $info
 set -- $info
@@ -75,7 +85,7 @@ n=$((n + 1))
 echo_i "checking servfail statistics ($n)"
 ret=0
 rm -f ns3/named.stats
-$RNDCCMD stats
+rndccmd 10.53.0.3 stats
 for try in 1 2 3 4 5; do
     [ -f ns3/named.stats ] && break
     sleep 1
@@ -91,10 +101,10 @@ status=$((status+ret))
 n=$((n + 1))
 echo_i "checking lame server recovery ($n)"
 ret=0
-rm -f ans4/norespond
+test -f ans4/norespond && rm -f ans4/norespond
 for try in 1 2 3 4 5; do
-    burst b $try
-    stat 0 200 || ret=1
+    burst 10.53.0.3 b $try
+    stat 10.53.0.3 0 200 || ret=1
     [ $ret -eq 1 ] && break
     sleep 1
 done
@@ -104,7 +114,7 @@ status=$((status+ret))
 n=$((n + 1))
 echo_i "dumping ADB data ($n)"
 ret=0
-$RNDCCMD dumpdb -adb
+rndccmd 10.53.0.3 dumpdb -adb
 info=`grep '10.53.0.4' ns3/named_dump.db | sed 's/.*\(atr [.0-9]*\).*\(quota [0-9]*\).*/\1 \2/'`
 echo_i $info
 set -- $info
@@ -117,8 +127,8 @@ n=$((n + 1))
 echo_i "checking lame server recovery (continued) ($n)"
 ret=0
 for try in 1 2 3 4 5 6 7 8 9 10; do
-    burst c $try
-    stat 0 20 || ret=1
+    burst 10.53.0.3 c $try
+    stat 10.53.0.3 0 20 || ret=1
     [ $ret -eq 1 ] && break
     sleep 1
 done
@@ -128,7 +138,7 @@ status=$((status+ret))
 n=$((n + 1))
 echo_i "dumping ADB data ($n)"
 ret=0
-$RNDCCMD dumpdb -adb
+rndccmd 10.53.0.3 dumpdb -adb
 info=`grep '10.53.0.4' ns3/named_dump.db | sed 's/.*\(atr [.0-9]*\).*\(quota [0-9]*\).*/\1 \2/'`
 echo_i $info
 set -- $info
@@ -147,15 +157,15 @@ fail=0
 success=0
 touch ans4/norespond
 for try in 1 2 3 4 5; do
-    burst b $try 300
+    burst 10.53.0.3 b $try 300
     $DIGCMD a ${try}.example > dig.out.ns3.$n.$try
     grep "status: NOERROR" dig.out.ns3.$n.$try > /dev/null 2>&1 && \
             success=$((success+1))
     grep "status: SERVFAIL" dig.out.ns3.$n.$try > /dev/null 2>&1 && \
             fail=$(($fail+1))
-    stat 30 50 || ret=1
+    stat 10.53.0.3 30 50 || ret=1
     [ $ret -eq 1 ] && break
-    $RNDCCMD recursing 2>&1 | sed 's/^/ns3 /' | cat_i
+    rndccmd 10.53.0.3 recursing 2>&1 | sed 's/^/ns3 /' | cat_i
     sleep 1
 done
 echo_i "$success successful valid queries, $fail SERVFAIL"
@@ -166,7 +176,7 @@ n=$((n + 1))
 echo_i "checking drop statistics ($n)"
 ret=0
 rm -f ns3/named.stats
-$RNDCCMD stats
+rndccmd 10.53.0.3 stats
 for try in 1 2 3 4 5; do
     [ -f ns3/named.stats ] && break
     sleep 1
@@ -190,9 +200,9 @@ exceeded=0
 success=0
 touch ans4/norespond
 for try in 1 2 3 4 5; do
-    burst b $try 400
+    burst 10.53.0.3 b $try 400
     $DIGCMD +time=2 a ${try}.example > dig.out.ns3.$n.$try
-    stat 1 400 || exceeded=$((exceeded + 1))
+    stat 10.53.0.3 1 400 || exceeded=$((exceeded + 1))
     grep "status: NOERROR" dig.out.ns3.$n.$try > /dev/null 2>&1 && \
             success=$((success+1))
     grep "status: SERVFAIL" dig.out.ns3.$n.$try > /dev/null 2>&1 && \
@@ -213,7 +223,7 @@ echo_i "checking drop statistics ($n)"
 ret=0
 rm -f ns3/named.stats
 touch ns3/named.stats
-$RNDCCMD stats
+rndccmd 10.53.0.3 stats
 wait_for_log 5 "queries dropped due to recursive client limit" ns3/named.stats || ret=1
 drops=`grep 'queries dropped due to recursive client limit' ns3/named.stats | sed 's/\([0-9][0-9]*\) queries.*/\1/'`
 [ "${drops:-0}" -ne 0 ] || ret=1