tests.sh revision 1.1.1.3 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 SYSTEMTESTTOP=..
13 . $SYSTEMTESTTOP/conf.sh
14
15 RNDCCMD="$RNDC -c $SYSTEMTESTTOP/common/rndc.conf -p ${CONTROLPORT} -s"
16
17 status=0
18 n=0
19
20 #echo_i "check ans.pl server ($n)"
21 #$DIG -p ${PORT} @10.53.0.2 example NS
22 #$DIG -p ${PORT} @10.53.0.2 example SOA
23 #$DIG -p ${PORT} @10.53.0.2 ns.example A
24 #$DIG -p ${PORT} @10.53.0.2 ns.example AAAA
25 #$DIG -p ${PORT} @10.53.0.2 txt enable
26 #$DIG -p ${PORT} @10.53.0.2 txt disable
27 #$DIG -p ${PORT} @10.53.0.2 ns.example AAAA
28 #$DIG -p ${PORT} @10.53.0.2 txt enable
29 #$DIG -p ${PORT} @10.53.0.2 ns.example AAAA
30 #$DIG -p ${PORT} @10.53.0.2 data.example TXT
31 #$DIG -p ${PORT} @10.53.0.2 nodata.example TXT
32 #$DIG -p ${PORT} @10.53.0.2 nxdomain.example TXT
33
34 n=`expr $n + 1`
35 echo_i "prime cache longttl.example ($n)"
36 ret=0
37 $DIG -p ${PORT} @10.53.0.1 longttl.example TXT > dig.out.test$n
38 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
39 grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
40 if [ $ret != 0 ]; then echo_i "failed"; fi
41 status=`expr $status + $ret`
42
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 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
48 grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
49 if [ $ret != 0 ]; then echo_i "failed"; fi
50 status=`expr $status + $ret`
51
52 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 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
57 grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
58 if [ $ret != 0 ]; then echo_i "failed"; fi
59 status=`expr $status + $ret`
60
61 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 grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
66 grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
67 if [ $ret != 0 ]; then echo_i "failed"; fi
68 status=`expr $status + $ret`
69
70 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 grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
75 grep "TXT.\"0\"" dig.out.test$n > /dev/null || ret=1
76 if [ $ret != 0 ]; then echo_i "failed"; fi
77 status=`expr $status + $ret`
78
79 sleep 1
80
81 n=`expr $n + 1`
82 echo_i "check 'rndc serve-stale status' ($n)"
83 ret=0
84 $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 status=`expr $status + $ret`
88
89 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 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
94 grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
95 grep "data\.example\..*2.*IN.*TXT.*A text record with a 1 second ttl" dig.out.test$n > /dev/null || ret=1
96 # Run rndc dumpdb, test whether the stale data has correct comment printed.
97 # The max-stale-ttl is 3600 seconds, so the comment should say the data is
98 # stale for somewhere between 3500-3599 seconds.
99 $RNDCCMD 10.53.0.1 dumpdb > rndc.out.test$n 2>&1 || ret=1
100 awk '/; stale/ { x=$0; getline; print x, $0}' ns1/named_dump1.db |
101 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
102 # Also make sure the not expired data does not have a stale comment.
103 awk '/; answer/ { x=$0; getline; print x, $0}' ns1/named_dump1.db |
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 status=`expr $status + $ret`
107
108 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 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
113 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 status=`expr $status + $ret`
117
118 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 grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
123 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 status=`expr $status + $ret`
127
128 n=`expr $n + 1`
129 echo_i "running 'rndc serve-stale off' ($n)"
130 ret=0
131 $RNDCCMD 10.53.0.1 serve-stale off || ret=1
132 if [ $ret != 0 ]; then echo_i "failed"; fi
133 status=`expr $status + $ret`
134
135 n=`expr $n + 1`
136 echo_i "check 'rndc serve-stale status' ($n)"
137 ret=0
138 $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 status=`expr $status + $ret`
142
143 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 status=`expr $status + $ret`
152
153 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 status=`expr $status + $ret`
160
161 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 status=`expr $status + $ret`
168
169 n=`expr $n + 1`
170 echo_i "running 'rndc serve-stale on' ($n)"
171 ret=0
172 $RNDCCMD 10.53.0.1 serve-stale on || ret=1
173 if [ $ret != 0 ]; then echo_i "failed"; fi
174 status=`expr $status + $ret`
175
176 n=`expr $n + 1`
177 echo_i "check 'rndc serve-stale status' ($n)"
178 ret=0
179 $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 status=`expr $status + $ret`
183
184 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 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
189 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 status=`expr $status + $ret`
193
194 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 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
199 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 status=`expr $status + $ret`
203
204 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 grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
209 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 status=`expr $status + $ret`
213
214 n=`expr $n + 1`
215 echo_i "running 'rndc serve-stale no' ($n)"
216 ret=0
217 $RNDCCMD 10.53.0.1 serve-stale no || ret=1
218 if [ $ret != 0 ]; then echo_i "failed"; fi
219 status=`expr $status + $ret`
220
221 n=`expr $n + 1`
222 echo_i "check 'rndc serve-stale status' ($n)"
223 ret=0
224 $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 status=`expr $status + $ret`
228
229 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 status=`expr $status + $ret`
236
237 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 status=`expr $status + $ret`
244
245 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 status=`expr $status + $ret`
252
253 n=`expr $n + 1`
254 echo_i "running 'rndc serve-stale yes' ($n)"
255 ret=0
256 $RNDCCMD 10.53.0.1 serve-stale yes || ret=1
257 if [ $ret != 0 ]; then echo_i "failed"; fi
258 status=`expr $status + $ret`
259
260 n=`expr $n + 1`
261 echo_i "check 'rndc serve-stale status' ($n)"
262 ret=0
263 $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 status=`expr $status + $ret`
267
268 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 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
273 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 status=`expr $status + $ret`
277
278 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 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
283 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 status=`expr $status + $ret`
287
288 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 grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
293 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 status=`expr $status + $ret`
297
298 n=`expr $n + 1`
299 echo_i "running 'rndc serve-stale off' ($n)"
300 ret=0
301 $RNDCCMD 10.53.0.1 serve-stale off || ret=1
302 if [ $ret != 0 ]; then echo_i "failed"; fi
303 status=`expr $status + $ret`
304
305 n=`expr $n + 1`
306 echo_i "running 'rndc serve-stale reset' ($n)"
307 ret=0
308 $RNDCCMD 10.53.0.1 serve-stale reset || ret=1
309 if [ $ret != 0 ]; then echo_i "failed"; fi
310 status=`expr $status + $ret`
311
312 n=`expr $n + 1`
313 echo_i "check 'rndc serve-stale status' ($n)"
314 ret=0
315 $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 status=`expr $status + $ret`
319
320 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 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
325 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 status=`expr $status + $ret`
329
330 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 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
335 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 status=`expr $status + $ret`
339
340 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 grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
345 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 status=`expr $status + $ret`
349
350 n=`expr $n + 1`
351 echo_i "running 'rndc serve-stale off' ($n)"
352 ret=0
353 $RNDCCMD 10.53.0.1 serve-stale off || ret=1
354 if [ $ret != 0 ]; then echo_i "failed"; fi
355 status=`expr $status + $ret`
356
357 n=`expr $n + 1`
358 echo_i "check 'rndc serve-stale status' ($n)"
359 ret=0
360 $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 status=`expr $status + $ret`
364
365 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 status=`expr $status + $ret`
371
372 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 status=`expr $status + $ret`
378
379 n=`expr $n + 1`
380 echo_i "check 'rndc serve-stale status' ($n)"
381 ret=0
382 $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 status=`expr $status + $ret`
386
387 n=`expr $n + 1`
388 echo_i "check 'rndc serve-stale' ($n)"
389 ret=0
390 $RNDCCMD 10.53.0.1 serve-stale > rndc.out.test$n 2>&1 && ret=1
391 grep "unexpected end of input" rndc.out.test$n > /dev/null || ret=1
392 if [ $ret != 0 ]; then echo_i "failed"; fi
393 status=`expr $status + $ret`
394
395 n=`expr $n + 1`
396 echo_i "check 'rndc serve-stale unknown' ($n)"
397 ret=0
398 $RNDCCMD 10.53.0.1 serve-stale unknown > rndc.out.test$n 2>&1 && ret=1
399 grep "syntax error" rndc.out.test$n > /dev/null || ret=1
400 if [ $ret != 0 ]; then echo_i "failed"; fi
401 status=`expr $status + $ret`
402
403 n=`expr $n + 1`
404 echo_i "flush cache, re-enable serve-stale and query again ($n)"
405 ret=0
406 $RNDCCMD 10.53.0.1 flushtree example > rndc.out.test$n.1 2>&1 || ret=1
407 $RNDCCMD 10.53.0.1 serve-stale on > rndc.out.test$n.2 2>&1 || ret=1
408 $DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
409 grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
410 grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
411 if [ $ret != 0 ]; then echo_i "failed"; fi
412 status=`expr $status + $ret`
413
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 grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
419 grep "TXT.\"1\"" dig.out.test$n > /dev/null || ret=1
420 if [ $ret != 0 ]; then echo_i "failed"; fi
421 status=`expr $status + $ret`
422
423 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 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
428 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 status=`expr $status + $ret`
432
433 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 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
438 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 status=`expr $status + $ret`
442
443 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 grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
448 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 status=`expr $status + $ret`
452
453 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 grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
458 grep "TXT.\"0\"" dig.out.test$n > /dev/null || ret=1
459 if [ $ret != 0 ]; then echo_i "failed"; fi
460 status=`expr $status + $ret`
461
462 sleep 1
463
464 n=`expr $n + 1`
465 echo_i "check 'rndc serve-stale status' ($n)"
466 ret=0
467 $RNDCCMD 10.53.0.3 serve-stale status > rndc.out.test$n 2>&1 || ret=1
468 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 status=`expr $status + $ret`
471
472 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 grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
477 grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
478 if [ $ret != 0 ]; then echo_i "failed"; fi
479 status=`expr $status + $ret`
480
481 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 grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
486 grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
487 if [ $ret != 0 ]; then echo_i "failed"; fi
488 status=`expr $status + $ret`
489
490 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 grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
495 grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
496 if [ $ret != 0 ]; then echo_i "failed"; fi
497 status=`expr $status + $ret`
498
499 n=`expr $n + 1`
500 echo_i "check 'rndc serve-stale on' ($n)"
501 ret=0
502 $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 status=`expr $status + $ret`
505
506 n=`expr $n + 1`
507 echo_i "check 'rndc serve-stale status' ($n)"
508 ret=0
509 $RNDCCMD 10.53.0.3 serve-stale status > rndc.out.test$n 2>&1 || ret=1
510 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 status=`expr $status + $ret`
513
514 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 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
519 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 status=`expr $status + $ret`
523
524 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 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
529 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 status=`expr $status + $ret`
533
534 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 grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
539 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 status=`expr $status + $ret`
543
544 echo_i "exit status: $status"
545 [ $status -eq 0 ] || exit 1
546