tests.sh 5.37 KB
Newer Older
Evan Hunt's avatar
Evan Hunt committed
1 2
#!/bin/sh
#
3
# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
Evan Hunt's avatar
Evan Hunt committed
4
#
5 6 7
# 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/.
8 9 10
#
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
Evan Hunt's avatar
Evan Hunt committed
11 12 13 14

SYSTEMTESTTOP=..
. $SYSTEMTESTTOP/conf.sh

Evan Hunt's avatar
Evan Hunt committed
15 16
DIGCMD="$DIG @10.53.0.3 -p ${PORT} +tries=1 +time=1"
RNDCCMD="$RNDC -p ${CONTROLPORT} -s 10.53.0.3 -c ../common/rndc.conf"
Evan Hunt's avatar
Evan Hunt committed
17 18 19 20 21 22 23 24

burst() {
    num=${3:-20}
    rm -f burst.input.$$
    while [ $num -gt 0 ]; do
        num=`expr $num - 1`
        echo "${num}${1}${2}.lamesub.example A" >> burst.input.$$
    done
Evan Hunt's avatar
Evan Hunt committed
25
    $PERL ../ditch.pl -p ${PORT} -s 10.53.0.3 burst.input.$$
Evan Hunt's avatar
Evan Hunt committed
26 27 28 29 30 31
    rm -f burst.input.$$
}

stat() {
    clients=`$RNDCCMD status | grep "recursive clients" | 
            sed 's;.*: \([^/][^/]*\)/.*;\1;'`
Evan Hunt's avatar
Evan Hunt committed
32
    echo_i "clients: $clients"
Evan Hunt's avatar
Evan Hunt committed
33 34 35 36 37 38
    [ "$clients" = "" ] && return 1
    [ "$clients" -le $1 ]
}

status=0

Evan Hunt's avatar
Evan Hunt committed
39
echo_i "checking recursing clients are dropped at the per-server limit"
Evan Hunt's avatar
Evan Hunt committed
40 41 42 43 44 45 46 47 48 49 50 51 52
ret=0
# make the server lame and restart
$RNDCCMD flush
touch ans4/norespond
for try in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
    burst a $try
    # fetches-per-server is at 400, but at 20qps against a lame server,
    # we'll reach 200 at the tenth second, and the quota should have been
    # tuned to less than that by then
    stat 200 || ret=1
    [ $ret -eq 1 ] && break
    sleep 1
done
Evan Hunt's avatar
Evan Hunt committed
53
if [ $ret != 0 ]; then echo_i "failed"; fi
Evan Hunt's avatar
Evan Hunt committed
54 55
status=`expr $status + $ret`

Evan Hunt's avatar
Evan Hunt committed
56
echo_i "dumping ADB data"
Evan Hunt's avatar
Evan Hunt committed
57
$RNDCCMD dumpdb -adb
Evan Hunt's avatar
Evan Hunt committed
58 59
info=`grep '10.53.0.4' ns3/named_dump.db | sed 's/.*\(atr [.0-9]*\).*\(quota [0-9]*\).*/\1 \2/'`
echo_i $info
Evan Hunt's avatar
Evan Hunt committed
60 61 62 63
set -- $info
quota=$5
[ ${5:-200} -lt 200 ] || ret=1

Evan Hunt's avatar
Evan Hunt committed
64 65
echo_i "checking servfail statistics"
ret=0
Evan Hunt's avatar
Evan Hunt committed
66 67 68 69 70 71 72 73 74 75 76
rm -f ns3/named.stats
$RNDCCMD stats
for try in 1 2 3 4 5; do
    [ -f ns3/named.stats ] && break
    sleep 1
done
sspill=`grep 'spilled due to server' ns3/named.stats | sed 's/\([0-9][0-9]*\) spilled.*/\1/'`
[ -z "$sspill" ] && sspill=0
fails=`grep 'queries resulted in SERVFAIL' ns3/named.stats | sed 's/\([0-9][0-9]*\) queries.*/\1/'`
[ -z "$fails" ] && fails=0
[ "$fails" -ge "$sspill" ] || ret=1
Evan Hunt's avatar
Evan Hunt committed
77
if [ $ret != 0 ]; then echo_i "failed"; fi
Evan Hunt's avatar
Evan Hunt committed
78 79
status=`expr $status + $ret`

Evan Hunt's avatar
Evan Hunt committed
80
echo_i "checking lame server recovery"
Evan Hunt's avatar
Evan Hunt committed
81 82 83 84 85 86 87 88 89
ret=0
rm -f ans4/norespond
for try in 1 2 3 4 5; do
    burst b $try
    stat 200 || ret=1
    [ $ret -eq 1 ] && break
    sleep 1
done

Evan Hunt's avatar
Evan Hunt committed
90
echo_i "dumping ADB data"
Evan Hunt's avatar
Evan Hunt committed
91
$RNDCCMD dumpdb -adb
Evan Hunt's avatar
Evan Hunt committed
92 93
info=`grep '10.53.0.4' ns3/named_dump.db | sed 's/.*\(atr [.0-9]*\).*\(quota [0-9]*\).*/\1 \2/'`
echo_i $info
Evan Hunt's avatar
Evan Hunt committed
94 95 96 97 98 99 100 101 102 103 104
set -- $info
[ ${5:-${quota}} -lt $quota ] || ret=1
quota=$5

for try in 1 2 3 4 5 6 7 8 9 10; do
    burst c $try
    stat 20 || ret=1
    [ $ret -eq 1 ] && break
    sleep 1
done

