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