From: Michał Kępień Date: Thu, 31 Jan 2019 14:43:58 +0000 (+0100) Subject: Add system tests for AXFR statistics X-Git-Tag: v9.13.6~14^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a22e24a411c18099171d4f6a2abca59dd21182f3;p=thirdparty%2Fbind9.git Add system tests for AXFR statistics 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). --- diff --git a/bin/tests/system/xfer/axfr-stats.good b/bin/tests/system/xfer/axfr-stats.good new file mode 100644 index 00000000000..264af09705b --- /dev/null +++ b/bin/tests/system/xfer/axfr-stats.good @@ -0,0 +1,3 @@ +messages=16 +records=10003 +bytes=218227 diff --git a/bin/tests/system/xfer/clean.sh b/bin/tests/system/xfer/clean.sh index 10ff41a84f6..d5843e5dae0 100644 --- a/bin/tests/system/xfer/clean.sh +++ b/bin/tests/system/xfer/clean.sh @@ -15,10 +15,11 @@ 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 diff --git a/bin/tests/system/xfer/ns1/named.conf.in b/bin/tests/system/xfer/ns1/named.conf.in index c0e8112ec61..f665f728e57 100644 --- a/bin/tests/system/xfer/ns1/named.conf.in +++ b/bin/tests/system/xfer/ns1/named.conf.in @@ -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 index 00000000000..c57b7866200 --- /dev/null +++ b/bin/tests/system/xfer/ns1/xfer-stats.db @@ -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 $ diff --git a/bin/tests/system/xfer/ns3/named.conf.in b/bin/tests/system/xfer/ns3/named.conf.in index b4bfac519ee..7e8955dce34 100644 --- a/bin/tests/system/xfer/ns3/named.conf.in +++ b/bin/tests/system/xfer/ns3/named.conf.in @@ -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"; +}; diff --git a/bin/tests/system/xfer/tests.sh b/bin/tests/system/xfer/tests.sh index d9286c40161..dcd4d06ce55 100755 --- a/bin/tests/system/xfer/tests.sh +++ b/bin/tests/system/xfer/tests.sh @@ -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 diff --git a/util/copyrights b/util/copyrights index 88638c2c7ce..1881953c182 100644 --- a/util/copyrights +++ b/util/copyrights @@ -1161,6 +1161,7 @@ ./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