tests.sh 12.1 KB
Newer Older
1
2
#!/bin/sh
#
3
# Copyright (C) 2011, 2012, 2014-2017  Internet Systems Consortium, Inc. ("ISC")
Mark Andrews's avatar
Mark Andrews committed
4
5
6
7
8
9
10
11
12
13
14
15
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
16

17
# $Id: tests.sh,v 1.4 2011/06/10 01:32:37 each Exp $
18
19
20
21
22
23
24
25
26

SYSTEMTESTTOP=..
. $SYSTEMTESTTOP/conf.sh

DIGOPTS="+tcp +noadd +nosea +nostat +noquest +nocomm +nocmd"
DIGCMD="$DIG $DIGOPTS @10.53.0.2 -p 5300"
RNDCCMD="$RNDC -s 10.53.0.2 -p 9953 -c ../common/rndc.conf"

status=0
27
n=0
28

29
n=`expr $n + 1`
Mark Andrews's avatar
Mark Andrews committed
30
echo "I:preparing ($n)"
31
32
33
34
35
36
37
38
39
40
ret=0
$NSUPDATE -p 5300 -k ns2/session.key > /dev/null 2>&1 <<END || ret=1
server 10.53.0.2
zone nil.
update add text1.nil. 600 IN TXT "addition 1"
send
zone other.
update add text1.other. 600 IN TXT "addition 1"
send
END
41
42
43
44
45
46
[ -s ns2/nil.db.jnl ] || {
	echo "I: 'test -s ns2/nil.db.jnl' failed when it shouldn't have"; ret=1;
}
[ -s ns2/other.db.jnl ] || {
	echo "I: 'test -s ns2/other.db.jnl' failed when it shouldn't have"; ret=1;
}
47
48
49
50
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

echo "I:rndc freeze"
51
$RNDCCMD freeze | sed 's/^/I:ns2 /'
52

53
54
n=`expr $n + 1`
echo "I:checking zone was dumped ($n)"
55
ret=0
56
57
58
59
60
for i in 1 2 3 4 5 6 7 8 9 10
do
	grep "addition 1" ns2/nil.db > /dev/null && break
	sleep 1
done
61
62
63
64
grep "addition 1" ns2/nil.db > /dev/null 2>&1 || ret=1
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

65
66
n=`expr $n + 1`
echo "I:checking journal file is still present ($n)"
67
ret=0
68
69
70
[ -s ns2/nil.db.jnl ] || {
	echo "I: 'test -s ns2/nil.db.jnl' failed when it shouldn't have"; ret=1;
}
71
72
73
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

74
75
n=`expr $n + 1`
echo "I:checking zone not writable ($n)"
76
77
78
79
80
81
82
83
ret=0
$NSUPDATE -p 5300 -k ns2/session.key > /dev/null 2>&1 <<END && ret=1
server 10.53.0.2
zone nil.
update add text2.nil. 600 IN TXT "addition 2"
send
END

84
85
$DIGCMD text2.nil. TXT > dig.out.1.test$n
grep 'addition 2' dig.out.1.test$n >/dev/null && ret=1
86
87
88
89
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

echo "I:rndc thaw"
90
$RNDCCMD thaw | sed 's/^/I:ns2 /'
91

92
93
n=`expr $n + 1`
echo "I:checking zone now writable ($n)"
94
ret=0
95
$NSUPDATE -p 5300 -k ns2/session.key > nsupdate.out.1.test$n 2>&1 <<END || ret=1
96
97
98
99
100
server 10.53.0.2
zone nil.
update add text3.nil. 600 IN TXT "addition 3"
send
END
101
102
$DIGCMD text3.nil. TXT > dig.out.1.test$n
grep 'addition 3' dig.out.1.test$n >/dev/null || ret=1
103
104
105
106
107
108
109
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

echo "I:rndc sync"
ret=0
$RNDCCMD sync nil | sed 's/^/I:ns2 /'

110
111
n=`expr $n + 1`
echo "I:checking zone was dumped ($n)"
112
ret=0
113
114
115
116
117
for i in 1 2 3 4 5 6 7 8 9 10
do
	grep "addition 3" ns2/nil.db > /dev/null && break
	sleep 1
done
118
119
120
121
grep "addition 3" ns2/nil.db > /dev/null 2>&1 || ret=1
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

