]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add system tests for AXFR statistics
authorMichał Kępień <michal@isc.org>
Thu, 31 Jan 2019 14:43:58 +0000 (15:43 +0100)
committerEvan Hunt <each@isc.org>
Thu, 31 Jan 2019 21:55:01 +0000 (16:55 -0500)
Ensure AXFR statistics are calculated correctly by dig and named, both
for incoming and outgoing transfers.  Rather than employing a zone which
is already used in the "xfer" system test, create a new one whose AXFR
form spans multiple TCP messages.  Disable EDNS when using dig to
request an AXFR so that the same reference file can be used for testing
statistics calculated by both dig and named (dig uses EDNS by default
when sending transfer requests, which affects the number of bytes
transferred).

bin/tests/system/xfer/axfr-stats.good [new file with mode: 0644]
bin/tests/system/xfer/clean.sh
bin/tests/system/xfer/ns1/named.conf.in
bin/tests/system/xfer/ns1/xfer-stats.db [new file with mode: 0644]
bin/tests/system/xfer/ns3/named.conf.in
bin/tests/system/xfer/tests.sh
util/copyrights

diff --git a/bin/tests/system/xfer/axfr-stats.good b/bin/tests/system/xfer/axfr-stats.good
new file mode 100644 (file)
index 0000000..264af09
--- /dev/null
@@ -0,0 +1,3 @@
+messages=16
+records=10003
+bytes=218227
index 10ff41a84f65f026c270dc38d0885f4a7b236ddf..d5843e5dae0a7b28f0f6a2169bc09168be85a6c3 100644 (file)
 
 rm -f dig.out.*
 rm -f axfr.out
+rm -f stats.*
 rm -f ns1/slave.db ns2/slave.db
 rm -f ns1/edns-expire.db
 rm -f ns2/example.db ns2/tsigzone.db ns2/example.db.jnl
-rm -f ns3/example.bk ns3/tsigzone.bk ns3/example.bk.jnl
+rm -f ns3/example.bk ns3/xfer-stats.bk ns3/tsigzone.bk ns3/example.bk.jnl
 rm -f ns3/master.bk ns3/master.bk.jnl
 rm -f ns4/nil.db ns4/root.db
 rm -f ns6/*.db ns6/*.bk ns6/*.jnl
index c0e8112ec611b8aec76acbfd185eb07598a1812a..f665f728e5743f41ead7e5c67389812d036e29a3 100644 (file)
@@ -52,3 +52,8 @@ zone "ixfr-too-big" {
        allow-update { any; };
        file "ixfr-too-big.db";
 };
+
+zone "xfer-stats" {
+       type master;
+       file "xfer-stats.db";
+};
diff --git a/bin/tests/system/xfer/ns1/xfer-stats.db b/bin/tests/system/xfer/ns1/xfer-stats.db
new file mode 100644 (file)
index 0000000..c57b786
--- /dev/null
@@ -0,0 +1,13 @@
+; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+;
+; 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 http://mozilla.org/MPL/2.0/.
+;
+; See the COPYRIGHT file distributed with this work for additional
+; information regarding copyright ownership.
+
+$TTL 3600
+@                              SOA     . . 0 0 0 0 0
+@                              NS      .
+$GENERATE 1-10000      $       TXT     $
index b4bfac519eeee4aaefc02381b38c83b31740e4d9..7e8955dce34eb38e3656faae1aa7d01ab2cdd4b4 100644 (file)
@@ -69,3 +69,9 @@ zone "mapped" {
        masterfile-format map;
        file "mapped.bk";
 };
+
+zone "xfer-stats" {
+       type slave;
+       masters { 10.53.0.1; };
+       file "xfer-stats.bk";
+};
index d9286c40161557dac162eabeb3e652fdd8ff762d..dcd4d06ce55a903369cd2dcf2bf8e781e71bbd66 100755 (executable)
@@ -464,5 +464,49 @@ grep "'ixfr-too-big/IN'.*: too many records" ns6/named.run >/dev/null || tmp=1
 if test $tmp != 0 ; then echo_i "failed"; fi
 status=`expr $status + $tmp`
 
+n=`expr $n + 1`
+echo_i "checking whether dig calculates AXFR statistics correctly"
+# Loop until the secondary server manages to transfer the "xfer-stats" zone so
+# that we can both check dig output and immediately proceed with the next test.
+# Use -b so that we can discern between incoming and outgoing transfers in ns3
+# logs later on.
+tmp=1
+for i in 1 2 3 4 5 6 7 8 9 10; do
+       $DIG $DIGOPTS +noedns +stat -b 10.53.0.2 @10.53.0.3 xfer-stats. AXFR > dig.out.ns3.$n
+       if grep "; Transfer failed" dig.out.ns3.$n > /dev/null; then
+               sleep 1
+       else
+               tmp=0
+               break
+       fi
+done
+if [ $tmp -ne 0 ]; then
+       echo_i "timed out waiting for zone transfer"
+else
+       get_dig_xfer_stats dig.out.ns3.$n > stats.dig
+       diff axfr-stats.good stats.dig || tmp=1
+fi
+if test $tmp != 0 ; then echo_i "failed"; fi
+status=`expr $status + $tmp`
+
+# Note: in the next two tests, we use ns3 logs for checking both incoming and
+# outgoing transfer statistics as ns3 is both a secondary server (for ns1) and a
+# primary server (for dig queries from the previous test) for "xfer-stats".
+n=`expr $n + 1`
+echo_i "checking whether named calculates incoming AXFR statistics correctly"
+tmp=0
+get_named_xfer_stats ns3/named.run 10.53.0.1 xfer-stats "Transfer completed" > stats.incoming
+diff axfr-stats.good stats.incoming || tmp=1
+if test $tmp != 0 ; then echo_i "failed"; fi
+status=`expr $status + $tmp`
+
+n=`expr $n + 1`
+echo_i "checking whether named calculates outgoing AXFR statistics correctly"
+tmp=0
+get_named_xfer_stats ns3/named.run 10.53.0.2 xfer-stats "AXFR ended" > stats.outgoing
+diff axfr-stats.good stats.outgoing || tmp=1
+if test $tmp != 0 ; then echo_i "failed"; fi
+status=`expr $status + $tmp`
+
 echo_i "exit status: $status"
 [ $status -eq 0 ] || exit 1
index 88638c2c7ce791ec6067282cfec5f3c473c384b4..1881953c182f60bba4c53ddc78d329f973b130a3 100644 (file)
 ./bin/tests/system/xfer/ans5/unknownkey                X       2011,2018,2019
 ./bin/tests/system/xfer/ans5/unsigned          X       2011,2018,2019
 ./bin/tests/system/xfer/ans5/wrongkey          X       2011,2018,2019
+./bin/tests/system/xfer/axfr-stats.good                X       2019
 ./bin/tests/system/xfer/clean.sh               SH      2000,2001,2004,2007,2011,2012,2013,2014,2015,2016,2018,2019
 ./bin/tests/system/xfer/dig1.good              X       2000,2001,2003,2004,2009,2011,2012,2013,2014,2015,2016,2017,2018,2019
 ./bin/tests/system/xfer/dig2.good              X       2000,2001,2003,2004,2009,2011,2012,2013,2014,2015,2016,2017,2018,2019