tests.sh revision 1.1.1.5
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
317rndc_dumpdb ns3 || ret=1
318if [ $ret != 0 ]; then echo_i "failed"; fi
319status=`expr $status + $ret`
320
321n=`expr $n + 1`
322echo_i "test 'rndc reload' on a zone with include files ($n)"
323ret=0
324grep "incl/IN: skipping load" ns2/named.run > /dev/null && ret=1
325loads=`grep "incl/IN: starting load" ns2/named.run | wc -l`
326[ "$loads" -eq 1 ] || ret=1
327$RNDCCMD 10.53.0.2 reload > /dev/null || ret=1
328for i in 1 2 3 4 5 6 7 8 9
329do
330    tmp=0
331    grep "incl/IN: skipping load" ns2/named.run > /dev/null || tmp=1
332    [ $tmp -eq 0 ] && break
333    sleep 1
334done
335[ $tmp -eq 1 ] && ret=1
336touch ns2/static.db
337$RNDCCMD 10.53.0.2 reload > /dev/null || ret=1
338for i in 1 2 3 4 5 6 7 8 9
339do
340    tmp=0
341    loads=`grep "incl/IN: starting load" ns2/named.run | wc -l`
342    [ "$loads" -eq 2 ] || tmp=1
343    [ $tmp -eq 0 ] && break
344    sleep 1
345done
346[ $tmp -eq 1 ] && ret=1
347if [ $ret != 0 ]; then echo_i "failed"; fi
348status=`expr $status + $ret`
349
350n=`expr $n + 1`
351echo_i "testing rndc with hmac-md5 ($n)"
352ret=0
353$RNDC -s 10.53.0.4 -p ${EXTRAPORT1} -c ns4/key1.conf status > /dev/null 2>&1 || ret=1
354for i in 2 3 4 5 6
355do
356        $RNDC -s 10.53.0.4 -p ${EXTRAPORT1} -c ns4/key${i}.conf status > /dev/null 2>&1 && ret=1
357done
358if [ $ret != 0 ]; then echo_i "failed"; fi
359status=`expr $status + $ret`
360
361n=`expr $n + 1`
362echo_i "testing rndc with hmac-sha1 ($n)"
363ret=0
364$RNDC -s 10.53.0.4 -p ${EXTRAPORT2} -c ns4/key2.conf status > /dev/null 2>&1 || ret=1
365for i in 1 3 4 5 6
366do
367        $RNDC -s 10.53.0.4 -p ${EXTRAPORT2} -c ns4/key${i}.conf status > /dev/null 2>&1 && ret=1
368done
369if [ $ret != 0 ]; then echo_i "failed"; fi
370status=`expr $status + $ret`
371
372n=`expr $n + 1`
373echo_i "testing rndc with hmac-sha224 ($n)"
374ret=0
375$RNDC -s 10.53.0.4 -p ${EXTRAPORT3} -c ns4/key3.conf status > /dev/null 2>&1 || ret=1
376for i in 1 2 4 5 6
377do
378        $RNDC -s 10.53.0.4 -p ${EXTRAPORT3} -c ns4/key${i}.conf status > /dev/null 2>&1 && ret=1
379done
380if [ $ret != 0 ]; then echo_i "failed"; fi
381status=`expr $status + $ret`
382
383n=`expr $n + 1`
384echo_i "testing rndc with hmac-sha256 ($n)"
385ret=0
386$RNDC -s 10.53.0.4 -p ${EXTRAPORT4} -c ns4/key4.conf status > /dev/null 2>&1 || ret=1
387for i in 1 2 3 5 6
388do
389        $RNDC -s 10.53.0.4 -p ${EXTRAPORT4} -c ns4/key${i}.conf status > /dev/null 2>&1 && ret=1
390done
391if [ $ret != 0 ]; then echo_i "failed"; fi
392status=`expr $status + $ret`
393
394n=`expr $n + 1`
395echo_i "testing rndc with hmac-sha384 ($n)"
396ret=0
397$RNDC -s 10.53.0.4 -p ${EXTRAPORT5} -c ns4/key5.conf status > /dev/null 2>&1 || ret=1
398for i in 1 2 3 4 6
399do
400        $RNDC -s 10.53.0.4 -p ${EXTRAPORT5} -c ns4/key${i}.conf status > /dev/null 2>&1 && ret=1
401done
402if [ $ret != 0 ]; then echo_i "failed"; fi
403status=`expr $status + $ret`
404
405n=`expr $n + 1`
406echo_i "testing rndc with hmac-sha512 ($n)"
407ret=0
408$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf status > /dev/null 2>&1 || ret=1
409for i in 1 2 3 4 5
410do
411        $RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key${i}.conf status > /dev/null 2>&1 2>&1 && ret=1
412done
413if [ $ret != 0 ]; then echo_i "failed"; fi
414status=`expr $status + $ret`
415
416n=`expr $n + 1`
417echo_i "testing automatic zones are reported ($n)"
418ret=0
419$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf status > rndc.out.1.test$n || ret=1
420grep "number of zones: 200 (198 automatic)" rndc.out.1.test$n > /dev/null || ret=1
421if [ $ret != 0 ]; then echo_i "failed"; fi
422status=`expr $status + $ret`
423
424n=`expr $n + 1`
425echo_i "testing rndc with null command ($n)"
426ret=0
427$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf null || ret=1
428if [ $ret != 0 ]; then echo_i "failed"; fi
429status=`expr $status + $ret`
430
431n=`expr $n + 1`
432echo_i "testing rndc with unknown control channel command ($n)"
433ret=0
434$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf obviouslynotacommand >/dev/null 2>&1 && ret=1
435# rndc: 'obviouslynotacommand' failed: unknown command
436if [ $ret != 0 ]; then echo_i "failed"; fi
437status=`expr $status + $ret`
438
439n=`expr $n + 1`
440echo_i "testing rndc with querylog command ($n)"
441ret=0
442# first enable it with querylog on option
443$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf querylog on >/dev/null 2>&1 || ret=1
444grep "query logging is now on" ns4/named.run > /dev/null || ret=1
445# query for builtin and check if query was logged (without +subnet)
446$DIG @10.53.0.4 -p ${PORT} -c ch -t txt foo12345.bind > /dev/null || ret=1
447grep "query: foo12345.bind CH TXT.*(.*)$" ns4/named.run > /dev/null || ret=1
448# query for another builtin zone and check if query was logged (with +subnet=127.0.0.1)
449$DIG +subnet=127.0.0.1 @10.53.0.4 -p ${PORT} -c ch -t txt foo12346.bind > /dev/null || ret=1
450grep "query: foo12346.bind CH TXT.*\[ECS 127\.0\.0\.1\/32\/0]" ns4/named.run > /dev/null || ret=1
451# query for another builtin zone and check if query was logged (with +subnet=127.0.0.1/24)
452$DIG +subnet=127.0.0.1/24 @10.53.0.4 -p ${PORT} -c ch -t txt foo12347.bind > /dev/null || ret=1
453grep "query: foo12347.bind CH TXT.*\[ECS 127\.0\.0\.0\/24\/0]" ns4/named.run > /dev/null || ret=1
454# query for another builtin zone and check if query was logged (with +subnet=::1)
455$DIG +subnet=::1 @10.53.0.4 -p ${PORT} -c ch -t txt foo12348.bind > /dev/null || ret=1
456grep "query: foo12348.bind CH TXT.*\[ECS \:\:1\/128\/0]" ns4/named.run > /dev/null || ret=1
457# toggle query logging and check again
458$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf querylog > /dev/null 2>&1 || ret=1
459grep "query logging is now off" ns4/named.run > /dev/null || ret=1
460# query for another builtin zone and check if query was logged (without +subnet)
461$DIG @10.53.0.4 -p ${PORT} -c ch -t txt foo9876.bind > /dev/null || ret=1
462grep "query: foo9876.bind CH TXT.*(.*)$" ns4/named.run > /dev/null && ret=1
463if [ $ret != 0 ]; then echo_i "failed"; fi
464status=`expr $status + $ret`
465
466RNDCCMD4="$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf"
467n=`expr $n + 1`
468echo_i "testing rndc nta time limits ($n)"
469ret=0
470$RNDCCMD4 nta -l 2h nta1.example > rndc.out.1.test$n 2>&1
471grep "Negative trust anchor added" rndc.out.1.test$n > /dev/null || ret=1
472$RNDCCMD4 nta -l 1d nta2.example > rndc.out.2.test$n 2>&1
473grep "Negative trust anchor added" rndc.out.2.test$n > /dev/null || ret=1
474$RNDCCMD4 nta -l 1w nta3.example > rndc.out.3.test$n 2>&1
475grep "Negative trust anchor added" rndc.out.3.test$n > /dev/null || ret=1
476$RNDCCMD4 nta -l 8d nta4.example > rndc.out.4.test$n 2>&1
477grep "NTA lifetime cannot exceed one week" rndc.out.4.test$n > /dev/null || ret=1
478if [ $ret != 0 ]; then echo_i "failed"; fi
479status=`expr $status + $ret`
480
481n=`expr $n + 1`
482echo_i "testing rndc nta -class option ($n)"
483ret=0
484nextpart ns4/named.run > /dev/null
485$RNDCCMD4 nta -c in nta1.example > rndc.out.1.test$n 2>&1
486nextpart ns4/named.run | grep "added NTA 'nta1.example'" > /dev/null || ret=1
487$RNDCCMD4 nta -c any nta1.example > rndc.out.2.test$n 2>&1
488nextpart ns4/named.run | grep "added NTA 'nta1.example'" > /dev/null || ret=1
489$RNDCCMD4 nta -c ch nta1.example > rndc.out.3.test$n 2>&1
490nextpart ns4/named.run | grep "added NTA 'nta1.example'" > /dev/null && ret=1
491$RNDCCMD4 nta -c fake nta1.example > rndc.out.4.test$n 2>&1
492nextpart ns4/named.run | grep "added NTA 'nta1.example'" > /dev/null && ret=1
493grep 'unknown class' rndc.out.4.test$n > /dev/null || ret=1
494if [ $ret != 0 ]; then echo_i "failed"; fi
495status=`expr $status + $ret`
496
497for i in 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288
498do
499	n=`expr $n + 1`
500	echo_i "testing rndc buffer size limits (size=${i}) ($n)"
501	ret=0
502	$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf testgen ${i} 2>&1 > rndc.out.$i.test$n || ret=1
503	actual_size=`$GENCHECK rndc.out.$i.test$n`
504	if [ "$?" = "0" ]; then
505	    expected_size=`expr $i + 1`
506	    if [ $actual_size != $expected_size ]; then ret=1; fi
507	else
508	    ret=1
509	fi
510
511	if [ $ret != 0 ]; then echo_i "failed"; fi
512	status=`expr $status + $ret`
513done
514
515n=`expr $n + 1`
516echo_i "testing rndc -r (show result) ($n)"
517ret=0
518$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf -r testgen 0 2>&1 > rndc.out.1.test$n || ret=1
519grep "ISC_R_SUCCESS 0" rndc.out.1.test$n > /dev/null || ret=1
520if [ $ret != 0 ]; then echo_i "failed"; fi
521status=`expr $status + $ret`
522
523n=`expr $n + 1`
524echo_i "testing rndc with a token containing a space ($n)"
525ret=0
526$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
527grep "not found" 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 "test 'rndc reconfig' with a broken config ($n)"
533ret=0
534$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf reconfig > /dev/null || ret=1
535sleep 1
536mv ns4/named.conf ns4/named.conf.save
537echo "error error error" >> ns4/named.conf
538$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf reconfig > rndc.out.1.test$n 2>&1 && ret=1
539grep "rndc: 'reconfig' failed: unexpected token" rndc.out.1.test$n > /dev/null || ret=1
540if [ $ret != 0 ]; then echo_i "failed"; fi
541status=`expr $status + $ret`
542
543n=`expr $n + 1`
544echo_i "check rndc status reports failure ($n)"
545ret=0
546$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf status > rndc.out.1.test$n 2>&1 || ret=1
547grep "reload/reconfig failed" rndc.out.1.test$n > /dev/null || ret=1
548if [ $ret != 0 ]; then echo_i "failed"; fi
549status=`expr $status + $ret`
550
551n=`expr $n + 1`
552echo_i "restore working config ($n)"
553ret=0
554mv ns4/named.conf.save ns4/named.conf
555sleep 1
556$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf reconfig > /dev/null || ret=1
557sleep 1
558if [ $ret != 0 ]; then echo_i "failed"; fi
559status=`expr $status + $ret`
560
561n=`expr $n + 1`
562echo_i "check 'rndc status' 'reload/reconfig failure' is cleared after successful reload/reconfig ($n)"
563ret=0
564$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf status > rndc.out.1.test$n 2>&1 || ret=1
565grep "reload/reconfig failed" rndc.out.1.test$n > /dev/null && ret=1
566if [ $ret != 0 ]; then echo_i "failed"; fi
567status=`expr $status + $ret`
568
569n=`expr $n + 1`
570echo_i "test read-only control channel access ($n)"
571ret=0
572$RNDCCMD 10.53.0.5 status > rndc.out.1.test$n 2>&1 || ret=1
573$RNDCCMD 10.53.0.5 nta -dump > rndc.out.2.test$n 2>&1 || ret=1
574$RNDCCMD 10.53.0.5 reconfig > rndc.out.3.test$n 2>&1 && ret=1
575if [ $ret != 0 ]; then echo_i "failed"; fi
576status=`expr $status + $ret`
577
578n=`expr $n + 1`
579echo_i "test rndc status shows running on ($n)"
580ret=0
581$RNDCCMD 10.53.0.5 status > rndc.out.1.test$n 2>&1 || ret=1
582grep "^running on " rndc.out.1.test$n > /dev/null || ret=1
583if [ $ret != 0 ]; then echo_i "failed"; fi
584status=`expr $status + $ret`
585
586n=`expr $n + 1`
587echo_i "test 'rndc reconfig' with loading of a large zone ($n)"
588ret=0
589cur=`awk 'BEGIN {l=0} /^/ {l++} END { print l }' ns6/named.run`
590cp ns6/named.conf ns6/named.conf.save
591echo "zone \"huge.zone\" { type master; file \"huge.zone.db\"; };" >> ns6/named.conf
592echo_i "reloading config"
593$RNDCCMD 10.53.0.6 reconfig > rndc.out.1.test$n 2>&1 || ret=1
594if [ $ret != 0 ]; then echo_i "failed"; fi
595status=`expr $status + $ret`
596sleep 1
597n=`expr $n + 1`
598echo_i "check if zone load was scheduled ($n)"
599grep "scheduled loading new zones" ns6/named.run > /dev/null || ret=1
600if [ $ret != 0 ]; then echo_i "failed"; fi
601status=`expr $status + $ret`
602
603n=`expr $n + 1`
604echo_i "check if query for the zone returns SERVFAIL ($n)"
605$DIG @10.53.0.6 -p ${PORT} -t soa huge.zone > dig.out.1.test$n
606grep "SERVFAIL" dig.out.1.test$n > /dev/null || ret=1
607if [ $ret != 0 ]; then echo_i "failed (ignored)"; ret=0; fi
608status=`expr $status + $ret`
609
610n=`expr $n + 1`
611echo_i "wait for the zones to be loaded ($n)"
612ret=1
613try=0
614while test $try -lt 100
615do
616    sleep 1
617    sed -n "$cur,"'$p' < ns6/named.run | grep "any newly configured zones are now loaded" > /dev/null && {
618        ret=0
619        break
620    }
621    try=`expr $try + 1`
622done
623if [ $ret != 0 ]; then echo_i "failed"; fi
624status=`expr $status + $ret`
625
626n=`expr $n + 1`
627echo_i "check if query for the zone returns NOERROR ($n)"
628$DIG @10.53.0.6 -p ${PORT} -t soa huge.zone > dig.out.1.test$n
629grep "NOERROR" dig.out.1.test$n > /dev/null || ret=1
630if [ $ret != 0 ]; then echo_i "failed"; fi
631status=`expr $status + $ret`
632
633n=`expr $n + 1`
634echo_i "verify that the full command is logged ($n)"
635ret=0
636$RNDCCMD 10.53.0.2 null with extra arguments > /dev/null 2>&1
637grep "received control channel command 'null with extra arguments'" ns2/named.run > /dev/null || ret=1
638if [ $ret != 0 ]; then echo_i "failed"; fi
639status=`expr $status + $ret`
640
641mv ns6/named.conf.save ns6/named.conf
642sleep 1
643$RNDCCMD 10.53.0.6 reconfig > /dev/null || ret=1
644sleep 1
645if [ $ret != 0 ]; then echo_i "failed"; fi
646status=`expr $status + $ret`
647
648if [ -x "$PYTHON" ]; then
649    n=`expr $n + 1`
650    echo_i "test rndc python bindings ($n)"
651    ret=0
652    $PYTHON > python.out.1.test$n << EOF
653import sys
654sys.path.insert(0, '../../../../bin/python')
655from isc import *
656r = rndc(('10.53.0.5', ${CONTROLPORT}), 'hmac-sha256', '1234abcd8765')
657result = r.call('status')
658print(result['text'])
659EOF
660    grep 'server is up and running' python.out.1.test$n > /dev/null 2>&1 || ret=1
661    if [ $ret != 0 ]; then echo_i "failed"; fi
662    status=`expr $status + $ret`
663fi
664
665n=`expr $n + 1`
666echo_i "check 'rndc \"\"' is handled ($n)"
667ret=0
668$RNDCCMD 10.53.0.2 "" > rndc.out.1.test$n 2>&1 && ret=1
669grep "rndc: '' failed: failure" rndc.out.1.test$n > /dev/null
670if [ $ret != 0 ]; then echo_i "failed"; fi
671status=`expr $status + $ret`
672
673n=`expr $n + 1`
674echo_i "check rndc -4 -6 ($n)"
675ret=0
676$RNDCCMD 10.53.0.2 -4 -6 status > rndc.out.1.test$n 2>&1 && ret=1
677grep "only one of -4 and -6 allowed" rndc.out.1.test$n > /dev/null || ret=1
678if [ $ret != 0 ]; then echo_i "failed"; fi
679status=`expr $status + $ret`
680
681n=`expr $n + 1`
682echo_i "check rndc -4 with an IPv6 server address ($n)"
683ret=0
684$RNDCCMD fd92:7065:b8e:ffff::2 -4 status > rndc.out.1.test$n 2>&1 && ret=1
685grep "address family not supported" rndc.out.1.test$n > /dev/null || ret=1
686if [ $ret != 0 ]; then echo_i "failed"; fi
687status=`expr $status + $ret`
688
689n=`expr $n + 1`
690echo_i "check rndc nta reports adding to multiple views ($n)"
691ret=0
692$RNDCCMD 10.53.0.3 nta test.com > rndc.out.test$n 2>&1 || ret=1
693lines=`cat rndc.out.test$n | wc -l`
694[ ${lines:-0} -eq 2 ] || ret=1
695if [ $ret != 0 ]; then echo_i "failed"; fi
696status=`expr $status + $ret`
697
698echo_i "exit status: $status"
699[ $status -eq 0 ] || exit 1
700