tests.sh revision 1.1.1.2
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 http://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 @10.53.0.2 -p ${PORT}"
17RNDCCMD="$RNDC -p ${CONTROLPORT} -c ../common/rndc.conf -s"
18
19status=0
20n=0
21
22n=`expr $n + 1`
23echo_i "preparing ($n)"
24ret=0
25$NSUPDATE -p ${PORT} -k ns2/session.key > /dev/null 2>&1 <<END || ret=1
26server 10.53.0.2
27zone nil.
28update add text1.nil. 600 IN TXT "addition 1"
29send
30zone other.
31update add text1.other. 600 IN TXT "addition 1"
32send
33END
34[ -s ns2/nil.db.jnl ] || {
35	echo_i "'test -s ns2/nil.db.jnl' failed when it shouldn't have"; ret=1;
36}
37[ -s ns2/other.db.jnl ] || {
38	echo_i "'test -s ns2/other.db.jnl' failed when it shouldn't have"; ret=1;
39}
40if [ $ret != 0 ]; then echo_i "failed"; fi
41status=`expr $status + $ret`
42
43echo_i "rndc freeze"
44$RNDCCMD 10.53.0.2 freeze | sed 's/^/ns2 /' | cat_i | cat_i
45
46n=`expr $n + 1`
47echo_i "checking zone was dumped ($n)"
48ret=0
49for i in 1 2 3 4 5 6 7 8 9 10
50do
51	grep "addition 1" ns2/nil.db > /dev/null && break
52	sleep 1
53done
54grep "addition 1" ns2/nil.db > /dev/null 2>&1 || ret=1
55if [ $ret != 0 ]; then echo_i "failed"; fi
56status=`expr $status + $ret`
57
58n=`expr $n + 1`
59echo_i "checking journal file is still present ($n)"
60ret=0
61[ -s ns2/nil.db.jnl ] || {
62	echo_i "'test -s ns2/nil.db.jnl' failed when it shouldn't have"; ret=1;
63}
64if [ $ret != 0 ]; then echo_i "failed"; fi
65status=`expr $status + $ret`
66
67n=`expr $n + 1`
68echo_i "checking zone not writable ($n)"
69ret=0
70$NSUPDATE -p ${PORT} -k ns2/session.key > /dev/null 2>&1 <<END && ret=1
71server 10.53.0.2
72zone nil.
73update add text2.nil. 600 IN TXT "addition 2"
74send
75END
76
77$DIGCMD text2.nil. TXT > dig.out.1.test$n
78grep 'addition 2' dig.out.1.test$n >/dev/null && ret=1
79if [ $ret != 0 ]; then echo_i "failed"; fi
80status=`expr $status + $ret`
81
82echo_i "rndc thaw"
83$RNDCCMD 10.53.0.2 thaw | sed 's/^/ns2 /' | cat_i
84
85n=`expr $n + 1`
86echo_i "checking zone now writable ($n)"
87ret=0
88$NSUPDATE -p ${PORT} -k ns2/session.key > nsupdate.out.1.test$n 2>&1 <<END || ret=1
89server 10.53.0.2
90zone nil.
91update add text3.nil. 600 IN TXT "addition 3"
92send
93END
94$DIGCMD text3.nil. TXT > dig.out.1.test$n
95grep 'addition 3' dig.out.1.test$n >/dev/null || ret=1
96if [ $ret != 0 ]; then echo_i "failed"; fi
97status=`expr $status + $ret`
98
99echo_i "rndc sync"
100ret=0
101$RNDCCMD 10.53.0.2 sync nil | sed 's/^/ns2 /' | cat_i
102
103n=`expr $n + 1`
104echo_i "checking zone was dumped ($n)"
105ret=0
106for i in 1 2 3 4 5 6 7 8 9 10
107do
108	grep "addition 3" ns2/nil.db > /dev/null && break
109	sleep 1
110done
111grep "addition 3" ns2/nil.db > /dev/null 2>&1 || ret=1
112if [ $ret != 0 ]; then echo_i "failed"; fi
113status=`expr $status + $ret`
114
115n=`expr $n + 1`
116echo_i "checking journal file is still present ($n)"
117ret=0
118[ -s ns2/nil.db.jnl ] || {
119	echo_i "'test -s ns2/nil.db.jnl' failed when it shouldn't have"; ret=1;
120}
121if [ $ret != 0 ]; then echo_i "failed"; fi
122status=`expr $status + $ret`
123
124n=`expr $n + 1`
125echo_i "checking zone is still writable ($n)"
126ret=0
127$NSUPDATE -p ${PORT} -k ns2/session.key > nsupdate.out.1.test$n 2>&1 <<END || ret=1
128server 10.53.0.2
129zone nil.
130update add text4.nil. 600 IN TXT "addition 4"
131send
132END
133
134$DIGCMD text4.nil. TXT > dig.out.1.test$n
135grep 'addition 4' dig.out.1.test$n > /dev/null || ret=1
136if [ $ret != 0 ]; then echo_i "failed"; fi
137status=`expr $status + $ret`
138
139echo_i "rndc sync -clean"
140ret=0
141$RNDCCMD 10.53.0.2 sync -clean nil | sed 's/^/ns2 /' | cat_i
142
143n=`expr $n + 1`
144echo_i "checking zone was dumped ($n)"
145ret=0
146for i in 1 2 3 4 5 6 7 8 9 10
147do
148	grep "addition 4" ns2/nil.db > /dev/null && break
149	sleep 1
150done
151grep "addition 4" ns2/nil.db > /dev/null 2>&1 || ret=1
152if [ $ret != 0 ]; then echo_i "failed"; fi
153status=`expr $status + $ret`
154
155n=`expr $n + 1`
156echo_i "checking journal file is deleted ($n)"
157ret=0
158[ -s ns2/nil.db.jnl ] && {
159	echo_i "'test -s ns2/nil.db.jnl' failed when it shouldn't have"; ret=1;
160}
161if [ $ret != 0 ]; then echo_i "failed"; fi
162status=`expr $status + $ret`
163
164n=`expr $n + 1`
165echo_i "checking zone is still writable ($n)"
166ret=0
167$NSUPDATE -p ${PORT} -k ns2/session.key > /dev/null 2>&1 <<END || ret=1
168server 10.53.0.2
169zone nil.
170update add text5.nil. 600 IN TXT "addition 5"
171send
172END
173
174$DIGCMD text4.nil. TXT > dig.out.1.test$n
175grep 'addition 4' dig.out.1.test$n >/dev/null || ret=1
176if [ $ret != 0 ]; then echo_i "failed"; fi
177status=`expr $status + $ret`
178
179n=`expr $n + 1`
180echo_i "checking other journal files not removed ($n)"
181ret=0
182[ -s ns2/other.db.jnl ] || {
183	echo_i "'test -s ns2/other.db.jnl' failed when it shouldn't have"; ret=1;
184}
185if [ $ret != 0 ]; then echo_i "failed"; fi
186status=`expr $status + $ret`
187
188echo_i "cleaning all zones ($n)"
189$RNDCCMD 10.53.0.2 sync -clean | sed 's/^/ns2 /' | cat_i
190
191n=`expr $n + 1`
192echo_i "checking all journals removed ($n)"
193ret=0
194[ -s ns2/nil.db.jnl ] && {
195	echo_i "'test -s ns2/nil.db.jnl' succeeded when it shouldn't have"; ret=1;
196}
197[ -s ns2/other.db.jnl ] && {
198	echo_i "'test -s ns2/other.db.jnl' succeeded when it shouldn't have"; ret=1;
199}
200if [ $ret != 0 ]; then echo_i "failed"; fi
201status=`expr $status + $ret`
202
203n=`expr $n + 1`
204echo_i "checking that freezing static zones is not allowed ($n)"
205ret=0
206$RNDCCMD 10.53.0.2 freeze static > rndc.out.1.test$n 2>&1
207grep 'not dynamic' rndc.out.1.test$n > /dev/null || ret=1
208if [ $ret != 0 ]; then echo_i "failed"; fi
209status=`expr $status + $ret`
210
211n=`expr $n + 1`
212echo_i "checking that journal is removed when serial is changed before thaw ($n)"
213ret=0
214sleep 1
215$NSUPDATE -p ${PORT} -k ns2/session.key > nsupdate.out.1.test$n 2>&1 <<END || ret=1
216server 10.53.0.2
217zone other.
218update add text6.other. 600 IN TXT "addition 6"
219send
220END
221[ -s ns2/other.db.jnl ] || {
222	echo_i "'test -s ns2/other.db.jnl' failed when it shouldn't have"; ret=1;
223}
224$RNDCCMD 10.53.0.2 freeze other 2>&1 | sed 's/^/ns2 /' | cat_i
225for i in 1 2 3 4 5 6 7 8 9 10
226do
227	grep "addition 6" ns2/other.db > /dev/null && break
228	sleep 1
229done
230serial=`awk '$3 == "serial" {print $1}' ns2/other.db`
231newserial=`expr $serial + 1`
232sed s/$serial/$newserial/ ns2/other.db > ns2/other.db.new
233echo 'frozen TXT "frozen addition"' >> ns2/other.db.new
234mv -f ns2/other.db.new ns2/other.db
235$RNDCCMD 10.53.0.2 thaw 2>&1 | sed 's/^/ns2 /' | cat_i
236sleep 1
237[ -f ns2/other.db.jnl ] && {
238	echo_i "'test -f ns2/other.db.jnl' succeeded when it shouldn't have"; ret=1;
239}
240$NSUPDATE -p ${PORT} -k ns2/session.key > nsupdate.out.2.test$n 2>&1 <<END || ret=1
241server 10.53.0.2
242zone other.
243update add text7.other. 600 IN TXT "addition 7"
244send
245END
246$DIGCMD text6.other. TXT > dig.out.1.test$n
247grep 'addition 6' dig.out.1.test$n >/dev/null || ret=1
248$DIGCMD text7.other. TXT > dig.out.2.test$n
249grep 'addition 7' dig.out.2.test$n >/dev/null || ret=1
250$DIGCMD frozen.other. TXT > dig.out.3.test$n
251grep 'frozen addition' dig.out.3.test$n >/dev/null || ret=1
252if [ $ret != 0 ]; then echo_i "failed"; fi
253status=`expr $status + $ret`
254
255n=`expr $n + 1`
256echo_i "checking that journal is kept when ixfr-from-differences is in use ($n)"
257ret=0
258$NSUPDATE -p ${PORT} -k ns2/session.key > nsupdate.out.1.test$n 2>&1 <<END || ret=1
259server 10.53.0.2
260zone nil.
261update add text6.nil. 600 IN TXT "addition 6"
262send
263END
264[ -s ns2/nil.db.jnl ] || {
265	echo_i "'test -s ns2/nil.db.jnl' failed when it shouldn't have"; ret=1;
266}
267$RNDCCMD 10.53.0.2 freeze nil 2>&1 | sed 's/^/ns2 /' | cat_i
268for i in 1 2 3 4 5 6 7 8 9 10
269do
270	grep "addition 6" ns2/nil.db > /dev/null && break
271	sleep 1
272done
273serial=`awk '$3 == "serial" {print $1}' ns2/nil.db`
274newserial=`expr $serial + 1`
275sed s/$serial/$newserial/ ns2/nil.db > ns2/nil.db.new
276echo 'frozen TXT "frozen addition"' >> ns2/nil.db.new
277mv -f ns2/nil.db.new ns2/nil.db
278$RNDCCMD 10.53.0.2 thaw 2>&1 | sed 's/^/ns2 /' | cat_i
279sleep 1
280[ -s ns2/nil.db.jnl ] || {
281	echo_i "'test -s ns2/nil.db.jnl' failed when it shouldn't have"; ret=1;
282}
283$NSUPDATE -p ${PORT} -k ns2/session.key > nsupdate.out.2.test$n 2>&1 <<END || ret=1
284server 10.53.0.2
285zone nil.
286update add text7.nil. 600 IN TXT "addition 7"
287send
288END
289$DIGCMD text6.nil. TXT > dig.out.1.test$n
290grep 'addition 6' dig.out.1.test$n > /dev/null || ret=1
291$DIGCMD text7.nil. TXT > dig.out.2.test$n
292grep 'addition 7' dig.out.2.test$n > /dev/null || ret=1
293$DIGCMD frozen.nil. TXT > dig.out.3.test$n
294grep 'frozen addition' dig.out.3.test$n >/dev/null || ret=1
295if [ $ret != 0 ]; then echo_i "failed"; fi
296status=`expr $status + $ret`
297
298# temp test
299echo_i "dumping stats ($n)"
300$RNDCCMD 10.53.0.2 stats
301n=`expr $n + 1`
302echo_i "verifying adb records in named.stats ($n)"
303grep "ADB stats" ns2/named.stats > /dev/null || ret=1
304if [ $ret != 0 ]; then echo_i "failed"; fi
305status=`expr $status + $ret`
306
307n=`expr $n + 1`
308echo_i "test using second key ($n)"
309ret=0
310$RNDC -s 10.53.0.2 -p ${CONTROLPORT} -c ns2/secondkey.conf status > /dev/null || ret=1
311if [ $ret != 0 ]; then echo_i "failed"; fi
312status=`expr $status + $ret`
313
314n=`expr $n + 1`
315echo_i "test 'rndc dumpdb' on a empty cache ($n)"
316ret=0
317$RNDCCMD 10.53.0.3 dumpdb > /dev/null || ret=1
318for i in 1 2 3 4 5 6 7 8 9
319do
320	tmp=0
321	grep "Dump complete" ns3/named_dump.db > /dev/null || tmp=1
322	[ $tmp -eq 0 ] && break
323	sleep 1
324done
325[ $tmp -eq 1 ] && ret=1
326if [ $ret != 0 ]; then echo_i "failed"; fi
327status=`expr $status + $ret`
328
329n=`expr $n + 1`
330echo_i "test 'rndc reload' on a zone with include files ($n)"
331ret=0
332grep "incl/IN: skipping load" ns2/named.run > /dev/null && ret=1
333loads=`grep "incl/IN: starting load" ns2/named.run | wc -l`
334[ "$loads" -eq 1 ] || ret=1
335$RNDCCMD 10.53.0.2 reload > /dev/null || ret=1
336for i in 1 2 3 4 5 6 7 8 9
337do
338    tmp=0
339    grep "incl/IN: skipping load" ns2/named.run > /dev/null || tmp=1
340    [ $tmp -eq 0 ] && break
341    sleep 1
342done
343[ $tmp -eq 1 ] && ret=1
344touch ns2/static.db
345$RNDCCMD 10.53.0.2 reload > /dev/null || ret=1
346for i in 1 2 3 4 5 6 7 8 9
347do
348    tmp=0
349    loads=`grep "incl/IN: starting load" ns2/named.run | wc -l`
350    [ "$loads" -eq 2 ] || tmp=1
351    [ $tmp -eq 0 ] && break
352    sleep 1
353done
354[ $tmp -eq 1 ] && ret=1
355if [ $ret != 0 ]; then echo_i "failed"; fi
356status=`expr $status + $ret`
357
358n=`expr $n + 1`
359echo_i "testing rndc with hmac-md5 ($n)"
360ret=0
361$RNDC -s 10.53.0.4 -p ${EXTRAPORT1} -c ns4/key1.conf status > /dev/null 2>&1 || ret=1
362for i in 2 3 4 5 6
363do
364        $RNDC -s 10.53.0.4 -p ${EXTRAPORT1} -c ns4/key${i}.conf status > /dev/null 2>&1 && ret=1
365done
366if [ $ret != 0 ]; then echo_i "failed"; fi
367status=`expr $status + $ret`
368
369n=`expr $n + 1`
370echo_i "testing rndc with hmac-sha1 ($n)"
371ret=0
372$RNDC -s 10.53.0.4 -p ${EXTRAPORT2} -c ns4/key2.conf status > /dev/null 2>&1 || ret=1
373for i in 1 3 4 5 6
374do
375        $RNDC -s 10.53.0.4 -p ${EXTRAPORT2} -c ns4/key${i}.conf status > /dev/null 2>&1 && ret=1
376done
377if [ $ret != 0 ]; then echo_i "failed"; fi
378status=`expr $status + $ret`
379
380n=`expr $n + 1`
381echo_i "testing rndc with hmac-sha224 ($n)"
382ret=0
383$RNDC -s 10.53.0.4 -p ${EXTRAPORT3} -c ns4/key3.conf status > /dev/null 2>&1 || ret=1
384for i in 1 2 4 5 6
385do
386        $RNDC -s 10.53.0.4 -p ${EXTRAPORT3} -c ns4/key${i}.conf status > /dev/null 2>&1 && ret=1
387done
388if [ $ret != 0 ]; then echo_i "failed"; fi
389status=`expr $status + $ret`
390
391n=`expr $n + 1`
392echo_i "testing rndc with hmac-sha256 ($n)"
393ret=0
394$RNDC -s 10.53.0.4 -p ${EXTRAPORT4} -c ns4/key4.conf status > /dev/null 2>&1 || ret=1
395for i in 1 2 3 5 6
396do
397        $RNDC -s 10.53.0.4 -p ${EXTRAPORT4} -c ns4/key${i}.conf status > /dev/null 2>&1 && ret=1
398done
399if [ $ret != 0 ]; then echo_i "failed"; fi
400status=`expr $status + $ret`
401
402n=`expr $n + 1`
403echo_i "testing rndc with hmac-sha384 ($n)"
404ret=0
405$RNDC -s 10.53.0.4 -p ${EXTRAPORT5} -c ns4/key5.conf status > /dev/null 2>&1 || ret=1
406for i in 1 2 3 4 6
407do
408        $RNDC -s 10.53.0.4 -p ${EXTRAPORT5} -c ns4/key${i}.conf status > /dev/null 2>&1 && ret=1
409done
410if [ $ret != 0 ]; then echo_i "failed"; fi
411status=`expr $status + $ret`
412
413n=`expr $n + 1`
414echo_i "testing rndc with hmac-sha512 ($n)"
415ret=0
416$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf status > /dev/null 2>&1 || ret=1
417for i in 1 2 3 4 5
418do
419        $RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key${i}.conf status > /dev/null 2>&1 2>&1 && ret=1
420done
421if [ $ret != 0 ]; then echo_i "failed"; fi
422status=`expr $status + $ret`
423
424n=`expr $n + 1`
425echo_i "testing automatic zones are reported ($n)"
426ret=0
427$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf status > rndc.out.1.test$n || ret=1
428grep "number of zones: 200 (198 automatic)" rndc.out.1.test$n > /dev/null || ret=1
429if [ $ret != 0 ]; then echo_i "failed"; fi
430status=`expr $status + $ret`
431
432n=`expr $n + 1`
433echo_i "testing rndc with null command ($n)"
434ret=0
435$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf null || ret=1
436if [ $ret != 0 ]; then echo_i "failed"; fi
437status=`expr $status + $ret`
438
439n=`expr $n + 1`
440echo_i "testing rndc with unknown control channel command ($n)"
441ret=0
442$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf obviouslynotacommand >/dev/null 2>&1 && ret=1
443# rndc: 'obviouslynotacommand' failed: unknown command
444if [ $ret != 0 ]; then echo_i "failed"; fi
445status=`expr $status + $ret`
446
447n=`expr $n + 1`
448echo_i "testing rndc with querylog command ($n)"
449ret=0
450# first enable it with querylog on option
451$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf querylog on >/dev/null 2>&1 || ret=1
452grep "query logging is now on" ns4/named.run > /dev/null || ret=1
453# query for builtin and check if query was logged (without +subnet)
454$DIG @10.53.0.4 -p ${PORT} -c ch -t txt foo12345.bind > /dev/null || ret=1
455grep "query: foo12345.bind CH TXT.*(.*)$" ns4/named.run > /dev/null || ret=1
456# query for another builtin zone and check if query was logged (with +subnet=127.0.0.1)
457$DIG +subnet=127.0.0.1 @10.53.0.4 -p ${PORT} -c ch -t txt foo12346.bind > /dev/null || ret=1
458grep "query: foo12346.bind CH TXT.*\[ECS 127\.0\.0\.1\/32\/0]" ns4/named.run > /dev/null || ret=1
459# query for another builtin zone and check if query was logged (with +subnet=127.0.0.1/24)
460$DIG +subnet=127.0.0.1/24 @10.53.0.4 -p ${PORT} -c ch -t txt foo12347.bind > /dev/null || ret=1
461grep "query: foo12347.bind CH TXT.*\[ECS 127\.0\.0\.0\/24\/0]" ns4/named.run > /dev/null || ret=1
462# query for another builtin zone and check if query was logged (with +subnet=::1)
463$DIG +subnet=::1 @10.53.0.4 -p ${PORT} -c ch -t txt foo12348.bind > /dev/null || ret=1
464grep "query: foo12348.bind CH TXT.*\[ECS \:\:1\/128\/0]" ns4/named.run > /dev/null || ret=1
465# toggle query logging and check again
466$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf querylog > /dev/null 2>&1 || ret=1
467grep "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)
469$DIG @10.53.0.4 -p ${PORT} -c ch -t txt foo9876.bind > /dev/null || ret=1
470grep "query: foo9876.bind CH TXT.*(.*)$" ns4/named.run > /dev/null && ret=1
471if [ $ret != 0 ]; then echo_i "failed"; fi
472status=`expr $status + $ret`
473
474RNDCCMD4="$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf"
475n=`expr $n + 1`
476echo_i "testing rndc nta time limits ($n)"
477ret=0
478$RNDCCMD4 nta -l 2h nta1.example > rndc.out.1.test$n 2>&1
479grep "Negative trust anchor added" rndc.out.1.test$n > /dev/null || ret=1
480$RNDCCMD4 nta -l 1d nta2.example > rndc.out.2.test$n 2>&1
481grep "Negative trust anchor added" rndc.out.2.test$n > /dev/null || ret=1
482$RNDCCMD4 nta -l 1w nta3.example > rndc.out.3.test$n 2>&1
483grep "Negative trust anchor added" rndc.out.3.test$n > /dev/null || ret=1
484$RNDCCMD4 nta -l 8d nta4.example > rndc.out.4.test$n 2>&1
485grep "NTA lifetime cannot exceed one week" rndc.out.4.test$n > /dev/null || ret=1
486if [ $ret != 0 ]; then echo_i "failed"; fi
487status=`expr $status + $ret`
488
489n=`expr $n + 1`
490echo_i "testing rndc nta -class option ($n)"
491ret=0
492nextpart ns4/named.run > /dev/null
493$RNDCCMD4 nta -c in nta1.example > rndc.out.1.test$n 2>&1
494nextpart ns4/named.run | grep "added NTA 'nta1.example'" > /dev/null || ret=1
495$RNDCCMD4 nta -c any nta1.example > rndc.out.2.test$n 2>&1
496nextpart ns4/named.run | grep "added NTA 'nta1.example'" > /dev/null || ret=1
497$RNDCCMD4 nta -c ch nta1.example > rndc.out.3.test$n 2>&1
498nextpart ns4/named.run | grep "added NTA 'nta1.example'" > /dev/null && ret=1
499$RNDCCMD4 nta -c fake nta1.example > rndc.out.4.test$n 2>&1
500nextpart ns4/named.run | grep "added NTA 'nta1.example'" > /dev/null && ret=1
501grep 'unknown class' rndc.out.4.test$n > /dev/null || ret=1
502if [ $ret != 0 ]; then echo_i "failed"; fi
503status=`expr $status + $ret`
504
505for i in 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288
506do
507	n=`expr $n + 1`
508	echo_i "testing rndc buffer size limits (size=${i}) ($n)"
509	ret=0
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	if [ "$?" = "0" ]; then
513	    expected_size=`expr $i + 1`
514	    if [ $actual_size != $expected_size ]; then ret=1; fi
515	else
516	    ret=1
517	fi
518
519	if [ $ret != 0 ]; then echo_i "failed"; fi
520	status=`expr $status + $ret`
521done
522
523n=`expr $n + 1`
524echo_i "testing rndc -r (show result) ($n)"
525ret=0
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
527grep "ISC_R_SUCCESS 0" rndc.out.1.test$n > /dev/null || ret=1
528if [ $ret != 0 ]; then echo_i "failed"; fi
529status=`expr $status + $ret`
530
531n=`expr $n + 1`
532echo_i "testing rndc with a token containing a space ($n)"
533ret=0
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
535grep "not found" rndc.out.1.test$n > /dev/null && ret=1
536if [ $ret != 0 ]; then echo_i "failed"; fi
537status=`expr $status + $ret`
538
539n=`expr $n + 1`
540echo_i "test 'rndc reconfig' with a broken config ($n)"
541ret=0
542$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf reconfig > /dev/null || ret=1
543sleep 1
544mv ns4/named.conf ns4/named.conf.save
545echo "error error error" >> ns4/named.conf
546$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf reconfig > rndc.out.1.test$n 2>&1 && ret=1
547grep "rndc: 'reconfig' failed: unexpected token" rndc.out.1.test$n > /dev/null || ret=1
548mv ns4/named.conf.save ns4/named.conf
549sleep 1
550$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf reconfig > /dev/null || ret=1
551sleep 1
552if [ $ret != 0 ]; then echo_i "failed"; fi
553status=`expr $status + $ret`
554
555n=`expr $n + 1`
556echo_i "test read-only control channel access ($n)"
557ret=0
558$RNDCCMD 10.53.0.5 status > rndc.out.1.test$n 2>&1 || ret=1
559$RNDCCMD 10.53.0.5 nta -dump > rndc.out.2.test$n 2>&1 || ret=1
560$RNDCCMD 10.53.0.5 reconfig > rndc.out.3.test$n 2>&1 && ret=1
561if [ $ret != 0 ]; then echo_i "failed"; fi
562status=`expr $status + $ret`
563
564n=`expr $n + 1`
565echo_i "test rndc status shows running on ($n)"
566ret=0
567$RNDCCMD 10.53.0.5 status > rndc.out.1.test$n 2>&1 || ret=1
568grep "^running on " rndc.out.1.test$n > /dev/null || ret=1
569if [ $ret != 0 ]; then echo_i "failed"; fi
570status=`expr $status + $ret`
571
572n=`expr $n + 1`
573echo_i "test 'rndc reconfig' with loading of a large zone ($n)"
574ret=0
575cur=`awk 'BEGIN {l=0} /^/ {l++} END { print l }' ns6/named.run`
576cp ns6/named.conf ns6/named.conf.save
577echo "zone \"huge.zone\" { type master; file \"huge.zone.db\"; };" >> ns6/named.conf
578echo_i "reloading config"
579$RNDCCMD 10.53.0.6 reconfig > rndc.out.1.test$n 2>&1 || ret=1
580if [ $ret != 0 ]; then echo_i "failed"; fi
581status=`expr $status + $ret`
582sleep 1
583n=`expr $n + 1`
584echo_i "check if zone load was scheduled ($n)"
585grep "scheduled loading new zones" ns6/named.run > /dev/null || ret=1
586if [ $ret != 0 ]; then echo_i "failed"; fi
587status=`expr $status + $ret`
588
589n=`expr $n + 1`
590echo_i "check if query for the zone returns SERVFAIL ($n)"
591$DIG @10.53.0.6 -p ${PORT} -t soa huge.zone > dig.out.1.test$n
592grep "SERVFAIL" dig.out.1.test$n > /dev/null || ret=1
593if [ $ret != 0 ]; then echo_i "failed (ignored)"; ret=0; fi
594status=`expr $status + $ret`
595
596n=`expr $n + 1`
597echo_i "wait for the zones to be loaded ($n)"
598ret=1
599try=0
600while test $try -lt 100
601do
602    sleep 1
603    sed -n "$cur,"'$p' < ns6/named.run | grep "any newly configured zones are now loaded" > /dev/null && {
604        ret=0
605        break
606    }
607    try=`expr $try + 1`
608done
609if [ $ret != 0 ]; then echo_i "failed"; fi
610status=`expr $status + $ret`
611
612n=`expr $n + 1`
613echo_i "check if query for the zone returns NOERROR ($n)"
614$DIG @10.53.0.6 -p ${PORT} -t soa huge.zone > dig.out.1.test$n
615grep "NOERROR" dig.out.1.test$n > /dev/null || ret=1
616if [ $ret != 0 ]; then echo_i "failed"; fi
617status=`expr $status + $ret`
618
619n=`expr $n + 1`
620echo_i "verify that the full command is logged ($n)"
621ret=0
622$RNDCCMD 10.53.0.2 null with extra arguments > /dev/null 2>&1
623grep "received control channel command 'null with extra arguments'" ns2/named.run > /dev/null || ret=1
624if [ $ret != 0 ]; then echo_i "failed"; fi
625status=`expr $status + $ret`
626
627mv ns6/named.conf.save ns6/named.conf
628sleep 1
629$RNDCCMD 10.53.0.6 reconfig > /dev/null || ret=1
630sleep 1
631if [ $ret != 0 ]; then echo_i "failed"; fi
632status=`expr $status + $ret`
633
634if [ -x "$PYTHON" ]; then
635    n=`expr $n + 1`
636    echo_i "test rndc python bindings ($n)"
637    ret=0
638    $PYTHON > python.out.1.test$n << EOF
639import sys
640sys.path.insert(0, '../../../../bin/python')
641from isc import *
642r = rndc(('10.53.0.5', ${CONTROLPORT}), 'hmac-sha256', '1234abcd8765')
643result = r.call('status')
644print(result['text'])
645EOF
646    grep 'server is up and running' python.out.1.test$n > /dev/null 2>&1 || ret=1
647    if [ $ret != 0 ]; then echo_i "failed"; fi
648    status=`expr $status + $ret`
649fi
650
651n=`expr $n + 1`
652echo_i "check 'rndc \"\"' is handled ($n)"
653ret=0
654$RNDCCMD 10.53.0.2 "" > rndc.out.1.test$n 2>&1 && ret=1
655grep "rndc: '' failed: failure" rndc.out.1.test$n > /dev/null
656if [ $ret != 0 ]; then echo_i "failed"; fi
657status=`expr $status + $ret`
658
659n=`expr $n + 1`
660echo_i "check rndc -4 -6 ($n)"
661ret=0
662$RNDCCMD 10.53.0.2 -4 -6 status > rndc.out.1.test$n 2>&1 && ret=1
663grep "only one of -4 and -6 allowed" rndc.out.1.test$n > /dev/null || ret=1
664if [ $ret != 0 ]; then echo_i "failed"; fi
665status=`expr $status + $ret`
666
667n=`expr $n + 1`
668echo_i "check rndc -4 with an IPv6 server address ($n)"
669ret=0
670$RNDCCMD fd92:7065:b8e:ffff::2 -4 status > rndc.out.1.test$n 2>&1 && ret=1
671grep "address family not supported" rndc.out.1.test$n > /dev/null || ret=1
672if [ $ret != 0 ]; then echo_i "failed"; fi
673status=`expr $status + $ret`
674
675n=`expr $n + 1`
676echo_i "check rndc nta reports adding to multiple views ($n)"
677ret=0
678$RNDCCMD 10.53.0.3 nta test.com > rndc.out.test$n 2>&1 || ret=1
679lines=`cat rndc.out.test$n | wc -l`
680[ ${lines:-0} -eq 2 ] || ret=1
681if [ $ret != 0 ]; then echo_i "failed"; fi
682status=`expr $status + $ret`
683
684echo_i "exit status: $status"
685[ $status -eq 0 ] || exit 1
686