tests.sh 19.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
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
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.
99
100
rndc_dumpdb ns1 || ret=1
awk '/; stale/ { x=$0; getline; print x, $0}' ns1/named_dump.db.test$n |
101
102
    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.
103
awk '/; answer/ { x=$0; getline; print x, $0}' ns1/named_dump.db.test$n |
104
    grep "; answer longttl\.example.*A text record with a 600 second ttl" > /dev/null 2>&1 || ret=1
105
if [ $ret != 0 ]; then echo_i "failed"; fi
106
107
108
status=`expr $status + $ret`

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

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

n=`expr $n + 1`
129
echo_i "running 'rndc serve-stale off' ($n)"
130
131
ret=0
$RNDCCMD 10.53.0.1 serve-stale off || ret=1
132
if [ $ret != 0 ]; then echo_i "failed"; fi
133
134
135
status=`expr $status + $ret`

n=`expr $n + 1`
136
echo_i "check 'rndc serve-stale status' ($n)"
137
138
ret=0
$RNDCCMD 10.53.0.1 serve-stale status > rndc.out.test$n 2>&1 || ret=1
139
grep '_default: off (rndc) (stale-answer-ttl=2 max-stale-ttl=3600)' rndc.out.test$n > /dev/null || ret=1
140
if [ $ret != 0 ]; then echo_i "failed"; fi
141
142
143
status=`expr $status + $ret`

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

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

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

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

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

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

n=`expr $n + 1`
195
echo_i "check stale nodata.example (serve-stale on) ($n)"
196
ret=0
197
$DIG -p ${PORT} @10.53.0.1 nodata.example TXT > dig.out.test$n
198
199
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
200
grep "example\..*2.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
201
if [ $ret != 0 ]; then echo_i "failed"; fi
202
203
204
status=`expr $status + $ret`

n=`expr $n + 1`
205
echo_i "check stale nxdomain.example (serve-stale on) ($n)"
206
ret=0
207
$DIG -p ${PORT} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
208
209
grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
210
grep "example\..*2.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
211
if [ $ret != 0 ]; then echo_i "failed"; fi
212
213
214
status=`expr $status + $ret`

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

n=`expr $n + 1`
222
echo_i "check 'rndc serve-stale status' ($n)"
223
224
ret=0
$RNDCCMD 10.53.0.1 serve-stale status > rndc.out.test$n 2>&1 || ret=1
225
grep '_default: off (rndc) (stale-answer-ttl=2 max-stale-ttl=3600)' rndc.out.test$n > /dev/null || ret=1
226
if [ $ret != 0 ]; then echo_i "failed"; fi
227
228
229
status=`expr $status + $ret`

n=`expr $n + 1`
230
echo_i "check stale data.example (serve-stale no) ($n)"
231
ret=0
232
$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
233
grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
234
if [ $ret != 0 ]; then echo_i "failed"; fi
235
236
237
status=`expr $status + $ret`

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

n=`expr $n + 1`
246
echo_i "check stale nxdomain.example (serve-stale no) ($n)"
247
ret=0
248
$DIG -p ${PORT} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
249
grep "status: SERVFAIL" 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 yes' ($n)"
255
256
ret=0
$RNDCCMD 10.53.0.1 serve-stale yes || 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: on (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 yes) ($n)"
270
ret=0
271
$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
272
273
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
274
grep "data\.example\..*2.*IN.*TXT.*A text record with a 1 second ttl" dig.out.test$n > /dev/null || ret=1
275
if [ $ret != 0 ]; then echo_i "failed"; fi
276
277
278
status=`expr $status + $ret`

n=`expr $n + 1`
279
echo_i "check stale nodata.example (serve-stale yes) ($n)"
280
ret=0
281
$DIG -p ${PORT} @10.53.0.1 nodata.example TXT > dig.out.test$n
282
283
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
284
grep "example\..*2.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
285
if [ $ret != 0 ]; then echo_i "failed"; fi
286
287
288
status=`expr $status + $ret`

n=`expr $n + 1`
289
echo_i "check stale nxdomain.example (serve-stale yes) ($n)"
290
ret=0
291
$DIG -p ${PORT} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
292
293
grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
294
grep "example\..*2.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
295
if [ $ret != 0 ]; then echo_i "failed"; fi
296
297
298
status=`expr $status + $ret`

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

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

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

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

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

n=`expr $n + 1`
341
echo_i "check stale nxdomain.example (serve-stale reset) ($n)"
342
ret=0
343
$DIG -p ${PORT} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
344
345
grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
346
grep "example\..*2.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
347
if [ $ret != 0 ]; then echo_i "failed"; fi
348
349
350
status=`expr $status + $ret`

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

n=`expr $n + 1`
358
echo_i "check 'rndc serve-stale status' ($n)"
359
360
ret=0
$RNDCCMD 10.53.0.1 serve-stale status > rndc.out.test$n 2>&1 || ret=1
361
grep '_default: off (rndc) (stale-answer-ttl=2 max-stale-ttl=3600)' rndc.out.test$n > /dev/null || ret=1
362
if [ $ret != 0 ]; then echo_i "failed"; fi
363
364
365
status=`expr $status + $ret`

n=`expr $n + 1`
366
echo_i "updating ns1/named.conf ($n)"
367
ret=0
368
copy_setports ns1/named2.conf.in ns1/named.conf
369
if [ $ret != 0 ]; then echo_i "failed"; fi
370
371
372
status=`expr $status + $ret`

n=`expr $n + 1`
373
echo_i "running 'rndc reload' ($n)"
374
ret=0
375
rndc_reload ns1 10.53.0.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 'rndc serve-stale status' ($n)"
381
382
ret=0
$RNDCCMD 10.53.0.1 serve-stale status > rndc.out.test$n 2>&1 || ret=1
383
grep '_default: off (rndc) (stale-answer-ttl=3 max-stale-ttl=7200)' rndc.out.test$n > /dev/null || ret=1
384
if [ $ret != 0 ]; then echo_i "failed"; fi
385
386
387
status=`expr $status + $ret`

n=`expr $n + 1`
388
echo_i "check 'rndc serve-stale' ($n)"
389
390
391
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
392
if [ $ret != 0 ]; then echo_i "failed"; fi
393
394
395
status=`expr $status + $ret`

n=`expr $n + 1`
396
echo_i "check 'rndc serve-stale unknown' ($n)"
397
398
399
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
400
if [ $ret != 0 ]; then echo_i "failed"; fi
401
402
status=`expr $status + $ret`

403
404
405
406
407
408
409
410
411
412
413
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`

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

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

n=`expr $n + 1`
434
echo_i "prime cache nodata.example (max-stale-ttl default) ($n)"
435
ret=0
436
$DIG -p ${PORT} @10.53.0.3 nodata.example TXT > dig.out.test$n
437
438
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
439
grep "example\..*1.*IN.*SOA" 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 "prime cache nxdomain.example (max-stale-ttl default) ($n)"
445
ret=0
446
$DIG -p ${PORT} @10.53.0.3 nxdomain.example TXT > dig.out.test$n
447
448
grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
449
grep "example\..*1.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
450
if [ $ret != 0 ]; then echo_i "failed"; fi
451
452
453
status=`expr $status + $ret`

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

sleep 1

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

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

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

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

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

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

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

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

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

544
echo_i "exit status: $status"
545
[ $status -eq 0 ] || exit 1