tests.sh 28.6 KB
Newer Older
1 2
#!/bin/sh
#
3
# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
4 5 6 7
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 9 10
#
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
11 12 13

SYSTEMTESTTOP=..
. $SYSTEMTESTTOP/conf.sh
14

15
RNDCCMD="$RNDC -c $SYSTEMTESTTOP/common/rndc.conf -p ${CONTROLPORT} -s"
16

17 18 19
status=0
n=0

20
#echo_i "check ans.pl server ($n)"
21 22 23 24 25 26 27 28 29
#$DIG -p ${PORT} @10.53.0.2 example NS
#$DIG -p ${PORT} @10.53.0.2 example SOA
#$DIG -p ${PORT} @10.53.0.2 ns.example A
#$DIG -p ${PORT} @10.53.0.2 ns.example AAAA
#$DIG -p ${PORT} @10.53.0.2 txt enable
#$DIG -p ${PORT} @10.53.0.2 txt disable
#$DIG -p ${PORT} @10.53.0.2 ns.example AAAA
#$DIG -p ${PORT} @10.53.0.2 txt enable
#$DIG -p ${PORT} @10.53.0.2 ns.example AAAA
30
#$DIG -p ${PORT} @10.53.0.2 data.example TXT
31 32
#$DIG -p ${PORT} @10.53.0.2 nodata.example TXT
#$DIG -p ${PORT} @10.53.0.2 nxdomain.example TXT
33

34 35 36 37 38
#
# First test server with serve-stale options set.
#
echo_i "test server with serve-stale options set"

39 40 41 42 43 44 45 46 47
n=`expr $n + 1`
echo_i "prime cache longttl.example ($n)"
ret=0
$DIG -p ${PORT} @10.53.0.1 longttl.example TXT > dig.out.test$n
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`

48
n=`expr $n + 1`
49
echo_i "prime cache data.example ($n)"
50
ret=0
51
$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
52 53
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
54
if [ $ret != 0 ]; then echo_i "failed"; fi
55 56 57
status=`expr $status + $ret`

n=`expr $n + 1`
58
echo_i "prime cache nodata.example ($n)"
59
ret=0
60
$DIG -p ${PORT} @10.53.0.1 nodata.example TXT > dig.out.test$n
61 62
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
63
if [ $ret != 0 ]; then echo_i "failed"; fi
64 65 66
status=`expr $status + $ret`

n=`expr $n + 1`
67
echo_i "prime cache nxdomain.example ($n)"
68
ret=0
69
$DIG -p ${PORT} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
70 71
grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
72
if [ $ret != 0 ]; then echo_i "failed"; fi
73 74
status=`expr $status + $ret`

75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
n=`expr $n + 1`
echo_i "verify prime cache statistics ($n)"
ret=0
rm -f ns1/named.stats
$RNDCCMD 10.53.0.1 stats > /dev/null 2>&1
[ -f ns1/named.stats ] || ret=1
cp ns1/named.stats ns1/named.stats.$n
# Check first 10 lines of Cache DB statistics.  After prime queries, we expect
# two active TXT one nxrrset TXT, and one NXDOMAIN.
grep -A 10 "++ Cache DB RRsets ++" ns1/named.stats.$n > ns1/named.stats.$n.cachedb || ret=1
grep "2 TXT" ns1/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 !TXT" ns1/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 NXDOMAIN" ns1/named.stats.$n.cachedb > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`

91
n=`expr $n + 1`
92
echo_i "disable responses from authoritative server ($n)"
93
ret=0
94
$DIG -p ${PORT} @10.53.0.2 txt disable  > dig.out.test$n
95 96
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
grep "TXT.\"0\"" dig.out.test$n > /dev/null || ret=1
97
if [ $ret != 0 ]; then echo_i "failed"; fi
98 99 100 101 102
status=`expr $status + $ret`

sleep 1

