From 3b9b6d0b8e7f798023c9d109c490449d528fde80 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 17:59:48 +0200 Subject: Adding upstream version 1:9.18.19. Signed-off-by: Daniel Baumann --- bin/tests/system/statistics/ans4/ans.pl | 118 +++++++++ bin/tests/system/statistics/clean.sh | 32 +++ bin/tests/system/statistics/ns1/named.conf.in | 44 ++++ bin/tests/system/statistics/ns1/root.db | 24 ++ bin/tests/system/statistics/ns1/zone.db | 14 + bin/tests/system/statistics/ns2/example.db | 28 ++ bin/tests/system/statistics/ns2/internal.db | 30 +++ bin/tests/system/statistics/ns2/named.conf.in | 50 ++++ bin/tests/system/statistics/ns2/named2.conf.in | 51 ++++ bin/tests/system/statistics/ns3/internal.db | 28 ++ bin/tests/system/statistics/ns3/named.conf.in | 58 +++++ bin/tests/system/statistics/ns3/root.hint | 21 ++ bin/tests/system/statistics/setup.sh | 18 ++ bin/tests/system/statistics/tests.sh | 282 +++++++++++++++++++++ bin/tests/system/statistics/tests_sh_statistics.py | 14 + 15 files changed, 812 insertions(+) create mode 100644 bin/tests/system/statistics/ans4/ans.pl create mode 100644 bin/tests/system/statistics/clean.sh create mode 100644 bin/tests/system/statistics/ns1/named.conf.in create mode 100644 bin/tests/system/statistics/ns1/root.db create mode 100644 bin/tests/system/statistics/ns1/zone.db create mode 100644 bin/tests/system/statistics/ns2/example.db create mode 100644 bin/tests/system/statistics/ns2/internal.db create mode 100644 bin/tests/system/statistics/ns2/named.conf.in create mode 100644 bin/tests/system/statistics/ns2/named2.conf.in create mode 100644 bin/tests/system/statistics/ns3/internal.db create mode 100644 bin/tests/system/statistics/ns3/named.conf.in create mode 100644 bin/tests/system/statistics/ns3/root.hint create mode 100644 bin/tests/system/statistics/setup.sh create mode 100644 bin/tests/system/statistics/tests.sh create mode 100644 bin/tests/system/statistics/tests_sh_statistics.py (limited to 'bin/tests/system/statistics') diff --git a/bin/tests/system/statistics/ans4/ans.pl b/bin/tests/system/statistics/ans4/ans.pl new file mode 100644 index 0000000..3a37a82 --- /dev/null +++ b/bin/tests/system/statistics/ans4/ans.pl @@ -0,0 +1,118 @@ +#!/usr/bin/perl -w + +# 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. + +# +# Ad hoc name server +# + +use IO::File; +use IO::Socket; +use Net::DNS; +use Net::DNS::Packet; + +my $localport = int($ENV{'PORT'}); +if (!$localport) { $localport = 5300; } + +my $sock = IO::Socket::INET->new(LocalAddr => "10.53.0.4", + LocalPort => $localport, Proto => "udp") or die "$!"; + +my $pidf = new IO::File "ans.pid", "w" or die "cannot open pid file: $!"; +print $pidf "$$\n" or die "cannot write pid file: $!"; +$pidf->close or die "cannot close pid file: $!"; +sub rmpid { unlink "ans.pid"; exit 1; }; + +$SIG{INT} = \&rmpid; +$SIG{TERM} = \&rmpid; + +for (;;) { + $sock->recv($buf, 512); + + print "**** request from " , $sock->peerhost, " port ", $sock->peerport, "\n"; + + my $packet; + + if ($Net::DNS::VERSION > 0.68) { + $packet = new Net::DNS::Packet(\$buf, 0); + $@ and die $@; + } else { + my $err; + ($packet, $err) = new Net::DNS::Packet(\$buf, 0); + $err and die $err; + } + + print "REQUEST:\n"; + $packet->print; + + $packet->header->qr(1); + + my @questions = $packet->question; + my $qname = $questions[0]->qname; + my $qtype = $questions[0]->qtype; + + my $donotrespond = 0; + + if ($qname eq "foo.info") { + $donotrespond = 1; + } elsif ($qname eq "cname1.example.com") { + # Data for the "cname + other data / 1" test + $packet->push("answer", new Net::DNS::RR("cname1.example.com 300 CNAME cname1.example.com")); + $packet->push("answer", new Net::DNS::RR("cname1.example.com 300 A 1.2.3.4")); + } elsif ($qname eq "cname2.example.com") { + # Data for the "cname + other data / 2" test: same RRs in opposite order + $packet->push("answer", new Net::DNS::RR("cname2.example.com 300 A 1.2.3.4")); + $packet->push("answer", new Net::DNS::RR("cname2.example.com 300 CNAME cname2.example.com")); + } elsif ($qname eq "www.example.org" || $qname eq "www.example.net" || + $qname eq "badcname.example.org" || + $qname eq "goodcname.example.org" || + $qname eq "foo.baddname.example.org" || + $qname eq "foo.gooddname.example.org") { + # Data for address/alias filtering. + $packet->header->aa(1); + if ($qtype eq "A") { + $packet->push("answer", + new Net::DNS::RR($qname . + " 300 A 192.0.2.1")); + } elsif ($qtype eq "AAAA") { + $packet->push("answer", + new Net::DNS::RR($qname . + " 300 AAAA 2001:db8:beef::1")); + } + } elsif ($qname eq "badcname.example.net" || + $qname eq "goodcname.example.net") { + # Data for CNAME/DNAME filtering. We need to make one-level + # delegation to avoid automatic acceptance for subdomain aliases + $packet->push("authority", new Net::DNS::RR("example.net 300 NS ns.example.net")); + $packet->push("additional", new Net::DNS::RR("ns.example.net 300 A 10.53.0.3")); + } elsif ($qname =~ /^nodata\.example\.net$/i) { + $packet->header->aa(1); + } elsif ($qname =~ /^nxdomain\.example\.net$/i) { + $packet->header->aa(1); + $packet->header->rcode(NXDOMAIN); + } elsif ($qname =~ /sub\.example\.org/) { + # Data for CNAME/DNAME filtering. The final answers are + # expected to be accepted regardless of the filter setting. + $packet->push("authority", new Net::DNS::RR("sub.example.org 300 NS ns.sub.example.org")); + $packet->push("additional", new Net::DNS::RR("ns.sub.example.org 300 A 10.53.0.3")); + } else { + # Data for the "bogus referrals" test + $packet->push("authority", new Net::DNS::RR("below.www.example.com 300 NS ns.below.www.example.com")); + $packet->push("additional", new Net::DNS::RR("ns.below.www.example.com 300 A 10.53.0.3")); + } + + if ($donotrespond == 0) { + $sock->send($packet->data); + print "RESPONSE:\n"; + $packet->print; + print "\n"; + } +} diff --git a/bin/tests/system/statistics/clean.sh b/bin/tests/system/statistics/clean.sh new file mode 100644 index 0000000..37fa7dc --- /dev/null +++ b/bin/tests/system/statistics/clean.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +# 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. + +# +# Clean up after zone transfer tests. +# + +rm -f ns3/example.bk +rm -f ns3/internal.bk +rm -f */named.conf +rm -f */named.memstats +rm -f */named.run +rm -f */ans.run +rm -f */named.stats +rm -f */named.stats-stage* +rm -f dig.out* +rm -f curl.out.* +rm -f ns*/named.lock +rm -f stats*out +rm -f ns*/managed-keys.bind* +rm -f xsltproc.out.* +rm -f named.stats.* ns*/named.stats.* diff --git a/bin/tests/system/statistics/ns1/named.conf.in b/bin/tests/system/statistics/ns1/named.conf.in new file mode 100644 index 0000000..8fd14f9 --- /dev/null +++ b/bin/tests/system/statistics/ns1/named.conf.in @@ -0,0 +1,44 @@ +/* + * 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; }; + recursion no; + dnssec-validation no; + notify yes; +}; + +statistics-channels { + inet 10.53.0.1 port @EXTRAPORT1@ allow { any; }; +}; + +zone "." { + type primary; + file "root.db"; +}; + +zone "example.info." { + type primary; + file "example-info.db"; +}; + +zone "32/1.0.0.127-in-addr.example." { + type primary; + file "zone.db"; +}; diff --git a/bin/tests/system/statistics/ns1/root.db b/bin/tests/system/statistics/ns1/root.db new file mode 100644 index 0000000..17780d1 --- /dev/null +++ b/bin/tests/system/statistics/ns1/root.db @@ -0,0 +1,24 @@ +; 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. + +$TTL 300 +. IN SOA gson.nominum.com. a.root.servers.nil. ( + 2000042100 ; serial + 600 ; refresh + 600 ; retry + 1200 ; expire + 600 ; minimum + ) +. NS a.root-servers.nil. +a.root-servers.nil. A 10.53.0.1 + +example. NS ns2.example. +ns2.example. A 10.53.0.2 diff --git a/bin/tests/system/statistics/ns1/zone.db b/bin/tests/system/statistics/ns1/zone.db new file mode 100644 index 0000000..7feee2c --- /dev/null +++ b/bin/tests/system/statistics/ns1/zone.db @@ -0,0 +1,14 @@ +; 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. + +@ 3600 IN SOA ns.example. hostmaster.example. 1 3600 1200 604800 3600 +@ 3600 IN NS ns.example. +ns.example. 3600 IN A 10.53.0.1 diff --git a/bin/tests/system/statistics/ns2/example.db b/bin/tests/system/statistics/ns2/example.db new file mode 100644 index 0000000..4d60ce3 --- /dev/null +++ b/bin/tests/system/statistics/ns2/example.db @@ -0,0 +1,28 @@ +; 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. + +$ORIGIN . +$TTL 300 ; 5 minutes +example IN SOA mname1. . ( + 1 ; serial + 20 ; refresh (20 seconds) + 20 ; retry (20 seconds) + 1814400 ; expire (3 weeks) + 3600 ; minimum (1 hour) + ) +example. NS ns2.example. +ns2.example. A 10.53.0.2 + +$ORIGIN example. +a A 10.0.0.1 + MX 10 mail.example. + +mail A 10.0.0.2 diff --git a/bin/tests/system/statistics/ns2/internal.db b/bin/tests/system/statistics/ns2/internal.db new file mode 100644 index 0000000..4f1014f --- /dev/null +++ b/bin/tests/system/statistics/ns2/internal.db @@ -0,0 +1,30 @@ +; 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. + +$ORIGIN . +$TTL 300 ; 5 minutes +example IN SOA mname1. . ( + 2 ; serial + 20 ; refresh (20 seconds) + 20 ; retry (20 seconds) + 1814400 ; expire (3 weeks) + 3600 ; minimum (1 hour) + ) +example. NS ns2.example. +ns2.example. A 10.53.0.2 +example. NS ns3.example. +ns3.example. A 10.53.0.3 + +$ORIGIN example. +a A 10.1.0.1 + MX 10 intmail.example. + +intmail A 10.1.0.2 diff --git a/bin/tests/system/statistics/ns2/named.conf.in b/bin/tests/system/statistics/ns2/named.conf.in new file mode 100644 index 0000000..48fb8b4 --- /dev/null +++ b/bin/tests/system/statistics/ns2/named.conf.in @@ -0,0 +1,50 @@ +/* + * 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.2; + notify-source 10.53.0.2; + transfer-source 10.53.0.2; + port @PORT@; + pid-file "named.pid"; + listen-on { 10.53.0.2; }; + listen-on-v6 { none; }; + recursion yes; + dnssec-validation yes; + notify yes; +}; + +statistics-channels { + inet 10.53.0.2 port @EXTRAPORT1@ allow { any; }; +}; + +key rndc_key { + secret "1234abcd8765"; + algorithm @DEFAULT_HMAC@; +}; + +controls { + inet 10.53.0.2 port @CONTROLPORT@ allow { any; } keys { rndc_key; }; +}; + + +zone "." { + type hint; + file "../../common/root.hint"; +}; + +zone "example" { + type primary; + file "example.db"; + allow-update { any; }; +}; diff --git a/bin/tests/system/statistics/ns2/named2.conf.in b/bin/tests/system/statistics/ns2/named2.conf.in new file mode 100644 index 0000000..d370931 --- /dev/null +++ b/bin/tests/system/statistics/ns2/named2.conf.in @@ -0,0 +1,51 @@ +/* + * 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.2; + notify-source 10.53.0.2; + transfer-source 10.53.0.2; + port @PORT@; + pid-file "named.pid"; + listen-on { 10.53.0.2; }; + listen-on-v6 { none; }; + recursion yes; + dnssec-validation no; + notify yes; +}; + +statistics-channels { + inet 10.53.0.2 port @EXTRAPORT1@ allow { any; }; +}; + +key rndc_key { + secret "1234abcd8765"; + algorithm @DEFAULT_HMAC@; +}; + +controls { + inet 10.53.0.2 port @CONTROLPORT@ allow { any; } keys { rndc_key; }; +}; + + +zone "." { + type hint; + file "../../common/root.hint"; +}; + +zone "example" { + type primary; + file "example.db"; + allow-update { any; }; + zone-statistics full; +}; diff --git a/bin/tests/system/statistics/ns3/internal.db b/bin/tests/system/statistics/ns3/internal.db new file mode 100644 index 0000000..c93c2b0 --- /dev/null +++ b/bin/tests/system/statistics/ns3/internal.db @@ -0,0 +1,28 @@ +; 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. + +$ORIGIN . +$TTL 300 ; 5 minutes +example IN SOA mname1. . ( + 1 ; serial + 20 ; refresh (20 seconds) + 20 ; retry (20 seconds) + 1814400 ; expire (3 weeks) + 3600 ; minimum (1 hour) + ) +example. NS ns3.example. +ns3.example. A 10.53.0.3 + +$ORIGIN example. +a A 10.1.0.1 + MX 10 intmail.example. + +intmail A 10.1.0.2 diff --git a/bin/tests/system/statistics/ns3/named.conf.in b/bin/tests/system/statistics/ns3/named.conf.in new file mode 100644 index 0000000..4cc712d --- /dev/null +++ b/bin/tests/system/statistics/ns3/named.conf.in @@ -0,0 +1,58 @@ +/* + * 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.3; + notify-source 10.53.0.3; + transfer-source 10.53.0.3; + port @PORT@; + directory "."; + pid-file "named.pid"; + listen-on { 10.53.0.3; }; + listen-on-v6 { none; }; + recursion yes; + dnssec-validation yes; + notify yes; + qname-minimization disabled; + zone-statistics yes; +}; + +statistics-channels { + inet 10.53.0.3 port @EXTRAPORT1@ allow { any; }; +}; + +key rndc_key { + secret "1234abcd8765"; + algorithm @DEFAULT_HMAC@; +}; + +controls { + inet 10.53.0.3 port @CONTROLPORT@ allow { any; } keys { rndc_key; }; +}; + +zone "." { + type hint; + file "root.hint"; +}; + +zone "example" { + type primary; + allow-update { any; }; + file "internal.db"; +}; + +zone "a-secondary" { + type secondary; + file "sec.bk"; + primaries { 10.53.0.1; }; +}; diff --git a/bin/tests/system/statistics/ns3/root.hint b/bin/tests/system/statistics/ns3/root.hint new file mode 100644 index 0000000..0f5c701 --- /dev/null +++ b/bin/tests/system/statistics/ns3/root.hint @@ -0,0 +1,21 @@ +; 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. + +; +; The configured root server is intentionally bad here, +; so we can count queries "on fly", priming and the other +; counters that would be immediately resolved if the root +; nameservers would work. +; + +$TTL 999999 +. IN NS d.root-servers.nil. +d.root-servers.nil. IN A 10.53.0.4 diff --git a/bin/tests/system/statistics/setup.sh b/bin/tests/system/statistics/setup.sh new file mode 100644 index 0000000..7ffda55 --- /dev/null +++ b/bin/tests/system/statistics/setup.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +# 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. + +. ../conf.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 diff --git a/bin/tests/system/statistics/tests.sh b/bin/tests/system/statistics/tests.sh new file mode 100644 index 0000000..af57b60 --- /dev/null +++ b/bin/tests/system/statistics/tests.sh @@ -0,0 +1,282 @@ +#!/bin/sh + +# 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. + +set -e + +. ../conf.sh + +DIGCMD="$DIG +tcp -p ${PORT}" +RNDCCMD="$RNDC -p ${CONTROLPORT} -c ../common/rndc.conf" + +status=0 + +ret=0 +n=1 +stats=0 +nsock0nstat=0 +nsock1nstat=0 +rndc_stats() { + _ns=$1 + _ip=$2 + + $RNDCCMD -s $_ip stats > /dev/null 2>&1 || return 1 + [ -f "${_ns}/named.stats" ] || return 1 + + last_stats=named.stats.$_ns-$stats-$n + mv ${_ns}/named.stats $last_stats + stats=$((stats+1)) +} + +echo_i "fetching a.example from ns2's initial configuration ($n)" +$DIGCMD +noauth a.example. @10.53.0.2 any > dig.out.ns2.1 || ret=1 +if [ $ret != 0 ]; then echo_i "failed"; fi +status=$((status + ret)) +n=$((n + 1)) + +ret=0 +echo_i "dumping initial stats for ns2 ($n)" +rndc_stats ns2 10.53.0.2 || ret=1 +if [ $ret != 0 ]; then echo_i "failed"; fi +status=$((status + ret)) +n=$((n + 1)) + +ret=0 +echo_i "verifying adb records in named.stats ($n)" +grep "ADB stats" $last_stats > /dev/null || ret=1 +if [ $ret != 0 ]; then echo_i "failed"; fi +status=$((status + ret)) +n=$((n + 1)) + +echo_i "checking for 1 entry in adb hash table in named.stats ($n)" +grep "1 Addresses in hash table" $last_stats > /dev/null || ret=1 +if [ $ret != 0 ]; then echo_i "failed"; fi +status=$((status + ret)) +n=$((n + 1)) + +ret=0 +echo_i "verifying cache statistics in named.stats ($n)" +grep "Cache Statistics" $last_stats > /dev/null || ret=1 +if [ $ret != 0 ]; then echo_i "failed"; fi +status=$((status + ret)) +n=$((n + 1)) + +ret=0 +echo_i "checking for 2 entries in adb hash table in named.stats ($n)" +$DIGCMD a.example.info. @10.53.0.2 any > /dev/null 2>&1 +rndc_stats ns2 10.53.0.2 || ret=1 +grep "2 Addresses in hash table" $last_stats > /dev/null || ret=1 +if [ $ret != 0 ]; then echo_i "failed"; fi +status=$((status + ret)) +n=$((n + 1)) + +ret=0 +echo_i "dumping initial stats for ns3 ($n)" +rndc_stats ns3 10.53.0.3 || ret=1 +nsock0nstat=$(grep "UDP/IPv4 sockets active" $last_stats | awk '{print $1}') +[ 0 -ne ${nsock0nstat} ] || ret=1 +if [ $ret != 0 ]; then echo_i "failed"; fi +status=$((status + ret)) +n=$((n + 1)) + +echo_i "sending queries to ns3" +$DIGCMD +tries=2 +time=1 +recurse @10.53.0.3 foo.info. any > /dev/null 2>&1 || true + +ret=0 +echo_i "dumping updated stats for ns3 ($n)" +getstats() { + rndc_stats ns3 10.53.0.3 || return 1 + grep "2 recursing clients" $last_stats > /dev/null || return 1 +} +retry_quiet 5 getstats || ret=1 +if [ $ret != 0 ]; then echo_i "failed"; fi +status=$((status + ret)) +n=$((n + 1)) + +ret=0 +echo_i "verifying recursing clients output in named.stats ($n)" +grep "2 recursing clients" $last_stats > /dev/null || ret=1 +if [ $ret != 0 ]; then echo_i "failed"; fi +status=$((status + ret)) +n=$((n + 1)) + +ret=0 +echo_i "verifying active fetches output in named.stats ($n)" +grep "1 active fetches" $last_stats > /dev/null || ret=1 +if [ $ret != 0 ]; then echo_i "failed"; fi +status=$((status + ret)) +n=$((n + 1)) + +ret=0 +echo_i "verifying active sockets output in named.stats ($n)" +nsock1nstat=$(grep "UDP/IPv4 sockets active" $last_stats | awk '{print $1}') +[ $((nsock1nstat - nsock0nstat)) -eq 1 ] || ret=1 +if [ $ret != 0 ]; then echo_i "failed"; fi +status=$((status + ret)) +n=$((n + 1)) + +# there should be 1 UDP and no TCP queries. As the TCP counter is zero +# no status line is emitted. +ret=0 +echo_i "verifying queries in progress in named.stats ($n)" +grep "1 UDP queries in progress" $last_stats > /dev/null || ret=1 +grep "TCP queries in progress" $last_stats > /dev/null && ret=1 +if [ $ret != 0 ]; then echo_i "failed"; fi +status=$((status + ret)) +n=$((n + 1)) + +ret=0 +echo_i "verifying bucket size output ($n)" +grep "bucket size" $last_stats > /dev/null || ret=1 +if [ $ret != 0 ]; then echo_i "failed"; fi +status=$((status + ret)) +n=$((n + 1)) + +ret=0 +echo_i "checking priming queries are counted ($n)" +grep "priming queries" $last_stats > /dev/null || ret=1 +if [ $ret != 0 ]; then echo_i "failed"; fi +status=$((status + ret)) +n=$((n + 1)) + +ret=0 +echo_i "checking that zones with slash are properly shown in XML output ($n)" +if $FEATURETEST --have-libxml2 && [ -x ${CURL} ] ; then + ${CURL} http://10.53.0.1:${EXTRAPORT1}/xml/v3/zones > curl.out.${n} 2>/dev/null || ret=1 + grep '' curl.out.${n} > /dev/null || ret=1 +else + echo_i "skipping test as libxml2 and/or curl was not found" +fi +if [ $ret != 0 ]; then echo_i "failed"; fi +status=$((status + ret)) +n=$((n + 1)) + +ret=0 +echo_i "checking that zones return their type ($n)" +if $FEATURETEST --have-libxml2 && [ -x ${CURL} ] ; then + ${CURL} http://10.53.0.1:${EXTRAPORT1}/xml/v3/zones > curl.out.${n} 2>/dev/null || ret=1 + grep 'primary' curl.out.${n} > /dev/null || ret=1 +else + echo_i "skipping test as libxml2 and/or curl was not found" +fi +if [ $ret != 0 ]; then echo_i "failed"; fi +status=$((status + ret)) +n=$((n + 1)) + +ret=0 +echo_i "checking bind9.xsl vs xml ($n)" +if $FEATURETEST --have-libxml2 && "${CURL}" --http1.1 http://10.53.0.3:${EXTRAPORT1} > /dev/null 2>&1 && [ -x "${XSLTPROC}" ] ; then + $DIGCMD +notcp +recurse @10.53.0.3 soa . > dig.out.test$n.1 2>&1 + $DIGCMD +notcp +recurse @10.53.0.3 soa example > dig.out.test$n.2 2>&1 + # check multiple requests over the same socket + time1=$($PERL -e 'print time(), "\n";') + ${CURL} --http1.1 -o curl.out.${n}.xml http://10.53.0.3:${EXTRAPORT1}/xml/v3 \ + -o curl.out.${n}.xsl http://10.53.0.3:${EXTRAPORT1}/bind9.xsl 2>/dev/null || ret=1 + time2=$($PERL -e 'print time(), "\n";') + test $((time2 - time1)) -lt 5 || ret=1 + diff ${TOP_SRCDIR}/bin/named/bind9.xsl curl.out.${n}.xsl || ret=1 + ${XSLTPROC} curl.out.${n}.xsl - < curl.out.${n}.xml > xsltproc.out.${n} 2>/dev/null || ret=1 + cp curl.out.${n}.xml stats.xml.out || ret=1 + + # + # grep for expected sections. + # + grep "

