tests.sh 6.5 KB
Newer Older
Michael Sawyer's avatar
Michael Sawyer committed
1
#!/bin/sh
Michael Sawyer's avatar
Michael Sawyer committed
2
#
3
# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
Mark Andrews's avatar
Mark Andrews 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.
Mark Andrews's avatar
Mark Andrews committed
11

12 13
SYSTEMTESTTOP=..
. $SYSTEMTESTTOP/conf.sh
Michael Sawyer's avatar
Michael Sawyer committed
14

Evan Hunt's avatar
Evan Hunt committed
15 16 17
DIGOPTS="+tcp +noadd +nosea +nostat +noquest +nocomm +nocmd -p ${PORT}"
RNDCCMD="$RNDC -c $SYSTEMTESTTOP/common/rndc.conf -p ${CONTROLPORT} -s"

18
status=0
19
n=0
20

21 22 23
#
# Wait up to 10 seconds for the servers to finish starting before testing.
#
24 25 26
for i in 1 2 3 4 5 6 7 8 9 10
do
	ret=0
Evan Hunt's avatar
Evan Hunt committed
27
	$DIG +tcp -p ${PORT} example @10.53.0.2 soa > dig.out.ns2.test$n || ret=1
28 29
	grep "status: NOERROR" dig.out.ns2.test$n > /dev/null || ret=1
	grep "flags:.* aa[ ;]" dig.out.ns2.test$n > /dev/null || ret=1
Evan Hunt's avatar
Evan Hunt committed
30
	$DIG +tcp -p ${PORT} example @10.53.0.3 soa > dig.out.ns3.test$n || ret=1
31 32
	grep "status: NOERROR" dig.out.ns3.test$n > /dev/null || ret=1
	grep "flags:.* aa[ ;]" dig.out.ns3.test$n > /dev/null || ret=1
33 34
        nr=`grep 'x[0-9].*sending notify to' ns2/named.run | wc -l`
        [ $nr -eq 20 ] || ret=1
35 36 37 38
	[ $ret = 0 ] && break
	sleep 1
done

39
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
40
echo_i "checking initial status ($n)"
41
ret=0
Evan Hunt's avatar
Evan Hunt committed
42
$DIG $DIGOPTS a.example. @10.53.0.2 a > dig.out.ns2.test$n || ret=1
43
grep "10.0.0.1" dig.out.ns2.test$n > /dev/null || ret=1
Michael Sawyer's avatar
Michael Sawyer committed
44

Evan Hunt's avatar
Evan Hunt committed
45
$DIG $DIGOPTS a.example. @10.53.0.3 a > dig.out.ns3.test$n || ret=1
46
grep "10.0.0.1" dig.out.ns3.test$n > /dev/null || ret=1
Michael Sawyer's avatar
Michael Sawyer committed
47

Evan Hunt's avatar
Evan Hunt committed
48
digcomp dig.out.ns2.test$n dig.out.ns3.test$n || ret=1
Michael Sawyer's avatar
Michael Sawyer committed
49

Evan Hunt's avatar
Evan Hunt committed
50
[ $ret = 0 ] || echo_i "failed"
51 52
status=`expr $ret + $status`

53
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
54
echo_i "checking startup notify rate limit ($n)"
55
ret=0
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
awk '/x[0-9].*sending notify to/ {
	split($2, a, ":");
	this = a[1] * 3600 + a[2] * 60 + a[3];
	if (lasta1 && lasta1 > a[1]) {
		fix = 3600 * 24;
	}
	this += fix;
	if (last) {
		delta = this - last;
		print delta;
		if (!maxdelta || delta > maxdelta) {
			maxdelta = delta;
		}
		if (!mindelta || delta < mindelta) {
			mindelta = delta;
		}
	}
	lasta1 = a[1];
	last = this;
	count++;
}
END {
	print "mindelta:", mindelta
	print "maxdelta:" maxdelta
	print "count:", count;
	if (mindelta < 0.180) exit(1);
	if (count < 20) exit(1);
}' ns2/named.run > awk.out.ns2.test$n || ret=1
Evan Hunt's avatar
Evan Hunt committed
84
[ $ret = 0 ] || echo_i "failed"
85 86
status=`expr $ret + $status`