n=`expr $n + 1`
103
echo_i "check 'rndc serve-stale status' ($n)"
104 105
ret=0
$RNDCCMD 10.53.0.1 serve-stale status > rndc.out.test$n 2>&1 || ret=1
106
grep '_default: on (stale-answer-ttl=2 max-stale-ttl=3600)' rndc.out.test$n > /dev/null || ret=1
107
if [ $ret != 0 ]; then echo_i "failed"; fi
108 109 110
status=`expr $status + $ret`

n=`expr $n + 1`
111
echo_i "check stale data.example ($n)"
112
ret=0
113
$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
114 115
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
116 117 118 119
grep "data\.example\..*2.*IN.*TXT.*A text record with a 1 second ttl" dig.out.test$n > /dev/null || ret=1
# Run rndc dumpdb, test whether the stale data has correct comment printed.
# The max-stale-ttl is 3600 seconds, so the comment should say the data is
# stale for somewhere between 3500-3599 seconds.
120 121
rndc_dumpdb ns1 || ret=1
awk '/; stale/ { x=$0; getline; print x, $0}' ns1/named_dump.db.test$n |
122 123
    grep "; stale (will be retained for 35.. more seconds) data\.example.*A text record with a 1 second ttl" > /dev/null 2>&1 || ret=1
# Also make sure the not expired data does not have a stale comment.
124
awk '/; answer/ { x=$0; getline; print x, $0}' ns1/named_dump.db.test$n |
125
    grep "; answer longttl\.example.*A text record with a 600 second ttl" > /dev/null 2>&1 || ret=1
126
if [ $ret != 0 ]; then echo_i "failed"; fi
127 128 129
status=`expr $status + $ret`

n=`expr $n + 1`
130
echo_i "check stale nodata.example ($n)"
131
ret=0
132
$DIG -p ${PORT} @10.53.0.1 nodata.example TXT > dig.out.test$n
133 134
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
135
grep "example\..*2.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
136
if [ $ret != 0 ]; then echo_i "failed"; fi
137 138 139
status=`expr $status + $ret`

n=`expr $n + 1`
140
echo_i "check stale nxdomain.example ($n)"
141
ret=0
142
$DIG -p ${PORT} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
143 144
grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
145
grep "example\..*2.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
146
if [ $ret != 0 ]; then echo_i "failed"; fi
147 148
status=`expr $status + $ret`

149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
n=`expr $n + 1`
echo_i "verify stale cache statistics ($n)"
ret=0
rm -f ns1/named.stats
$RNDCCMD 10.53.0.1 stats > /dev/null 2>&1
[ -f ns1/named.stats ] || ret=1
cp ns1/named.stats ns1/named.stats.$n
# Check first 10 lines of Cache DB statistics.  After serve-stale queries, we
# expect one active TXT RRset, one stale TXT, one stale nxrrset TXT, and one
# stale NXDOMAIN.
grep -A 10 "++ Cache DB RRsets ++" ns1/named.stats.$n > ns1/named.stats.$n.cachedb || ret=1
grep "1 TXT" ns1/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 #TXT" ns1/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 #!TXT" ns1/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 #NXDOMAIN" ns1/named.stats.$n.cachedb > /dev/null || ret=1
status=`expr $status + $ret`
if [ $ret != 0 ]; then echo_i "failed"; fi

167
n=`expr $n + 1`
168
echo_i "running 'rndc serve-stale off' ($n)"
169 170
ret=0
$RNDCCMD 10.53.0.1 serve-stale off || ret=1
171
if [ $ret != 0 ]; then echo_i "failed"; fi
172 173 174
status=`expr $status + $ret`

n=`expr $n + 1`
175
echo_i "check 'rndc serve-stale status' ($n)"
176 177
ret=0
$RNDCCMD 10.53.0.1 serve-stale status > rndc.out.test$n 2>&1 || ret=1
178
grep '_default: off (rndc) (stale-answer-ttl=2 max-stale-ttl=3600)' rndc.out.test$n > /dev/null || ret=1
179
if [ $ret != 0 ]; then echo_i "failed"; fi
180 181 182
status=`expr $status + $ret`

