]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
address timing issues in padding system test
authorMark Andrews <marka@isc.org>
Wed, 18 Dec 2019 02:23:58 +0000 (13:23 +1100)
committerMark Andrews <marka@isc.org>
Thu, 23 Jan 2020 01:43:03 +0000 (12:43 +1100)
'rndc stats' is not instantaneous. Wait for the dump to complete
before looking at the content.

bin/tests/system/conf.sh.common
bin/tests/system/padding/clean.sh
bin/tests/system/padding/setup.sh
bin/tests/system/padding/tests.sh

index 2b965deb8309c1cba154b439716b1b4a3250e53d..af4fac1e91dee2f3fe2df588331b81778a4df71f 100644 (file)
@@ -378,14 +378,14 @@ nextpartpeek() {
 _search_log() (
        msg="$1"
        file="$2"
-       nextpart "$file" | grep -F "$msg" > /dev/null
+       nextpart "$file" | grep -F -e "$msg" > /dev/null
 )
 
 # _search_log_peek: look for message $1 in file $2 with nextpartpeek().
 _search_log_peek() (
        msg="$1"
        file="$2"
-       nextpartpeek "$file" | grep -F "$msg" > /dev/null
+       nextpartpeek "$file" | grep -F -e "$msg" > /dev/null
 )
 
 # wait_for_log: wait until message $2 in file $3 appears.  Bail out after
index a6e557f71f163a8f9c792892984d2264629db0fa..b75a3e1c46839b12b8d754e66fb5545db222d236 100644 (file)
@@ -11,6 +11,7 @@ rm -f dig.out.*
 rm -f ns*/named.memstats
 rm -f ns*/named.run
 rm -f ns*/named.stats
+rm -f ns*/named.stats.prev
 rm -f ns*/named.lock
 rm -f ns*/named.conf
 rm -f ns*/managed-keys.bind*
index 607a341724674d76edd154cd8b259999b9947d50..2252b7f0f89e7dd12cf2718b0ddd9848a8a27235 100644 (file)
 SYSTEMTESTTOP=..
 . $SYSTEMTESTTOP/conf.sh
 
+$SHELL ./clean.sh
+
 copy_setports ns1/named.conf.in ns1/named.conf
 copy_setports ns2/named.conf.in ns2/named.conf
 copy_setports ns3/named.conf.in ns3/named.conf
 copy_setports ns4/named.conf.in ns4/named.conf
+
+touch ns2/named.stats
index 5ea90fb4017b2d4fb1d7f99082048b8021ac964d..52b60c5a03b2eef093a788f36bd789f0eba2ebfe 100644 (file)
@@ -36,8 +36,11 @@ status=`expr $status + $ret`
 echo_i "checking that dig added padding ($n)"
 ret=0
 n=`expr $n + 1`
+nextpart ns2/named.stats > /dev/null
 $RNDCCMD 10.53.0.2 stats
-grep "EDNS padding option received" ns2/named.stats > /dev/null || ret=1
+wait_for_log_peek 5 "--- Statistics Dump ---" ns2/named.stats || ret=1
+nextpart ns2/named.stats | grep "EDNS padding option received" > /dev/null || ret=1
+
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
 
@@ -88,28 +91,30 @@ status=`expr $status + $ret`
 echo_i "checking that a TCP and padding server config enables padding ($n)"
 ret=0
 n=`expr $n + 1`
+nextpart ns2/named.stats > /dev/null
 $RNDCCMD 10.53.0.2 stats
-opad=`grep  "EDNS padding option received" ns2/named.stats | \
-    tail -1 | awk '{ print $1}'`
+wait_for_log_peek 5 "--- Statistics Dump ---" ns2/named.stats || ret=1
+opad=`nextpart ns2/named.stats | awk '/EDNS padding option received/ { print $1}'`
 $DIG $DIGOPTS foo.example @10.53.0.3 > dig.out.test$n
 $RNDCCMD 10.53.0.2 stats
-npad=`grep  "EDNS padding option received" ns2/named.stats | \
-    tail -1 | awk '{ print $1}'`
-if [ "$opad" -eq "$npad" ]; then ret=1; fi
+wait_for_log_peek 5 "--- Statistics Dump ---" ns2/named.stats || ret=1
+npad=`nextpart ns2/named.stats | awk '/EDNS padding option received/ { print $1}'`
+if [ "$opad" -eq "$npad" ]; then echo_i "error: opad ($opad) == npad ($npad)"; ret=1; fi
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
 
 echo_i "checking that a padding server config should enforce TCP ($n)"
 ret=0
 n=`expr $n + 1`
+nextpart ns2/named.stats > /dev/null
 $RNDCCMD 10.53.0.2 stats
-opad=`grep  "EDNS padding option received" ns2/named.stats | \
-    tail -1 | awk '{ print $1}'`
+wait_for_log_peek 5 "--- Statistics Dump ---" ns2/named.stats || ret=1
+opad=`nextpart ns2/named.stats | awk '/EDNS padding option received/ { print $1}'`
 $DIG $DIGOPTS foo.example @10.53.0.4 > dig.out.test$n
 $RNDCCMD 10.53.0.2 stats
-npad=`grep  "EDNS padding option received" ns2/named.stats | \
-    tail -1 | awk '{ print $1}'`
-if [ "$opad" -ne "$npad" ]; then ret=1; fi
+wait_for_log_peek 5 "--- Statistics Dump ---" ns2/named.stats || ret=1
+npad=`nextpart ns2/named.stats | awk '/EDNS padding option received/ { print $1}'`
+if [ "$opad" -ne "$npad" ]; then echo_i "error: opad ($opad) != npad ($npad)"; ret=1; fi
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`