Remove building with NOCRYPTO option
[minix.git] / external / bsd / bind / dist / bin / tests / system / ixfr / tests.sh
blob85c489046acad9cf0ba3ef9efbb14d90063ea84e
1 #!/bin/sh
3 # Copyright (C) 2004, 2007, 2011, 2012, 2014 Internet Systems Consortium, Inc. ("ISC")
4 # Copyright (C) 2001 Internet Software Consortium.
6 # Permission to use, copy, modify, and/or distribute this software for any
7 # purpose with or without fee is hereby granted, provided that the above
8 # copyright notice and this permission notice appear in all copies.
10 # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
11 # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12 # AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
13 # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14 # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
15 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 # PERFORMANCE OF THIS SOFTWARE.
18 # Id: tests.sh,v 1.11 2012/02/22 14:22:54 marka Exp
21 # WARNING: The test labelled "testing request-ixfr option in view vs zone"
22 # is fragile because it depends upon counting instances of records
23 # in the log file - need a better approach <sdm> - until then,
24 # if you add any tests above that point, you will break the test.
26 SYSTEMTESTTOP=..
27 . $SYSTEMTESTTOP/conf.sh
29 status=0
31 DIGOPTS="+tcp +noadd +nosea +nostat +noquest +nocomm +nocmd"
32 DIGCMD="$DIG $DIGOPTS @10.53.0.1 -p 5300"
33 SENDCMD="$PERL ../send.pl 10.53.0.2 5301"
34 RNDCCMD="$RNDC -s 10.53.0.1 -p 9953 -c ../common/rndc.conf"
36 echo "I:testing initial AXFR"
38 $SENDCMD <<EOF
39 /SOA/
40 nil. 300 SOA ns.nil. root.nil. 1 300 300 604800 300
41 /AXFR/
42 nil. 300 SOA ns.nil. root.nil. 1 300 300 604800 300
43 /AXFR/
44 nil. 300 NS ns.nil.
45 nil. 300 TXT "initial AXFR"
46 a.nil. 60 A 10.0.0.61
47 b.nil. 60 A 10.0.0.62
48 /AXFR/
49 nil. 300 SOA ns.nil. root.nil. 1 300 300 604800 300
50 EOF
52 sleep 1
54 # Initially, ns1 is not authoritative for anything (see setup.sh).
55 # Now that ans is up and running with the right data, we make it
56 # a slave for nil.
58 cat <<EOF >>ns1/named.conf
59 zone "nil" {
60 type slave;
61 file "myftp.db";
62 masters { 10.53.0.2; };
64 EOF
66 $RNDCCMD reload
68 for i in 0 1 2 3 4 5 6 7 8 9
70 $DIGCMD nil. SOA > dig.out
71 grep "SOA" dig.out > /dev/null && break
72 sleep 1
73 done
75 $DIGCMD nil. TXT | grep 'initial AXFR' >/dev/null || {
76 echo "I:failed"
77 status=1
80 echo "I:testing successful IXFR"
82 # We change the IP address of a.nil., and the TXT record at the apex.
83 # Then we do a SOA-only update.
85 $SENDCMD <<EOF
86 /SOA/
87 nil. 300 SOA ns.nil. root.nil. 3 300 300 604800 300
88 /IXFR/
89 nil. 300 SOA ns.nil. root.nil. 3 300 300 604800 300
90 nil. 300 SOA ns.nil. root.nil. 1 300 300 604800 300
91 a.nil. 60 A 10.0.0.61
92 nil. 300 TXT "initial AXFR"
93 nil. 300 SOA ns.nil. root.nil. 2 300 300 604800 300
94 nil. 300 TXT "successful IXFR"
95 a.nil. 60 A 10.0.1.61
96 nil. 300 SOA ns.nil. root.nil. 2 300 300 604800 300
97 nil. 300 SOA ns.nil. root.nil. 3 300 300 604800 300
98 nil. 300 SOA ns.nil. root.nil. 3 300 300 604800 300
99 EOF
101 sleep 1
103 $RNDCCMD refresh nil
105 sleep 2
107 $DIGCMD nil. TXT | grep 'successful IXFR' >/dev/null || {
108 echo "I:failed"
109 status=1
112 echo "I:testing AXFR fallback after IXFR failure"
114 # Provide a broken IXFR response and a working fallback AXFR response
116 $SENDCMD <<EOF
117 /SOA/
118 nil. 300 SOA ns.nil. root.nil. 4 300 300 604800 300
119 /IXFR/
120 nil. 300 SOA ns.nil. root.nil. 4 300 300 604800 300
121 nil. 300 SOA ns.nil. root.nil. 3 300 300 604800 300
122 nil. 300 TXT "delete-nonexistent-txt-record"
123 nil. 300 SOA ns.nil. root.nil. 4 300 300 604800 300
124 nil. 300 TXT "this-txt-record-would-be-added"
125 nil. 300 SOA ns.nil. root.nil. 4 300 300 604800 300
126 /AXFR/
127 nil. 300 SOA ns.nil. root.nil. 3 300 300 604800 300
128 /AXFR/
129 nil. 300 NS ns.nil.
130 nil. 300 TXT "fallback AXFR"
131 /AXFR/
132 nil. 300 SOA ns.nil. root.nil. 3 300 300 604800 300
135 sleep 1
137 $RNDCCMD refresh nil
139 sleep 2
141 $DIGCMD nil. TXT | grep 'fallback AXFR' >/dev/null || {
142 echo "I:failed"
143 status=1
146 echo "I:testing ixfr-from-differences option"
147 # ns3 is master; ns4 is slave
148 $CHECKZONE test. ns3/mytest.db > /dev/null 2>&1
149 if [ $? -ne 0 ]
150 then
151 echo "I:named-checkzone returned failure on ns3/mytest.db"
153 # modify the master
154 #echo "I: digging against master: "
155 #$DIG $DIGOPTS @10.53.0.3 -p 5300 a host1.test.
156 #echo "I: digging against slave: "
157 #$DIG $DIGOPTS @10.53.0.4 -p 5300 a host1.test.
159 cp ns3/mytest1.db ns3/mytest.db
160 $RNDC -s 10.53.0.3 -p 9953 -c ../common/rndc.conf reload
162 for i in 0 1 2 3 4 5 6 7 8 9
164 $DIG +tcp -p 5300 @10.53.0.4 SOA test > dig.out
165 grep -i "hostmaster\.test\..2" dig.out > /dev/null && break
166 sleep 1
167 done
169 # slave should have gotten notify and updated
171 for i in 0 1 2 3 4 5 6 7 8 9
173 INCR=`grep "test/IN/primary" ns4/named.run|grep "got incremental"|wc -l`
174 [ $INCR -eq 1 ] && break
175 sleep 1
176 done
177 if [ $INCR -ne 1 ]
178 then
179 echo "I:failed to get incremental response"
180 status=1
183 echo "I:testing request-ixfr option in view vs zone"
184 # There's a view with 2 zones. In the view, "request-ixfr yes"
185 # but in the zone "sub.test", request-ixfr no"
186 # we want to make sure that a change to sub.test results in AXFR, while
187 # changes to test. result in IXFR
189 echo "I: this result should be AXFR"
190 cp ns3/subtest1.db ns3/subtest.db # change to sub.test zone, should be AXFR
191 $RNDC -s 10.53.0.3 -p 9953 -c ../common/rndc.conf reload
193 for i in 0 1 2 3 4 5 6 7 8 9
195 $DIG +tcp -p 5300 @10.53.0.4 SOA sub.test > dig.out
196 grep -i "hostmaster\.test\..3" dig.out > /dev/null && break
197 sleep 1
198 done
200 echo "I: this result should be AXFR"
201 for i in 0 1 2 3 4 5 6 7 8 9
203 NONINCR=`grep 'sub\.test/IN/primary' ns4/named.run|grep "got nonincremental" | wc -l`
204 [ $NONINCR -eq 2 ] && break
205 sleep 1
206 done
207 if [ $NONINCR -ne 2 ]
208 then
209 echo "I:failed to get nonincremental response in 2nd AXFR test"
210 status=1
211 else
212 echo "I: success: AXFR it was"
215 echo "I: this result should be IXFR"
216 cp ns3/mytest2.db ns3/mytest.db # change to test zone, should be IXFR
217 $RNDC -s 10.53.0.3 -p 9953 -c ../common/rndc.conf reload
219 for i in 0 1 2 3 4 5 6 7 8 9
221 $DIG +tcp -p 5300 @10.53.0.4 SOA test > dig.out
222 grep -i "hostmaster\.test\..4" dig.out > /dev/null && break
223 sleep 1
224 done
226 for i in 0 1 2 3 4 5 6 7 8 9
228 INCR=`grep "test/IN/primary" ns4/named.run|grep "got incremental"|wc -l`
229 [ $INCR -eq 2 ] && break
230 sleep 1
231 done
232 if [ $INCR -ne 2 ]
233 then
234 echo "I:failed to get incremental response in 2nd IXFR test"
235 status=1
236 else
237 echo "I: success: IXFR it was"
240 echo "I:testing DiG's handling of a multi message AXFR style IXFR response"
242 (sleep 10 && kill $$) 2>/dev/null &
243 sub=$!
244 $DIG ixfr=0 large -p 5300 @10.53.0.3 > dig.out
245 kill $sub
247 lines=`grep hostmaster.large dig.out | wc -l`
248 test ${lines:-0} -eq 2 || { echo "I:failed"; status=1; }
249 messages=`sed -n 's/^;;.*messages \([0-9]*\),.*/\1/p' dig.out`
250 test ${messages:-0} -gt 1 || { echo "I:failed"; status=1; }
252 echo "I:test 'dig +notcp ixfr=<value>' vs 'dig ixfr=<value> +notcp' vs 'dig ixfr=<value>'"
253 ret=0
254 # Should be "switch to TCP" response
255 $DIG +notcp ixfr=1 test -p 5300 @10.53.0.4 > dig.out1 || ret=1
256 $DIG ixfr=1 +notcp test -p 5300 @10.53.0.4 > dig.out2 || ret=1
257 $PERL ../digcomp.pl dig.out1 dig.out2 || ret=1
258 awk '$4 == "SOA" { soacnt++} END {if (soacnt == 1) exit(0); else exit(1);}' dig.out1 || ret=1
259 awk '$4 == "SOA" { if ($7 == 4) exit(0); else exit(1);}' dig.out1 || ret=1
260 # Should be incremental transfer.
261 $DIG ixfr=1 test -p 5300 @10.53.0.4 > dig.out3 || ret=1
262 awk '$4 == "SOA" { soacnt++} END { if (soacnt == 6) exit(0); else exit(1);}' dig.out3 || ret=1
263 if [ ${ret} != 0 ]; then
264 echo "I:failed";
265 status=1;
268 echo "I:exit status: $status"
269 exit $status