n=`expr $n + 1`
183
echo_i "check stale data.example (serve-stale off) ($n)"
184
ret=0
185
$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
186
grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
187
if [ $ret != 0 ]; then echo_i "failed"; fi
188
status=`expr $status + $ret`
189
if [ $ret != 0 ]; then echo_i "failed"; fi
190 191 192
status=`expr $status + $ret`

n=`expr $n + 1`
193
echo_i "check stale nodata.example (serve-stale off) ($n)"
194
ret=0
195
$DIG -p ${PORT} @10.53.0.1 nodata.example TXT > dig.out.test$n
196
grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
197
if [ $ret != 0 ]; then echo_i "failed"; fi
198 199 200
status=`expr $status + $ret`

n=`expr $n + 1`
201
echo_i "check stale nxdomain.example (serve-stale off) ($n)"
202
ret=0
203
$DIG -p ${PORT} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
204
grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
205
if [ $ret != 0 ]; then echo_i "failed"; fi
206 207 208
status=`expr $status + $ret`

n=`expr $n + 1`
209
echo_i "running 'rndc serve-stale on' ($n)"
210 211
ret=0
$RNDCCMD 10.53.0.1 serve-stale on || ret=1
212
if [ $ret != 0 ]; then echo_i "failed"; fi
213 214 215
status=`expr $status + $ret`

n=`expr $n + 1`
216
echo_i "check 'rndc serve-stale status' ($n)"
217 218
ret=0
$RNDCCMD 10.53.0.1 serve-stale status > rndc.out.test$n 2>&1 || ret=1
219
grep '_default: on (rndc) (stale-answer-ttl=2 max-stale-ttl=3600)' rndc.out.test$n > /dev/null || ret=1
220
if [ $ret != 0 ]; then echo_i "failed"; fi
221 222 223
status=`expr $status + $ret`

n=`expr $n + 1`
224
echo_i "check stale data.example (serve-stale on) ($n)"
225
ret=0
226
$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
227 228
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
229
grep "data\.example\..*2.*IN.*TXT.*A text record with a 1 second ttl" dig.out.test$n > /dev/null || ret=1
230
if [ $ret != 0 ]; then echo_i "failed"; fi
231 232 233
status=`expr $status + $ret`

n=`expr $n + 1`
234
echo_i "check stale nodata.example (serve-stale on) ($n)"
235
ret=0
236
$DIG -p ${PORT} @10.53.0.1 nodata.example TXT > dig.out.test$n
237 238
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
239
grep "example\..*2.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
240
if [ $ret != 0 ]; then echo_i "failed"; fi
241 242 243
status=`expr $status + $ret`

n=`expr $n + 1`
244
echo_i "check stale nxdomain.example (serve-stale on) ($n)"
245
ret=0
246
$DIG -p ${PORT} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
247 248
grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
249
grep "example\..*2.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
250
if [ $ret != 0 ]; then echo_i "failed"; fi
251 252 253
status=`expr $status + $ret`

n=`expr $n + 1`
254
echo_i "running 'rndc serve-stale no' ($n)"
255 256
ret=0
$RNDCCMD 10.53.0.1 serve-stale no || ret=1
257
if [ $ret != 0 ]; then echo_i "failed"; fi
258 259 260
status=`expr $status + $ret`

n=`expr $n + 1`
261
echo_i "check 'rndc serve-stale status' ($n)"
262 263
ret=0
$RNDCCMD 10.53.0.1 serve-stale status > rndc.out.test$n 2>&1 || ret=1
264
grep '_default: off (rndc) (stale-answer-ttl=2 max-stale-ttl=3600)' rndc.out.test$n > /dev/null || ret=1
265
if [ $ret != 0 ]; then echo_i "failed"; fi
266 267 268
status=`expr $status + $ret`

n=`expr $n + 1`
269
echo_i "check stale data.example (serve-stale no) ($n)"
270
ret=0
271
$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
272
grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
273
if [ $ret != 0 ]; then echo_i "failed"; fi
274 275 276
status=`expr $status + $ret`

n=`expr $n + 1`
277
echo_i "check stale nodata.example (serve-stale no) ($n)"
278
ret=0
279
$DIG -p ${PORT} @10.53.0.1 nodata.example TXT > dig.out.test$n
280
grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
281
if [ $ret != 0 ]; then echo_i "failed"; fi
282 283 284
status=`expr $status + $ret`

