tests.sh 22.1 KB
Newer Older
1 2
#!/bin/sh
#
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.
11 12 13 14 15

SYSTEMTESTTOP=..
. $SYSTEMTESTTOP/conf.sh

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

status=0
Mark Andrews's avatar
Mark Andrews committed
20
n=0
21

Mark Andrews's avatar
Mark Andrews committed
22
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
23
echo_i "preparing ($n)"
24
ret=0
Evan Hunt's avatar
Evan Hunt committed
25
$NSUPDATE -p ${PORT} -k ns2/session.key > /dev/null 2>&1 <<END || ret=1
26 27 28 29 30 31 32 33
server 10.53.0.2
zone nil.
update add text1.nil. 600 IN TXT "addition 1"
send
zone other.
update add text1.other. 600 IN TXT "addition 1"
send
END
34
[ -s ns2/nil.db.jnl ] || {
Evan Hunt's avatar
Evan Hunt committed
35
	echo_i "'test -s ns2/nil.db.jnl' failed when it shouldn't have"; ret=1;
36 37
}
[ -s ns2/other.db.jnl ] || {
Evan Hunt's avatar
Evan Hunt committed
38
	echo_i "'test -s ns2/other.db.jnl' failed when it shouldn't have"; ret=1;
39
}
Evan Hunt's avatar
Evan Hunt committed
40
if [ $ret != 0 ]; then echo_i "failed"; fi
41 42
status=`expr $status + $ret`

Evan Hunt's avatar
Evan Hunt committed
43 44
echo_i "rndc freeze"
$RNDCCMD 10.53.0.2 freeze | sed 's/^/ns2 /' | cat_i | cat_i
45

Mark Andrews's avatar
Mark Andrews committed
46
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
47
echo_i "checking zone was dumped ($n)"
48
ret=0
49 50 51 52 53
for i in 1 2 3 4 5 6 7 8 9 10
do
	grep "addition 1" ns2/nil.db > /dev/null && break
	sleep 1
done
54
grep "addition 1" ns2/nil.db > /dev/null 2>&1 || ret=1
Evan Hunt's avatar
Evan Hunt committed
55
if [ $ret != 0 ]; then echo_i "failed"; fi
56 57
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
58
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
59
echo_i "checking journal file is still present ($n)"
60
ret=0
61
[ -s ns2/nil.db.jnl ] || {
Evan Hunt's avatar
Evan Hunt committed
62
	echo_i "'test -s ns2/nil.db.jnl' failed when it shouldn't have"; ret=1;
63
}
Evan Hunt's avatar
Evan Hunt committed
64
if [ $ret != 0 ]; then echo_i "failed"; fi
65 66
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
67
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
68
echo_i "checking zone not writable ($n)"
69
ret=0
Evan Hunt's avatar
Evan Hunt committed
70
$NSUPDATE -p ${PORT} -k ns2/session.key > /dev/null 2>&1 <<END && ret=1
71 72 73 74 75 76
server 10.53.0.2
zone nil.
update add text2.nil. 600 IN TXT "addition 2"
send
END

77 78
$DIGCMD text2.nil. TXT > dig.out.1.test$n
grep 'addition 2' dig.out.1.test$n >/dev/null && ret=1
Evan Hunt's avatar
Evan Hunt committed
79
if [ $ret != 0 ]; then echo_i "failed"; fi
80 81
status=`expr $status + $ret`

Evan Hunt's avatar
Evan Hunt committed
82 83
echo_i "rndc thaw"
$RNDCCMD 10.53.0.2 thaw | sed 's/^/ns2 /' | cat_i
84

Mark Andrews's avatar
Mark Andrews committed
85
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
86
echo_i "checking zone now writable ($n)"
87
ret=0
Evan Hunt's avatar
Evan Hunt committed
88
$NSUPDATE -p ${PORT} -k ns2/session.key > nsupdate.out.1.test$n 2>&1 <<END || ret=1
89 90 91 92 93
server 10.53.0.2
zone nil.
update add text3.nil. 600 IN TXT "addition 3"
send
END
94 95
$DIGCMD text3.nil. TXT > dig.out.1.test$n
grep 'addition 3' dig.out.1.test$n >/dev/null || ret=1
Evan Hunt's avatar
Evan Hunt committed
96
if [ $ret != 0 ]; then echo_i "failed"; fi
97 98
status=`expr $status + $ret`

Evan Hunt's avatar
Evan Hunt committed
99
echo_i "rndc sync"
100
ret=0
Evan Hunt's avatar
Evan Hunt committed
101
$RNDCCMD 10.53.0.2 sync nil | sed 's/^/ns2 /' | cat_i
102

Mark Andrews's avatar
Mark Andrews committed
103
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
104
echo_i "checking zone was dumped ($n)"
105
ret=0
106 107 108 109 110
for i in 1 2 3 4 5 6 7 8 9 10
do
	grep "addition 3" ns2/nil.db > /dev/null && break
	sleep 1