122
123
n=`expr $n + 1`
echo "I:checking journal file is still present ($n)"
124
ret=0
125
126
127
[ -s ns2/nil.db.jnl ] || {
	echo "I: 'test -s ns2/nil.db.jnl' failed when it shouldn't have"; ret=1;
}
128
129
130
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

131
132
n=`expr $n + 1`
echo "I:checking zone is still writable ($n)"
133
ret=0
134
$NSUPDATE -p 5300 -k ns2/session.key > nsupdate.out.1.test$n 2>&1 <<END || ret=1
135
136
137
138
139
140
server 10.53.0.2
zone nil.
update add text4.nil. 600 IN TXT "addition 4"
send
END

141
142
$DIGCMD text4.nil. TXT > dig.out.1.test$n
grep 'addition 4' dig.out.1.test$n > /dev/null || ret=1
143
144
145
146
147
148
149
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

echo "I:rndc sync -clean"
ret=0
$RNDCCMD sync -clean nil | sed 's/^/I:ns2 /'

150
151
n=`expr $n + 1`
echo "I:checking zone was dumped ($n)"
152
ret=0
153
154
155
156
157
for i in 1 2 3 4 5 6 7 8 9 10
do
	grep "addition 4" ns2/nil.db > /dev/null && break
	sleep 1
done
158
159
160
161
grep "addition 4" ns2/nil.db > /dev/null 2>&1 || ret=1
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

162
163
n=`expr $n + 1`
echo "I:checking journal file is deleted ($n)"
164
ret=0
165
166
167
[ -s ns2/nil.db.jnl ] && {
	echo "I: 'test -s ns2/nil.db.jnl' failed when it shouldn't have"; ret=1;
}
168
169
170
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

171
172
n=`expr $n + 1`
echo "I:checking zone is still writable ($n)"
173
174
175
176
177
178
179
180
ret=0
$NSUPDATE -p 5300 -k ns2/session.key > /dev/null 2>&1 <<END || ret=1
server 10.53.0.2
zone nil.
update add text5.nil. 600 IN TXT "addition 5"
send
END

181
182
$DIGCMD text4.nil. TXT > dig.out.1.test$n
grep 'addition 4' dig.out.1.test$n >/dev/null || ret=1
183
184
185
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

186
187
n=`expr $n + 1`
echo "I:checking other journal files not removed ($n)"
188
ret=0
189
190
191
[ -s ns2/other.db.jnl ] || {
	echo "I: 'test -s ns2/other.db.jnl' failed when it shouldn't have"; ret=1;
}
192
193
194
195
196
197
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

echo "I:cleaning all zones"
$RNDCCMD sync -clean | sed 's/^/I:ns2 /'

198
199
n=`expr $n + 1`
echo "I:checking all journals removed ($n)"
200
ret=0
201
202
203
204
205
206
[ -s ns2/nil.db.jnl ] && {
	echo "I: 'test -s ns2/nil.db.jnl' succeeded when it shouldn't have"; ret=1;
}
[ -s ns2/other.db.jnl ] && {
	echo "I: 'test -s ns2/other.db.jnl' succeeded when it shouldn't have"; ret=1;
}
207
208
209
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

210
211
n=`expr $n + 1`
echo "I:checking that freezing static zones is not allowed ($n)"
212
ret=0
213
214
$RNDCCMD freeze static > rndc.out.1.test$n 2>&1
grep 'not dynamic' rndc.out.1.test$n > /dev/null || ret=1
215
216
217
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

218
219
n=`expr $n + 1`
echo "I:checking that journal is removed when serial is changed before thaw ($n)"
220
221
ret=0
sleep 1
222
$NSUPDATE -p 5300 -k ns2/session.key > nsupdate.out.1.test$n 2>&1 <<END || ret=1
223
224
225
226
227
server 10.53.0.2
zone other.
update add text6.other. 600 IN TXT "addition 6"
send
END
228
229
230
[ -s ns2/other.db.jnl ] || {
	echo "I: 'test -s ns2/other.db.jnl' failed when it shouldn't have"; ret=1;
}
231
$RNDCCMD freeze other 2>&1 | sed 's/^/I:ns2 /'
232
233
234
235
236
for i in 1 2 3 4 5 6 7 8 9 10
do
	grep "addition 6" ns2/other.db > /dev/null && break
	sleep 1
