tests.sh 19.7 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
39
40
41
42
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`

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

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

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

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

sleep 1

n=`expr $n + 1`
82
echo_i "check 'rndc serve-stale status' ($n)"
83
84
ret=0
$RNDCCMD 10.53.0.1 serve-stale status > rndc.out.test$n 2>&1 || ret=1
85
grep '_default: on (stale-answer-ttl=2 max-stale-ttl=3600)' rndc.out.test$n > /dev/null || ret=1
86
if [ $ret != 0 ]; then echo_i "failed"; fi
87
88
89
status=`expr $status + $ret`

n=`expr $n + 1`
90
echo_i "check stale data.example ($n)"
91
ret=0
92
$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
93
94
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
95
96
97
98
99
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.
$RNDCCMD 10.53.0.1 dumpdb > rndc.out.test$n 2>&1 || ret=1
100
101
102
103
for i in 0 1 2 3 4 5 6 7 8 9; do
	grep '^; Dump complete$' ns1/named_dump1.db > /dev/null 2>&1 && break
	sleep 1
done
104
105
106
107
108
awk '/; stale/ { x=$0; getline; print x, $0}' ns1/named_dump1.db |
    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.
awk '/; answer/ { x=$0; getline; print x, $0}' ns1/named_dump1.db |
    grep "; answer longttl\.example.*A text record with a 600 second ttl" > /dev/null 2>&1 || ret=1
109
if [ $ret != 0 ]; then echo_i "failed"; fi
110
111
112
status=`expr $status + $ret`

n=`expr $n + 1`
113
echo_i "check stale nodata.example ($n)"
114
ret=0
115
$DIG -p ${PORT} @10.53.0.1 nodata.example TXT > dig.out.test$n
116
117
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
118
grep "example\..*2.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
119
if [ $ret != 0 ]; then echo_i "failed"; fi
120
121
122
status=`expr $status + $ret`

n=`expr $n + 1`
123
echo_i "check stale nxdomain.example ($n)"
124
ret=0
125
$DIG -p ${PORT} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
126
127
grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
128
grep "example\..*2.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
129
if [ $ret != 0 ]; then echo_i "failed"; fi
130
131
132
status=`expr $status + $ret`

n=`expr $n + 1`
133
echo_i "running 'rndc serve-stale off' ($n)"
134
135
ret=0
$RNDCCMD 10.53.0.1 serve-stale off || 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 'rndc serve-stale status' ($n)"
141
142
ret=0
$RNDCCMD 10.53.0.1 serve-stale status > rndc.out.test$n 2>&1 || ret=1
143
grep '_default: off (rndc) (stale-answer-ttl=2 max-stale-ttl=3600)' rndc.out.test$n > /dev/null || ret=1
144
if [ $ret != 0 ]; then echo_i "failed"; fi
145
146
147
status=`expr $status + $ret`

n=`expr $n + 1`
148
echo_i "check stale data.example (serve-stale off) ($n)"
149
ret=0
150
$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
151
grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
152
if [ $ret != 0 ]; then echo_i "failed"; fi
153
status=`expr $status + $ret`
154
if [ $ret != 0 ]; then echo_i "failed"; fi
155
156
157
status=`expr $status + $ret`

n=`expr $n + 1`
158
echo_i "check stale nodata.example (serve-stale off) ($n)"
159
ret=0
160
$DIG -p ${PORT} @10.53.0.1 nodata.example TXT > dig.out.test$n
161
grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
162
if [ $ret != 0 ]; then echo_i "failed"; fi
163
164
165
status=`expr $status + $ret`

n=`expr $n + 1`
166
echo_i "check stale nxdomain.example (serve-stale off) ($n)"
167
ret=0
168
$DIG -p ${PORT} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
169
grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
170
if [ $ret != 0 ]; then echo_i "failed"; fi
171
172
173
status=`expr $status + $ret`

n=`expr $n + 1`
174
echo_i "running 'rndc serve-stale on' ($n)"
175
176
ret=0
$RNDCCMD 10.53.0.1 serve-stale on || ret=1
177
if [ $ret != 0 ]; then echo_i "failed"; fi
178
179
180
status=`expr $status + $ret`

n=`expr $n + 1`
181
echo_i "check 'rndc serve-stale status' ($n)"
182
183
ret=0
$RNDCCMD 10.53.0.1 serve-stale status > rndc.out.test$n 2>&1 || ret=1
184
grep '_default: on (rndc) (stale-answer-ttl=2 max-stale-ttl=3600)' rndc.out.test$n > /dev/null || ret=1
185
if [ $ret != 0 ]; then echo_i "failed"; fi
186
187
188
status=`expr $status + $ret`

n=`expr $n + 1`
189
echo_i "check stale data.example (serve-stale on) ($n)"
190
ret=0
191
$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
192
193
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
194
grep "data\.example\..*2.*IN.*TXT.*A text record with a 1 second ttl" dig.out.test$n > /dev/null || ret=1
195
if [ $ret != 0 ]; then echo_i "failed"; fi
196
197
198
status=`expr $status + $ret`

n=`expr $n + 1`
199
echo_i "check stale nodata.example (serve-stale on) ($n)"
200
ret=0
201
$DIG -p ${PORT} @10.53.0.1 nodata.example TXT > dig.out.test$n
202
203
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
204
grep "example\..*2.*IN.*SOA" 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 "check stale nxdomain.example (serve-stale on) ($n)"
210
ret=0
211
$DIG -p ${PORT} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
212
213
grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
214
grep "example\..*2.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
215
if [ $ret != 0 ]; then echo_i "failed"; fi
216
217
218
status=`expr $status + $ret`

n=`expr $n + 1`
219
echo_i "running 'rndc serve-stale no' ($n)"
220
221
ret=0
$RNDCCMD 10.53.0.1 serve-stale no || ret=1
222
if [ $ret != 0 ]; then echo_i "failed"; fi
223
224
225
status=`expr $status + $ret`

n=`expr $n + 1`
226
echo_i "check 'rndc serve-stale status' ($n)"
227
228
ret=0
$RNDCCMD 10.53.0.1 serve-stale status > rndc.out.test$n 2>&1 || ret=1
229
grep '_default: off (rndc) (stale-answer-ttl=2 max-stale-ttl=3600)' rndc.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 data.example (serve-stale no) ($n)"
235
ret=0
236
$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
237
grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
238
if [ $ret != 0 ]; then echo_i "failed"; fi
239
240
241
status=`expr $status + $ret`

n=`expr $n + 1`
242
echo_i "check stale nodata.example (serve-stale no) ($n)"
243
ret=0
244
$DIG -p ${PORT} @10.53.0.1 nodata.example TXT > dig.out.test$n
245
grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
246
if [ $ret != 0 ]; then echo_i "failed"; fi
247
248
249
status=`expr $status + $ret`

n=`expr $n + 1`
250
echo_i "check stale nxdomain.example (serve-stale no) ($n)"
251
ret=0
252
$DIG -p ${PORT} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
253
grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
254
if [ $ret != 0 ]; then echo_i "failed"; fi
255
256
257
status=`expr $status + $ret`

n=`expr $n + 1`
258
echo_i "running 'rndc serve-stale yes' ($n)"
259
260
ret=0
$RNDCCMD 10.53.0.1 serve-stale yes || ret=1
261
if [ $ret != 0 ]; then echo_i "failed"; fi
262
263
264
status=`expr $status + $ret`

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

n=`expr $n + 1`
273
echo_i "check stale data.example (serve-stale yes) ($n)"
274
ret=0
275
$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
276
277
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
278
grep "data\.example\..*2.*IN.*TXT.*A text record with a 1 second ttl" dig.out.test$n > /dev/null || ret=1
279
if [ $ret != 0 ]; then echo_i "failed"; fi
280
281
282
status=`expr $status + $ret`

n=`expr $n + 1`
283
echo_i "check stale nodata.example (serve-stale yes) ($n)"
284
ret=0
285
$DIG -p ${PORT} @10.53.0.1 nodata.example TXT > dig.out.test$n
286
287
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
288
grep "example\..*2.*IN.*SOA" 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 "check stale nxdomain.example (serve-stale yes) ($n)"
294
ret=0
295
$DIG -p ${PORT} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
296
297
grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
298
grep "example\..*2.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
299
if [ $ret != 0 ]; then echo_i "failed"; fi
300
301
302
status=`expr $status + $ret`

n=`expr $n + 1`
303
echo_i "running 'rndc serve-stale off' ($n)"
304
305
ret=0
$RNDCCMD 10.53.0.1 serve-stale off || ret=1
306
if [ $ret != 0 ]; then echo_i "failed"; fi
307
308
309
status=`expr $status + $ret`

n=`expr $n + 1`
310
echo_i "running 'rndc serve-stale reset' ($n)"
311
312
ret=0
$RNDCCMD 10.53.0.1 serve-stale reset || ret=1
313
if [ $ret != 0 ]; then echo_i "failed"; fi
314
315
316
status=`expr $status + $ret`

n=`expr $n + 1`
317
echo_i "check 'rndc serve-stale status' ($n)"
318
319
ret=0
$RNDCCMD 10.53.0.1 serve-stale status > rndc.out.test$n 2>&1 || ret=1
320
grep '_default: on (stale-answer-ttl=2 max-stale-ttl=3600)' rndc.out.test$n > /dev/null || ret=1
321
if [ $ret != 0 ]; then echo_i "failed"; fi
322
323
324
status=`expr $status + $ret`

n=`expr $n + 1`
325
echo_i "check stale data.example (serve-stale reset) ($n)"
326
ret=0
327
$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
328
329
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
330
grep "data\.example\..*2.*IN.*TXT.*A text record with a 1 second ttl" dig.out.test$n > /dev/null || ret=1
331
if [ $ret != 0 ]; then echo_i "failed"; fi
332
333
334
status=`expr $status + $ret`

n=`expr $n + 1`
335
echo_i "check stale nodata.example (serve-stale reset) ($n)"
336
ret=0
337
$DIG -p ${PORT} @10.53.0.1 nodata.example TXT > dig.out.test$n
338
339
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
340
grep "example\..*2.*IN.*SOA" dig.out.test$n > /dev/null || 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 "check stale nxdomain.example (serve-stale reset) ($n)"
346
ret=0
347
$DIG -p ${PORT} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
348
349
grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
350
grep "example\..*2.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
351
if [ $ret != 0 ]; then echo_i "failed"; fi
352
353
354
status=`expr $status + $ret`

n=`expr $n + 1`
355
echo_i "running 'rndc serve-stale off' ($n)"
356
357
ret=0
$RNDCCMD 10.53.0.1 serve-stale off || ret=1
358
if [ $ret != 0 ]; then echo_i "failed"; fi
359
360
361
status=`expr $status + $ret`

n=`expr $n + 1`
362
echo_i "check 'rndc serve-stale status' ($n)"
363
364
ret=0
$RNDCCMD 10.53.0.1 serve-stale status > rndc.out.test$n 2>&1 || ret=1
365
grep '_default: off (rndc) (stale-answer-ttl=2 max-stale-ttl=3600)' rndc.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 "updating ns1/named.conf ($n)"
371
ret=0
372
copy_setports ns1/named2.conf.in ns1/named.conf
373
if [ $ret != 0 ]; then echo_i "failed"; fi
374
375
376
status=`expr $status + $ret`

n=`expr $n + 1`
377
echo_i "running 'rndc reload' ($n)"
378
ret=0
379
rndc_reload ns1 10.53.0.1
380
if [ $ret != 0 ]; then echo_i "failed"; fi
381
382
383
status=`expr $status + $ret`

n=`expr $n + 1`
384
echo_i "check 'rndc serve-stale status' ($n)"
385
386
ret=0
$RNDCCMD 10.53.0.1 serve-stale status > rndc.out.test$n 2>&1 || ret=1
387
grep '_default: off (rndc) (stale-answer-ttl=3 max-stale-ttl=7200)' rndc.out.test$n > /dev/null || ret=1
388
if [ $ret != 0 ]; then echo_i "failed"; fi
389
390
391
status=`expr $status + $ret`

n=`expr $n + 1`
392
echo_i "check 'rndc serve-stale' ($n)"
393
394
395
ret=0
$RNDCCMD 10.53.0.1 serve-stale > rndc.out.test$n 2>&1 && ret=1
grep "unexpected end of input" rndc.out.test$n > /dev/null || ret=1
396
if [ $ret != 0 ]; then echo_i "failed"; fi
397
398
399
status=`expr $status + $ret`

n=`expr $n + 1`
400
echo_i "check 'rndc serve-stale unknown' ($n)"
401
402
403
ret=0
$RNDCCMD 10.53.0.1 serve-stale unknown > rndc.out.test$n 2>&1 && ret=1
grep "syntax error" rndc.out.test$n > /dev/null || ret=1
404
if [ $ret != 0 ]; then echo_i "failed"; fi
405
406
status=`expr $status + $ret`

407
408
409
410
411
412
413
414
415
416
417
n=`expr $n + 1`
echo_i "flush cache, re-enable serve-stale and query again ($n)"
ret=0
$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
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`

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