done
111
grep "addition 3" ns2/nil.db > /dev/null 2>&1 || ret=1
Evan Hunt's avatar
Evan Hunt committed
112
if [ $ret != 0 ]; then echo_i "failed"; fi
113 114
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
115
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
116
echo_i "checking journal file is still present ($n)"
117
ret=0
118
[ -s ns2/nil.db.jnl ] || {
Evan Hunt's avatar
Evan Hunt committed
119
	echo_i "'test -s ns2/nil.db.jnl' failed when it shouldn't have"; ret=1;
120
}
Evan Hunt's avatar
Evan Hunt committed
121
if [ $ret != 0 ]; then echo_i "failed"; fi
122 123
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
124
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
125
echo_i "checking zone is still writable ($n)"
126
ret=0
Evan Hunt's avatar
Evan Hunt committed
127
$NSUPDATE -p ${PORT} -k ns2/session.key > nsupdate.out.1.test$n 2>&1 <<END || ret=1
128 129 130 131 132 133
server 10.53.0.2
zone nil.
update add text4.nil. 600 IN TXT "addition 4"
send
END

134 135
$DIGCMD text4.nil. TXT > dig.out.1.test$n
grep 'addition 4' dig.out.1.test$n > /dev/null || ret=1
Evan Hunt's avatar
Evan Hunt committed
136
if [ $ret != 0 ]; then echo_i "failed"; fi
137 138
status=`expr $status + $ret`

Evan Hunt's avatar
Evan Hunt committed
139
echo_i "rndc sync -clean"
140
ret=0
Evan Hunt's avatar
Evan Hunt committed
141
$RNDCCMD 10.53.0.2 sync -clean nil | sed 's/^/ns2 /' | cat_i
142

Mark Andrews's avatar
Mark Andrews committed
143
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
144
echo_i "checking zone was dumped ($n)"
145
ret=0
146 147 148 149 150
for i in 1 2 3 4 5 6 7 8 9 10
do
	grep "addition 4" ns2/nil.db > /dev/null && break
	sleep 1
done
151
grep "addition 4" ns2/nil.db > /dev/null 2>&1 || ret=1
Evan Hunt's avatar
Evan Hunt committed
152
if [ $ret != 0 ]; then echo_i "failed"; fi
153 154
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
155
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
156
echo_i "checking journal file is deleted ($n)"
157
ret=0
158
[ -s ns2/nil.db.jnl ] && {
Evan Hunt's avatar
Evan Hunt committed
159
	echo_i "'test -s ns2/nil.db.jnl' failed when it shouldn't have"; ret=1;
160
}
Evan Hunt's avatar
Evan Hunt committed
161
if [ $ret != 0 ]; then echo_i "failed"; fi
162 163
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
164
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
165
echo_i "checking zone is still writable ($n)"
166
ret=0
Evan Hunt's avatar
Evan Hunt committed
167
$NSUPDATE -p ${PORT} -k ns2/session.key > /dev/null 2>&1 <<END || ret=1
168 169 170 171 172 173
server 10.53.0.2
zone nil.
update add text5.nil. 600 IN TXT "addition 5"
send
END

174 175
$DIGCMD text4.nil. TXT > dig.out.1.test$n
grep 'addition 4' dig.out.1.test$n >/dev/null || ret=1
Evan Hunt's avatar
Evan Hunt committed
176
if [ $ret != 0 ]; then echo_i "failed"; fi
177 178
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
179
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
180
echo_i "checking other journal files not removed ($n)"
181
ret=0
182
[ -s ns2/other.db.jnl ] || {
Evan Hunt's avatar
Evan Hunt committed
183
	echo_i "'test -s ns2/other.db.jnl' failed when it shouldn't have"; ret=1;
184
}
Evan Hunt's avatar
Evan Hunt committed
185
if [ $ret != 0 ]; then echo_i "failed"; fi
186 187
status=`expr $status + $ret`

Evan Hunt's avatar
Evan Hunt committed
188 189
echo_i "cleaning all zones ($n)"
$RNDCCMD 10.53.0.2 sync -clean | sed 's/^/ns2 /' | cat_i
190

