]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add more log/tap rotation tests
authorMatthijs Mekking <matthijs@isc.org>
Thu, 6 Apr 2023 07:21:09 +0000 (09:21 +0200)
committerMatthijs Mekking <matthijs@isc.org>
Wed, 3 May 2023 07:12:11 +0000 (09:12 +0200)
Add more tests to the dnstap system test to roll with different values.
Touch some files to make sure the number of existing files exceed the
number that we want to keep.

Add a test to the logfileconfig system test for the increment suffix.

bin/tests/system/dnstap/tests.sh
bin/tests/system/logfileconfig/clean.sh
bin/tests/system/logfileconfig/ns1/named.incconf.in [new file with mode: 0644]
bin/tests/system/logfileconfig/tests.sh

index 5ed1d94c3cd90e9ff8e42c0fd52331b8ed440d03..9e28c956895761380bb6ad056bca68a6a3a68cb3 100644 (file)
@@ -787,28 +787,42 @@ 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() (
+_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"
+    test "$files" -eq "${n}" && test "$files" -ge "1"
 )
 
-echo_i "checking 'rndc -roll <value>' (no versions)"
-ret=0
+
+test_dnstap_roll() {
+       echo_i "checking 'rndc -roll $4' ($1)"
+       ret=0
+
+       try=0
+       while test $try -lt 12
+       do
+               touch "$3/dnstap.out.$try"
+               try=`expr $try + 1`
+       done
+
+       _repeat 10 _test_dnstap_roll $2 $3 $4 || ret=1
+       if [ $ret != 0 ]; then echo_i "failed"; fi
+       status=$((status+ret))
+}
+
 start_server --noclean --restart --port "${PORT}" ns3
-_repeat 5 test_dnstap_roll 10.53.0.3 ns3 3 || ret=1
-if [ $ret != 0 ]; then echo_i "failed"; fi
-status=$((status+ret))
+test_dnstap_roll "no versions" 10.53.0.3 ns3 6
+test_dnstap_roll "no versions" 10.53.0.3 ns3 3
+test_dnstap_roll "no versions" 10.53.0.3 ns3 1
 
-echo_i "checking 'rndc -roll <value>' (versions)"
-ret=0
 start_server --noclean --restart --port "${PORT}" 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))
+test_dnstap_roll "versions" 10.53.0.2 ns2 6
+test_dnstap_roll "versions" 10.53.0.2 ns2 3
+test_dnstap_roll "versions" 10.53.0.2 ns2 1
 
 echo_i "exit status: $status"
 [ "$status" -eq 0 ] || exit 1
index 18aa5de2dd60749bc79a4ba657c1b9249cb963ee..befbcfe84e53e5050282e4d5d1bb85863789971f 100644 (file)
@@ -31,6 +31,8 @@ rm -f ns1/named_vers
 rm -f ns1/named_vers.*
 rm -f ns1/named_ts
 rm -f ns1/named_ts.*
+rm -f ns1/named_inc
+rm -f ns1/named_inc.*
 rm -f ns1/named_unlimited
 rm -f ns1/named_unlimited.*
 rm -f ns*/managed-keys.bind*
diff --git a/bin/tests/system/logfileconfig/ns1/named.incconf.in b/bin/tests/system/logfileconfig/ns1/named.incconf.in
new file mode 100644 (file)
index 0000000..d398c33
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * SPDX-License-Identifier: MPL-2.0
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, you can obtain one at https://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+options {
+       query-source address 10.53.0.1;
+       notify-source 10.53.0.1;
+       transfer-source 10.53.0.1;
+       port @PORT@;
+       pid-file "named.pid";
+       listen-on { 10.53.0.1; };
+       listen-on-v6 { none; };
+       dnssec-validation no;
+       recursion no;
+       notify yes;
+};
+
+logging {
+       channel default_log {
+         buffered no;
+         file "named_inc" versions 1 size 1k suffix increment; # small size
+         severity debug 100;
+         print-time yes;
+       };
+       category default { default_log; default_debug; };
+       category lame-servers { null; };
+
+       channel query_log {
+         file "query_log";
+         print-time yes;
+         buffered yes;
+       };
+       category queries { query_log; };
+};
+
+controls {
+       inet 10.53.0.1 port @CONTROLPORT@ allow { any; } keys { "rndc-key"; };
+};
+
+key rndc-key {
+       secret "1234abcd8765";
+       algorithm hmac-sha256;
+};
index 397f9aa443a07be4a2fbc00a7fb16ad1570eed44..8c433b07f77cf3a5b917b3236ef6fbca7e9be019 100644 (file)
@@ -208,6 +208,34 @@ retry_quiet 5 _found2 || ret=1
 if [ "$ret" -ne 0 ]; then echo_i "failed"; fi
 status=$((status+ret))
 
+n=$((n+1))
+echo_i "testing incremented versions ($n)"
+ret=0
+copy_setports ns1/named.incconf.in ns1/named.conf
+try=0
+while test $try -lt 12
+do
+       touch ns1/named_inc.$try
+       try=`expr $try + 1`
+done
+rndc_reconfig ns1 10.53.0.1 > rndc.out.test$n
+_found2() (
+        $DIG version.bind txt ch @10.53.0.1 -p ${PORT} > dig.out.test$n
+        grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
+
+       try=1
+       while test $try -lt 12
+       do
+               [ -f ns1/named_inc.$try ] && return 1
+               try=`expr $try + 1`
+       done
+        set -- ns1/named_inc.*
+        [ "$#" -eq 1 ] || return 1
+)
+retry_quiet 5 _found2 || ret=1
+if [ "$ret" -ne 0 ]; then echo_i "failed"; fi
+status=$((status+ret))
+
 n=$((n+1))
 echo_i "testing unlimited versions ($n)"
 ret=0