done
237
238
239
240
241
242
243
serial=`awk '$3 == "serial" {print $1}' ns2/other.db`
newserial=`expr $serial + 1`
sed s/$serial/$newserial/ ns2/other.db > ns2/other.db.new
echo 'frozen TXT "frozen addition"' >> ns2/other.db.new
mv -f ns2/other.db.new ns2/other.db
$RNDCCMD thaw 2>&1 | sed 's/^/I:ns2 /'
sleep 1
244
245
246
247
[ -f ns2/other.db.jnl ] && {
	echo "I: 'test -f ns2/other.db.jnl' succeeded when it shouldn't have"; ret=1;
}
$NSUPDATE -p 5300 -k ns2/session.key > nsupdate.out.2.test$n 2>&1 <<END || ret=1
248
249
250
251
252
server 10.53.0.2
zone other.
update add text7.other. 600 IN TXT "addition 7"
send
END
253
254
255
256
257
258
$DIGCMD text6.other. TXT > dig.out.1.test$n
grep 'addition 6' dig.out.1.test$n >/dev/null || ret=1
$DIGCMD text7.other. TXT > dig.out.2.test$n
grep 'addition 7' dig.out.2.test$n >/dev/null || ret=1
$DIGCMD frozen.other. TXT > dig.out.3.test$n
grep 'frozen addition' dig.out.3.test$n >/dev/null || ret=1
259
260
261
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

262
263
n=`expr $n + 1`
echo "I:checking that journal is kept when ixfr-from-differences is in use ($n)"
264
ret=0
265
$NSUPDATE -p 5300 -k ns2/session.key > nsupdate.out.1.test$n 2>&1 <<END || ret=1
266
267
268
269
270
server 10.53.0.2
zone nil.
update add text6.nil. 600 IN TXT "addition 6"
send
END
271
272
273
[ -s ns2/nil.db.jnl ] || {
	echo "I: 'test -s ns2/nil.db.jnl' failed when it shouldn't have"; ret=1;
}
274
$RNDCCMD freeze nil 2>&1 | sed 's/^/I:ns2 /'
275
276
277
278
279
for i in 1 2 3 4 5 6 7 8 9 10
do
	grep "addition 6" ns2/nil.db > /dev/null && break
	sleep 1
done
280
281
282
283
284
285
286
serial=`awk '$3 == "serial" {print $1}' ns2/nil.db`
newserial=`expr $serial + 1`
sed s/$serial/$newserial/ ns2/nil.db > ns2/nil.db.new
echo 'frozen TXT "frozen addition"' >> ns2/nil.db.new
mv -f ns2/nil.db.new ns2/nil.db
$RNDCCMD thaw 2>&1 | sed 's/^/I:ns2 /'
sleep 1
287
288
289
290
[ -s ns2/nil.db.jnl ] || {
	echo "I: 'test -s ns2/nil.db.jnl' failed when it shouldn't have"; ret=1;
}
$NSUPDATE -p 5300 -k ns2/session.key > nsupdate.out.2.test$n 2>&1 <<END || ret=1
291
292
293
294
295
server 10.53.0.2
zone nil.
update add text7.nil. 600 IN TXT "addition 7"
send
END
296
297
298
299
300
301
$DIGCMD text6.nil. TXT > dig.out.1.test$n
grep 'addition 6' dig.out.1.test$n > /dev/null || ret=1
$DIGCMD text7.nil. TXT > dig.out.2.test$n
grep 'addition 7' dig.out.2.test$n > /dev/null || ret=1
$DIGCMD frozen.nil. TXT > dig.out.3.test$n
grep 'frozen addition' dig.out.3.test$n >/dev/null || ret=1
302
303
304
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

305
n=`expr $n + 1`
Mark Andrews's avatar
cleanup    
Mark Andrews committed
306
echo "I:test using second key ($n)"
307
ret=0
Evan Hunt's avatar
Evan Hunt committed
308
$RNDC -s 10.53.0.2 -p 9953 -c ns2/secondkey.conf status > /dev/null || ret=1
309
310
311
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

312
313
n=`expr $n + 1`
echo "I:test 'rndc dumpdb' on a empty cache ($n)"
314
315
ret=0
$RNDC -s 10.53.0.3 -p 9953 -c ../common/rndc.conf dumpdb > /dev/null || ret=1
Mark Andrews's avatar
cleanup    
Mark Andrews committed
316
for i in 1 2 3 4 5 6 7 8 9
317
318
319
320
321
322
323
324
325
326
do
	tmp=0
	grep "Dump complete" ns3/named_dump.db > /dev/null || tmp=1
	[ $tmp -eq 0 ] && break
	sleep 1