Mark Andrews's avatar
Mark Andrews committed
191
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
192
echo_i "checking all journals removed ($n)"
193
ret=0
194
[ -s ns2/nil.db.jnl ] && {
Evan Hunt's avatar
Evan Hunt committed
195
	echo_i "'test -s ns2/nil.db.jnl' succeeded when it shouldn't have"; ret=1;
196 197
}
[ -s ns2/other.db.jnl ] && {
Evan Hunt's avatar
Evan Hunt committed
198
	echo_i "'test -s ns2/other.db.jnl' succeeded when it shouldn't have"; ret=1;
199
}
Evan Hunt's avatar
Evan Hunt committed
200
if [ $ret != 0 ]; then echo_i "failed"; fi
201 202
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
203
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
204
echo_i "checking that freezing static zones is not allowed ($n)"
205
ret=0
Evan Hunt's avatar
Evan Hunt committed
206
$RNDCCMD 10.53.0.2 freeze static > rndc.out.1.test$n 2>&1
207
grep 'not dynamic' rndc.out.1.test$n > /dev/null || ret=1
Evan Hunt's avatar
Evan Hunt committed
208
if [ $ret != 0 ]; then echo_i "failed"; fi
209 210
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
211
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
212
echo_i "checking that journal is removed when serial is changed before thaw ($n)"
213 214
ret=0
sleep 1
Evan Hunt's avatar
Evan Hunt committed
215
$NSUPDATE -p ${PORT} -k ns2/session.key > nsupdate.out.1.test$n 2>&1 <<END || ret=1
216 217 218 219 220
server 10.53.0.2
zone other.
update add text6.other. 600 IN TXT "addition 6"
send
END
221
[ -s ns2/other.db.jnl ] || {
Evan Hunt's avatar
Evan Hunt committed
222
	echo_i "'test -s ns2/other.db.jnl' failed when it shouldn't have"; ret=1;
223
}
Evan Hunt's avatar
Evan Hunt committed
224
$RNDCCMD 10.53.0.2 freeze other 2>&1 | sed 's/^/ns2 /' | cat_i
225 226 227 228 229
for i in 1 2 3 4 5 6 7 8 9 10
do
	grep "addition 6" ns2/other.db > /dev/null && break
	sleep 1
done
230 231 232 233 234
serial=`awk '$3 == "serial" {print $1}' ns2/other.db`
newserial=`expr $serial + 1`
sed s/$serial/$newserial/ ns2/other.db > ns2/other.db.new
echo 'frozen TXT "frozen addition"' >> ns2/other.db.new
mv -f ns2/other.db.new ns2/other.db
Evan Hunt's avatar
Evan Hunt committed
235
$RNDCCMD 10.53.0.2 thaw 2>&1 | sed 's/^/ns2 /' | cat_i
236
sleep 1
237
[ -f ns2/other.db.jnl ] && {
Evan Hunt's avatar
Evan Hunt committed
238
	echo_i "'test -f ns2/other.db.jnl' succeeded when it shouldn't have"; ret=1;
239
}
Evan Hunt's avatar
Evan Hunt committed
240
$NSUPDATE -p ${PORT} -k ns2/session.key > nsupdate.out.2.test$n 2>&1 <<END || ret=1
241 242 243 244 245
server 10.53.0.2
zone other.
update add text7.other. 600 IN TXT "addition 7"
send
END
246 247 248 249 250 251
$DIGCMD text6.other. TXT > dig.out.1.test$n
grep 'addition 6' dig.out.1.test$n >/dev/null || ret=1
$DIGCMD text7.other. TXT > dig.out.2.test$n
grep 'addition 7' dig.out.2.test$n >/dev/null || ret=1
$DIGCMD frozen.other. TXT > dig.out.3.test$n
grep 'frozen addition' dig.out.3.test$n >/dev/null || ret=1
Evan Hunt's avatar
Evan Hunt committed
252
if [ $ret != 0 ]; then echo_i "failed"; fi
253 254
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
255
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
256
echo_i "checking that journal is kept when ixfr-from-differences is in use ($n)"
257
ret=0
Evan Hunt's avatar
Evan Hunt committed
258
$NSUPDATE -p ${PORT} -k ns2/session.key > nsupdate.out.1.test$n 2>&1 <<END || ret=1
259 260 261 262 263
server 10.53.0.2
zone nil.
update add text6.nil. 600 IN TXT "addition 6"
send
END
264
[ -s ns2/nil.db.jnl ] || {
Evan Hunt's avatar
Evan Hunt committed
265
	echo_i "'test -s ns2/nil.db.jnl' failed when it shouldn't have"; ret=1;
266
}
Evan Hunt's avatar
Evan Hunt committed
267
$RNDCCMD 10.53.0.2 freeze nil 2>&1 | sed 's/^/ns2 /' | cat_i
268 269 270 271 272
for i in 1 2 3 4 5 6 7 8 9 10
do
	grep "addition 6" ns2/nil.db > /dev/null && break
	sleep 1
done
273 274 275 276 277
serial=`awk '$3 == "serial" {print $1}' ns2/nil.db`
newserial=`expr $serial + 1`
sed s/$serial/$newserial/ ns2/nil.db > ns2/nil.db.new
echo 'frozen TXT "frozen addition"' >> ns2/nil.db.new
mv -f ns2/nil.db.new ns2/nil.db
Evan Hunt's avatar
Evan Hunt committed
278
$RNDCCMD 10.53.0.2 thaw 2>&1 | sed 's/^/ns2 /' | cat_i
279
sleep 1
280
[ -s ns2/nil.db.jnl ] || {
Evan Hunt's avatar
Evan Hunt committed
281
	echo_i "'test -s ns2/nil.db.jnl' failed when it shouldn't have"; ret=1;
282
}
Evan Hunt's avatar
Evan Hunt committed
283
$NSUPDATE -p ${PORT} -k ns2/session.key > nsupdate.out.2.test$n 2>&1 <<END || ret=1
284 285 286 287 288
server 10.53.0.2
zone nil.
update add text7.nil. 600 IN TXT "addition 7"
send
END
289 290 291 292 293 294
$DIGCMD text6.nil. TXT > dig.out.1.test$n
grep 'addition 6' dig.out.1.test$n > /dev/null || ret=1
$DIGCMD text7.nil. TXT > dig.out.2.test$n
grep 'addition 7' dig.out.2.test$n > /dev/null || ret=1
$DIGCMD frozen.nil. TXT > dig.out.3.test$n
grep 'frozen addition' dig.out.3.test$n >/dev/null || ret=1
Evan Hunt's avatar
Evan Hunt committed
295
if [ $ret != 0 ]; then echo_i "failed"; fi
296 297
status=`expr $status + $ret`