87 88
nextpart ns3/named.run > /dev/null

89
sleep 1 # make sure filesystem time stamp is newer for reload.
90
rm -f ns2/example.db
91
cp -f ns2/example2.db ns2/example.db
92
if [ ! "$CYGWIN" ]; then
Evan Hunt's avatar
Evan Hunt committed
93
    echo_i "reloading with example2 using HUP and waiting up to 45 seconds"
94 95
    $KILL -HUP `cat ns2/named.pid`
else
Evan Hunt's avatar
Evan Hunt committed
96
    echo_i "reloading with example2 using rndc and waiting up to 45 seconds"
97
    rndc_reload ns2 10.53.0.2
98
fi
99

100 101 102
try=0
while test $try -lt 45
do
103
    nextpart ns3/named.run > tmp
104
    grep "transfer of 'example/IN' from 10.53.0.2#.*success" tmp > /dev/null && break
105 106 107
    sleep 1
    try=`expr $try + 1`
done
Michael Sawyer's avatar
Michael Sawyer committed
108

109
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
110
echo_i "checking notify message was logged ($n)"
111 112
ret=0
grep 'notify from 10.53.0.2#[0-9][0-9]*: serial 2$' ns3/named.run > /dev/null || ret=1
Evan Hunt's avatar
Evan Hunt committed
113
[ $ret = 0 ] || echo_i "failed"
114 115
status=`expr $ret + $status`

116
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
117
echo_i "checking example2 loaded ($n)"
118
ret=0
Evan Hunt's avatar
Evan Hunt committed
119
$DIG $DIGOPTS a.example. @10.53.0.2 a > dig.out.ns2.test$n || ret=1
120
grep "10.0.0.2" dig.out.ns2.test$n > /dev/null || ret=1
121

Evan Hunt's avatar
Evan Hunt committed
122
[ $ret = 0 ] || echo_i "failed"
123
status=`expr $ret + $status`
Michael Sawyer's avatar
Michael Sawyer committed
124

125
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
126
echo_i "checking example2 contents have been transferred after HUP reload ($n)"
127
ret=0
Evan Hunt's avatar
Evan Hunt committed
128
$DIG $DIGOPTS a.example. @10.53.0.2 a > dig.out.ns2.test$n || ret=1
129
grep "10.0.0.2" dig.out.ns2.test$n > /dev/null || ret=1
Michael Sawyer's avatar
Michael Sawyer committed
130

Evan Hunt's avatar
Evan Hunt committed
131
$DIG $DIGOPTS a.example. @10.53.0.3 a > dig.out.ns3.test$n || ret=1
132 133
grep "10.0.0.2" dig.out.ns3.test$n > /dev/null || ret=1

Evan Hunt's avatar
Evan Hunt committed
134
digcomp dig.out.ns2.test$n dig.out.ns3.test$n || ret=1
Michael Sawyer's avatar
Michael Sawyer committed
135

Evan Hunt's avatar
Evan Hunt committed
136
[ $ret = 0 ] || echo_i "failed"
137
status=`expr $ret + $status`
Michael Sawyer's avatar
Michael Sawyer committed
138

Evan Hunt's avatar
Evan Hunt committed
139
echo_i "stopping master and restarting with example4 then waiting up to 45 seconds"
140
$PERL $SYSTEMTESTTOP/stop.pl notify ns2
141

142
rm -f ns2/example.db
143
cp -f ns2/example4.db ns2/example.db
144

145
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} notify ns2
146

147 148 149
try=0
while test $try -lt 45
do
150
    nextpart ns3/named.run > tmp
151
    grep "transfer of 'example/IN' from 10.53.0.2#.*success" tmp > /dev/null && break
152 153 154
    sleep 1
    try=`expr $try + 1`
done
Michael Sawyer's avatar
Michael Sawyer committed
155

156
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
157
echo_i "checking notify message was logged ($n)"
158 159
ret=0
grep 'notify from 10.53.0.2#[0-9][0-9]*: serial 4$' ns3/named.run > /dev/null || ret=1
Evan Hunt's avatar
Evan Hunt committed
160
[ $ret = 0 ] || echo_i "failed"
161 162
status=`expr $ret + $status`

