xref: /netbsd-src/external/mpl/bind/dist/bin/tests/system/rrsetorder/tests.sh (revision 33881f779a77dce6440bdc44610d94de75bebefe)
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
12SYSTEMTESTTOP=..
13. $SYSTEMTESTTOP/conf.sh
14
15DIGOPTS="+nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short +nocookie"
16DIGCMD="$DIG $DIGOPTS -p ${PORT}"
17
18status=0
19
20GOOD_RANDOM="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24"
21GOOD_RANDOM_NO=24
22
23if grep "^#define DNS_RDATASET_FIXED" $TOP/config.h > /dev/null 2>&1 ; then
24    test_fixed=true
25else
26    echo_i "Order 'fixed' disabled at compile time"
27    test_fixed=false
28fi
29
30#
31#
32#
33if $test_fixed; then
34    echo_i "Checking order fixed (master)"
35    ret=0
36    for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
37    do
38    $DIGCMD @10.53.0.1 fixed.example > dig.out.fixed || ret=1
39    $DIFF dig.out.fixed dig.out.fixed.good >/dev/null || ret=1
40    done
41    if [ $ret != 0 ]; then echo_i "failed"; fi
42    status=`expr $status + $ret`
43else
44    echo_i "Checking order fixed behaves as cyclic when disabled (master)"
45    ret=0
46    matches=0
47    for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
48    do
49        j=`expr $i % 4`
50	$DIGCMD @10.53.0.1 fixed.example > dig.out.fixed  || ret=1
51        if [ $i -le 4 ]; then
52            cp dig.out.fixed dig.out.$j
53        else
54            $DIFF dig.out.fixed dig.out.$j >/dev/null && matches=`expr $matches + 1`
55        fi
56    done
57    $DIFF dig.out.0 dig.out.1 >/dev/null && ret=1
58    $DIFF dig.out.0 dig.out.2 >/dev/null && ret=1
59    $DIFF dig.out.0 dig.out.3 >/dev/null && ret=1
60    $DIFF dig.out.1 dig.out.2 >/dev/null && ret=1
61    $DIFF dig.out.1 dig.out.3 >/dev/null && ret=1
62    $DIFF dig.out.2 dig.out.3 >/dev/null && ret=1
63    if [ $matches -ne 16 ]; then ret=1; fi
64    if [ $ret != 0 ]; then echo_i "failed"; fi
65    status=`expr $status + $ret`
66fi
67
68#
69#
70#
71echo_i "Checking order cyclic (master + additional)"
72ret=0
73matches=0
74for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
75do
76    j=`expr $i % 4`
77    $DIGCMD @10.53.0.1 cyclic.example > dig.out.cyclic || ret=1
78    if [ $i -le 4 ]; then
79        cp dig.out.cyclic dig.out.$j
80    else
81        $DIFF dig.out.cyclic dig.out.$j >/dev/null && matches=`expr $matches + 1`
82    fi
83done
84$DIFF dig.out.0 dig.out.1 >/dev/null && ret=1
85$DIFF dig.out.0 dig.out.2 >/dev/null && ret=1
86$DIFF dig.out.0 dig.out.3 >/dev/null && ret=1
87$DIFF dig.out.1 dig.out.2 >/dev/null && ret=1
88$DIFF dig.out.1 dig.out.3 >/dev/null && ret=1
89$DIFF dig.out.2 dig.out.3 >/dev/null && ret=1
90if [ $matches -ne 16 ]; then ret=1; fi
91if [ $ret != 0 ]; then echo_i "failed"; fi
92status=`expr $status + $ret`
93
94#
95#
96#
97echo_i "Checking order cyclic (master)"
98ret=0
99matches=0
100for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
101do
102    j=`expr $i % 4`
103    $DIGCMD @10.53.0.1 cyclic2.example > dig.out.cyclic2 || ret=1
104    if [ $i -le 4 ]; then
105        cp dig.out.cyclic2 dig.out.$j
106    else
107        $DIFF dig.out.cyclic2 dig.out.$j >/dev/null && matches=`expr $matches + 1`
108    fi
109done
110$DIFF dig.out.0 dig.out.1 >/dev/null && ret=1
111$DIFF dig.out.0 dig.out.2 >/dev/null && ret=1
112$DIFF dig.out.0 dig.out.3 >/dev/null && ret=1
113$DIFF dig.out.1 dig.out.2 >/dev/null && ret=1
114$DIFF dig.out.1 dig.out.3 >/dev/null && ret=1
115$DIFF dig.out.2 dig.out.3 >/dev/null && ret=1
116if [ $matches -ne 16 ]; then ret=1; fi
117if [ $ret != 0 ]; then echo_i "failed"; fi
118status=`expr $status + $ret`
119echo_i "Checking order random (master)"
120ret=0
121for i in $GOOD_RANDOM
122do
123	eval match$i=0
124done
125for i in a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 9
126do
127    $DIGCMD @10.53.0.1 random.example > dig.out.random || ret=1
128    match=0
129    for j in $GOOD_RANDOM
130    do
131	eval "$DIFF dig.out.random dig.out.random.good$j >/dev/null && match$j=1 match=1"
132	if [ $match -eq 1 ]; then break; fi
133    done
134    if [ $match -eq 0 ]; then ret=1; fi
135done
136match=0
137for i in $GOOD_RANDOM
138do
139	eval "match=\`expr \$match + \$match$i\`"
140done
141echo_i "Random selection return $match of ${GOOD_RANDOM_NO} possible orders in 36 samples"
142if [ $match -lt `expr ${GOOD_RANDOM_NO} / 3` ]; then ret=1; fi
143if [ $ret != 0 ]; then echo_i "failed"; fi
144status=`expr $status + $ret`
145
146#
147#
148#
149if $test_fixed; then
150    echo_i "Checking order fixed (slave)"
151    ret=0
152    for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
153    do
154    $DIGCMD @10.53.0.2 fixed.example > dig.out.fixed || ret=1
155    $DIFF dig.out.fixed dig.out.fixed.good || ret=1
156    done
157    if [ $ret != 0 ]; then echo_i "failed"; fi
158    status=`expr $status + $ret`
159fi
160
161#
162#
163#
164echo_i "Checking order cyclic (slave + additional)"
165ret=0
166matches=0
167for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
168do
169    j=`expr $i % 4`
170    $DIGCMD @10.53.0.2 cyclic.example > dig.out.cyclic || ret=1
171    if [ $i -le 4 ]; then
172        cp dig.out.cyclic dig.out.$j
173    else
174        $DIFF dig.out.cyclic dig.out.$j >/dev/null && matches=`expr $matches + 1`
175    fi
176done
177$DIFF dig.out.0 dig.out.1 >/dev/null && ret=1
178$DIFF dig.out.0 dig.out.2 >/dev/null && ret=1
179$DIFF dig.out.0 dig.out.3 >/dev/null && ret=1
180$DIFF dig.out.1 dig.out.2 >/dev/null && ret=1
181$DIFF dig.out.1 dig.out.3 >/dev/null && ret=1
182$DIFF dig.out.2 dig.out.3 >/dev/null && ret=1
183if [ $matches -ne 16 ]; then ret=1; fi
184if [ $ret != 0 ]; then echo_i "failed"; fi
185status=`expr $status + $ret`
186
187#
188#
189#
190echo_i "Checking order cyclic (slave)"
191ret=0
192matches=0
193for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
194do
195    j=`expr $i % 4`
196    $DIGCMD @10.53.0.2 cyclic2.example > dig.out.cyclic2 || ret=1
197    if [ $i -le 4 ]; then
198        cp dig.out.cyclic2 dig.out.$j
199    else
200        $DIFF dig.out.cyclic2 dig.out.$j >/dev/null && matches=`expr $matches + 1`
201    fi
202done
203$DIFF dig.out.0 dig.out.1 >/dev/null && ret=1
204$DIFF dig.out.0 dig.out.2 >/dev/null && ret=1
205$DIFF dig.out.0 dig.out.3 >/dev/null && ret=1
206$DIFF dig.out.1 dig.out.2 >/dev/null && ret=1
207$DIFF dig.out.1 dig.out.3 >/dev/null && ret=1
208$DIFF dig.out.2 dig.out.3 >/dev/null && ret=1
209if [ $matches -ne 16 ]; then ret=1; fi
210if [ $ret != 0 ]; then echo_i "failed"; fi
211status=`expr $status + $ret`
212
213echo_i "Checking order random (slave)"
214ret=0
215for i in $GOOD_RANDOM
216do
217	eval match$i=0
218done
219for i in a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 9
220do
221    $DIGCMD @10.53.0.2 random.example > dig.out.random || ret=1
222    match=0
223    for j in $GOOD_RANDOM
224    do
225	eval "$DIFF dig.out.random dig.out.random.good$j >/dev/null && match$j=1 match=1"
226	if [ $match -eq 1 ]; then break; fi
227    done
228    if [ $match -eq 0 ]; then ret=1; fi
229done
230match=0
231for i in $GOOD_RANDOM
232do
233eval "match=\`expr \$match + \$match$i\`"
234done
235echo_i "Random selection return $match of ${GOOD_RANDOM_NO} possible orders in 36 samples"
236if [ $match -lt `expr ${GOOD_RANDOM_NO} / 3` ]; then ret=1; fi
237if [ $ret != 0 ]; then echo_i "failed"; fi
238status=`expr $status + $ret`
239
240echo_i "Shutting down slave"
241
242(cd ..; $SHELL stop.sh rrsetorder ns2 )
243
244echo_i "Checking for slave's on disk copy of zone"
245
246if [ ! -f ns2/root.bk ]
247then
248	echo_i "failed";
249	status=`expr $status + 1`
250fi
251
252echo_i "Re-starting slave"
253
254$PERL $SYSTEMTESTTOP/start.pl --noclean --port ${PORT} rrsetorder ns2
255
256#
257#
258#
259if $test_fixed; then
260    echo_i "Checking order fixed (slave loaded from disk)"
261    ret=0
262    for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
263    do
264    $DIGCMD @10.53.0.2 fixed.example > dig.out.fixed || ret=1
265    $DIFF dig.out.fixed dig.out.fixed.good || ret=1
266    done
267    if [ $ret != 0 ]; then echo_i "failed"; fi
268    status=`expr $status + $ret`
269fi
270
271#
272#
273#
274echo_i "Checking order cyclic (slave + additional, loaded from disk)"
275ret=0
276matches=0
277for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
278do
279    j=`expr $i % 4`
280    $DIGCMD @10.53.0.2 cyclic.example > dig.out.cyclic || ret=1
281    if [ $i -le 4 ]; then
282        cp dig.out.cyclic dig.out.$j
283    else
284        $DIFF dig.out.cyclic dig.out.$j >/dev/null && matches=`expr $matches + 1`
285    fi
286done
287$DIFF dig.out.0 dig.out.1 >/dev/null && ret=1
288$DIFF dig.out.0 dig.out.2 >/dev/null && ret=1
289$DIFF dig.out.0 dig.out.3 >/dev/null && ret=1
290$DIFF dig.out.1 dig.out.2 >/dev/null && ret=1
291$DIFF dig.out.1 dig.out.3 >/dev/null && ret=1
292$DIFF dig.out.2 dig.out.3 >/dev/null && ret=1
293if [ $matches -ne 16 ]; then ret=1; fi
294if [ $ret != 0 ]; then echo_i "failed"; fi
295status=`expr $status + $ret`
296
297#
298#
299#
300echo_i "Checking order cyclic (slave loaded from disk)"
301ret=0
302matches=0
303for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
304do
305    j=`expr $i % 4`
306    $DIGCMD @10.53.0.2 cyclic2.example > dig.out.cyclic2 || ret=1
307    if [ $i -le 4 ]; then
308        cp dig.out.cyclic2 dig.out.$j
309    else
310        $DIFF dig.out.cyclic2 dig.out.$j >/dev/null && matches=`expr $matches + 1`
311    fi
312done
313$DIFF dig.out.0 dig.out.1 >/dev/null && ret=1
314$DIFF dig.out.0 dig.out.2 >/dev/null && ret=1
315$DIFF dig.out.0 dig.out.3 >/dev/null && ret=1
316$DIFF dig.out.1 dig.out.2 >/dev/null && ret=1
317$DIFF dig.out.1 dig.out.3 >/dev/null && ret=1
318$DIFF dig.out.2 dig.out.3 >/dev/null && ret=1
319if [ $matches -ne 16 ]; then ret=1; fi
320if [ $ret != 0 ]; then echo_i "failed"; fi
321status=`expr $status + $ret`
322
323echo_i "Checking order random (slave loaded from disk)"
324ret=0
325for i in $GOOD_RANDOM
326do
327	eval match$i=0
328done
329for i in a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 9
330do
331	$DIGCMD @10.53.0.2 random.example > dig.out.random || ret=1
332	match=0
333	for j in $GOOD_RANDOM
334	do
335		eval "$DIFF dig.out.random dig.out.random.good$j >/dev/null && match$j=1 match=1"
336		if [ $match -eq 1 ]; then break; fi
337	done
338	if [ $match -eq 0 ]; then ret=1; fi
339done
340match=0
341for i in $GOOD_RANDOM
342do
343eval "match=\`expr \$match + \$match$i\`"
344done
345echo_i "Random selection return $match of ${GOOD_RANDOM_NO} possible orders in 36 samples"
346if [ $match -lt `expr ${GOOD_RANDOM_NO} / 3` ]; then ret=1; fi
347if [ $ret != 0 ]; then echo_i "failed"; fi
348status=`expr $status + $ret`
349
350#
351#
352#
353if $test_fixed; then
354    echo_i "Checking order fixed (cache)"
355    ret=0
356    for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
357    do
358    $DIGCMD @10.53.0.3 fixed.example > dig.out.fixed || ret=1
359    $DIFF dig.out.fixed dig.out.fixed.good || ret=1
360    done
361    if [ $ret != 0 ]; then echo_i "failed"; fi
362    status=`expr $status + $ret`
363fi
364
365#
366#
367#
368echo_i "Checking order cyclic (cache + additional)"
369ret=0
370# prime acache
371$DIGCMD @10.53.0.3 cyclic.example > dig.out.cyclic || ret=1
372matches=0
373for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
374do
375    j=`expr $i % 4`
376    $DIGCMD @10.53.0.3 cyclic.example > dig.out.cyclic || ret=1
377    if [ $i -le 4 ]; then
378        cp dig.out.cyclic dig.out.$j
379    else
380        $DIFF dig.out.cyclic dig.out.$j >/dev/null && matches=`expr $matches + 1`
381    fi
382done
383$DIFF dig.out.0 dig.out.1 >/dev/null && ret=1
384$DIFF dig.out.0 dig.out.2 >/dev/null && ret=1
385$DIFF dig.out.0 dig.out.3 >/dev/null && ret=1
386$DIFF dig.out.1 dig.out.2 >/dev/null && ret=1
387$DIFF dig.out.1 dig.out.3 >/dev/null && ret=1
388$DIFF dig.out.2 dig.out.3 >/dev/null && ret=1
389if [ $matches -ne 16 ]; then ret=1; fi
390if [ $ret != 0 ]; then echo_i "failed"; fi
391status=`expr $status + $ret`
392
393#
394#
395#
396echo_i "Checking order cyclic (cache)"
397ret=0
398# prime acache
399$DIGCMD @10.53.0.3 cyclic2.example > dig.out.cyclic2 || ret=1
400matches=0
401for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
402do
403    j=`expr $i % 4`
404    $DIGCMD @10.53.0.3 cyclic2.example > dig.out.cyclic2 || ret=1
405    if [ $i -le 4 ]; then
406        cp dig.out.cyclic2 dig.out.$j
407    else
408        $DIFF dig.out.cyclic2 dig.out.$j >/dev/null && matches=`expr $matches + 1`
409    fi
410done
411$DIFF dig.out.0 dig.out.1 >/dev/null && ret=1
412$DIFF dig.out.0 dig.out.2 >/dev/null && ret=1
413$DIFF dig.out.0 dig.out.3 >/dev/null && ret=1
414$DIFF dig.out.1 dig.out.2 >/dev/null && ret=1
415$DIFF dig.out.1 dig.out.3 >/dev/null && ret=1
416$DIFF dig.out.2 dig.out.3 >/dev/null && ret=1
417if [ $matches -ne 16 ]; then ret=1; fi
418if [ $ret != 0 ]; then echo_i "failed"; fi
419status=`expr $status + $ret`
420
421echo_i "Checking order random (cache)"
422ret=0
423for i in $GOOD_RANDOM
424do
425	eval match$i=0
426done
427for i in a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 9
428do
429	$DIGCMD @10.53.0.3 random.example > dig.out.random || ret=1
430	match=0
431	for j in $GOOD_RANDOM
432	do
433		eval "$DIFF dig.out.random dig.out.random.good$j >/dev/null && match$j=1 match=1"
434		if [ $match -eq 1 ]; then break; fi
435	done
436	if [ $match -eq 0 ]; then ret=1; fi
437done
438match=0
439for i in $GOOD_RANDOM
440do
441eval "match=\`expr \$match + \$match$i\`"
442done
443echo_i "Random selection return $match of ${GOOD_RANDOM_NO} possible orders in 36 samples"
444if [ $match -lt `expr ${GOOD_RANDOM_NO} / 3` ]; then ret=1; fi
445if [ $ret != 0 ]; then echo_i "failed"; fi
446
447echo_i "Checking default order (cache)"
448ret=0
449for i in $GOOD_RANDOM
450do
451	eval match$i=0
452done
453for i in a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 9
454do
455	$DIGCMD @10.53.0.5 random.example > dig.out.random || ret=1
456	match=0
457	for j in $GOOD_RANDOM
458	do
459		eval "$DIFF dig.out.random dig.out.random.good$j >/dev/null && match$j=1 match=1"
460		if [ $match -eq 1 ]; then break; fi
461	done
462	if [ $match -eq 0 ]; then ret=1; fi
463done
464match=0
465for i in $GOOD_RANDOM
466do
467eval "match=\`expr \$match + \$match$i\`"
468done
469echo_i "Default selection return $match of ${GOOD_RANDOM_NO} possible orders in 36 samples"
470if [ $match -lt `expr ${GOOD_RANDOM_NO} / 3` ]; then ret=1; fi
471if [ $ret != 0 ]; then echo_i "failed"; fi
472
473echo_i "Checking default order no match in rrset-order (no shuffling)"
474ret=0
475for i in $GOOD_RANDOM
476do
477	eval match$i=0
478done
479for i in a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 9
480do
481$DIGCMD @10.53.0.4 nomatch.example > dig.out.nomatch|| ret=1
482	match=0
483	for j in $GOOD_RANDOM
484	do
485		eval "$DIFF dig.out.nomatch dig.out.random.good$j >/dev/null && match$j=1 match=1"
486		if [ $match -eq 1 ]; then break; fi
487	done
488	if [ $match -eq 0 ]; then ret=1; fi
489done
490match=0
491for i in $GOOD_RANDOM
492do
493eval "match=\`expr \$match + \$match$i\`"
494done
495echo_i "Consistent selection return $match of ${GOOD_RANDOM_NO} possible orders in 36 samples"
496if [ $match -ne 1 ]; then ret=1; fi
497if [ $ret != 0 ]; then echo_i "failed"; fi
498
499status=`expr $status + $ret`
500echo_i "exit status: $status"
501[ $status -eq 0 ] || exit 1
502