n=`expr $n + 1`
428
echo_i "prime cache data.example (max-stale-ttl default) ($n)"
429
ret=0
430
$DIG -p ${PORT} @10.53.0.3 data.example TXT > dig.out.test$n
431
432
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
433
grep "data\.example\..*1.*IN.*TXT.*A text record with a 1 second ttl" dig.out.test$n > /dev/null || ret=1
434
if [ $ret != 0 ]; then echo_i "failed"; fi
435
436
437
status=`expr $status + $ret`

n=`expr $n + 1`
438
echo_i "prime cache nodata.example (max-stale-ttl default) ($n)"
439
ret=0
440
$DIG -p ${PORT} @10.53.0.3 nodata.example TXT > dig.out.test$n
441
442
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
443
grep "example\..*1.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
444
if [ $ret != 0 ]; then echo_i "failed"; fi
445
446
447
status=`expr $status + $ret`

n=`expr $n + 1`
448
echo_i "prime cache nxdomain.example (max-stale-ttl default) ($n)"
449
ret=0
450
$DIG -p ${PORT} @10.53.0.3 nxdomain.example TXT > dig.out.test$n
451
452
grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
453
grep "example\..*1.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
454
if [ $ret != 0 ]; then echo_i "failed"; fi
455
456
457
status=`expr $status + $ret`

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

