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