3 # Copyright (C) 2005, 2007, 2011-2014 Internet Systems Consortium, Inc. ("ISC")
5 # Permission to use, copy, modify, and/or distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 # AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 # PERFORMANCE OF THIS SOFTWARE.
20 .
$SYSTEMTESTTOP/conf.sh
23 $PERL -e 'binmode STDIN;
24 read(STDIN, $input, 8);
25 ($style, $version) = unpack("NN", $input);
26 exit 1 if ($style != 3 || $version > 1);' < $1
31 $PERL -e 'binmode STDIN;
32 read(STDIN, $input, 8);
33 ($style, $version) = unpack("NN", $input);
34 exit 1 if ($style != 2 || $version > 1);' < $1
39 $PERL -e 'binmode STDIN;
40 read(STDIN, $input, 8);
41 if (length($input) < 8) { print "not raw\n"; exit 0; };
42 ($style, $version) = unpack("NN", $input);
43 print ($style == 2 || $style == 3 ? "$version\n" :
44 "not raw or map\n");' < $1
48 $PERL -e 'binmode STDIN;
49 read(STDIN, $input, 20);
50 if (length($input) < 20) { print "UNSET\n"; exit; };
51 ($format, $version, $dumptime, $flags, $sourceserial) =
52 unpack("NNNNN", $input);
53 if ($format != 2 || $version < 1) { print "UNSET\n"; exit; };
55 print $sourceserial . "\n";
62 $PERL -e 'open(my $file, "+<", $ARGV[0]);
64 seek($file, $ARGV[1], 0);
65 for (my $i = 0; $i < $ARGV[2]; $i++) {
66 print $file pack('C
', $ARGV[3]);
68 close($file);' $1 $2 $3 $4
73 (cd ..
; $PERL start.pl
--noclean --restart masterformat ns3
)
76 DIGOPTS
="+tcp +noauth +noadd +nosea +nostat +noquest +nocomm +nocmd"
80 echo "I:checking that master files in raw format loaded"
83 for zone
in example example-explicit example-compat
; do
85 for name
in ns mx a aaaa cname dname txt rrsig nsec \
86 dnskey ds cdnskey cds
; do
87 $DIG $DIGOPTS $name.
$zone.
$name @
10.53.0.
$server -p 5300
89 done > dig.out.
$zone.
$server
91 $PERL ..
/digcomp.pl
dig.out.
$zone.1 dig.out.
$zone.2 || ret
=1
92 if [ $zone = "example" ]; then
94 $PERL ..
/digcomp.pl
dig.out.
$zone.1 dig.out.
$zone.3 || ret
=1
97 [ $ret -eq 0 ] ||
echo "I:failed"
98 status
=`expr $status + $ret`
100 echo "I:checking raw format versions"
102 israw ns
1/example.db.raw || ret
=1
103 israw ns
1/example.db.raw1 || ret
=1
104 israw ns
1/example.db.compat || ret
=1
105 ismap ns
1/example.db.map || ret
=1
106 [ "`rawversion ns1/example.db.raw`" = 1 ] || ret
=1
107 [ "`rawversion ns1/example.db.raw1`" = 1 ] || ret
=1
108 [ "`rawversion ns1/example.db.compat`" = 0 ] || ret
=1
109 [ "`rawversion ns1/example.db.map`" = 1 ] || ret
=1
110 [ $ret -eq 0 ] ||
echo "I:failed"
111 status
=`expr $status + $ret`
113 echo "I:checking source serial numbers"
115 [ "`sourceserial ns1/example.db.raw`" = "UNSET" ] || ret
=1
116 [ "`sourceserial ns1/example.db.serial.raw`" = "3333" ] || ret
=1
117 [ $ret -eq 0 ] ||
echo "I:failed"
118 status
=`expr $status + $ret`
120 echo "I:waiting for transfers to complete"
121 for i
in 0 1 2 3 4 5 6 7 8 9
123 test -f ns
2/transfer.db.raw
-a -f ns
2/transfer.db.txt
&& break
127 echo "I:checking that slave was saved in raw format by default"
129 israw ns
2/transfer.db.raw || ret
=1
130 [ $ret -eq 0 ] ||
echo "I:failed"
131 status
=`expr $status + $ret`
133 echo "I:checking that slave was saved in text format when configured"
135 israw ns
2/transfer.db.txt
&& ret
=1
136 [ $ret -eq 0 ] ||
echo "I:failed"
137 status
=`expr $status + $ret`
139 echo "I:checking that slave formerly in text format is now raw"
140 for i
in 0 1 2 3 4 5 6 7 8 9
143 israw ns
2/formerly-text.db
> /dev
/null
2>&1 || ret
=1
144 [ "`rawversion ns2/formerly-text.db`" = 1 ] || ret
=1
145 [ $ret -eq 0 ] && break
148 [ $ret -eq 0 ] ||
echo "I:failed"
149 status
=`expr $status + $ret`
151 echo "I:checking that large rdatasets loaded"
152 for i
in 0 1 2 3 4 5 6 7 8 9
157 $DIG +tcp txt
${a}.large @
10.53.0.2 -p 5300 > dig.out
158 grep "status: NOERROR" dig.out
> /dev
/null || ret
=1
160 [ $ret -eq 0 ] && break
164 echo "I:checking format transitions: text->raw->map->text"
166 .
/named-compilezone
-D -f text
-F text
-o baseline.txt example.nil ns
1/example.db
> /dev
/null
167 .
/named-compilezone
-D -f text
-F raw
-o raw
.1 example.nil baseline.txt
> /dev
/null
168 .
/named-compilezone
-D -f raw
-F map
-o map
.1 example.nil raw
.1 > /dev
/null
169 .
/named-compilezone
-D -f map
-F text
-o text
.1 example.nil map
.1 > /dev
/null
170 cmp -s baseline.txt text
.1 || ret
=0
171 [ $ret -eq 0 ] ||
echo "I:failed"
172 status
=`expr $status + $ret`
174 echo "I:checking format transitions: text->map->raw->text"
176 .
/named-compilezone
-D -f text
-F map
-o map
.2 example.nil baseline.txt
> /dev
/null
177 .
/named-compilezone
-D -f map
-F raw
-o raw
.2 example.nil map
.2 > /dev
/null
178 .
/named-compilezone
-D -f raw
-F text
-o text
.2 example.nil raw
.2 > /dev
/null
179 cmp -s baseline.txt text
.2 || ret
=0
180 [ $ret -eq 0 ] ||
echo "I:failed"
181 status
=`expr $status + $ret`
183 echo "I:checking map format loading with journal file rollforward"
185 $NSUPDATE <<END > /dev/null || status=1
186 server 10.53.0.3 5300
188 update add newtext.dynamic IN TXT "added text"
189 update delete aaaa.dynamic
192 $DIG $DIGOPTS @
10.53.0.3 -p 5300 newtext.dynamic txt
> dig.out.dynamic
.3.1
193 grep "added text" dig.out.dynamic
.3.1 > /dev
/null
2>&1 || ret
=1
194 $DIG $DIGOPTS +comm @
10.53.0.3 -p 5300 added.dynamic txt
> dig.out.dynamic
.3.2
195 grep "NXDOMAIN" dig.out.dynamic
.3.2 > /dev
/null
2>&1 || ret
=1
196 # using "rndc halt" ensures that we don't dump the zone file
197 $RNDC -c ..
/common
/rndc.conf
-s 10.53.0.3 -p 9953 halt
2>&1 |
sed 's/^/I:ns3 /'
199 for i
in 0 1 2 3 4 5 6 7 8 9; do
201 $DIG $DIGOPTS @
10.53.0.3 -p 5300 newtext.dynamic txt
> dig.out.dynamic
.3.3
202 grep "added text" dig.out.dynamic
.3.3 > /dev
/null
2>&1 || lret
=1
203 [ $lret -eq 0 ] && break;
205 [ $lret -eq 1 ] && ret
=1
206 $DIG $DIGOPTS +comm @
10.53.0.3 -p 5300 added.dynamic txt
> dig.out.dynamic
.3.4
207 grep "NXDOMAIN" dig.out.dynamic
.3.4 > /dev
/null
2>&1 || ret
=1
208 [ $ret -eq 0 ] ||
echo "I:failed"
209 status
=`expr $status + $ret`
211 echo "I:checking map format file dumps correctly"
213 $NSUPDATE <<END > /dev/null || status=1
214 server 10.53.0.3 5300
216 update add moretext.dynamic IN TXT "more text"
219 $DIG $DIGOPTS @
10.53.0.3 -p 5300 moretext.dynamic txt
> dig.out.dynamic
.3.5
220 grep "more text" dig.out.dynamic
.3.5 > /dev
/null
2>&1 || ret
=1
221 # using "rndc stop" will cause the zone file to flush before shutdown
222 $RNDC -c ..
/common
/rndc.conf
-s 10.53.0.3 -p 9953 stop
2>&1 |
sed 's/^/I:ns3 /'
225 for i
in 0 1 2 3 4 5 6 7 8 9; do
227 $DIG $DIGOPTS +comm @
10.53.0.3 -p 5300 moretext.dynamic txt
> dig.out.dynamic
.3.6
228 grep "more text" dig.out.dynamic
.3.6 > /dev
/null
2>&1 || lret
=1
229 [ $lret -eq 0 ] && break;
231 [ $lret -eq 1 ] && ret
=1
232 [ $ret -eq 0 ] ||
echo "I:failed"
233 status
=`expr $status + $ret`
235 # stomp on the file data so it hashes differently.
236 # these are small and subtle changes, so that the resulting file
237 # would appear to be a legitimate map file and would not trigger an
238 # assertion failure if loaded into memory, but should still fail to
239 # load because of a SHA1 hash mismatch.
240 echo "I:checking corrupt map files fail to load (bad node header)"
242 .
/named-compilezone
-D -f text
-F map
-o map
.5 example.nil baseline.txt
> /dev
/null
244 stomp badmap
2754 2 99
245 .
/named-compilezone
-D -f map
-F text
-o text
.5 example.nil badmap
> /dev
/null
247 [ $ret -eq 0 ] ||
echo "I:failed"
248 status
=`expr $status + $ret`
250 echo "I:checking corrupt map files fail to load (bad node data)"
253 stomp badmap
2897 5 127
254 .
/named-compilezone
-D -f map
-F text
-o text
.5 example.nil badmap
> /dev
/null
256 [ $ret -eq 0 ] ||
echo "I:failed"
257 status
=`expr $status + $ret`
259 echo "I:checking map format zone is scheduled for resigning (compilezone)"
261 $RNDC -c ..
/common
/rndc.conf
-s 10.53.0.1 -p 9953 zonestatus signed
> rndc.out
2>&1 || ret
=1
262 grep 'next resign' rndc.out
> /dev
/null
2>&1 || ret
=1
263 [ $ret -eq 0 ] ||
echo "I:failed"
264 status
=`expr $status + $ret`
266 echo "I:checking map format zone is scheduled for resigning (signzone)"
268 $RNDC -c ..
/common
/rndc.conf
-s 10.53.0.1 -p 9953 freeze signed
> rndc.out
2>&1 || ret
=1
270 $SIGNER -S -O map
-f signed.db.map
-o signed signed.db
> /dev
/null
2>&1
272 $RNDC -c ..
/common
/rndc.conf
-s 10.53.0.1 -p 9953 reload signed
> rndc.out
2>&1 || ret
=1
273 $RNDC -c ..
/common
/rndc.conf
-s 10.53.0.1 -p 9953 zonestatus signed
> rndc.out
2>&1 || ret
=1
274 grep 'next resign' rndc.out
> /dev
/null
2>&1 || ret
=1
275 [ $ret -eq 0 ] ||
echo "I:failed"
276 status
=`expr $status + $ret`
278 echo "I:exit status: $status"