n=`expr $n + 1`
285
echo_i "check stale nxdomain.example (serve-stale no) ($n)"
286
ret=0
287
$DIG -p ${PORT} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
288
grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
289
if [ $ret != 0 ]; then echo_i "failed"; fi
290 291 292
status=`expr $status + $ret`

n=`expr $n + 1`
293
echo_i "running 'rndc serve-stale yes' ($n)"
294 295
ret=0
$RNDCCMD 10.53.0.1 serve-stale yes || ret=1
296
if [ $ret != 0 ]; then echo_i "failed"; fi
297 298 299
status=`expr $status + $ret`

n=`expr $n + 1`
300
echo_i "check 'rndc serve-stale status' ($n)"
301 302
ret=0
$RNDCCMD 10.53.0.1 serve-stale status > rndc.out.test$n 2>&1 || ret=1
303
grep '_default: on (rndc) (stale-answer-ttl=2 max-stale-ttl=3600)' rndc.out.test$n > /dev/null || ret=1
304
if [ $ret != 0 ]; then echo_i "failed"; fi
305 306 307
status=`expr $status + $ret`

n=`expr $n + 1`
308
echo_i "check stale data.example (serve-stale yes) ($n)"
309
ret=0
310
$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
311 312
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
313
grep "data\.example\..*2.*IN.*TXT.*A text record with a 1 second ttl" dig.out.test$n > /dev/null || ret=1
314
if [ $ret != 0 ]; then echo_i "failed"; fi
315 316 317
status=`expr $status + $ret`

n=`expr $n + 1`
318
echo_i "check stale nodata.example (serve-stale yes) ($n)"
319
ret=0
320
$DIG -p ${PORT} @10.53.0.1 nodata.example TXT > dig.out.test$n
321 322
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
323
grep "example\..*2.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
324
if [ $ret != 0 ]; then echo_i "failed"; fi
325 326 327
status=`expr $status + $ret`

n=`expr $n + 1`
328
echo_i "check stale nxdomain.example (serve-stale yes) ($n)"
329
ret=0
330
$DIG -p ${PORT} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
331 332
grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
333
grep "example\..*2.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
334
if [ $ret != 0 ]; then echo_i "failed"; fi
335 336 337
status=`expr $status + $ret`

n=`expr $n + 1`
338
echo_i "running 'rndc serve-stale off' ($n)"
339 340
ret=0
$RNDCCMD 10.53.0.1 serve-stale off || ret=1
341
if [ $ret != 0 ]; then echo_i "failed"; fi
342 343 344
status=`expr $status + $ret`

n=`expr $n + 1`
345
echo_i "running 'rndc serve-stale reset' ($n)"
346 347
ret=0
$RNDCCMD 10.53.0.1 serve-stale reset || ret=1
348
if [ $ret != 0 ]; then echo_i "failed"; fi
349 350 351
status=`expr $status + $ret`

n=`expr $n + 1`
352
echo_i "check 'rndc serve-stale status' ($n)"
353 354
ret=0
$RNDCCMD 10.53.0.1 serve-stale status > rndc.out.test$n 2>&1 || ret=1
355
grep '_default: on (stale-answer-ttl=2 max-stale-ttl=3600)' rndc.out.test$n > /dev/null || ret=1
356
if [ $ret != 0 ]; then echo_i "failed"; fi
357 358 359
status=`expr $status + $ret`

n=`expr $n + 1`
360
echo_i "check stale data.example (serve-stale reset) ($n)"
361
ret=0
362
$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
363 364
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
365
grep "data\.example\..*2.*IN.*TXT.*A text record with a 1 second ttl" dig.out.test$n > /dev/null || ret=1
366
if [ $ret != 0 ]; then echo_i "failed"; fi
367 368 369
status=`expr $status + $ret`

