1#!/bin/sh 2# 3# Copyright (C) Internet Systems Consortium, Inc. ("ISC") 4# 5# This Source Code Form is subject to the terms of the Mozilla Public 6# License, v. 2.0. If a copy of the MPL was not distributed with this 7# file, you can obtain one at https://mozilla.org/MPL/2.0/. 8# 9# See the COPYRIGHT file distributed with this work for additional 10# information regarding copyright ownership. 11 12SYSTEMTESTTOP=.. 13. $SYSTEMTESTTOP/conf.sh 14 15DIGOPTS="+tcp +noadd +nosea +nostat +noquest +nocomm +nocmd" 16DIGCMD="$DIG $DIGOPTS -p ${PORT}" 17RNDCCMD="$RNDC -p ${CONTROLPORT} -c ../common/rndc.conf" 18 19status=0 20 21ret=0 22n=1 23stats=0 24rndc_stats() { 25 _ns=$1 26 _ip=$2 27 28 $RNDCCMD -s $_ip stats > /dev/null 2>&1 || return 1 29 [ -f "${_ns}/named.stats" ] || return 1 30 31 last_stats=named.stats.$_ns-$stats-$n 32 mv ${_ns}/named.stats $last_stats 33 stats=$((stats+1)) 34} 35 36echo_i "fetching a.example from ns2's initial configuration ($n)" 37$DIGCMD +noauth a.example. @10.53.0.2 any > dig.out.ns2.1 || ret=1 38if [ $ret != 0 ]; then echo_i "failed"; fi 39status=`expr $status + $ret` 40n=`expr $n + 1` 41 42ret=0 43echo_i "dumping initial stats for ns2 ($n)" 44rndc_stats ns2 10.53.0.2 || ret=1 45if [ $ret != 0 ]; then echo_i "failed"; fi 46status=`expr $status + $ret` 47n=`expr $n + 1` 48 49ret=0 50echo_i "verifying adb records in named.stats ($n)" 51grep "ADB stats" $last_stats > /dev/null || ret=1 52if [ $ret != 0 ]; then echo_i "failed"; fi 53status=`expr $status + $ret` 54n=`expr $n + 1` 55 56echo_i "checking for 1 entry in adb hash table in named.stats ($n)" 57grep "1 Addresses in hash table" $last_stats > /dev/null || ret=1 58if [ $ret != 0 ]; then echo_i "failed"; fi 59status=`expr $status + $ret` 60n=`expr $n + 1` 61 62ret=0 63echo_i "verifying cache statistics in named.stats ($n)" 64grep "Cache Statistics" $last_stats > /dev/null || ret=1 65if [ $ret != 0 ]; then echo_i "failed"; fi 66status=`expr $status + $ret` 67n=`expr $n + 1` 68 69ret=0 70echo_i "checking for 2 entries in adb hash table in named.stats ($n)" 71$DIGCMD a.example.info. @10.53.0.2 any > /dev/null 2>&1 72rndc_stats ns2 10.53.0.2 || ret=1 73grep "2 Addresses in hash table" $last_stats > /dev/null || ret=1 74if [ $ret != 0 ]; then echo_i "failed"; fi 75status=`expr $status + $ret` 76n=`expr $n + 1` 77 78ret=0 79echo_i "dumping initial stats for ns3 ($n)" 80rndc_stats ns3 10.53.0.3 || ret=1 81if [ ! "$CYGWIN" ]; then 82 nsock0nstat=`grep "UDP/IPv4 sockets active" $last_stats | awk '{print $1}'` 83 [ 0 -ne ${nsock0nstat:-0} ] || ret=1 84fi 85if [ $ret != 0 ]; then echo_i "failed"; fi 86status=`expr $status + $ret` 87n=`expr $n + 1` 88 89echo_i "sending queries to ns3" 90$DIGCMD +tries=2 +time=1 +recurse @10.53.0.3 foo.info. any > /dev/null 2>&1 91 92ret=0 93echo_i "dumping updated stats for ns3 ($n)" 94rndc_stats ns3 10.53.0.3 || ret=1 95if [ $ret != 0 ]; then echo_i "failed"; fi 96status=`expr $status + $ret` 97n=`expr $n + 1` 98 99ret=0 100echo_i "verifying recursing clients output in named.stats ($n)" 101grep "2 recursing clients" $last_stats > /dev/null || ret=1 102if [ $ret != 0 ]; then echo_i "failed"; fi 103status=`expr $status + $ret` 104n=`expr $n + 1` 105 106ret=0 107echo_i "verifying active fetches output in named.stats ($n)" 108grep "1 active fetches" $last_stats > /dev/null || ret=1 109if [ $ret != 0 ]; then echo_i "failed"; fi 110status=`expr $status + $ret` 111n=`expr $n + 1` 112 113if [ ! "$CYGWIN" ]; then 114 ret=0 115 echo_i "verifying active sockets output in named.stats ($n)" 116 nsock1nstat=`grep "UDP/IPv4 sockets active" $last_stats | awk '{print $1}'` 117 [ `expr ${nsock1nstat:-0} - ${nsock0nstat:-0}` -eq 1 ] || ret=1 118 if [ $ret != 0 ]; then echo_i "failed"; fi 119 status=`expr $status + $ret` 120 n=`expr $n + 1` 121fi 122 123# there should be 1 UDP and no TCP queries. As the TCP counter is zero 124# no status line is emitted. 125ret=0 126echo_i "verifying queries in progress in named.stats ($n)" 127grep "1 UDP queries in progress" $last_stats > /dev/null || ret=1 128grep "TCP queries in progress" $last_stats > /dev/null && ret=1 129if [ $ret != 0 ]; then echo_i "failed"; fi 130status=`expr $status + $ret` 131n=`expr $n + 1` 132 133ret=0 134echo_i "verifying bucket size output ($n)" 135grep "bucket size" $last_stats > /dev/null || ret=1 136if [ $ret != 0 ]; then echo_i "failed"; fi 137status=`expr $status + $ret` 138n=`expr $n + 1` 139 140ret=0 141echo_i "checking that zones with slash are properly shown in XML output ($n)" 142if $FEATURETEST --have-libxml2 && [ -x ${CURL} ] ; then 143 ${CURL} http://10.53.0.1:${EXTRAPORT1}/xml/v3/zones > curl.out.${n} 2>/dev/null || ret=1 144 grep '<zone name="32/1.0.0.127-in-addr.example" rdataclass="IN">' curl.out.${n} > /dev/null || ret=1 145else 146 echo_i "skipping test as libxml2 and/or curl was not found" 147fi 148if [ $ret != 0 ]; then echo_i "failed"; fi 149status=`expr $status + $ret` 150n=`expr $n + 1` 151 152ret=0 153echo_i "checking that zones return their type ($n)" 154if $FEATURETEST --have-libxml2 && [ -x ${CURL} ] ; then 155 ${CURL} http://10.53.0.1:${EXTRAPORT1}/xml/v3/zones > curl.out.${n} 2>/dev/null || ret=1 156 grep '<zone name="32/1.0.0.127-in-addr.example" rdataclass="IN"><type>master</type>' curl.out.${n} > /dev/null || ret=1 157else 158 echo_i "skipping test as libxml2 and/or curl was not found" 159fi 160if [ $ret != 0 ]; then echo_i "failed"; fi 161status=`expr $status + $ret` 162n=`expr $n + 1` 163 164ret=0 165echo_i "checking bind9.xsl vs xml ($n)" 166if $FEATURETEST --have-libxml2 && [ -x "${CURL}" ] && [ -x "${XSLTPROC}" ] ; then 167 $DIGCMD +notcp +recurse @10.53.0.3 soa . > /dev/null 2>&1 168 $DIGCMD +notcp +recurse @10.53.0.3 soa example > /dev/null 2>&1 169 ${CURL} http://10.53.0.3:${EXTRAPORT1}/xml/v3 > curl.out.${n}.xml 2>/dev/null || ret=1 170 ${CURL} http://10.53.0.3:${EXTRAPORT1}/bind9.xsl > curl.out.${n}.xsl 2>/dev/null || ret=1 171 ${XSLTPROC} curl.out.${n}.xsl - < curl.out.${n}.xml > xsltproc.out.${n} 2>/dev/null || ret=1 172 cp curl.out.${n}.xml stats.xml.out || ret=1 173 174 # 175 # grep for expected sections. 176 # 177 grep "<h1>ISC Bind 9 Configuration and Statistics</h1>" xsltproc.out.${n} >/dev/null || ret=1 178 grep "<h2>Server Status</h2>" xsltproc.out.${n} >/dev/null || ret=1 179 grep "<h2>Incoming Requests by DNS Opcode</h2>" xsltproc.out.${n} >/dev/null || ret=1 180 grep "<h3>Incoming Queries by Query Type</h3>" xsltproc.out.${n} >/dev/null || ret=1 181 grep "<h2>Outgoing Queries per view</h2>" xsltproc.out.${n} >/dev/null || ret=1 182 grep "<h3>View " xsltproc.out.${n} >/dev/null || ret=1 183 grep "<h2>Server Statistics</h2>" xsltproc.out.${n} >/dev/null || ret=1 184 grep "<h2>Zone Maintenance Statistics</h2>" xsltproc.out.${n} >/dev/null || ret=1 185 grep "<h2>Resolver Statistics (Common)</h2>" xsltproc.out.${n} >/dev/null || ret=1 186 grep "<h3>Resolver Statistics for View " xsltproc.out.${n} >/dev/null || ret=1 187 grep "<h3>ADB Statistics for View " xsltproc.out.${n} >/dev/null || ret=1 188 grep "<h3>Cache Statistics for View " xsltproc.out.${n} >/dev/null || ret=1 189 # grep "<h3>Cache DB RRsets for View " xsltproc.out.${n} >/dev/null || ret=1 190 grep "<h2>Traffic Size Statistics</h2>" xsltproc.out.${n} >/dev/null || ret=1 191 grep "<h4>UDP Requests Received</h4>" xsltproc.out.${n} >/dev/null || ret=1 192 grep "<h4>UDP Responses Sent</h4>" xsltproc.out.${n} >/dev/null || ret=1 193 grep "<h4>TCP Requests Received</h4>" xsltproc.out.${n} >/dev/null || ret=1 194 grep "<h4>TCP Responses Sent</h4>" xsltproc.out.${n} >/dev/null || ret=1 195 grep "<h2>Socket I/O Statistics</h2>" xsltproc.out.${n} >/dev/null || ret=1 196 grep "<h3>Zones for View " xsltproc.out.${n} >/dev/null || ret=1 197 grep "<h2>Received QTYPES per view/zone</h2>" xsltproc.out.${n} >/dev/null || ret=1 198 grep "<h3>View _default" xsltproc.out.${n} >/dev/null || ret=1 199 grep "<h4>Zone example" xsltproc.out.${n} >/dev/null || ret=1 200 grep "<h2>Response Codes per view/zone</h2>" xsltproc.out.${n} >/dev/null || ret=1 201 grep "<h3>View _default" xsltproc.out.${n} >/dev/null || ret=1 202 grep "<h4>Zone example" xsltproc.out.${n} >/dev/null || ret=1 203 # grep "<h2>Glue cache statistics</h2>" xsltproc.out.${n} >/dev/null || ret=1 204 grep "<h3>View _default" xsltproc.out.${n} >/dev/null || ret=1 205 grep "<h4>Zone example" xsltproc.out.${n} >/dev/null || ret=1 206 grep "<h2>Network Status</h2>" xsltproc.out.${n} >/dev/null || ret=1 207 grep "<h2>Task Manager Configuration</h2>" xsltproc.out.${n} >/dev/null || ret=1 208 grep "<h2>Tasks</h2>" xsltproc.out.${n} >/dev/null || ret=1 209 grep "<h2>Memory Usage Summary</h2>" xsltproc.out.${n} >/dev/null || ret=1 210 grep "<h2>Memory Contexts</h2>" xsltproc.out.${n} >/dev/null || ret=1 211else 212 echo_i "skipping test as libxml2 and/or curl and/or xsltproc was not found" 213fi 214if [ $ret != 0 ]; then echo_i "failed"; fi 215status=`expr $status + $ret` 216n=`expr $n + 1` 217 218ret=0 219echo_i "checking bind9.xml socket statistics ($n)" 220if $FEATURETEST --have-libxml2 && [ -x "${CURL}" ] && [ -x "${XSLTPROC}" ] ; then 221 # Socket statistics (expect no errors) 222 grep "<counter name=\"TCP4AcceptFail\">0</counter>" stats.xml.out >/dev/null || ret=1 223 grep "<counter name=\"TCP4BindFail\">0</counter>" stats.xml.out >/dev/null || ret=1 224 grep "<counter name=\"TCP4ConnFail\">0</counter>" stats.xml.out >/dev/null || ret=1 225 grep "<counter name=\"TCP4OpenFail\">0</counter>" stats.xml.out >/dev/null || ret=1 226 grep "<counter name=\"TCP4RecvErr\">0</counter>" stats.xml.out >/dev/null || ret=1 227 grep "<counter name=\"TCP4SendErr\">0</counter>" stats.xml.out >/dev/null || ret=1 228 229 grep "<counter name=\"TCP6AcceptFail\">0</counter>" stats.xml.out >/dev/null || ret=1 230 grep "<counter name=\"TCP6BindFail\">0</counter>" stats.xml.out >/dev/null || ret=1 231 grep "<counter name=\"TCP6ConnFail\">0</counter>" stats.xml.out >/dev/null || ret=1 232 grep "<counter name=\"TCP6OpenFail\">0</counter>" stats.xml.out >/dev/null || ret=1 233 grep "<counter name=\"TCP6RecvErr\">0</counter>" stats.xml.out >/dev/null || ret=1 234 grep "<counter name=\"TCP6SendErr\">0</counter>" stats.xml.out >/dev/null || ret=1 235else 236 echo_i "skipping test as libxml2 and/or curl and/or xsltproc was not found" 237fi 238if [ $ret != 0 ]; then echo_i "failed"; fi 239status=`expr $status + $ret` 240n=`expr $n + 1` 241 242ret=0 243echo_i "checking priming queries are counted ($n)" 244grep "1 priming queries" $last_stats 245if [ $ret != 0 ]; then echo_i "failed"; fi 246status=`expr $status + $ret` 247n=`expr $n + 1` 248 249echo_i "Check that 'zone-statistics full;' is processed by 'rndc reconfig' ($n)" 250ret=0 251# off by default 252rndc_stats ns2 10.53.0.2 || ret=1 253sed -n '/Per Zone Query Statistics/,/^++/p' $last_stats | grep -F '[example]' > /dev/null && ret=0 254# turn on 255copy_setports ns2/named2.conf.in ns2/named.conf 256rndc_reconfig ns2 10.53.0.2 257rndc_stats ns2 10.53.0.2 || ret=1 258sed -n '/Per Zone Query Statistics/,/^++/p' $last_stats | grep -F '[example]' > /dev/null || ret=1 259# turn off 260copy_setports ns2/named.conf.in ns2/named.conf 261rndc_reconfig ns2 10.53.0.2 262rndc_stats ns2 10.53.0.2 || ret=1 263sed -n '/Per Zone Query Statistics/,/^++/p' $last_stats | grep -F '[example]' > /dev/null && ret=0 264# turn on 265copy_setports ns2/named2.conf.in ns2/named.conf 266rndc_reconfig ns2 10.53.0.2 267rndc_stats ns2 10.53.0.2 || ret=1 268sed -n '/Per Zone Query Statistics/,/^++/p' $last_stats | grep -F '[example]' > /dev/null || ret=1 269if [ $ret != 0 ]; then echo_i "failed"; fi 270status=`expr $status + $ret` 271n=`expr $n + 1` 272 273echo_i "exit status: $status" 274[ $status -eq 0 ] || exit 1 275