Evan Hunt's avatar
Evan Hunt committed
105
echo_i "dumping ADB data"
Evan Hunt's avatar
Evan Hunt committed
106
$RNDCCMD dumpdb -adb
Evan Hunt's avatar
Evan Hunt committed
107 108
info=`grep '10.53.0.4' ns3/named_dump.db | sed 's/.*\(atr [.0-9]*\).*\(quota [0-9]*\).*/\1 \2/'`
echo_i $info
Evan Hunt's avatar
Evan Hunt committed
109 110 111
set -- $info
[ ${5:-${quota}} -gt $quota ] || ret=1
quota=$5
Evan Hunt's avatar
Evan Hunt committed
112
if [ $ret != 0 ]; then echo_i "failed"; fi
Evan Hunt's avatar
Evan Hunt committed
113 114
status=`expr $status + $ret`

Evan Hunt's avatar
Evan Hunt committed
115
if [ $ret != 0 ]; then echo_i "failed"; fi
Evan Hunt's avatar
Evan Hunt committed
116 117
status=`expr $status + $ret`

Evan Hunt's avatar
Evan Hunt committed
118
copy_setports ns3/named2.conf.in ns3/named.conf
119
rndc_reconfig ns3 10.53.0.3
Evan Hunt's avatar
Evan Hunt committed
120

Evan Hunt's avatar
Evan Hunt committed
121
echo_i "checking lame server clients are dropped at the per-domain limit"
Evan Hunt's avatar
Evan Hunt committed
122 123 124 125 126 127 128 129 130 131 132 133 134
ret=0
fail=0
success=0
touch ans4/norespond
for try in 1 2 3 4 5; do
    burst b $try 300
    $DIGCMD a ${try}.example > dig.out.ns3.$try
    grep "status: NOERROR" dig.out.ns3.$try > /dev/null 2>&1 && \
            success=`expr $success + 1`
    grep "status: SERVFAIL" dig.out.ns3.$try > /dev/null 2>&1 && \
            fail=`expr $fail + 1`
    stat 50 || ret=1
    [ $ret -eq 1 ] && break
Evan Hunt's avatar
Evan Hunt committed
135
    $RNDCCMD recursing 2>&1 | sed 's/^/ns3 /' | cat_i
Evan Hunt's avatar
Evan Hunt committed
136 137
    sleep 1
done
Evan Hunt's avatar
Evan Hunt committed
138 139
echo_i "$success successful valid queries, $fail SERVFAIL"
if [ $ret != 0 ]; then echo_i "failed"; fi
Evan Hunt's avatar
Evan Hunt committed
140 141
status=`expr $status + $ret`

Evan Hunt's avatar
Evan Hunt committed
142
echo_i "checking drop statistics"
Evan Hunt's avatar
Evan Hunt committed
143 144 145 146 147 148 149 150 151 152 153
rm -f ns3/named.stats
$RNDCCMD stats
for try in 1 2 3 4 5; do
    [ -f ns3/named.stats ] && break
    sleep 1
done
zspill=`grep 'spilled due to zone' ns3/named.stats | sed 's/\([0-9][0-9]*\) spilled.*/\1/'`
[ -z "$zspill" ] && zspill=0
drops=`grep 'queries dropped' ns3/named.stats | sed 's/\([0-9][0-9]*\) queries.*/\1/'`
[ -z "$drops" ] && drops=0
[ "$drops" -ge "$zspill" ] || ret=1
Evan Hunt's avatar
Evan Hunt committed
154
if [ $ret != 0 ]; then echo_i "failed"; fi
Evan Hunt's avatar
Evan Hunt committed
155 156
status=`expr $status + $ret`

Evan Hunt's avatar
Evan Hunt committed
157
copy_setports ns3/named3.conf.in ns3/named.conf
158
rndc_reconfig ns3 10.53.0.3
Evan Hunt's avatar
Evan Hunt committed
159

160
echo_i "checking lame server clients are dropped near the soft limit"
Evan Hunt's avatar
Evan Hunt committed
161 162
ret=0
fail=0
Evan Hunt's avatar
Evan Hunt committed
163
exceeded=0
Evan Hunt's avatar
Evan Hunt committed
164 165 166 167
success=0
touch ans4/norespond
for try in 1 2 3 4 5; do
    burst b $try 400
Evan Hunt's avatar
Evan Hunt committed
168
    $DIG @10.53.0.3 -p ${PORT}  a ${try}.example > dig.out.ns3.$try
169
    stat 380 || exceeded=`expr $exceeded + 1`
Evan Hunt's avatar
Evan Hunt committed
170 171 172 173 174 175
    grep "status: NOERROR" dig.out.ns3.$try > /dev/null 2>&1 && \
            success=`expr $success + 1`
    grep "status: SERVFAIL" dig.out.ns3.$try > /dev/null 2>&1 && \
            fail=`expr $fail + 1`
    sleep 1
done
Evan Hunt's avatar
Evan Hunt committed
176 177 178 179
echo_i "$success successful valid queries (expected 5)"
[ "$success" -eq 5 ] || { echo_i "failed"; ret=1; }
echo_i "$fail SERVFAIL responses (expected 0)"
[ "$fail" -eq 0 ] || { echo_i "failed"; ret=1; }
180
echo_i "clients count exceeded 380 on $exceeded trials (expected 0)"
Evan Hunt's avatar
Evan Hunt committed
181
[ "$exceeded" -eq 0 ] || { echo_i "failed"; ret=1; }
Evan Hunt's avatar
Evan Hunt committed
182
if [ $ret != 0 ]; then echo_i "failed"; fi
Evan Hunt's avatar
Evan Hunt committed
183 184
status=`expr $status + $ret`

Evan Hunt's avatar
Evan Hunt committed
185
echo_i "exit status: $status"
186
[ $status -eq 0 ] || exit 1