]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Check that 'rndc dnstap -roll <value>' works
authorMark Andrews <marka@isc.org>
Mon, 22 Jun 2020 04:41:55 +0000 (14:41 +1000)
committerMark Andrews <marka@isc.org>
Mon, 29 Jun 2020 22:39:19 +0000 (08:39 +1000)
(cherry picked from commit a289a57c7f21fe2d1b9fb80e34f4d143c89cfc70)

bin/tests/system/conf.sh.in
bin/tests/system/conf.sh.win32
bin/tests/system/dnstap/clean.sh
bin/tests/system/dnstap/tests.sh

index 769980913e57f3e5d1bb7a924a0b0940e9275ea5..f04a3167c22cc34210796531302cf96ab519cf37 100644 (file)
@@ -516,6 +516,22 @@ retry_quiet() {
        _retry "$@"
 }
 
+# _repeat: keep running command up to $1 times, unless it fails
+_repeat() (
+    __retries="${1}"
+    shift
+    while :; do
+        if ! "$@"; then
+            return 1
+        fi
+        __retries=$((__retries-1))
+        if [ "${__retries}" -le 0 ]; then
+            break
+        fi
+    done
+    return 0
+)
+
 # rndc_dumpdb: call "rndc dumpdb [...]" and wait until it completes
 #
 # The first argument is the name server instance to send the command to, in the
index bc0a055b5040cb77c90a7412b6c9459b8af22c56..5a2775fdd2d5bf7303e0ea472a5dae67caa05c24 100644 (file)
@@ -479,6 +479,22 @@ retry_quiet() {
        _retry "$@"
 }
 
+# _repeat: keep running command up to $1 times, unless it fails
+_repeat() (
+    __retries="${1}"
+    shift
+    while :; do
+        if ! "$@"; then
+            return 1
+        fi
+        __retries=$((__retries-1))
+        if [ "${__retries}" -le 0 ]; then
+            break
+        fi
+    done
+    return 0
+)
+
 # rndc_dumpdb: call "rndc dumpdb [...]" and wait until it completes
 #
 # The first argument is the name server instance to send the command to, in the
index f0852e03e4b5f76e15da3f52b6fe53a391b87ab8..01f1c9a66884f72c08a3f0b15a6b7df11f409387 100644 (file)
@@ -22,4 +22,6 @@ rm -f ns*/dnstap.out
 rm -f ns*/dnstap.out.save
 rm -f ns*/dnstap.out.save.?
 rm -f ns*/named.lock
+rm -f ns2/dnstap.out.*
+rm -f ns3/dnstap.out.*
 rm -f ydump.out
index 12cdd22e8e76d5cefc3987d9e43925ba76f2630f..d36cd289b44fdd320f1eb0c8094bf447c34db203 100644 (file)
@@ -49,7 +49,7 @@ status=`expr $status + $ret`
 # be correct.
 
 $DIG $DIGOPTS @10.53.0.3 a.example > dig.out
-wait_for_log 20 "(./NS): query_reset" ns1/named.run || true
+wait_for_log 20 "(.): endrequest" ns1/named.run || true
 
 # check three different dnstap reopen/roll methods:
 # ns1: dnstap-reopen; ns2: dnstap -reopen; ns3: dnstap -roll
@@ -611,5 +611,21 @@ lines=`$DNSTAPREAD -y large-answer.fstrm | grep -c "opcode: QUERY"`
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
 
+test_dnstap_roll() (
+    ip="$1"
+    ns="$2"
+    n="$3"
+    $RNDCCMD -s "${ip}" dnstap -roll "${n}" | sed "s/^/${ns} /" | cat_i &&
+    files=$(find "${ns}" -name "dnstap.out.[0-9]" | wc -l) &&
+    test "$files" -le "${n}" && test "$files" -ge "1"
+)
+
+echo_i "checking 'rndc -roll <value>'"
+ret=0
+$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} dnstap ns2
+_repeat 5 test_dnstap_roll 10.53.0.2 ns2 3 || ret=1
+if [ $ret != 0 ]; then echo_i "failed"; fi
+status=$((status+ret))
+
 echo_i "exit status: $status"
-[ $status -eq 0 ] || exit 1
+[ "$status" -eq 0 ] || exit 1