298
# temp test
Evan Hunt's avatar
Evan Hunt committed
299 300
echo_i "dumping stats ($n)"
$RNDCCMD 10.53.0.2 stats
Mark Andrews's avatar
Mark Andrews committed
301
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
302
echo_i "verifying adb records in named.stats ($n)"
303
grep "ADB stats" ns2/named.stats > /dev/null || ret=1
Evan Hunt's avatar
Evan Hunt committed
304
if [ $ret != 0 ]; then echo_i "failed"; fi
305 306
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
307
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
308
echo_i "test using second key ($n)"
309
ret=0
Evan Hunt's avatar
Evan Hunt committed
310 311
$RNDC -s 10.53.0.2 -p ${CONTROLPORT} -c ns2/secondkey.conf status > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
312 313
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
314
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
315
echo_i "test 'rndc dumpdb' on a empty cache ($n)"
316
ret=0
Evan Hunt's avatar
Evan Hunt committed
317
$RNDCCMD 10.53.0.3 dumpdb > /dev/null || ret=1
Evan Hunt's avatar
Evan Hunt committed
318
for i in 1 2 3 4 5 6 7 8 9
319 320 321 322 323 324 325
do
	tmp=0
	grep "Dump complete" ns3/named_dump.db > /dev/null || tmp=1
	[ $tmp -eq 0 ] && break
	sleep 1
done
[ $tmp -eq 1 ] && ret=1
Evan Hunt's avatar
Evan Hunt committed
326
if [ $ret != 0 ]; then echo_i "failed"; fi
327 328
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
329
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
330
echo_i "test 'rndc reload' on a zone with include files ($n)"
Evan Hunt's avatar
Evan Hunt committed
331 332 333 334
ret=0
grep "incl/IN: skipping load" ns2/named.run > /dev/null && ret=1
loads=`grep "incl/IN: starting load" ns2/named.run | wc -l`
[ "$loads" -eq 1 ] || ret=1
Evan Hunt's avatar
Evan Hunt committed
335
$RNDCCMD 10.53.0.2 reload > /dev/null || ret=1
Evan Hunt's avatar
Evan Hunt committed
336 337 338 339 340 341 342 343 344
for i in 1 2 3 4 5 6 7 8 9
do
    tmp=0
    grep "incl/IN: skipping load" ns2/named.run > /dev/null || tmp=1
    [ $tmp -eq 0 ] && break
    sleep 1
done
[ $tmp -eq 1 ] && ret=1
touch ns2/static.db
Evan Hunt's avatar
Evan Hunt committed
345
$RNDCCMD 10.53.0.2 reload > /dev/null || ret=1
Evan Hunt's avatar
Evan Hunt committed
346 347 348 349 350 351 352 353 354
for i in 1 2 3 4 5 6 7 8 9
do
    tmp=0
    loads=`grep "incl/IN: starting load" ns2/named.run | wc -l`
    [ "$loads" -eq 2 ] || tmp=1
    [ $tmp -eq 0 ] && break
    sleep 1
done
[ $tmp -eq 1 ] && ret=1
Evan Hunt's avatar
Evan Hunt committed
355
if [ $ret != 0 ]; then echo_i "failed"; fi
Evan Hunt's avatar
Evan Hunt committed
356 357
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
358
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
359
echo_i "testing rndc with hmac-md5 ($n)"
360
ret=0
Evan Hunt's avatar
Evan Hunt committed
361
$RNDC -s 10.53.0.4 -p ${EXTRAPORT1} -c ns4/key1.conf status > /dev/null 2>&1 || ret=1
362 363
for i in 2 3 4 5 6
do
Evan Hunt's avatar
Evan Hunt committed
364
        $RNDC -s 10.53.0.4 -p ${EXTRAPORT1} -c ns4/key${i}.conf status > /dev/null 2>&1 && ret=1