ISC Bind 9 Configuration and Statistics

" xsltproc.out.${n} >/dev/null || ret=1 + grep "

Server Status

" xsltproc.out.${n} >/dev/null || ret=1 + grep "

Incoming Requests by DNS Opcode

" xsltproc.out.${n} >/dev/null || ret=1 + grep "

Incoming Queries by Query Type

" xsltproc.out.${n} >/dev/null || ret=1 + grep "

Outgoing Queries per view

" xsltproc.out.${n} >/dev/null || ret=1 + grep "

View " xsltproc.out.${n} >/dev/null || ret=1 + grep "

Server Statistics

" xsltproc.out.${n} >/dev/null || ret=1 + grep "

Zone Maintenance Statistics

" xsltproc.out.${n} >/dev/null || ret=1 + # grep "

Resolver Statistics (Common)

" xsltproc.out.${n} >/dev/null || ret=1 + grep "

Resolver Statistics for View " xsltproc.out.${n} >/dev/null || ret=1 + grep "

ADB Statistics for View " xsltproc.out.${n} >/dev/null || ret=1 + grep "

Cache Statistics for View " xsltproc.out.${n} >/dev/null || ret=1 + # grep "

Cache DB RRsets for View " xsltproc.out.${n} >/dev/null || ret=1 + grep "

