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.
27 .
$SYSTEMTESTTOP/conf.sh
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"
40 nil. 300 SOA ns.nil. root.nil. 1 300 300 604800 300
42 nil. 300 SOA ns.nil. root.nil. 1 300 300 604800 300
45 nil. 300 TXT "initial AXFR"
49 nil. 300 SOA ns.nil. root.nil. 1 300 300 604800 300
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
58 cat <<EOF >>ns1/named.conf
62 masters { 10.53.0.2; };
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
75 $DIGCMD nil. TXT |
grep 'initial AXFR' >/dev
/null ||
{
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.
87 nil. 300 SOA ns.nil. root.nil. 3 300 300 604800 300
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
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"
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
107 $DIGCMD nil. TXT |
grep 'successful IXFR' >/dev
/null ||
{
112 echo "I:testing AXFR fallback after IXFR failure"
114 # Provide a broken IXFR response and a working fallback AXFR response
118 nil. 300 SOA ns.nil. root.nil. 4 300 300 604800 300
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
127 nil. 300 SOA ns.nil. root.nil. 3 300 300 604800 300
130 nil. 300 TXT "fallback AXFR"
132 nil. 300 SOA ns.nil. root.nil. 3 300 300 604800 300
141 $DIGCMD nil. TXT |
grep 'fallback AXFR' >/dev
/null ||
{
146 echo "I:testing ixfr-from-differences option"
147 # ns3 is master; ns4 is slave
148 $CHECKZONE test. ns
3/mytest.db
> /dev
/null
2>&1
151 echo "I:named-checkzone returned failure on ns3/mytest.db"
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 ns
3/mytest1.db ns
3/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
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
179 echo "I:failed to get incremental response"
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 ns
3/subtest1.db ns
3/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
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
207 if [ $NONINCR -ne 2 ]
209 echo "I:failed to get nonincremental response in 2nd AXFR test"
212 echo "I: success: AXFR it was"
215 echo "I: this result should be IXFR"
216 cp ns
3/mytest2.db ns
3/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
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
234 echo "I:failed to get incremental response in 2nd IXFR test"
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
&
244 $DIG ixfr
=0 large
-p 5300 @
10.53.0.3 > dig.out
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>'"
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
268 echo "I:exit status: $status"