365
done
Evan Hunt's avatar
Evan Hunt committed
366
if [ $ret != 0 ]; then echo_i "failed"; fi
367 368
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
369
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
370
echo_i "testing rndc with hmac-sha1 ($n)"
371
ret=0
Evan Hunt's avatar
Evan Hunt committed
372
$RNDC -s 10.53.0.4 -p ${EXTRAPORT2} -c ns4/key2.conf status > /dev/null 2>&1 || ret=1
373 374
for i in 1 3 4 5 6
do
Evan Hunt's avatar
Evan Hunt committed
375
        $RNDC -s 10.53.0.4 -p ${EXTRAPORT2} -c ns4/key${i}.conf status > /dev/null 2>&1 && ret=1
376
done
Evan Hunt's avatar
Evan Hunt committed
377
if [ $ret != 0 ]; then echo_i "failed"; fi
378 379
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
380
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
381
echo_i "testing rndc with hmac-sha224 ($n)"
382
ret=0
Evan Hunt's avatar
Evan Hunt committed
383
$RNDC -s 10.53.0.4 -p ${EXTRAPORT3} -c ns4/key3.conf status > /dev/null 2>&1 || ret=1
384 385
for i in 1 2 4 5 6
do
Evan Hunt's avatar
Evan Hunt committed
386
        $RNDC -s 10.53.0.4 -p ${EXTRAPORT3} -c ns4/key${i}.conf status > /dev/null 2>&1 && ret=1
387
done
Evan Hunt's avatar
Evan Hunt committed
388
if [ $ret != 0 ]; then echo_i "failed"; fi
389 390
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
391
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
392
echo_i "testing rndc with hmac-sha256 ($n)"
393
ret=0
Evan Hunt's avatar
Evan Hunt committed
394
$RNDC -s 10.53.0.4 -p ${EXTRAPORT4} -c ns4/key4.conf status > /dev/null 2>&1 || ret=1
395 396
for i in 1 2 3 5 6
do
Evan Hunt's avatar
Evan Hunt committed
397
        $RNDC -s 10.53.0.4 -p ${EXTRAPORT4} -c ns4/key${i}.conf status > /dev/null 2>&1 && ret=1
398
done
Evan Hunt's avatar
Evan Hunt committed
399
if [ $ret != 0 ]; then echo_i "failed"; fi
400 401
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
402
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
403
echo_i "testing rndc with hmac-sha384 ($n)"
404
ret=0
Evan Hunt's avatar
Evan Hunt committed
405
$RNDC -s 10.53.0.4 -p ${EXTRAPORT5} -c ns4/key5.conf status > /dev/null 2>&1 || ret=1
406 407
for i in 1 2 3 4 6
do
Evan Hunt's avatar
Evan Hunt committed
408
        $RNDC -s 10.53.0.4 -p ${EXTRAPORT5} -c ns4/key${i}.conf status > /dev/null 2>&1 && ret=1
409
done
Evan Hunt's avatar
Evan Hunt committed
410
if [ $ret != 0 ]; then echo_i "failed"; fi
411 412
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
413
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
414
echo_i "testing rndc with hmac-sha512 ($n)"
415
ret=0
Evan Hunt's avatar
Evan Hunt committed
416
$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf status > /dev/null 2>&1 || ret=1
417 418
for i in 1 2 3 4 5
do
Evan Hunt's avatar
Evan Hunt committed
419
        $RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key${i}.conf status > /dev/null 2>&1 2>&1 && ret=1