Traffic Size Statistics

" xsltproc.out.${n} >/dev/null || ret=1 + grep "

UDP Requests Received

" xsltproc.out.${n} >/dev/null || ret=1 + grep "

UDP Responses Sent

" xsltproc.out.${n} >/dev/null || ret=1 + grep "

TCP Requests Received

" xsltproc.out.${n} >/dev/null || ret=1 + grep "

TCP Responses Sent

" xsltproc.out.${n} >/dev/null || ret=1 + grep "

Socket I/O Statistics

" xsltproc.out.${n} >/dev/null || ret=1 + grep "

Zones for View " xsltproc.out.${n} >/dev/null || ret=1 + grep "

Received QTYPES per view/zone

" xsltproc.out.${n} >/dev/null || ret=1 + grep "

View _default" xsltproc.out.${n} >/dev/null || ret=1 + grep "

Zone example" xsltproc.out.${n} >/dev/null || ret=1 + grep "

Response Codes per view/zone

" xsltproc.out.${n} >/dev/null || ret=1 + grep "

View _default" xsltproc.out.${n} >/dev/null || ret=1 + grep "

Zone example" xsltproc.out.${n} >/dev/null || ret=1 + # grep "

Glue cache statistics

" xsltproc.out.${n} >/dev/null || ret=1 + grep "