n=`expr $n + 1`
370
echo_i "check stale nodata.example (serve-stale reset) ($n)"
371
ret=0
372
$DIG -p ${PORT} @10.53.0.1 nodata.example TXT > dig.out.test$n
373 374
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
375
grep "example\..*2.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
376
if [ $ret != 0 ]; then echo_i "failed"; fi
377 378 379
status=`expr $status + $ret`

n=`expr $n + 1`
380
echo_i "check stale nxdomain.example (serve-stale reset) ($n)"
381
ret=0
382
$DIG -p ${PORT} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
383 384
grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
385
grep "example\..*2.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
386
if [ $ret != 0 ]; then echo_i "failed"; fi
387 388 389
status=`expr $status + $ret`

n=`expr $n + 1`
390
echo_i "running 'rndc serve-stale off' ($n)"
391 392
ret=0
$RNDCCMD 10.53.0.1 serve-stale off || ret=1
393
if [ $ret != 0 ]; then echo_i "failed"; fi
394 395 396
status=`expr $status + $ret`

n=`expr $n + 1`
397
echo_i "check 'rndc serve-stale status' ($n)"
398 399
ret=0
$RNDCCMD 10.53.0.1 serve-stale status > rndc.out.test$n 2>&1 || ret=1
400
grep '_default: off (rndc) (stale-answer-ttl=2 max-stale-ttl=3600)' rndc.out.test$n > /dev/null || ret=1
401
if [ $ret != 0 ]; then echo_i "failed"; fi
402 403
status=`expr $status + $ret`

404 405 406 407 408 409
#
# Update named.conf.
# Test server with low max-stale-ttl.
#
echo_i "test server with serve-stale options set, low max-stale-ttl"

410
n=`expr $n + 1`
411
echo_i "updating ns1/named.conf ($n)"
412
ret=0
413
copy_setports ns1/named2.conf.in ns1/named.conf
414
if [ $ret != 0 ]; then echo_i "failed"; fi
415 416 417
status=`expr $status + $ret`

n=`expr $n + 1`
418
echo_i "running 'rndc reload' ($n)"
419
ret=0
420
rndc_reload ns1 10.53.0.1
421
if [ $ret != 0 ]; then echo_i "failed"; fi
422 423 424
status=`expr $status + $ret`

n=`expr $n + 1`
425
echo_i "check 'rndc serve-stale status' ($n)"
426 427
ret=0
$RNDCCMD 10.53.0.1 serve-stale status > rndc.out.test$n 2>&1 || ret=1
428
grep '_default: off (rndc) (stale-answer-ttl=3 max-stale-ttl=35)' rndc.out.test$n > /dev/null || ret=1
429
if [ $ret != 0 ]; then echo_i "failed"; fi
430 431 432
status=`expr $status + $ret`

n=`expr $n + 1`
433
echo_i "flush cache, re-enable serve-stale and query again ($n)"
434
ret=0
435 436 437 438 439
$RNDCCMD 10.53.0.1 flushtree example > rndc.out.test$n.1 2>&1 || ret=1
$RNDCCMD 10.53.0.1 serve-stale on > rndc.out.test$n.2 2>&1 || ret=1
$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
440
if [ $ret != 0 ]; then echo_i "failed"; fi
441 442 443
status=`expr $status + $ret`

n=`expr $n + 1`
444
echo_i "check 'rndc serve-stale status' ($n)"
445
ret=0
446 447
$RNDCCMD 10.53.0.1 serve-stale status > rndc.out.test$n 2>&1 || ret=1
grep '_default: on (rndc) (stale-answer-ttl=3 max-stale-ttl=35)' rndc.out.test$n > /dev/null || ret=1
448
if [ $ret != 0 ]; then echo_i "failed"; fi
449 450
status=`expr $status + $ret`

451
n=`expr $n + 1`
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472
echo_i "enable responses from authoritative server ($n)"
ret=0
$DIG -p ${PORT} @10.53.0.2 txt enable  > dig.out.test$n
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
grep "TXT.\"1\"" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`

sleep 1

n=`expr $n + 1`
echo_i "prime cache longttl.example (low max-stale-ttl) ($n)"
ret=0
$DIG -p ${PORT} @10.53.0.1 longttl.example TXT > dig.out.test$n
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`