420
done
Evan Hunt's avatar
Evan Hunt committed
421
if [ $ret != 0 ]; then echo_i "failed"; fi
422 423
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
424
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
425
echo_i "testing automatic zones are reported ($n)"
426
ret=0
Evan Hunt's avatar
Evan Hunt committed
427
$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf status > rndc.out.1.test$n || ret=1
428
grep "number of zones: 200 (198 automatic)" rndc.out.1.test$n > /dev/null || ret=1
Evan Hunt's avatar
Evan Hunt committed
429
if [ $ret != 0 ]; then echo_i "failed"; fi
430 431
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
432
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
433
echo_i "testing rndc with null command ($n)"
Evan Hunt's avatar
Evan Hunt committed
434
ret=0
Evan Hunt's avatar
Evan Hunt committed
435 436
$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
Evan Hunt's avatar
Evan Hunt committed
437 438
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
439
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
440
echo_i "testing rndc with unknown control channel command ($n)"
Evan Hunt's avatar
Evan Hunt committed
441
ret=0
Evan Hunt's avatar
Evan Hunt committed
442
$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf obviouslynotacommand >/dev/null 2>&1 && ret=1
Evan Hunt's avatar
Evan Hunt committed
443
# rndc: 'obviouslynotacommand' failed: unknown command
Evan Hunt's avatar
Evan Hunt committed
444
if [ $ret != 0 ]; then echo_i "failed"; fi
Evan Hunt's avatar
Evan Hunt committed
445 446
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
447
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
448
echo_i "testing rndc with querylog command ($n)"
Evan Hunt's avatar
Evan Hunt committed
449 450
ret=0
# first enable it with querylog on option
Evan Hunt's avatar
Evan Hunt committed
451
$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf querylog on >/dev/null 2>&1 || ret=1
Evan Hunt's avatar
Evan Hunt committed
452
grep "query logging is now on" ns4/named.run > /dev/null || ret=1
453
# query for builtin and check if query was logged (without +subnet)
Evan Hunt's avatar
Evan Hunt committed
454
$DIG @10.53.0.4 -p ${PORT} -c ch -t txt foo12345.bind > /dev/null || ret=1
455 456
grep "query: foo12345.bind CH TXT.*(.*)$" ns4/named.run > /dev/null || ret=1
# query for another builtin zone and check if query was logged (with +subnet=127.0.0.1)
Evan Hunt's avatar
Evan Hunt committed
457
$DIG +subnet=127.0.0.1 @10.53.0.4 -p ${PORT} -c ch -t txt foo12346.bind > /dev/null || ret=1
458 459
grep "query: foo12346.bind CH TXT.*\[ECS 127\.0\.0\.1\/32\/0]" ns4/named.run > /dev/null || ret=1
# query for another builtin zone and check if query was logged (with +subnet=127.0.0.1/24)
Evan Hunt's avatar
Evan Hunt committed
460
$DIG +subnet=127.0.0.1/24 @10.53.0.4 -p ${PORT} -c ch -t txt foo12347.bind > /dev/null || ret=1
461 462
grep "query: foo12347.bind CH TXT.*\[ECS 127\.0\.0\.0\/24\/0]" ns4/named.run > /dev/null || ret=1
# query for another builtin zone and check if query was logged (with +subnet=::1)
Evan Hunt's avatar
Evan Hunt committed
463
$DIG +subnet=::1 @10.53.0.4 -p ${PORT} -c ch -t txt foo12348.bind > /dev/null || ret=1
464
grep "query: foo12348.bind CH TXT.*\[ECS \:\:1\/128\/0]" ns4/named.run > /dev/null || ret=1
Evan Hunt's avatar
Evan Hunt committed
465
# toggle query logging and check again
Evan Hunt's avatar
Evan Hunt committed
466
$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf querylog > /dev/null 2>&1 || ret=1
Evan Hunt's avatar
Evan Hunt committed
467
grep "query logging is now off" ns4/named.run > /dev/null || ret=1
468
# query for another builtin zone and check if query was logged (without +subnet)
Evan Hunt's avatar
Evan Hunt committed
469
$DIG @10.53.0.4 -p ${PORT} -c ch -t txt foo9876.bind > /dev/null || ret=1
470
grep "query: foo9876.bind CH TXT.*(.*)$" ns4/named.run > /dev/null && ret=1
Evan Hunt's avatar
Evan Hunt committed
471
if [ $ret != 0 ]; then echo_i "failed"; fi
Evan Hunt's avatar
Evan Hunt committed
472 473
status=`expr $status + $ret`

Evan Hunt's avatar
Evan Hunt committed
474
RNDCCMD4="$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf"
Mark Andrews's avatar
Mark Andrews committed
475
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
476
echo_i "testing rndc nta time limits ($n)"
477
ret=0
478 479 480 481 482 483 484 485
$RNDCCMD4 nta -l 2h nta1.example > rndc.out.1.test$n 2>&1
grep "Negative trust anchor added" rndc.out.1.test$n > /dev/null || ret=1
$RNDCCMD4 nta -l 1d nta2.example > rndc.out.2.test$n 2>&1
grep "Negative trust anchor added" rndc.out.2.test$n > /dev/null || ret=1
$RNDCCMD4 nta -l 1w nta3.example > rndc.out.3.test$n 2>&1
grep "Negative trust anchor added" rndc.out.3.test$n > /dev/null || ret=1
$RNDCCMD4 nta -l 8d nta4.example > rndc.out.4.test$n 2>&1
grep "NTA lifetime cannot exceed one week" rndc.out.4.test$n > /dev/null || ret=1
Evan Hunt's avatar
Evan Hunt committed
486
if [ $ret != 0 ]; then echo_i "failed"; fi
Evan Hunt's avatar
Evan Hunt committed
487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502
status=`expr $status + $ret`

n=`expr $n + 1`
echo_i "testing rndc nta -class option ($n)"
ret=0
nextpart ns4/named.run > /dev/null
$RNDCCMD4 nta -c in nta1.example > rndc.out.1.test$n 2>&1
nextpart ns4/named.run | grep "added NTA 'nta1.example'" > /dev/null || ret=1
$RNDCCMD4 nta -c any nta1.example > rndc.out.2.test$n 2>&1
nextpart ns4/named.run | grep "added NTA 'nta1.example'" > /dev/null || ret=1
$RNDCCMD4 nta -c ch nta1.example > rndc.out.3.test$n 2>&1
nextpart ns4/named.run | grep "added NTA 'nta1.example'" > /dev/null && ret=1
$RNDCCMD4 nta -c fake nta1.example > rndc.out.4.test$n 2>&1
nextpart ns4/named.run | grep "added NTA 'nta1.example'" > /dev/null && ret=1
grep 'unknown class' rndc.out.4.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
503 504 505 506
status=`expr $status + $ret`

