tests.sh revision 1.1.1.3.4.1
1#!/bin/sh 2# 3# Copyright (C) 2004, 2007, 2011, 2012 Internet Systems Consortium, Inc. ("ISC") 4# Copyright (C) 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 19 20 21# WARNING: The test labelled "testing request-ixfr option in view vs zone" 22# is fragile because it depends upon counting instances of records 23# in the log file - need a better approach <sdm> - until then, 24# if you add any tests above that point, you will break the test. 25 26SYSTEMTESTTOP=.. 27. $SYSTEMTESTTOP/conf.sh 28 29status=0 30 31DIGOPTS="+tcp +noadd +nosea +nostat +noquest +nocomm +nocmd" 32DIGCMD="$DIG $DIGOPTS @10.53.0.1 -p 5300" 33SENDCMD="$PERL ../send.pl 10.53.0.2 5301" 34RNDCCMD="$RNDC -s 10.53.0.1 -p 9953 -c ../common/rndc.conf" 35 36echo "I:testing initial AXFR" 37 38$SENDCMD <<EOF 39/SOA/ 40nil. 300 SOA ns.nil. root.nil. 1 300 300 604800 300 41/AXFR/ 42nil. 300 SOA ns.nil. root.nil. 1 300 300 604800 300 43/AXFR/ 44nil. 300 NS ns.nil. 45nil. 300 TXT "initial AXFR" 46a.nil. 60 A 10.0.0.61 47b.nil. 60 A 10.0.0.62 48/AXFR/ 49nil. 300 SOA ns.nil. root.nil. 1 300 300 604800 300 50EOF 51 52sleep 1 53 54# Initially, ns1 is not authoritative for anything (see setup.sh). 55# Now that ans is up and running with the right data, we make it 56# a slave for nil. 57 58cat <<EOF >>ns1/named.conf 59zone "nil" { 60 type slave; 61 file "myftp.db"; 62 masters { 10.53.0.2; }; 63}; 64EOF 65 66$RNDCCMD reload 67 68for i in 0 1 2 3 4 5 6 7 8 9 69do 70 $DIGCMD nil. SOA > dig.out 71 grep "SOA" dig.out > /dev/null && break 72 sleep 1 73done 74 75$DIGCMD nil. TXT | grep 'initial AXFR' >/dev/null || { 76 echo "I:failed" 77 status=1 78} 79 80echo "I:testing successful IXFR" 81 82# We change the IP address of a.nil., and the TXT record at the apex. 83# Then we do a SOA-only update. 84 85$SENDCMD <<EOF 86/SOA/ 87nil. 300 SOA ns.nil. root.nil. 3 300 300 604800 300 88/IXFR/ 89nil. 300 SOA ns.nil. root.nil. 3 300 300 604800 300 90nil. 300 SOA ns.nil. root.nil. 1 300 300 604800 300 91a.nil. 60 A 10.0.0.61 92nil. 300 TXT "initial AXFR" 93nil. 300 SOA ns.nil. root.nil. 2 300 300 604800 300 94nil. 300 TXT "successful IXFR" 95a.nil. 60 A 10.0.1.61 96nil. 300 SOA ns.nil. root.nil. 2 300 300 604800 300 97nil. 300 SOA ns.nil. root.nil. 3 300 300 604800 300 98nil. 300 SOA ns.nil. root.nil. 3 300 300 604800 300 99EOF 100 101sleep 1 102 103$RNDCCMD refresh nil 104 105sleep 2 106 107$DIGCMD nil. TXT | grep 'successful IXFR' >/dev/null || { 108 echo "I:failed" 109 status=1 110} 111 112echo "I:testing AXFR fallback after IXFR failure" 113 114# Provide a broken IXFR response and a working fallback AXFR response 115 116$SENDCMD <<EOF 117/SOA/ 118nil. 300 SOA ns.nil. root.nil. 4 300 300 604800 300 119/IXFR/ 120nil. 300 SOA ns.nil. root.nil. 4 300 300 604800 300 121nil. 300 SOA ns.nil. root.nil. 3 300 300 604800 300 122nil. 300 TXT "delete-nonexistent-txt-record" 123nil. 300 SOA ns.nil. root.nil. 4 300 300 604800 300 124nil. 300 TXT "this-txt-record-would-be-added" 125nil. 300 SOA ns.nil. root.nil. 4 300 300 604800 300 126/AXFR/ 127nil. 300 SOA ns.nil. root.nil. 3 300 300 604800 300 128/AXFR/ 129nil. 300 NS ns.nil. 130nil. 300 TXT "fallback AXFR" 131/AXFR/ 132nil. 300 SOA ns.nil. root.nil. 3 300 300 604800 300 133EOF 134 135sleep 1 136 137$RNDCCMD refresh nil 138 139sleep 2 140 141$DIGCMD nil. TXT | grep 'fallback AXFR' >/dev/null || { 142 echo "I:failed" 143 status=1 144} 145 146echo "I:testing ixfr-from-differences option" 147# ns3 is master; ns4 is slave 148$CHECKZONE test. ns3/mytest.db > /dev/null 2>&1 149if [ $? -ne 0 ] 150then 151 echo "I:named-checkzone returned failure on ns3/mytest.db" 152fi 153# modify the master 154#echo "I: digging against master: " 155#$DIG $DIGOPTS @10.53.0.3 -p 5300 a host1.test. 156#echo "I: digging against slave: " 157#$DIG $DIGOPTS @10.53.0.4 -p 5300 a host1.test. 158 159cp ns3/mytest1.db ns3/mytest.db 160$RNDC -s 10.53.0.3 -p 9953 -c ../common/rndc.conf reload 161 162for i in 0 1 2 3 4 5 6 7 8 9 163do 164 $DIG +tcp -p 5300 @10.53.0.4 SOA test > dig.out 165 grep -i "hostmaster\.test\..2" dig.out > /dev/null && break 166 sleep 1 167done 168 169# slave should have gotten notify and updated 170 171INCR=`grep "test/IN/primary" ns4/named.run|grep "got incremental"|wc -l` 172if [ $INCR -ne 1 ] 173then 174 echo "I:failed to get incremental response" 175 status=1 176fi 177 178echo "I:testing request-ixfr option in view vs zone" 179# There's a view with 2 zones. In the view, "request-ixfr yes" 180# but in the zone "sub.test", request-ixfr no" 181# we want to make sure that a change to sub.test results in AXFR, while 182# changes to test. result in IXFR 183 184echo "I: this result should be AXFR" 185cp ns3/subtest1.db ns3/subtest.db # change to sub.test zone, should be AXFR 186$RNDC -s 10.53.0.3 -p 9953 -c ../common/rndc.conf reload 187 188for i in 0 1 2 3 4 5 6 7 8 9 189do 190 $DIG +tcp -p 5300 @10.53.0.4 SOA sub.test > dig.out 191 grep -i "hostmaster\.test\..3" dig.out > /dev/null && break 192 sleep 1 193done 194 195echo "I: this result should be AXFR" 196NONINCR=`grep 'sub\.test/IN/primary' ns4/named.run|grep "got nonincremental" | wc -l` 197if [ $NONINCR -ne 2 ] 198then 199 echo "I:failed to get nonincremental response in 2nd AXFR test" 200 status=1 201else 202 echo "I: success: AXFR it was" 203fi 204 205echo "I: this result should be IXFR" 206cp ns3/mytest2.db ns3/mytest.db # change to test zone, should be IXFR 207$RNDC -s 10.53.0.3 -p 9953 -c ../common/rndc.conf reload 208 209for i in 0 1 2 3 4 5 6 7 8 9 210do 211 $DIG +tcp -p 5300 @10.53.0.4 SOA test > dig.out 212 grep -i "hostmaster\.test\..4" dig.out > /dev/null && break 213 sleep 1 214done 215 216INCR=`grep "test/IN/primary" ns4/named.run|grep "got incremental"|wc -l` 217if [ $INCR -ne 2 ] 218then 219 echo "I:failed to get incremental response in 2nd IXFR test" 220 status=1 221else 222 echo "I: success: IXFR it was" 223fi 224 225 226echo "I:exit status: $status" 227exit $status 228