1#!/bin/sh 2# 3# Copyright (C) 2004, 2007, 2011-2014 Internet Systems Consortium, Inc. ("ISC") 4# Copyright (C) 2000, 2001 Internet Software Consortium. 5# 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. 9# 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. 17 18# Id: tests.sh,v 1.13 2011/10/13 22:18:05 marka Exp 19 20# ns1 = stealth master 21# ns2 = slave with update forwarding disabled; not currently used 22# ns3 = slave with update forwarding enabled 23 24SYSTEMTESTTOP=.. 25. $SYSTEMTESTTOP/conf.sh 26 27status=0 28n=1 29 30sleep 5 31 32echo "I:waiting for servers to be ready for testing ($n)" 33for i in 1 2 3 4 5 6 7 8 9 10 34do 35 ret=0 36 $DIG +tcp example. @10.53.0.1 soa -p 5300 > dig.out.ns1 || ret=1 37 grep "status: NOERROR" dig.out.ns1 > /dev/null || ret=1 38 $DIG +tcp example. @10.53.0.2 soa -p 5300 > dig.out.ns2 || ret=1 39 grep "status: NOERROR" dig.out.ns2 > /dev/null || ret=1 40 $DIG +tcp example. @10.53.0.3 soa -p 5300 > dig.out.ns3 || ret=1 41 grep "status: NOERROR" dig.out.ns3 > /dev/null || ret=1 42 test $ret = 0 && break 43 sleep 1 44done 45if [ $ret != 0 ] ; then echo "I:failed"; status=`expr $status + $ret`; fi 46n=`expr $n + 1` 47 48echo "I:fetching master copy of zone before update ($n)" 49ret=0 50$DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd example.\ 51 @10.53.0.1 axfr -p 5300 > dig.out.ns1 || ret=1 52if [ $ret != 0 ] ; then echo "I:failed"; status=`expr $status + $ret`; fi 53n=`expr $n + 1` 54 55echo "I:fetching slave 1 copy of zone before update ($n)" 56$DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd example.\ 57 @10.53.0.2 axfr -p 5300 > dig.out.ns2 || ret=1 58if [ $ret != 0 ] ; then echo "I:failed"; status=`expr $status + $ret`; fi 59n=`expr $n + 1` 60 61echo "I:fetching slave 2 copy of zone before update ($n)" 62ret=0 63$DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd example.\ 64 @10.53.0.3 axfr -p 5300 > dig.out.ns3 || ret=1 65if [ $ret != 0 ] ; then echo "I:failed"; status=`expr $status + $ret`; fi 66n=`expr $n + 1` 67 68echo "I:comparing pre-update copies to known good data ($n)" 69ret=0 70$PERL ../digcomp.pl knowngood.before dig.out.ns1 || ret=1 71$PERL ../digcomp.pl knowngood.before dig.out.ns2 || ret=1 72$PERL ../digcomp.pl knowngood.before dig.out.ns3 || ret=1 73if [ $ret != 0 ] ; then echo "I:failed"; status=`expr $status + $ret`; fi 74 75echo "I:updating zone (signed) ($n)" 76ret=0 77$NSUPDATE -y update.example:c3Ryb25nIGVub3VnaCBmb3IgYSBtYW4gYnV0IG1hZGUgZm9yIGEgd29tYW4K -- - <<EOF || ret=1 78server 10.53.0.3 5300 79update add updated.example. 600 A 10.10.10.1 80update add updated.example. 600 TXT Foo 81send 82EOF 83if [ $ret != 0 ] ; then echo "I:failed"; status=`expr $status + $ret`; fi 84n=`expr $n + 1` 85 86echo "I:sleeping 15 seconds for server to incorporate changes" 87sleep 15 88 89echo "I:fetching master copy of zone after update ($n)" 90ret=0 91$DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd example.\ 92 @10.53.0.1 axfr -p 5300 > dig.out.ns1 || ret=1 93if [ $ret != 0 ] ; then echo "I:failed"; status=`expr $status + $ret`; fi 94n=`expr $n + 1` 95 96echo "I:fetching slave 1 copy of zone after update ($n)" 97ret=0 98$DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd example.\ 99 @10.53.0.2 axfr -p 5300 > dig.out.ns2 || ret=1 100if [ $ret != 0 ] ; then echo "I:failed"; status=`expr $status + $ret`; fi 101 102echo "I:fetching slave 2 copy of zone after update ($n)" 103ret=0 104$DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd example.\ 105 @10.53.0.3 axfr -p 5300 > dig.out.ns3 || ret=1 106if [ $ret != 0 ] ; then echo "I:failed"; status=`expr $status + $ret`; fi 107n=`expr $n + 1` 108 109echo "I:comparing post-update copies to known good data ($n)" 110ret=0 111$PERL ../digcomp.pl knowngood.after1 dig.out.ns1 || ret=1 112$PERL ../digcomp.pl knowngood.after1 dig.out.ns2 || ret=1 113$PERL ../digcomp.pl knowngood.after1 dig.out.ns3 || ret=1 114if [ $ret != 0 ] ; then echo "I:failed"; status=`expr $status + $ret`; fi 115 116echo "I:checking 'forwarding update for zone' is logged ($n)" 117ret=0 118grep "forwarding update for zone 'example/IN'" ns3/named.run > /dev/null || ret=1 119if [ $ret != 0 ] ; then echo "I:failed"; status=`expr $status + $ret`; fi 120n=`expr $n + 1` 121 122echo "I:updating zone (unsigned) ($n)" 123ret=0 124$NSUPDATE -- - <<EOF || ret=1 125server 10.53.0.3 5300 126update add unsigned.example. 600 A 10.10.10.1 127update add unsigned.example. 600 TXT Foo 128send 129EOF 130if [ $ret != 0 ] ; then echo "I:failed"; status=`expr $status + $ret`; fi 131n=`expr $n + 1` 132 133echo "I:sleeping 15 seconds for server to incorporate changes" 134sleep 15 135 136echo "I:fetching master copy of zone after update ($n)" 137ret=0 138$DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd example.\ 139 @10.53.0.1 axfr -p 5300 > dig.out.ns1 || ret=1 140if [ $ret != 0 ] ; then echo "I:failed"; status=`expr $status + $ret`; fi 141 142echo "I:fetching slave 1 copy of zone after update ($n)" 143ret=0 144$DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd example.\ 145 @10.53.0.2 axfr -p 5300 > dig.out.ns2 || ret=1 146if [ $ret != 0 ] ; then echo "I:failed"; status=`expr $status + $ret`; fi 147n=`expr $n + 1` 148 149echo "I:fetching slave 2 copy of zone after update ($n)" 150ret=0 151$DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd example.\ 152 @10.53.0.3 axfr -p 5300 > dig.out.ns3 || ret=1 153if [ $ret != 0 ] ; then echo "I:failed"; status=`expr $status + $ret`; fi 154 155echo "I:comparing post-update copies to known good data ($n)" 156ret=0 157$PERL ../digcomp.pl knowngood.after2 dig.out.ns1 || ret=1 158$PERL ../digcomp.pl knowngood.after2 dig.out.ns2 || ret=1 159$PERL ../digcomp.pl knowngood.after2 dig.out.ns3 || ret=1 160if [ $ret != 0 ] ; then echo "I:failed"; status=`expr $status + $ret`; fi 161n=`expr $n + 1` 162 163echo "I:checking update forwarding to dead master ($n)" 164count=0 165ret=0 166while [ $count -lt 5 -a $ret -eq 0 ] 167do 168( 169$NSUPDATE -- - <<EOF 170server 10.53.0.3 5300 171zone nomaster 172update add unsigned.nomaster. 600 A 10.10.10.1 173update add unsigned.nomaster. 600 TXT Foo 174send 175EOF 176) > /dev/null 2>&1 & 177 $DIG +notcp +noadd +noauth nomaster.\ 178 @10.53.0.3 soa -p 5300 > dig.out.ns3 || ret=1 179 grep "status: NOERROR" dig.out.ns3 > /dev/null || ret=1 180 count=`expr $count + 1` 181done 182if [ $ret != 0 ] ; then echo "I:failed"; status=`expr $status + $ret`; fi 183n=`expr $n + 1` 184 185if test -f keyname 186then 187 echo "I:checking update forwarding to with sig0 ($n)" 188 ret=0 189 keyname=`cat keyname` 190 $NSUPDATE -k $keyname.private -- - <<EOF 191 server 10.53.0.3 5300 192 zone example2 193 update add unsigned.example2. 600 A 10.10.10.1 194 update add unsigned.example2. 600 TXT Foo 195 send 196EOF 197 $DIG unsigned.example2 A @10.53.0.1 -p 5300 > dig.out.ns1.test$n 198 grep "status: NOERROR" dig.out.ns1.test$n > /dev/null || ret=1 199 if [ $ret != 0 ] ; then echo "I:failed"; fi 200 status=`expr $status + $ret` 201 n=`expr $n + 1` 202fi 203 204echo "I:exit status: $status" 205exit $status 206