n=`expr $n + 1`
echo_i "prime cache data.example (low max-stale-ttl) ($n)"
473 474
ret=0
$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`

n=`expr $n + 1`
echo_i "prime cache nodata.example (low max-stale-ttl) ($n)"
ret=0
$DIG -p ${PORT} @10.53.0.1 nodata.example TXT > dig.out.test$n
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`

n=`expr $n + 1`
echo_i "prime cache nxdomain.example (low max-stale-ttl) ($n)"
ret=0
$DIG -p ${PORT} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`

n=`expr $n + 1`
echo_i "verify prime cache statistics (low max-stale-ttl) ($n)"
ret=0
rm -f ns1/named.stats
$RNDCCMD 10.53.0.1 stats > /dev/null 2>&1
[ -f ns1/named.stats ] || ret=1
cp ns1/named.stats ns1/named.stats.$n
# Check first 10 lines of Cache DB statistics.  After prime queries, we expect
# two active TXT RRsets, one nxrrset TXT, and one NXDOMAIN.
grep -A 10 "++ Cache DB RRsets ++" ns1/named.stats.$n > ns1/named.stats.$n.cachedb || ret=1
grep "2 TXT" ns1/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 !TXT" ns1/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 NXDOMAIN" ns1/named.stats.$n.cachedb > /dev/null || ret=1
status=`expr $status + $ret`
if [ $ret != 0 ]; then echo_i "failed"; fi

n=`expr $n + 1`
echo_i "disable responses from authoritative server ($n)"
ret=0
$DIG -p ${PORT} @10.53.0.2 txt disable  > dig.out.test$n
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
grep "TXT.\"0\"" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`

sleep 1

n=`expr $n + 1`
echo_i "check stale data.example (low max-stale-ttl) ($n)"
ret=0
$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
grep "data\.example\..*3.*IN.*TXT.*A text record with a 1 second ttl" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`

n=`expr $n + 1`
echo_i "check stale nodata.example (low max-stale-ttl) ($n)"
ret=0
$DIG -p ${PORT} @10.53.0.1 nodata.example TXT > dig.out.test$n
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
grep "example\..*3.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`

n=`expr $n + 1`
echo_i "check stale nxdomain.example (low max-stale-ttl) ($n)"
ret=0
$DIG -p ${PORT} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
grep "example\..*3.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`

n=`expr $n + 1`
echo_i "verify stale cache statistics (low max-stale-ttl) ($n)"
ret=0
rm -f ns1/named.stats
$RNDCCMD 10.53.0.1 stats > /dev/null 2>&1
[ -f ns1/named.stats ] || ret=1
cp ns1/named.stats ns1/named.stats.$n
# Check first 10 lines of Cache DB statistics.  After serve-stale queries, we
# expect one active TXT RRset, one stale TXT, one stale nxrrset TXT, and one
# stale NXDOMAIN.
grep -A 10 "++ Cache DB RRsets ++" ns1/named.stats.$n > ns1/named.stats.$n.cachedb || ret=1
grep "1 TXT" ns1/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 #TXT" ns1/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 #!TXT" ns1/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 #NXDOMAIN" ns1/named.stats.$n.cachedb > /dev/null || ret=1
status=`expr $status + $ret`
if [ $ret != 0 ]; then echo_i "failed"; fi

sleep 1

n=`expr $n + 1`
echo_i "check ancient data.example (low max-stale-ttl) ($n)"
ret=0
$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`

n=`expr $n + 1`
echo_i "check ancient nodata.example (low max-stale-ttl) ($n)"
ret=0
$DIG -p ${PORT} @10.53.0.1 nodata.example TXT > dig.out.test$n
588 589 590 591 592
grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`