for i in 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288
do
Mark Andrews's avatar
Mark Andrews committed
507
	n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
508
	echo_i "testing rndc buffer size limits (size=${i}) ($n)"
509
	ret=0
Evan Hunt's avatar
Evan Hunt committed
510
	$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf testgen ${i} 2>&1 > rndc.out.$i.test$n || ret=1
511
	actual_size=`$GENCHECK rndc.out.$i.test$n`
512 513 514 515 516 517 518
	if [ "$?" = "0" ]; then
	    expected_size=`expr $i + 1`
	    if [ $actual_size != $expected_size ]; then ret=1; fi
	else
	    ret=1
	fi

Evan Hunt's avatar
Evan Hunt committed
519
	if [ $ret != 0 ]; then echo_i "failed"; fi
520 521 522
	status=`expr $status + $ret`
done

Mark Andrews's avatar
Mark Andrews committed
523
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
524
echo_i "testing rndc -r (show result) ($n)"
525
ret=0
Evan Hunt's avatar
Evan Hunt committed
526
$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf -r testgen 0 2>&1 > rndc.out.1.test$n || ret=1
527
grep "ISC_R_SUCCESS 0" rndc.out.1.test$n > /dev/null || ret=1
Evan Hunt's avatar
Evan Hunt committed
528
if [ $ret != 0 ]; then echo_i "failed"; fi
529 530
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
531
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
532
echo_i "testing rndc with a token containing a space ($n)"
533
ret=0
Evan Hunt's avatar
Evan Hunt committed
534
$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf -r flush '"view with a space"' 2>&1 > rndc.out.1.test$n || ret=1
535
grep "not found" rndc.out.1.test$n > /dev/null && ret=1
Evan Hunt's avatar
Evan Hunt committed
536
if [ $ret != 0 ]; then echo_i "failed"; fi
537 538
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
539
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
540
echo_i "test 'rndc reconfig' with a broken config ($n)"
541
ret=0
Evan Hunt's avatar
Evan Hunt committed
542
$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf reconfig > /dev/null || ret=1
543 544 545
sleep 1
mv ns4/named.conf ns4/named.conf.save
echo "error error error" >> ns4/named.conf
Evan Hunt's avatar
Evan Hunt committed
546
$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf reconfig > rndc.out.1.test$n 2>&1 && ret=1
547
grep "rndc: 'reconfig' failed: unexpected token" rndc.out.1.test$n > /dev/null || ret=1
548 549
mv ns4/named.conf.save ns4/named.conf
sleep 1
Evan Hunt's avatar
Evan Hunt committed
550
$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf reconfig > /dev/null || ret=1
551
sleep 1
Evan Hunt's avatar
Evan Hunt committed
552
if [ $ret != 0 ]; then echo_i "failed"; fi
553 554
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
555
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
556
echo_i "test read-only control channel access ($n)"
557
ret=0
Evan Hunt's avatar
Evan Hunt committed
558 559 560 561
$RNDCCMD 10.53.0.5 status > rndc.out.1.test$n 2>&1 || ret=1
$RNDCCMD 10.53.0.5 nta -dump > rndc.out.2.test$n 2>&1 || ret=1
$RNDCCMD 10.53.0.5 reconfig > rndc.out.3.test$n 2>&1 && ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
562 563
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
564
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
565
echo_i "test rndc status shows running on ($n)"
566
ret=0
Evan Hunt's avatar
Evan Hunt committed
567
$RNDCCMD 10.53.0.5 status > rndc.out.1.test$n 2>&1 || ret=1
568
grep "^running on " rndc.out.1.test$n > /dev/null || ret=1
Evan Hunt's avatar
Evan Hunt committed
569
if [ $ret != 0 ]; then echo_i "failed"; fi
570 571
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
572
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
573
echo_i "test 'rndc reconfig' with loading of a large zone ($n)"
574 575 576 577
ret=0
cur=`awk 'BEGIN {l=0} /^/ {l++} END { print l }' ns6/named.run`
cp ns6/named.conf ns6/named.conf.save
echo "zone \"huge.zone\" { type master; file \"huge.zone.db\"; };" >> ns6/named.conf
Evan Hunt's avatar
Evan Hunt committed
578 579 580
echo_i "reloading config"
$RNDCCMD 10.53.0.6 reconfig > rndc.out.1.test$n 2>&1 || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
581 582
status=`expr $status + $ret`
sleep 1
Mark Andrews's avatar
Mark Andrews committed
583
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
584
echo_i "check if zone load was scheduled ($n)"
585
grep "scheduled loading new zones" ns6/named.run > /dev/null || ret=1
Evan Hunt's avatar
Evan Hunt committed
586
if [ $ret != 0 ]; then echo_i "failed"; fi
587 588
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
589
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
590 591
echo_i "check if query for the zone returns SERVFAIL ($n)"
$DIG @10.53.0.6 -p ${PORT} -t soa huge.zone > dig.out.1.test$n
592
grep "SERVFAIL" dig.out.1.test$n > /dev/null || ret=1
Evan Hunt's avatar
Evan Hunt committed
593
if [ $ret != 0 ]; then echo_i "failed (ignored)"; ret=0; fi
594 595
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
596
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
597
echo_i "wait for the zones to be loaded ($n)"
598 599
ret=1
try=0
600
while test $try -lt 100
601 602 603 604 605 606 607 608
do
    sleep 1
    sed -n "$cur,"'$p' < ns6/named.run | grep "any newly configured zones are now loaded" > /dev/null && {
        ret=0
        break
    }
    try=`expr $try + 1`