done
[ $tmp -eq 1 ] && ret=1
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

327
328
n=`expr $n + 1`
echo "I:testing rndc with null command ($n)"
Evan Hunt's avatar
Evan Hunt committed
329
330
331
332
333
ret=0
$RNDC -s 10.53.0.3 -p 9953 -c ../common/rndc.conf null || ret=1
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

334
335
n=`expr $n + 1`
echo "I:testing rndc with unknown control channel command ($n)"
Evan Hunt's avatar
Evan Hunt committed
336
337
338
339
340
341
ret=0
$RNDC -s 10.53.0.3 -p 9953 -c ../common/rndc.conf obviouslynotacommand >/dev/null 2>&1 && ret=1
# rndc: 'obviouslynotacommand' failed: unknown command
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

342
343
n=`expr $n + 1`
echo "I:testing rndc with querylog command ($n)"
Evan Hunt's avatar
Evan Hunt committed
344
345
346
ret=0
# first enable it with querylog on option
$RNDC -s 10.53.0.3 -p 9953 -c ../common/rndc.conf querylog on >/dev/null 2>&1 || ret=1
Mark Andrews's avatar
Mark Andrews committed
347
grep "query logging is now on" ns3/named.run > /dev/null || ret=1
Evan Hunt's avatar
Evan Hunt committed
348
# query for builtin and check if query was logged
349
$DIG @10.53.0.3 -p 5300 -c ch -t txt foo12345.bind > /dev/null || ret=1
Evan Hunt's avatar
Evan Hunt committed
350
351
# toggle query logging and check again
$RNDC -s 10.53.0.3 -p 9953 -c ../common/rndc.conf querylog >/dev/null 2>&1 || ret=1
Mark Andrews's avatar
Mark Andrews committed
352
grep "query logging is now off" ns3/named.run > /dev/null || ret=1
Evan Hunt's avatar
Evan Hunt committed
353
# query for another builtin zone and check if query was logged
354
$DIG @10.53.0.3 -p 5300 -c ch -t txt foo9876.bind > /dev/null || ret=1
Evan Hunt's avatar
Evan Hunt committed
355
356
357
358
grep "query: foo9876.bind CH TXT" ns3/named.run > /dev/null && ret=1
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

359
360
n=`expr $n + 1`
echo "I:testing rndc with a token containing a space ($n)"
361
ret=0
362
363
$RNDC -s 10.53.0.4 -p 9953 -c ../common/rndc.conf flush '"view with a space"' 2>&1 > rndc.out.1.test$n || ret=1
grep "not found" rndc.out.1.test$n > /dev/null && ret=1
364
365
366
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

367
368
n=`expr $n + 1`
echo "I:test 'rndc reconfig' with a broken config ($n)"
369
370
371
372
373
ret=0
$RNDC -s 10.53.0.3 -p 9953 -c ../common/rndc.conf reconfig > /dev/null || ret=1
sleep 1
mv ns3/named.conf ns3/named.conf.save
echo "error error error" >> ns3/named.conf
374
375
$RNDC -s 10.53.0.3 -p 9953 -c ../common/rndc.conf reconfig > rndc.out.1.test$n 2>&1 && ret=1
grep "rndc: 'reconfig' failed: unexpected token" rndc.out.1.test$n > /dev/null || ret=1
376
377
378
379
380
381
382
mv ns3/named.conf.save ns3/named.conf
sleep 1
$RNDC -s 10.53.0.3 -p 9953 -c ../common/rndc.conf reconfig > /dev/null || ret=1
sleep 1
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

383
384
385
386
387
388
389
390
n=`expr $n + 1`
echo "I:verify that the full command is logged ($n)"
ret=0
$RNDCCMD null with extra arguments > /dev/null 2>&1
grep "received control channel command 'null with extra arguments'" ns2/named.run > /dev/null || ret=1
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

391
392
393
n=`expr $n + 1`
echo "I:check 'rndc \"\"' is handled ($n)"
ret=0
394
395
$RNDCCMD "" > rndc.out.1.test$n 2>&1 && ret=1
grep "rndc: '' failed: failure" rndc.out.1.test$n > /dev/null
396
397
398
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

399
echo "I:exit status: $status"
400
[ $status -eq 0 ] || exit 1