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 15DIGCMD="$DIG @10.53.0.3 -p ${PORT} +tcp +tries=1 +time=1" 16RNDCCMD="$RNDC -p ${CONTROLPORT} -s 10.53.0.3 -c ../common/rndc.conf" 17 18burst() { 19 num=${3:-20} 20 rm -f burst.input.$$ 21 while [ $num -gt 0 ]; do 22 num=`expr $num - 1` 23 echo "${num}${1}${2}.lamesub.example A" >> burst.input.$$ 24 done 25 $PERL ../ditch.pl -p ${PORT} -s 10.53.0.3 burst.input.$$ 26 rm -f burst.input.$$ 27} 28 29stat() { 30 clients=`$RNDCCMD status | grep "recursive clients" | 31 sed 's;.*: \([^/][^/]*\)/.*;\1;'` 32 echo_i "clients: $clients" 33 [ "$clients" = "" ] && return 1 34 [ "$clients" -le $1 ] 35} 36 37status=0 38 39echo_i "checking recursing clients are dropped at the per-server limit" 40ret=0 41# make the server lame and restart 42$RNDCCMD flush 43touch ans4/norespond 44for try in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do 45 burst a $try 46 # fetches-per-server is at 400, but at 20qps against a lame server, 47 # we'll reach 200 at the tenth second, and the quota should have been 48 # tuned to less than that by then 49 stat 200 || ret=1 50 [ $ret -eq 1 ] && break 51 sleep 1 52done 53if [ $ret != 0 ]; then echo_i "failed"; fi 54status=`expr $status + $ret` 55 56echo_i "dumping ADB data" 57$RNDCCMD dumpdb -adb 58info=`grep '10.53.0.4' ns3/named_dump.db | sed 's/.*\(atr [.0-9]*\).*\(quota [0-9]*\).*/\1 \2/'` 59echo_i $info 60set -- $info 61quota=$5 62[ ${5:-200} -lt 200 ] || ret=1 63 64echo_i "checking servfail statistics" 65ret=0 66rm -f ns3/named.stats 67$RNDCCMD stats 68for try in 1 2 3 4 5; do 69 [ -f ns3/named.stats ] && break 70 sleep 1 71done 72sspill=`grep 'spilled due to server' ns3/named.stats | sed 's/\([0-9][0-9]*\) spilled.*/\1/'` 73[ -z "$sspill" ] && sspill=0 74fails=`grep 'queries resulted in SERVFAIL' ns3/named.stats | sed 's/\([0-9][0-9]*\) queries.*/\1/'` 75[ -z "$fails" ] && fails=0 76[ "$fails" -ge "$sspill" ] || ret=1 77if [ $ret != 0 ]; then echo_i "failed"; fi 78status=`expr $status + $ret` 79 80echo_i "checking lame server recovery" 81ret=0 82rm -f ans4/norespond 83for try in 1 2 3 4 5; do 84 burst b $try 85 stat 200 || ret=1 86 [ $ret -eq 1 ] && break 87 sleep 1 88done 89 90echo_i "dumping ADB data" 91$RNDCCMD dumpdb -adb 92info=`grep '10.53.0.4' ns3/named_dump.db | sed 's/.*\(atr [.0-9]*\).*\(quota [0-9]*\).*/\1 \2/'` 93echo_i $info 94set -- $info 95[ ${5:-${quota}} -lt $quota ] || ret=1 96quota=$5 97 98for try in 1 2 3 4 5 6 7 8 9 10; do 99 burst c $try 100 stat 20 || ret=1 101 [ $ret -eq 1 ] && break 102 sleep 1 103done 104 105echo_i "dumping ADB data" 106$RNDCCMD dumpdb -adb 107info=`grep '10.53.0.4' ns3/named_dump.db | sed 's/.*\(atr [.0-9]*\).*\(quota [0-9]*\).*/\1 \2/'` 108echo_i $info 109set -- $info 110[ ${5:-${quota}} -gt $quota ] || ret=1 111quota=$5 112if [ $ret != 0 ]; then echo_i "failed"; fi 113status=`expr $status + $ret` 114 115copy_setports ns3/named2.conf.in ns3/named.conf 116$RNDCCMD reconfig 2>&1 | sed 's/^/ns3 /' | cat_i 117 118echo_i "checking lame server clients are dropped at the per-domain limit" 119ret=0 120fail=0 121success=0 122touch ans4/norespond 123for try in 1 2 3 4 5; do 124 burst b $try 300 125 $DIGCMD a ${try}.example > dig.out.ns3.$try 126 grep "status: NOERROR" dig.out.ns3.$try > /dev/null 2>&1 && \ 127 success=`expr $success + 1` 128 grep "status: SERVFAIL" dig.out.ns3.$try > /dev/null 2>&1 && \ 129 fail=`expr $fail + 1` 130 stat 50 || ret=1 131 [ $ret -eq 1 ] && break 132 $RNDCCMD recursing 2>&1 | sed 's/^/ns3 /' | cat_i 133 sleep 1 134done 135echo_i "$success successful valid queries, $fail SERVFAIL" 136if [ $ret != 0 ]; then echo_i "failed"; fi 137status=`expr $status + $ret` 138 139echo_i "checking drop statistics" 140rm -f ns3/named.stats 141$RNDCCMD stats 142for try in 1 2 3 4 5; do 143 [ -f ns3/named.stats ] && break 144 sleep 1 145done 146zspill=`grep 'spilled due to zone' ns3/named.stats | sed 's/\([0-9][0-9]*\) spilled.*/\1/'` 147[ -z "$zspill" ] && zspill=0 148drops=`grep 'queries dropped' ns3/named.stats | sed 's/\([0-9][0-9]*\) queries.*/\1/'` 149[ -z "$drops" ] && drops=0 150[ "$drops" -ge "$zspill" ] || ret=1 151if [ $ret != 0 ]; then echo_i "failed"; fi 152status=`expr $status + $ret` 153 154copy_setports ns3/named3.conf.in ns3/named.conf 155$RNDCCMD reconfig 2>&1 | sed 's/^/ns3 /' | cat_i 156 157echo_i "checking lame server clients are dropped at the soft limit" 158ret=0 159fail=0 160exceeded=0 161success=0 162touch ans4/norespond 163for try in 1 2 3 4 5; do 164 burst b $try 400 165 $DIGCMD a ${try}.example > dig.out.ns3.$try 166 stat 380 || exceeded=`expr $exceeded + 1` 167 grep "status: NOERROR" dig.out.ns3.$try > /dev/null 2>&1 && \ 168 success=`expr $success + 1` 169 grep "status: SERVFAIL" dig.out.ns3.$try > /dev/null 2>&1 && \ 170 fail=`expr $fail + 1` 171 sleep 1 172done 173echo_i "$success successful valid queries (expected 5)" 174[ "$success" -eq 5 ] || { echo_i "failed"; ret=1; } 175echo_i "$fail SERVFAIL responses (expected 0)" 176[ "$fail" -eq 0 ] || { echo_i "failed"; ret=1; } 177echo_i "clients count exceeded 360 on $exceeded trials (expected 0)" 178[ "$exceeded" -eq 0 ] || { echo_i "failed"; ret=1; } 179if [ $ret != 0 ]; then echo_i "failed"; fi 180status=`expr $status + $ret` 181 182echo_i "checking drop statistics" 183rm -f ns3/named.stats 184$RNDCCMD stats 185for try in 1 2 3 4 5; do 186 [ -f ns3/named.stats ] && break 187 sleep 1 188done 189drops=`grep 'queries dropped due to recursive client limit' ns3/named.stats | sed 's/\([0-9][0-9]*\) queries.*/\1/'` 190[ "${drops:-0}" -ne 0 ] || ret=1 191if [ $ret != 0 ]; then echo_i "failed"; fi 192status=`expr $status + $ret` 193 194echo_i "exit status: $status" 195[ $status -eq 0 ] || exit 1 196