sleep 1

n=`expr $n + 1`
469
echo_i "check 'rndc serve-stale status' ($n)"
470
471
472
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
473
if [ $ret != 0 ]; then echo_i "failed"; fi
474
475
476
status=`expr $status + $ret`

n=`expr $n + 1`
477
echo_i "check fail of data.example (max-stale-ttl default) ($n)"
478
ret=0
479
$DIG -p ${PORT} @10.53.0.3 data.example TXT > dig.out.test$n
480
481
grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
482
if [ $ret != 0 ]; then echo_i "failed"; fi
483
484
485
status=`expr $status + $ret`

n=`expr $n + 1`
486
echo_i "check fail of nodata.example (max-stale-ttl default) ($n)"
487
ret=0
488
$DIG -p ${PORT} @10.53.0.3 nodata.example TXT > dig.out.test$n
489
490
grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
491
if [ $ret != 0 ]; then echo_i "failed"; fi
492
493
494
status=`expr $status + $ret`

n=`expr $n + 1`
495
echo_i "check fail of nxdomain.example (max-stale-ttl default) ($n)"
496
ret=0
497
$DIG -p ${PORT} @10.53.0.3 nxdomain.example TXT > dig.out.test$n
498
499
grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
500
if [ $ret != 0 ]; then echo_i "failed"; fi
501
502
503
status=`expr $status + $ret`