View _default" xsltproc.out.${n} >/dev/null || ret=1 + grep "

Zone example" xsltproc.out.${n} >/dev/null || ret=1 + grep "

Task Manager Configuration

" xsltproc.out.${n} >/dev/null || ret=1 + grep "

Tasks

" xsltproc.out.${n} >/dev/null || ret=1 + grep "

Memory Usage Summary

" xsltproc.out.${n} >/dev/null || ret=1 + grep "

Memory Contexts

" xsltproc.out.${n} >/dev/null || ret=1 +else + echo_i "skipping test as libxml2 and/or curl with HTTP/1.1 support and/or xsltproc was not found" +fi +if [ $ret != 0 ]; then echo_i "failed"; fi +status=$((status + ret)) +n=$((n + 1)) + +ret=0 +echo_i "checking bind9.xml socket statistics ($n)" +if $FEATURETEST --have-libxml2 && [ -e stats.xml.out ] && [ -x "${XSLTPROC}" ] ; then + # Socket statistics (expect no errors) + grep "0" stats.xml.out >/dev/null || ret=1 + grep "0" stats.xml.out >/dev/null || ret=1 + grep "0" stats.xml.out >/dev/null || ret=1 + grep "0" stats.xml.out >/dev/null || ret=1 + grep "0" stats.xml.out >/dev/null || ret=1 + # grep "0" stats.xml.out >/dev/null || ret=1 + + grep "0" stats.xml.out >/dev/null || ret=1 + grep "0" stats.xml.out >/dev/null || ret=1 + grep "0" stats.xml.out >/dev/null || ret=1 + grep "0" stats.xml.out >/dev/null || ret=1 + grep "0" stats.xml.out >/dev/null || ret=1 + grep "0" stats.xml.out >/dev/null || ret=1 +else + echo_i "skipping test as libxml2 and/or stats.xml.out file and/or xsltproc was not found" +fi +if [ $ret != 0 ]; then echo_i "failed"; fi +status=$((status + ret)) +n=$((n + 1)) + +echo_i "Check that 'zone-statistics full;' is processed by 'rndc reconfig' ($n)" +ret=0 +# off by default +rndc_stats ns2 10.53.0.2 || ret=1 +sed -n '/Per Zone Query Statistics/,/^++/p' $last_stats | grep -F '[example]' > /dev/null && ret=0 +# turn on +copy_setports ns2/named2.conf.in ns2/named.conf +rndc_reconfig ns2 10.53.0.2 +rndc_stats ns2 10.53.0.2 || ret=1 +sed -n '/Per Zone Query Statistics/,/^++/p' $last_stats | grep -F '[example]' > /dev/null || ret=1 +# turn off +copy_setports ns2/named.conf.in ns2/named.conf +rndc_reconfig ns2 10.53.0.2 +rndc_stats ns2 10.53.0.2 || ret=1 +sed -n '/Per Zone Query Statistics/,/^++/p' $last_stats | grep -F '[example]' > /dev/null && ret=0 +# turn on +copy_setports ns2/named2.conf.in ns2/named.conf +rndc_reconfig ns2 10.53.0.2 +rndc_stats ns2 10.53.0.2 || ret=1 +sed -n '/Per Zone Query Statistics/,/^++/p' $last_stats | grep -F '[example]' > /dev/null || ret=1 +if [ $ret != 0 ]; then echo_i "failed"; fi +status=$((status + ret)) +n=$((n + 1)) + +echo_i "exit status: $status" +[ $status -eq 0 ] || exit 1 diff --git a/bin/tests/system/statistics/tests_sh_statistics.py b/bin/tests/system/statistics/tests_sh_statistics.py new file mode 100644 index 0000000..d87688f --- /dev/null +++ b/bin/tests/system/statistics/tests_sh_statistics.py @@ -0,0 +1,14 @@ +# 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. + + +def test_statistics(run_tests_sh): + run_tests_sh() -- cgit v1.2.3