593 594 595 596 597 598 599 600 601 602 603 604 605 606
n=`expr $n + 1`
echo_i "check ancient nxdomain.example (low max-stale-ttl) ($n)"
ret=0
$DIG -p ${PORT} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`

#
# Now test server with no serve-stale options set.
#
echo_i "test server with no serve-stale options set"

607
n=`expr $n + 1`
608
echo_i "enable responses from authoritative server ($n)"
609
ret=0
610
$DIG -p ${PORT} @10.53.0.2 txt enable  > dig.out.test$n
611 612
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
grep "TXT.\"1\"" dig.out.test$n > /dev/null || ret=1
613
if [ $ret != 0 ]; then echo_i "failed"; fi
614 615
status=`expr $status + $ret`

616 617 618 619 620 621 622 623 624
n=`expr $n + 1`
echo_i "prime cache longttl.example (max-stale-ttl default) ($n)"
ret=0
$DIG -p ${PORT} @10.53.0.3 longttl.example TXT > dig.out.test$n
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`

625
n=`expr $n + 1`
626
echo_i "prime cache data.example (max-stale-ttl default) ($n)"
627
ret=0
628
$DIG -p ${PORT} @10.53.0.3 data.example TXT > dig.out.test$n
629 630
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
631
grep "data\.example\..*1.*IN.*TXT.*A text record with a 1 second ttl" dig.out.test$n > /dev/null || ret=1
632
if [ $ret != 0 ]; then echo_i "failed"; fi
633 634 635
status=`expr $status + $ret`

n=`expr $n + 1`
636
echo_i "prime cache nodata.example (max-stale-ttl default) ($n)"
637
ret=0
638
$DIG -p ${PORT} @10.53.0.3 nodata.example TXT > dig.out.test$n
639 640
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
641
grep "example\..*1.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
642
if [ $ret != 0 ]; then echo_i "failed"; fi
643 644 645
status=`expr $status + $ret`

n=`expr $n + 1`
646
echo_i "prime cache nxdomain.example (max-stale-ttl default) ($n)"
647
ret=0
648
$DIG -p ${PORT} @10.53.0.3 nxdomain.example TXT > dig.out.test$n
649 650
grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
651
grep "example\..*1.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
652
if [ $ret != 0 ]; then echo_i "failed"; fi
653 654 655
status=`expr $status + $ret`

n=`expr $n + 1`
656
echo_i "disable responses from authoritative server ($n)"
657
ret=0
658
$DIG -p ${PORT} @10.53.0.2 txt disable  > dig.out.test$n
659 660
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
grep "TXT.\"0\"" dig.out.test$n > /dev/null || ret=1
661
if [ $ret != 0 ]; then echo_i "failed"; fi
662 663
status=`expr $status + $ret`

664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679
n=`expr $n + 1`
echo_i "verify prime cache statistics (max-stale-ttl default) ($n)"
ret=0
rm -f ns3/named.stats
$RNDCCMD 10.53.0.3 stats > /dev/null 2>&1
[ -f ns3/named.stats ] || ret=1
cp ns3/named.stats ns3/named.stats.$n
# Check first 10 lines of Cache DB statistics.  After prime queries, we expect
# two active TXT RRsets, one nxrrset TXT, and one NXDOMAIN.
grep -A 10 "++ Cache DB RRsets ++" ns3/named.stats.$n > ns3/named.stats.$n.cachedb || ret=1
grep "2 TXT" ns3/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 !TXT" ns3/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 NXDOMAIN" ns3/named.stats.$n.cachedb > /dev/null || ret=1
status=`expr $status + $ret`
if [ $ret != 0 ]; then echo_i "failed"; fi

680 681 682
sleep 1

n=`expr $n + 1`
683
echo_i "check 'rndc serve-stale status' ($n)"
684 685 686
ret=0
$RNDCCMD 10.53.0.3 serve-stale status > rndc.out.test$n 2>&1 || ret=1
grep '_default: off (stale-answer-ttl=1 max-stale-ttl=604800)' rndc.out.test$n > /dev/null || ret=1
687
if [ $ret != 0 ]; then echo_i "failed"; fi
688 689 690
status=`expr $status + $ret`

n=`expr $n + 1`
691
echo_i "check fail of data.example (max-stale-ttl default) ($n)"
692
ret=0
693
$DIG -p ${PORT} @10.53.0.3 data.example TXT > dig.out.test$n
694 695
grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
696
if [ $ret != 0 ]; then echo_i "failed"; fi
697 698 699
status=`expr $status + $ret`