163
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
164
echo_i "checking example4 loaded ($n)"
165
ret=0
Evan Hunt's avatar
Evan Hunt committed
166
$DIG $DIGOPTS a.example. @10.53.0.2 a > dig.out.ns2.test$n || ret=1
167 168
grep "10.0.0.4" dig.out.ns2.test$n > /dev/null || ret=1

Evan Hunt's avatar
Evan Hunt committed
169
[ $ret = 0 ] || echo_i "failed"
170 171 172
status=`expr $ret + $status`

n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
173
echo_i "checking example4 contents have been transfered after restart ($n)"
174
ret=0
Evan Hunt's avatar
Evan Hunt committed
175
$DIG $DIGOPTS a.example. @10.53.0.2 a > dig.out.ns2.test$n || ret=1
176
grep "10.0.0.4" dig.out.ns2.test$n > /dev/null || ret=1
Michael Sawyer's avatar
Michael Sawyer committed
177

Evan Hunt's avatar
Evan Hunt committed
178
$DIG $DIGOPTS a.example. @10.53.0.3 a > dig.out.ns3.test$n || ret=1
179 180
grep "10.0.0.4" dig.out.ns3.test$n > /dev/null || ret=1

Evan Hunt's avatar
Evan Hunt committed
181
digcomp dig.out.ns2.test$n dig.out.ns3.test$n || ret=1
Michael Sawyer's avatar
Michael Sawyer committed
182

Evan Hunt's avatar
Evan Hunt committed
183
[ $ret = 0 ] || echo_i "failed"
184
status=`expr $ret + $status`
Michael Sawyer's avatar
Michael Sawyer committed
185

186
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
187
echo_i "checking notify to alternate port with master inheritance ($n)"
188
$NSUPDATE << EOF
Evan Hunt's avatar
Evan Hunt committed
189
server 10.53.0.2 ${PORT}
190 191 192 193 194 195
zone x21
update add added.x21 0 in txt "test string"
send
EOF
for i in 1 2 3 4 5 6 7 8 9
do
Evan Hunt's avatar
Evan Hunt committed
196
	$DIG $DIGOPTS added.x21. @10.53.0.4 txt -p $EXTRAPORT1 > dig.out.ns4.test$n || ret=1
197 198 199 200 201
	grep "test string" dig.out.ns4.test$n > /dev/null && break
	sleep 1
done
grep "test string" dig.out.ns4.test$n > /dev/null || ret=1

Evan Hunt's avatar
Evan Hunt committed
202
[ $ret = 0 ] || echo_i "failed"
203 204
status=`expr $ret + $status`

205
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
206
echo_i "checking notify to multiple views using tsig ($n)"
207 208
ret=0
$NSUPDATE << EOF
Evan Hunt's avatar
Evan Hunt committed
209
server 10.53.0.5 ${PORT}
210 211 212 213 214 215 216 217
zone x21
key a aaaaaaaaaaaaaaaaaaaa
update add added.x21 0 in txt "test string"
send
EOF

for i in 1 2 3 4 5 6 7 8 9
do
Evan Hunt's avatar
Evan Hunt committed
218 219 220 221
	$DIG $DIGOPTS added.x21. -y b:bbbbbbbbbbbbbbbbbbbb @10.53.0.5 \
		txt > dig.out.b.ns5.test$n || ret=1
	$DIG $DIGOPTS added.x21. -y c:cccccccccccccccccccc @10.53.0.5 \
		txt > dig.out.c.ns5.test$n || ret=1
222 223 224 225 226 227 228 229
	grep "test string" dig.out.b.ns5.test$n > /dev/null &&
	grep "test string" dig.out.c.ns5.test$n > /dev/null &&
        break
	sleep 1
done
grep "test string" dig.out.b.ns5.test$n > /dev/null || ret=1
grep "test string" dig.out.c.ns5.test$n > /dev/null || ret=1

Evan Hunt's avatar
Evan Hunt committed
230
[ $ret = 0 ] || echo_i "failed"
231 232
status=`expr $ret + $status`

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