No empty .Rs/.Re
[netbsd-mini2440.git] / external / bsd / bind / dist / bin / tests / system / nsupdate / tests.sh
blobe6d7392b4ca92c55e403b89cf6fec7c2c1e69f36
1 #!/bin/sh
3 # Copyright (C) 2004, 2007, 2009 Internet Systems Consortium, Inc. ("ISC")
4 # Copyright (C) 2000, 2001 Internet Software Consortium.
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.
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.
18 # Id: tests.sh,v 1.28 2009/09/04 17:14:58 each Exp
20 SYSTEMTESTTOP=..
21 . $SYSTEMTESTTOP/conf.sh
23 status=0
25 # wait for zone transfer to complete
26 tries=0
27 while true; do
28 if [ $tries -eq 10 ]
29 then
30 exit 1
33 if grep "example.nil/IN.*Transfer completed" ns2/named.run > /dev/null
34 then
35 break
36 else
37 echo "I:zones are not fully loaded, waiting..."
38 tries=`expr $tries + 1`
39 sleep 1
41 done
43 echo "I:fetching first copy of zone before update"
44 $DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd example.nil.\
45 @10.53.0.1 axfr -p 5300 > dig.out.ns1 || status=1
47 echo "I:fetching second copy of zone before update"
48 $DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd example.nil.\
49 @10.53.0.2 axfr -p 5300 > dig.out.ns2 || status=1
51 echo "I:comparing pre-update copies to known good data"
52 $PERL ../digcomp.pl knowngood.ns1.before dig.out.ns1 || status=1
53 $PERL ../digcomp.pl knowngood.ns1.before dig.out.ns2 || status=1
55 echo "I:updating zone"
56 # nsupdate will print a ">" prompt to stdout as it gets each input line.
57 $NSUPDATE -k ns1/ddns.key <<END > /dev/null || status=1
58 server 10.53.0.1 5300
59 update add updated.example.nil. 600 A 10.10.10.1
60 update add updated.example.nil. 600 TXT Foo
61 update delete t.example.nil.
63 END
64 echo "I:sleeping 15 seconds for server to incorporate changes"
65 sleep 15
67 echo "I:fetching first copy of zone after update"
68 $DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd example.nil.\
69 @10.53.0.1 axfr -p 5300 > dig.out.ns1 || status=1
71 echo "I:fetching second copy of zone after update"
72 $DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd example.nil.\
73 @10.53.0.2 axfr -p 5300 > dig.out.ns2 || status=1
75 echo "I:comparing post-update copies to known good data"
76 $PERL ../digcomp.pl knowngood.ns1.after dig.out.ns1 || status=1
77 $PERL ../digcomp.pl knowngood.ns1.after dig.out.ns2 || status=1
79 echo "I:testing local update policy"
80 pre=`$DIG +short new.other.nil. @10.53.0.1 a -p 5300` || status=1
81 [ -z "$pre" ] || status=1
83 echo "I:updating zone"
84 # nsupdate will print a ">" prompt to stdout as it gets each input line.
85 $NSUPDATE -l -p 5300 -k ns1/session.key > /dev/null <<END || status=1
86 zone other.nil.
87 update add new.other.nil. 600 IN A 10.10.10.1
88 send
89 END
91 echo "I:sleeping 5 seconds for server to incorporate changes"
92 sleep 5
94 echo "I:checking result of update"
95 post=`$DIG +short new.other.nil. @10.53.0.1 a -p 5300` || status=1
96 [ "$post" = "10.10.10.1" ] || status=1
98 echo "I:comparing post-update copy to known good data"
99 $PERL ../digcomp.pl knowngood.ns1.after dig.out.ns1 || status=1
101 if $PERL -e 'use Net::DNS;' 2>/dev/null
102 then
103 echo "I:running update.pl test"
104 $PERL update_test.pl -s 10.53.0.1 -p 5300 update.nil. || status=1
105 else
106 echo "I:The second part of this test requires the Net::DNS library." >&2
109 echo "I:fetching first copy of test zone"
110 $DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd example.nil.\
111 @10.53.0.1 axfr -p 5300 > dig.out.ns1 || status=1
113 echo "I:fetching second copy of test zone"
114 $DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd example.nil.\
115 @10.53.0.2 axfr -p 5300 > dig.out.ns2 || status=1
117 echo "I:comparing zones"
118 $PERL ../digcomp.pl dig.out.ns1 dig.out.ns2 || status=1
120 echo "I:SIGKILL and restart server ns1"
121 cd ns1
122 kill -KILL `cat named.pid`
123 rm named.pid
124 cd ..
125 sleep 10
127 $PERL $SYSTEMTESTTOP/start.pl --noclean . ns1
128 then
129 echo "I:restarted server ns1"
130 else
131 echo "I:could not restart server ns1"
132 exit 1
134 sleep 10
136 echo "I:fetching ns1 after hard restart"
137 $DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd example.nil.\
138 @10.53.0.1 axfr -p 5300 > dig.out.ns1.after || status=1
140 echo "I:comparing zones"
141 $PERL ../digcomp.pl dig.out.ns1 dig.out.ns1.after || status=1
143 echo "I:begin RT #482 regression test"
145 echo "I:update master"
146 $NSUPDATE -k ns1/ddns.key <<END > /dev/null || status=1
147 server 10.53.0.1 5300
148 update add updated2.example.nil. 600 A 10.10.10.2
149 update add updated2.example.nil. 600 TXT Bar
150 update delete c.example.nil.
151 send
154 sleep 5
156 echo "I:SIGHUP slave"
157 kill -HUP `cat ns2/named.pid`
159 sleep 5
161 echo "I:update master again"
162 $NSUPDATE -k ns1/ddns.key <<END > /dev/null || status=1
163 server 10.53.0.1 5300
164 update add updated3.example.nil. 600 A 10.10.10.3
165 update add updated3.example.nil. 600 TXT Zap
166 update delete d.example.nil.
167 send
170 sleep 5
172 echo "I:SIGHUP slave again"
173 kill -HUP `cat ns2/named.pid`
175 sleep 5
177 if grep "out of sync" ns2/named.run
178 then
179 status=1
182 echo "I:end RT #482 regression test"
184 echo "I:testing that rndc stop updates the master file"
185 $NSUPDATE -k ns1/ddns.key <<END > /dev/null || status=1
186 server 10.53.0.1 5300
187 update add updated4.example.nil. 600 A 10.10.10.3
188 send
190 $PERL $SYSTEMTESTTOP/stop.pl --use-rndc . ns1
191 # Removing the journal file and restarting the server means
192 # that the data served by the new server process are exactly
193 # those dumped to the master file by "rndc stop".
194 rm -f ns1/*jnl
195 $PERL $SYSTEMTESTTOP/start.pl --noclean . ns1
196 $DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd updated4.example.nil.\
197 @10.53.0.1 a -p 5300 > dig.out.ns1 || status=1
198 $PERL ../digcomp.pl knowngood.ns1.afterstop dig.out.ns1 || status=1
200 echo "I:exit status: $status"
201 exit $status