1#!/bin/sh 2# 3# Copyright (C) 2004, 2007, 2011-2015 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.36 2011/10/17 01:33:27 marka Exp 19 20SYSTEMTESTTOP=.. 21. $SYSTEMTESTTOP/conf.sh 22 23status=0 24n=0 25 26# 27# Wait up to 10 seconds for the servers to finish starting before testing. 28# 29for i in 1 2 3 4 5 6 7 8 9 10 30do 31 ret=0 32 $DIG +tcp example @10.53.0.2 soa -p 5300 > dig.out.ns2.test$n || ret=1 33 grep "status: NOERROR" dig.out.ns2.test$n > /dev/null || ret=1 34 grep "flags:.* aa[ ;]" dig.out.ns2.test$n > /dev/null || ret=1 35 $DIG +tcp example @10.53.0.3 soa -p 5300 > dig.out.ns3.test$n || ret=1 36 grep "status: NOERROR" dig.out.ns3.test$n > /dev/null || ret=1 37 grep "flags:.* aa[ ;]" dig.out.ns3.test$n > /dev/null || ret=1 38 [ $ret = 0 ] && break 39 sleep 1 40done 41 42n=`expr $n + 1` 43echo "I:checking initial status ($n)" 44ret=0 45$DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd a.example.\ 46 @10.53.0.2 a -p 5300 > dig.out.ns2.test$n || ret=1 47grep "10.0.0.1" dig.out.ns2.test$n > /dev/null || ret=1 48 49$DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd a.example.\ 50 @10.53.0.3 a -p 5300 > dig.out.ns3.test$n || ret=1 51grep "10.0.0.1" dig.out.ns3.test$n > /dev/null || ret=1 52 53$PERL ../digcomp.pl dig.out.ns2.test$n dig.out.ns3.test$n || ret=1 54 55[ $ret = 0 ] || echo "I:failed" 56status=`expr $ret + $status` 57 58echo "I:reloading with example2 using HUP and waiting 45 seconds" 59sleep 1 # make sure filesystem time stamp is newer for reload. 60rm -f ns2/example.db 61cp -f ns2/example2.db ns2/example.db 62kill -HUP `cat ns2/named.pid` 63sleep 45 64 65n=`expr $n + 1` 66echo "I:checking notify message was logged ($n)" 67ret=0 68grep 'notify from 10.53.0.2#[0-9][0-9]*: serial 2$' ns3/named.run > /dev/null || ret=1 69[ $ret = 0 ] || echo "I:failed" 70status=`expr $ret + $status` 71 72n=`expr $n + 1` 73echo "I:checking example2 loaded ($n)" 74ret=0 75$DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd a.example.\ 76 @10.53.0.2 a -p 5300 > dig.out.ns2.test$n || ret=1 77grep "10.0.0.2" dig.out.ns2.test$n > /dev/null || ret=1 78 79[ $ret = 0 ] || echo "I:failed" 80status=`expr $ret + $status` 81 82n=`expr $n + 1` 83echo "I:checking example2 contents have been transferred after HUP reload ($n)" 84ret=0 85$DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd a.example.\ 86 @10.53.0.2 a -p 5300 > dig.out.ns2.test$n || ret=1 87grep "10.0.0.2" dig.out.ns2.test$n > /dev/null || ret=1 88 89$DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd a.example.\ 90 @10.53.0.3 a -p 5300 > dig.out.ns3.test$n || ret=1 91grep "10.0.0.2" dig.out.ns3.test$n > /dev/null || ret=1 92 93$PERL ../digcomp.pl dig.out.ns2.test$n dig.out.ns3.test$n || ret=1 94 95[ $ret = 0 ] || echo "I:failed" 96status=`expr $ret + $status` 97 98echo "I:stopping master and restarting with example4 then waiting 45 seconds" 99$PERL $SYSTEMTESTTOP/stop.pl . ns2 100 101rm -f ns2/example.db 102cp -f ns2/example4.db ns2/example.db 103 104$PERL $SYSTEMTESTTOP/start.pl --noclean --restart . ns2 105 106sleep 45 107 108n=`expr $n + 1` 109echo "I:checking notify message was logged ($n)" 110ret=0 111grep 'notify from 10.53.0.2#[0-9][0-9]*: serial 4$' ns3/named.run > /dev/null || ret=1 112[ $ret = 0 ] || echo "I:failed" 113status=`expr $ret + $status` 114 115n=`expr $n + 1` 116echo "I:checking example4 loaded ($n)" 117ret=0 118$DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd a.example.\ 119 @10.53.0.2 a -p 5300 > dig.out.ns2.test$n || ret=1 120grep "10.0.0.4" dig.out.ns2.test$n > /dev/null || ret=1 121 122[ $ret = 0 ] || echo "I:failed" 123status=`expr $ret + $status` 124 125n=`expr $n + 1` 126echo "I:checking example4 contents have been transfered after restart ($n)" 127ret=0 128$DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd a.example.\ 129 @10.53.0.2 a -p 5300 > dig.out.ns2.test$n || ret=1 130grep "10.0.0.4" dig.out.ns2.test$n > /dev/null || ret=1 131 132$DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd a.example.\ 133 @10.53.0.3 a -p 5300 > dig.out.ns3.test$n || ret=1 134grep "10.0.0.4" dig.out.ns3.test$n > /dev/null || ret=1 135 136$PERL ../digcomp.pl dig.out.ns2.test$n dig.out.ns3.test$n || ret=1 137 138[ $ret = 0 ] || echo "I:failed" 139status=`expr $ret + $status` 140 141n=`expr $n + 1` 142echo "I:checking notify to alternate port with master inheritance" 143$NSUPDATE << EOF 144server 10.53.0.2 5300 145zone x21 146update add added.x21 0 in txt "test string" 147send 148EOF 149for i in 1 2 3 4 5 6 7 8 9 150do 151 $DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd added.x21.\ 152 @10.53.0.4 txt -p 5301 > dig.out.ns4.test$n || ret=1 153 grep "test string" dig.out.ns4.test$n > /dev/null && break 154 sleep 1 155done 156grep "test string" dig.out.ns4.test$n > /dev/null || ret=1 157 158[ $ret = 0 ] || echo "I:failed" 159status=`expr $ret + $status` 160 161n=`expr $n + 1` 162echo "I:checking notify to multiple views using tsig" 163ret=0 164$NSUPDATE << EOF 165server 10.53.0.5 5300 166zone x21 167key a aaaaaaaaaaaaaaaaaaaa 168update add added.x21 0 in txt "test string" 169send 170EOF 171 172for i in 1 2 3 4 5 6 7 8 9 173do 174 $DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd added.x21.\ 175 -y b:bbbbbbbbbbbbbbbbbbbb @10.53.0.5 \ 176 txt -p 5300 > dig.out.b.ns5.test$n || ret=1 177 $DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd added.x21.\ 178 -y c:cccccccccccccccccccc @10.53.0.5 \ 179 txt -p 5300 > dig.out.c.ns5.test$n || ret=1 180 grep "test string" dig.out.b.ns5.test$n > /dev/null && 181 grep "test string" dig.out.c.ns5.test$n > /dev/null && 182 break 183 sleep 1 184done 185grep "test string" dig.out.b.ns5.test$n > /dev/null || ret=1 186grep "test string" dig.out.c.ns5.test$n > /dev/null || ret=1 187 188[ $ret = 0 ] || echo "I:failed" 189status=`expr $ret + $status` 190 191echo "I:exit status: $status" 192exit $status 193