n=`expr $n + 1`
700
echo_i "check fail of nodata.example (max-stale-ttl default) ($n)"
701
ret=0
702
$DIG -p ${PORT} @10.53.0.3 nodata.example TXT > dig.out.test$n
703 704
grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
705
if [ $ret != 0 ]; then echo_i "failed"; fi
706 707 708
status=`expr $status + $ret`

n=`expr $n + 1`
709
echo_i "check fail of nxdomain.example (max-stale-ttl default) ($n)"
710
ret=0
711
$DIG -p ${PORT} @10.53.0.3 nxdomain.example TXT > dig.out.test$n
712 713
grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
714
if [ $ret != 0 ]; then echo_i "failed"; fi
715 716
status=`expr $status + $ret`

717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734
n=`expr $n + 1`
echo_i "verify stale cache statistics (max-stale-ttl default) ($n)"
ret=0
rm -f ns3/named.stats
$RNDCCMD 10.53.0.3 stats > /dev/null 2>&1
[ -f ns3/named.stats ] || ret=1
cp ns3/named.stats ns3/named.stats.$n
# Check first 10 lines of Cache DB statistics. After last queries, we expect
# one active TXT RRset, one stale TXT, one stale nxrrset TXT, and one
# stale NXDOMAIN.
grep -A 10 "++ Cache DB RRsets ++" ns3/named.stats.$n > ns3/named.stats.$n.cachedb || ret=1
grep "1 TXT" ns3/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 #TXT" ns3/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 #!TXT" ns3/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 #NXDOMAIN" ns3/named.stats.$n.cachedb > /dev/null || ret=1
status=`expr $status + $ret`
if [ $ret != 0 ]; then echo_i "failed"; fi

735
n=`expr $n + 1`
736
echo_i "check 'rndc serve-stale on' ($n)"
737 738
ret=0
$RNDCCMD 10.53.0.3 serve-stale on > rndc.out.test$n 2>&1 || ret=1
739
if [ $ret != 0 ]; then echo_i "failed"; fi
740 741 742
status=`expr $status + $ret`

n=`expr $n + 1`
743
echo_i "check 'rndc serve-stale status' ($n)"
744 745 746
ret=0
$RNDCCMD 10.53.0.3 serve-stale status > rndc.out.test$n 2>&1 || ret=1
grep '_default: on (rndc) (stale-answer-ttl=1 max-stale-ttl=604800)' rndc.out.test$n > /dev/null || ret=1
747
if [ $ret != 0 ]; then echo_i "failed"; fi
748 749 750
status=`expr $status + $ret`

n=`expr $n + 1`
751
echo_i "check data.example (max-stale-ttl default) ($n)"
752
ret=0
753
$DIG -p ${PORT} @10.53.0.3 data.example TXT > dig.out.test$n
754 755
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
756
grep "data\.example\..*1.*IN.*TXT.*A text record with a 1 second ttl" dig.out.test$n > /dev/null || ret=1
757
if [ $ret != 0 ]; then echo_i "failed"; fi
758 759 760
status=`expr $status + $ret`

n=`expr $n + 1`
761
echo_i "check nodata.example (max-stale-ttl default) ($n)"
762
ret=0
763
$DIG -p ${PORT} @10.53.0.3 nodata.example TXT > dig.out.test$n
764 765
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
766
grep "example\..*1.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
767
if [ $ret != 0 ]; then echo_i "failed"; fi
768 769 770
status=`expr $status + $ret`

n=`expr $n + 1`
771
echo_i "check nxdomain.example (max-stale-ttl default) ($n)"
772
ret=0
773
$DIG -p ${PORT} @10.53.0.3 nxdomain.example TXT > dig.out.test$n
774 775
grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
776
grep "example\..*1.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
777
if [ $ret != 0 ]; then echo_i "failed"; fi
778 779
status=`expr $status + $ret`

780
echo_i "exit status: $status"
781
[ $status -eq 0 ] || exit 1