done
Evan Hunt's avatar
Evan Hunt committed
609
if [ $ret != 0 ]; then echo_i "failed"; fi
610 611
status=`expr $status + $ret`

Mark Andrews's avatar
Mark Andrews committed
612
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
613 614
echo_i "check if query for the zone returns NOERROR ($n)"
$DIG @10.53.0.6 -p ${PORT} -t soa huge.zone > dig.out.1.test$n
615
grep "NOERROR" dig.out.1.test$n > /dev/null || ret=1
Evan Hunt's avatar
Evan Hunt committed
616
if [ $ret != 0 ]; then echo_i "failed"; fi
617 618
status=`expr $status + $ret`

619
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
620
echo_i "verify that the full command is logged ($n)"
621
ret=0
Evan Hunt's avatar
Evan Hunt committed
622
$RNDCCMD 10.53.0.2 null with extra arguments > /dev/null 2>&1
623
grep "received control channel command 'null with extra arguments'" ns2/named.run > /dev/null || ret=1
Evan Hunt's avatar
Evan Hunt committed
624
if [ $ret != 0 ]; then echo_i "failed"; fi
625 626
status=`expr $status + $ret`

627 628
mv ns6/named.conf.save ns6/named.conf
sleep 1
Evan Hunt's avatar
Evan Hunt committed
629
$RNDCCMD 10.53.0.6 reconfig > /dev/null || ret=1
630
sleep 1
Evan Hunt's avatar
Evan Hunt committed
631
if [ $ret != 0 ]; then echo_i "failed"; fi
632 633
status=`expr $status + $ret`

634
if [ -x "$PYTHON" ]; then
Mark Andrews's avatar
Mark Andrews committed
635
    n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
636
    echo_i "test rndc python bindings ($n)"
637
    ret=0
638
    $PYTHON > python.out.1.test$n << EOF
639 640 641
import sys
sys.path.insert(0, '../../../../bin/python')
from isc import *
Evan Hunt's avatar
Evan Hunt committed
642
r = rndc(('10.53.0.5', ${CONTROLPORT}), 'hmac-sha256', '1234abcd8765')
643 644 645
result = r.call('status')
print(result['text'])
EOF
646
    grep 'server is up and running' python.out.1.test$n > /dev/null 2>&1 || ret=1
Evan Hunt's avatar
Evan Hunt committed
647
    if [ $ret != 0 ]; then echo_i "failed"; fi
648 649 650
    status=`expr $status + $ret`
fi

651
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
652
echo_i "check 'rndc \"\"' is handled ($n)"
653
ret=0
Evan Hunt's avatar
Evan Hunt committed
654
$RNDCCMD 10.53.0.2 "" > rndc.out.1.test$n 2>&1 && ret=1
655
grep "rndc: '' failed: failure" rndc.out.1.test$n > /dev/null
Evan Hunt's avatar
Evan Hunt committed
656
if [ $ret != 0 ]; then echo_i "failed"; fi
657 658
status=`expr $status + $ret`

659
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
660
echo_i "check rndc -4 -6 ($n)"
661
ret=0
Evan Hunt's avatar
Evan Hunt committed
662
$RNDCCMD 10.53.0.2 -4 -6 status > rndc.out.1.test$n 2>&1 && ret=1
663
grep "only one of -4 and -6 allowed" rndc.out.1.test$n > /dev/null || ret=1
Evan Hunt's avatar
Evan Hunt committed
664
if [ $ret != 0 ]; then echo_i "failed"; fi
665 666 667
status=`expr $status + $ret`

n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
668
echo_i "check rndc -4 with an IPv6 server address ($n)"
669
ret=0
Evan Hunt's avatar
Evan Hunt committed
670
$RNDCCMD fd92:7065:b8e:ffff::2 -4 status > rndc.out.1.test$n 2>&1 && ret=1
671
grep "address family not supported" rndc.out.1.test$n > /dev/null || ret=1
Evan Hunt's avatar
Evan Hunt committed
672
if [ $ret != 0 ]; then echo_i "failed"; fi
673 674
status=`expr $status + $ret`

675 676 677 678 679 680 681 682 683
n=`expr $n + 1`
echo_i "check rndc nta reports adding to multiple views ($n)"
ret=0
$RNDCCMD 10.53.0.3 nta test.com > rndc.out.test$n 2>&1 || ret=1
lines=`cat rndc.out.test$n | wc -l`
[ ${lines:-0} -eq 2 ] || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`

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