tests.sh revision bf8267aa453e5d2a735ed732a043b77a0b355b20
d29b2c4438482eb00488be49a1f5d6835f455546ab#!/bin/sh
d29b2c4438482eb00488be49a1f5d6835f455546ab#
d29b2c4438482eb00488be49a1f5d6835f455546ab# Copyright (C) 2005, 2007, 2011, 2012 Internet Systems Consortium, Inc. ("ISC")
d29b2c4438482eb00488be49a1f5d6835f455546ab#
d29b2c4438482eb00488be49a1f5d6835f455546ab# Permission to use, copy, modify, and/or distribute this software for any
d29b2c4438482eb00488be49a1f5d6835f455546ab# purpose with or without fee is hereby granted, provided that the above
d29b2c4438482eb00488be49a1f5d6835f455546ab# copyright notice and this permission notice appear in all copies.
d29b2c4438482eb00488be49a1f5d6835f455546ab#
d29b2c4438482eb00488be49a1f5d6835f455546ab# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
d29b2c4438482eb00488be49a1f5d6835f455546ab# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
d29b2c4438482eb00488be49a1f5d6835f455546ab# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
d29b2c4438482eb00488be49a1f5d6835f455546ab# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
d29b2c4438482eb00488be49a1f5d6835f455546ab# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
d29b2c4438482eb00488be49a1f5d6835f455546ab# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
d29b2c4438482eb00488be49a1f5d6835f455546ab# PERFORMANCE OF THIS SOFTWARE.
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab# $Id$
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546abSYSTEMTESTTOP=..
d29b2c4438482eb00488be49a1f5d6835f455546ab. $SYSTEMTESTTOP/conf.sh
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546abisfast () {
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami perl -e 'binmode STDIN;
d29b2c4438482eb00488be49a1f5d6835f455546ab read(STDIN, $input, 8);
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami ($style, $version) = unpack("NN", $input);
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami exit 1 if ($style != 3 || $version > 1);' < $1
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami return $?
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami}
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahramiisraw () {
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami perl -e 'binmode STDIN;
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami read(STDIN, $input, 8);
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami ($style, $version) = unpack("NN", $input);
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami exit 1 if ($style != 2 || $version > 1);' < $1
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami return $?
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami}
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami
d29b2c4438482eb00488be49a1f5d6835f455546abrawversion () {
d29b2c4438482eb00488be49a1f5d6835f455546ab perl -e 'binmode STDIN;
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami read(STDIN, $input, 8);
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami if (length($input) < 8) { print "not raw\n"; exit 0; };
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami ($style, $version) = unpack("NN", $input);
d29b2c4438482eb00488be49a1f5d6835f455546ab print ($style == 2 || $style == 3 ? "$version\n" :
d29b2c4438482eb00488be49a1f5d6835f455546ab "not raw or fast\n");' < $1
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546absourceserial () {
d29b2c4438482eb00488be49a1f5d6835f455546ab perl -e 'binmode STDIN;
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami read(STDIN, $input, 20);
d29b2c4438482eb00488be49a1f5d6835f455546ab if (length($input) < 20) { print "UNSET\n"; exit; };
d29b2c4438482eb00488be49a1f5d6835f455546ab ($format, $version, $dumptime, $flags, $sourceserial) =
d29b2c4438482eb00488be49a1f5d6835f455546ab unpack("NNNNN", $input);
d29b2c4438482eb00488be49a1f5d6835f455546ab if ($format != 2 || $version < 1) { print "UNSET\n"; exit; };
d29b2c4438482eb00488be49a1f5d6835f455546ab if ($flags & 02) {
55ef6355bc6375ad080b10b10660e3528e2b7e6aab print $sourceserial . "\n";
d29b2c4438482eb00488be49a1f5d6835f455546ab } else {
d29b2c4438482eb00488be49a1f5d6835f455546ab print "UNSET\n";
55ef6355bc6375ad080b10b10660e3528e2b7e6aab }' < $1
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546abrestart () {
d29b2c4438482eb00488be49a1f5d6835f455546ab sleep 1
d29b2c4438482eb00488be49a1f5d6835f455546ab (cd ..; $PERL start.pl --noclean --restart masterformat ns3)
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546abDIGOPTS="+tcp +noauth +noadd +nosea +nostat +noquest +nocomm +nocmd"
cce0e03bb2d07f0fe27cabb93acae9c23655859fab
cce0e03bb2d07f0fe27cabb93acae9c23655859fabstatus=0
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546abecho "I:checking that master files in raw format loaded"
d29b2c4438482eb00488be49a1f5d6835f455546abret=0
d29b2c4438482eb00488be49a1f5d6835f455546abset -- 1 2 3
d29b2c4438482eb00488be49a1f5d6835f455546abfor zone in example example-explicit example-compat; do
d29b2c4438482eb00488be49a1f5d6835f455546ab for server in $*; do
d29b2c4438482eb00488be49a1f5d6835f455546ab for name in ns mx a aaaa cname dname txt rrsig nsec dnskey ds; do
d29b2c4438482eb00488be49a1f5d6835f455546ab $DIG $DIGOPTS $name.$zone. $name @10.53.0.$server -p 5300
d29b2c4438482eb00488be49a1f5d6835f455546ab echo
d29b2c4438482eb00488be49a1f5d6835f455546ab done > dig.out.$zone.$server
d29b2c4438482eb00488be49a1f5d6835f455546ab done
d29b2c4438482eb00488be49a1f5d6835f455546ab $PERL ../digcomp.pl dig.out.$zone.1 dig.out.$zone.2 || ret=1
d29b2c4438482eb00488be49a1f5d6835f455546ab if [ $zone = "example" ]; then
d29b2c4438482eb00488be49a1f5d6835f455546ab set -- 1 2
d29b2c4438482eb00488be49a1f5d6835f455546ab $PERL ../digcomp.pl dig.out.$zone.1 dig.out.$zone.3 || ret=1
d29b2c4438482eb00488be49a1f5d6835f455546ab fi
d29b2c4438482eb00488be49a1f5d6835f455546abdone
d29b2c4438482eb00488be49a1f5d6835f455546ab[ $ret -eq 0 ] || echo "I:failed"
d29b2c4438482eb00488be49a1f5d6835f455546abstatus=`expr $status + $ret`
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546abecho "I:checking raw format versions"
d29b2c4438482eb00488be49a1f5d6835f455546abret=0
d29b2c4438482eb00488be49a1f5d6835f455546abisraw ns1/example.db.raw || ret=1
d29b2c4438482eb00488be49a1f5d6835f455546abisraw ns1/example.db.raw1 || ret=1
d29b2c4438482eb00488be49a1f5d6835f455546abisraw ns1/example.db.compat || ret=1
d29b2c4438482eb00488be49a1f5d6835f455546abisfast ns1/example.db.fast || ret=1
d29b2c4438482eb00488be49a1f5d6835f455546ab[ "`rawversion ns1/example.db.raw`" = 1 ] || ret=1
d29b2c4438482eb00488be49a1f5d6835f455546ab[ "`rawversion ns1/example.db.raw1`" = 1 ] || ret=1
d29b2c4438482eb00488be49a1f5d6835f455546ab[ "`rawversion ns1/example.db.compat`" = 0 ] || ret=1
d29b2c4438482eb00488be49a1f5d6835f455546ab[ "`rawversion ns1/example.db.fast`" = 1 ] || ret=1
d29b2c4438482eb00488be49a1f5d6835f455546ab[ $ret -eq 0 ] || echo "I:failed"
d29b2c4438482eb00488be49a1f5d6835f455546abstatus=`expr $status + $ret`
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546abecho "I:checking source serial numbers"
d29b2c4438482eb00488be49a1f5d6835f455546abret=0
d29b2c4438482eb00488be49a1f5d6835f455546ab[ "`sourceserial ns1/example.db.raw`" = "UNSET" ] || ret=1
d29b2c4438482eb00488be49a1f5d6835f455546ab[ "`sourceserial ns1/example.db.serial.raw`" = "3333" ] || ret=1
d29b2c4438482eb00488be49a1f5d6835f455546ab[ $ret -eq 0 ] || echo "I:failed"
d29b2c4438482eb00488be49a1f5d6835f455546abstatus=`expr $status + $ret`
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546abecho "I:waiting for transfers to complete"
d29b2c4438482eb00488be49a1f5d6835f455546abfor i in 0 1 2 3 4 5 6 7 8 9
d29b2c4438482eb00488be49a1f5d6835f455546abdo
d29b2c4438482eb00488be49a1f5d6835f455546ab test -f ns2/transfer.db.raw -a -f ns2/transfer.db.txt && break
d29b2c4438482eb00488be49a1f5d6835f455546ab sleep 1
d29b2c4438482eb00488be49a1f5d6835f455546abdone
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546abecho "I:checking that slave was saved in raw format by default"
d29b2c4438482eb00488be49a1f5d6835f455546abret=0
d29b2c4438482eb00488be49a1f5d6835f455546abisraw ns2/transfer.db.raw || ret=1
d29b2c4438482eb00488be49a1f5d6835f455546ab[ $ret -eq 0 ] || echo "I:failed"
d29b2c4438482eb00488be49a1f5d6835f455546abstatus=`expr $status + $ret`
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546abecho "I:checking that slave was saved in text format when configured"
d29b2c4438482eb00488be49a1f5d6835f455546abret=0
d29b2c4438482eb00488be49a1f5d6835f455546abisraw ns2/transfer.db.txt && ret=1
d29b2c4438482eb00488be49a1f5d6835f455546ab[ $ret -eq 0 ] || echo "I:failed"
d29b2c4438482eb00488be49a1f5d6835f455546abstatus=`expr $status + $ret`
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546abecho "I:checking that slave formerly in text format is now raw"
d29b2c4438482eb00488be49a1f5d6835f455546abfor i in 0 1 2 3 4 5 6 7 8 9
d29b2c4438482eb00488be49a1f5d6835f455546abdo
d29b2c4438482eb00488be49a1f5d6835f455546ab ret=0
d29b2c4438482eb00488be49a1f5d6835f455546ab israw ns2/formerly-text.db > /dev/null 2>&1 || ret=1
d29b2c4438482eb00488be49a1f5d6835f455546ab [ "`rawversion ns2/formerly-text.db`" = 1 ] || ret=1
d29b2c4438482eb00488be49a1f5d6835f455546ab [ $ret -eq 0 ] && break
d29b2c4438482eb00488be49a1f5d6835f455546ab sleep 1
d29b2c4438482eb00488be49a1f5d6835f455546abdone
d29b2c4438482eb00488be49a1f5d6835f455546ab[ $ret -eq 0 ] || echo "I:failed"
d29b2c4438482eb00488be49a1f5d6835f455546abstatus=`expr $status + $ret`
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546abecho "I:checking that large rdatasets loaded"
d29b2c4438482eb00488be49a1f5d6835f455546abfor i in 0 1 2 3 4 5 6 7 8 9
d29b2c4438482eb00488be49a1f5d6835f455546abdo
d29b2c4438482eb00488be49a1f5d6835f455546abret=0
d29b2c4438482eb00488be49a1f5d6835f455546abfor a in a b c
d29b2c4438482eb00488be49a1f5d6835f455546abdo
d29b2c4438482eb00488be49a1f5d6835f455546ab $DIG +tcp txt ${a}.large @10.53.0.2 -p 5300 > dig.out
d29b2c4438482eb00488be49a1f5d6835f455546ab grep "status: NOERROR" dig.out > /dev/null || ret=1
d29b2c4438482eb00488be49a1f5d6835f455546abdone
d29b2c4438482eb00488be49a1f5d6835f455546ab[ $ret -eq 0 ] && break
d29b2c4438482eb00488be49a1f5d6835f455546absleep 1
d29b2c4438482eb00488be49a1f5d6835f455546abdone
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546abecho "I:checking format transitions: text->raw->fast->text"
d29b2c4438482eb00488be49a1f5d6835f455546abret=0
d29b2c4438482eb00488be49a1f5d6835f455546ab./named-compilezone -D -f text -F text -o baseline.txt example.nil ns1/example.db > /dev/null
d29b2c4438482eb00488be49a1f5d6835f455546ab./named-compilezone -D -f text -F raw -o raw.1 example.nil baseline.txt > /dev/null
d29b2c4438482eb00488be49a1f5d6835f455546ab./named-compilezone -D -f raw -F fast -o fast.1 example.nil raw.1 > /dev/null
d29b2c4438482eb00488be49a1f5d6835f455546ab./named-compilezone -D -f fast -F text -o text.1 example.nil fast.1 > /dev/null
cce0e03bb2d07f0fe27cabb93acae9c23655859fabcmp -s baseline.txt text.1 || ret=0
cce0e03bb2d07f0fe27cabb93acae9c23655859fab[ $ret -eq 0 ] || echo "I:failed"
cce0e03bb2d07f0fe27cabb93acae9c23655859fabstatus=`expr $status + $ret`
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546abecho "I:checking format transitions: text->fast->raw->text"
d29b2c4438482eb00488be49a1f5d6835f455546abret=0
d29b2c4438482eb00488be49a1f5d6835f455546ab./named-compilezone -D -f text -F fast -o fast.2 example.nil baseline.txt > /dev/null
d29b2c4438482eb00488be49a1f5d6835f455546ab./named-compilezone -D -f fast -F raw -o raw.2 example.nil fast.2 > /dev/null
d29b2c4438482eb00488be49a1f5d6835f455546ab./named-compilezone -D -f raw -F text -o text.2 example.nil raw.2 > /dev/null
d29b2c4438482eb00488be49a1f5d6835f455546abcmp -s baseline.txt text.2 || ret=0
d29b2c4438482eb00488be49a1f5d6835f455546ab[ $ret -eq 0 ] || echo "I:failed"
d29b2c4438482eb00488be49a1f5d6835f455546abstatus=`expr $status + $ret`
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546abecho "I:checking fast format loading with journal file rollforward"
d29b2c4438482eb00488be49a1f5d6835f455546abret=0
d29b2c4438482eb00488be49a1f5d6835f455546ab$NSUPDATE <<END > /dev/null || status=1
d29b2c4438482eb00488be49a1f5d6835f455546abserver 10.53.0.3 5300
d29b2c4438482eb00488be49a1f5d6835f455546abttl 600
d29b2c4438482eb00488be49a1f5d6835f455546abupdate add newtext.dynamic IN TXT "added text"
d29b2c4438482eb00488be49a1f5d6835f455546abupdate delete aaaa.dynamic
d29b2c4438482eb00488be49a1f5d6835f455546absend
d29b2c4438482eb00488be49a1f5d6835f455546abEND
d29b2c4438482eb00488be49a1f5d6835f455546ab$DIG $DIGOPTS @10.53.0.3 -p 5300 newtext.dynamic txt > dig.out.dynamic.3.1
d29b2c4438482eb00488be49a1f5d6835f455546abgrep "added text" dig.out.dynamic.3.1 > /dev/null 2>&1 || ret=1
d29b2c4438482eb00488be49a1f5d6835f455546ab$DIG $DIGOPTS +comm @10.53.0.3 -p 5300 added.dynamic txt > dig.out.dynamic.3.2
d29b2c4438482eb00488be49a1f5d6835f455546abgrep "NXDOMAIN" dig.out.dynamic.3.2 > /dev/null 2>&1 || ret=1
d29b2c4438482eb00488be49a1f5d6835f455546ab# using "rndc halt" ensures that we don't dump the zone file
d29b2c4438482eb00488be49a1f5d6835f455546ab$RNDC -c ../common/rndc.conf -s 10.53.0.3 -p 9953 halt 2>&1 | sed 's/^/I:ns3 /'
d29b2c4438482eb00488be49a1f5d6835f455546abrestart
d29b2c4438482eb00488be49a1f5d6835f455546abfor i in 0 1 2 3 4 5 6 7 8 9; do
d29b2c4438482eb00488be49a1f5d6835f455546ab lret=0
d29b2c4438482eb00488be49a1f5d6835f455546ab $DIG $DIGOPTS @10.53.0.3 -p 5300 newtext.dynamic txt > dig.out.dynamic.3.3
d29b2c4438482eb00488be49a1f5d6835f455546ab grep "added text" dig.out.dynamic.3.3 > /dev/null 2>&1 || lret=1
d29b2c4438482eb00488be49a1f5d6835f455546ab [ $lret -eq 0 ] && break;
d29b2c4438482eb00488be49a1f5d6835f455546abdone
d29b2c4438482eb00488be49a1f5d6835f455546ab[ $lret -eq 1 ] && ret=1
d29b2c4438482eb00488be49a1f5d6835f455546ab$DIG $DIGOPTS +comm @10.53.0.3 -p 5300 added.dynamic txt > dig.out.dynamic.3.4
d29b2c4438482eb00488be49a1f5d6835f455546abgrep "NXDOMAIN" dig.out.dynamic.3.4 > /dev/null 2>&1 || ret=1
d29b2c4438482eb00488be49a1f5d6835f455546ab[ $ret -eq 0 ] || echo "I:failed"
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahramistatus=`expr $status + $ret`
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahrami
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahramiecho "I:checking fast format file dumps correctly"
d29b2c4438482eb00488be49a1f5d6835f455546abret=0
d29b2c4438482eb00488be49a1f5d6835f455546ab$NSUPDATE <<END > /dev/null || status=1
d29b2c4438482eb00488be49a1f5d6835f455546abserver 10.53.0.3 5300
d29b2c4438482eb00488be49a1f5d6835f455546abttl 600
d29b2c4438482eb00488be49a1f5d6835f455546abupdate add moretext.dynamic IN TXT "more text"
d29b2c4438482eb00488be49a1f5d6835f455546absend
END
$DIG $DIGOPTS @10.53.0.3 -p 5300 moretext.dynamic txt > dig.out.dynamic.3.5
grep "more text" dig.out.dynamic.3.5 > /dev/null 2>&1 || ret=1
# using "rndc stop" will cause the zone file to flush before shutdown
$RNDC -c ../common/rndc.conf -s 10.53.0.3 -p 9953 stop 2>&1 | sed 's/^/I:ns3 /'
rm ns3/*.jnl
restart
for i in 0 1 2 3 4 5 6 7 8 9; do
lret=0
$DIG $DIGOPTS +comm @10.53.0.3 -p 5300 moretext.dynamic txt > dig.out.dynamic.3.6
grep "more text" dig.out.dynamic.3.6 > /dev/null 2>&1 || lret=1
[ $lret -eq 0 ] && break;
done
[ $lret -eq 1 ] && ret=1
[ $ret -eq 0 ] || echo "I:failed"
status=`expr $status + $ret`
echo "I:exit status: $status"
exit $status