n=`expr $n + 1`
504
echo_i "check 'rndc serve-stale on' ($n)"
505
506
ret=0
$RNDCCMD 10.53.0.3 serve-stale on > rndc.out.test$n 2>&1 || ret=1
507
if [ $ret != 0 ]; then echo_i "failed"; fi
508
509
510
status=`expr $status + $ret`

n=`expr $n + 1`
511
echo_i "check 'rndc serve-stale status' ($n)"
512
513
514
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
515
if [ $ret != 0 ]; then echo_i "failed"; fi
516
517
518
status=`expr $status + $ret`

n=`expr $n + 1`
519
echo_i "check data.example (max-stale-ttl default) ($n)"
520
ret=0
521
$DIG -p ${PORT} @10.53.0.3 data.example TXT > dig.out.test$n
522
523
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
524
grep "data\.example\..*1.*IN.*TXT.*A text record with a 1 second ttl" dig.out.test$n > /dev/null || ret=1
525
if [ $ret != 0 ]; then echo_i "failed"; fi
526
527
528
status=`expr $status + $ret`

n=`expr $n + 1`
529
echo_i "check nodata.example (max-stale-ttl default) ($n)"
530
ret=0
531
$DIG -p ${PORT} @10.53.0.3 nodata.example TXT > dig.out.test$n
532
533
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
534
grep "example\..*1.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
535
if [ $ret != 0 ]; then echo_i "failed"; fi
536
537
538
status=`expr $status + $ret`

n=`expr $n + 1`
539
echo_i "check nxdomain.example (max-stale-ttl default) ($n)"
540
ret=0
541
$DIG -p ${PORT} @10.53.0.3 nxdomain.example TXT > dig.out.test$n
542
543
grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
544
grep "example\..*1.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
545
if [ $ret != 0 ]; then echo_i "failed"; fi
546
547
status=`expr $status + $ret`

548
echo_i "exit status: $status"
549
[ $status -eq 0 ] || exit 1