tests.sh 13.6 KB
Newer Older
1 2
#!/bin/sh
#
3
# Copyright (C) 2006-2008, 2011, 2012, 2014, 2015  Internet Systems Consortium, Inc. ("ISC")
Mark Andrews's avatar
Mark Andrews committed
4 5 6 7 8 9 10 11 12 13 14 15
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
16 17 18 19

SYSTEMTESTTOP=..
. $SYSTEMTESTTOP/conf.sh

20 21 22
DIGOPTS="+nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short +nocookie"
DIGCMD="$DIG $DIGOPTS -p 5300"

23 24
status=0

25
if grep "^#define DNS_RDATASET_FIXED" $TOP/config.h > /dev/null 2>&1 ; then
Evan Hunt's avatar
Evan Hunt committed
26 27 28 29 30 31
        test_fixed=true
else
        echo "I: Order 'fixed' disabled at compile time"
        test_fixed=false
fi

32 33 34
#
#
#
Evan Hunt's avatar
Evan Hunt committed
35
if $test_fixed; then
36 37
    echo "I: Checking order fixed (master)"
    ret=0
Evan Hunt's avatar
Evan Hunt committed
38 39
    for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
    do
40
    $DIGCMD @10.53.0.1 fixed.example > dig.out.fixed || ret=1
41
    cmp -s dig.out.fixed dig.out.fixed.good || ret=1
Evan Hunt's avatar
Evan Hunt committed
42 43 44
    done
    if [ $ret != 0 ]; then echo "I:failed"; fi
    status=`expr $status + $ret`
Evan Hunt's avatar
Evan Hunt committed
45 46 47
else
    echo "I: Checking order fixed behaves as cyclic when disabled (master)"
    ret=0
Mark Andrews's avatar
Mark Andrews committed
48
    matches=0
Evan Hunt's avatar
Evan Hunt committed
49 50 51
    for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
    do
        j=`expr $i % 4`
52
	$DIGCMD @10.53.0.1 fixed.example > dig.out.fixed  || ret=1
Evan Hunt's avatar
Evan Hunt committed
53
        if [ $i -le 4 ]; then
Mark Andrews's avatar
Mark Andrews committed
54
            cp dig.out.fixed dig.out.$j
Evan Hunt's avatar
Evan Hunt committed
55 56 57 58 59 60 61 62 63 64 65 66 67
        else
            cmp -s dig.out.fixed dig.out.$j && matches=`expr $matches + 1`
        fi
    done
    cmp -s dig.out.0 dig.out.1 && ret=1
    cmp -s dig.out.0 dig.out.2 && ret=1
    cmp -s dig.out.0 dig.out.3 && ret=1
    cmp -s dig.out.1 dig.out.2 && ret=1
    cmp -s dig.out.1 dig.out.3 && ret=1
    cmp -s dig.out.2 dig.out.3 && ret=1
    if [ $matches -ne 16 ]; then ret=1; fi
    if [ $ret != 0 ]; then echo "I:failed"; fi
    status=`expr $status + $ret`
Evan Hunt's avatar
Evan Hunt committed
68
fi
69 70 71 72

#
#
#
73
echo "I: Checking order cyclic (master + additional)"
74
ret=0
75 76
matches=0
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
77
do
78
    j=`expr $i % 4`
79
    $DIGCMD @10.53.0.1 cyclic.example > dig.out.cyclic || ret=1
80 81 82 83 84
    if [ $i -le 4 ]; then
        cp dig.out.cyclic dig.out.$j
    else
        cmp -s dig.out.cyclic dig.out.$j && matches=`expr $matches + 1`
    fi
85
done
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
cmp -s dig.out.0 dig.out.1 && ret=1
cmp -s dig.out.0 dig.out.2 && ret=1
cmp -s dig.out.0 dig.out.3 && ret=1
cmp -s dig.out.1 dig.out.2 && ret=1
cmp -s dig.out.1 dig.out.3 && ret=1
cmp -s dig.out.2 dig.out.3 && ret=1
if [ $matches -ne 16 ]; then ret=1; fi
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

#
#
#
echo "I: Checking order cyclic (master)"
ret=0
matches=0
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
103
do
104
    j=`expr $i % 4`
105
    $DIGCMD @10.53.0.1 cyclic2.example > dig.out.cyclic2 || ret=1
106 107 108 109 110
    if [ $i -le 4 ]; then
        cp dig.out.cyclic2 dig.out.$j
    else
        cmp -s dig.out.cyclic2 dig.out.$j && matches=`expr $matches + 1`
    fi
111
done
112 113 114 115 116 117 118
cmp -s dig.out.0 dig.out.1 && ret=1
cmp -s dig.out.0 dig.out.2 && ret=1
cmp -s dig.out.0 dig.out.3 && ret=1
cmp -s dig.out.1 dig.out.2 && ret=1
cmp -s dig.out.1 dig.out.3 && ret=1
cmp -s dig.out.2 dig.out.3 && ret=1
if [ $matches -ne 16 ]; then ret=1; fi
119 120
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`
121
echo "I: Checking order random (master)"
122 123 124 125 126 127 128
ret=0
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
do
	eval match$i=0
done
for 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
do
129
	$DIGCMD @10.53.0.1 random.example > dig.out.random || ret=1
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
	match=0
	for j in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
	do
		eval "cmp -s dig.out.random dig.out.random.good$j && match$j=1 match=1"
		if [ $match -eq 1 ]; then break; fi
	done
	if [ $match -eq 0 ]; then ret=1; fi
done
match=0
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
do
	eval "match=\`expr \$match + \$match$i\`"
done
echo "I: Random selection return $match of 24 possible orders in 36 samples"
if [ $match -lt 8 ]; then echo ret=1; fi
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

#
#
#
Evan Hunt's avatar
Evan Hunt committed
151
if $test_fixed; then
152
    echo "I: Checking order fixed (slave)"
Evan Hunt's avatar
Evan Hunt committed
153 154 155
    ret=0
    for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
    do
156
    $DIGCMD @10.53.0.2 fixed.example > dig.out.fixed || ret=1
157
    cmp -s dig.out.fixed dig.out.fixed.good || ret=1
Evan Hunt's avatar
Evan Hunt committed
158 159 160 161
    done
    if [ $ret != 0 ]; then echo "I:failed"; fi
    status=`expr $status + $ret`
fi
162 163 164 165

#
#
#
166
echo "I: Checking order cyclic (slave + additional)"
167
ret=0
168 169
matches=0
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
170
do
171
    j=`expr $i % 4`
172
    $DIGCMD @10.53.0.2 cyclic.example > dig.out.cyclic || ret=1
173 174 175 176 177
    if [ $i -le 4 ]; then
        cp dig.out.cyclic dig.out.$j
    else
        cmp -s dig.out.cyclic dig.out.$j && matches=`expr $matches + 1`
    fi
178
done
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
cmp -s dig.out.0 dig.out.1 && ret=1
cmp -s dig.out.0 dig.out.2 && ret=1
cmp -s dig.out.0 dig.out.3 && ret=1
cmp -s dig.out.1 dig.out.2 && ret=1
cmp -s dig.out.1 dig.out.3 && ret=1
cmp -s dig.out.2 dig.out.3 && ret=1
if [ $matches -ne 16 ]; then ret=1; fi
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

#
#
#
echo "I: Checking order cyclic (slave)"
ret=0
matches=0
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
196
do
197
    j=`expr $i % 4`
198
    $DIGCMD @10.53.0.2 cyclic2.example > dig.out.cyclic2 || ret=1
199 200 201 202 203
    if [ $i -le 4 ]; then
        cp dig.out.cyclic2 dig.out.$j
    else
        cmp -s dig.out.cyclic2 dig.out.$j && matches=`expr $matches + 1`
    fi
204
done
205 206 207 208 209 210 211
cmp -s dig.out.0 dig.out.1 && ret=1
cmp -s dig.out.0 dig.out.2 && ret=1
cmp -s dig.out.0 dig.out.3 && ret=1
cmp -s dig.out.1 dig.out.2 && ret=1
cmp -s dig.out.1 dig.out.3 && ret=1
cmp -s dig.out.2 dig.out.3 && ret=1
if [ $matches -ne 16 ]; then ret=1; fi
212 213 214
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

215
echo "I: Checking order random (slave)"
216 217 218 219 220 221 222
ret=0
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
do
	eval match$i=0
done
for 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
do
223
$DIGCMD @10.53.0.2 random.example > dig.out.random || ret=1
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
	match=0
	for j in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
	do
		eval "cmp -s dig.out.random dig.out.random.good$j && match$j=1 match=1"
		if [ $match -eq 1 ]; then break; fi
	done
	if [ $match -eq 0 ]; then ret=1; fi
done
match=0
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
do
eval "match=\`expr \$match + \$match$i\`"
done
echo "I: Random selection return $match of 24 possible orders in 36 samples"
if [ $match -lt 8 ]; then echo ret=1; fi
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

echo "I: Shutting down slave"

244
(cd ..; $SHELL stop.sh rrsetorder ns2 )
245

246
echo "I: Checking for slave's on disk copy of zone"
247 248 249 250 251 252 253 254 255

if [ ! -f ns2/root.bk ]
then
	echo "I:failed";
	status=`expr $status + 1`
fi

echo "I: Re-starting slave"

256
(cd ..; $SHELL start.sh --noclean rrsetorder ns2 )
257 258 259 260

#
#
#
Evan Hunt's avatar
Evan Hunt committed
261
if $test_fixed; then
262 263
    echo "I: Checking order fixed (slave loaded from disk)"
    ret=0
Evan Hunt's avatar
Evan Hunt committed
264 265
    for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
    do
266
    $DIGCMD @10.53.0.2 fixed.example > dig.out.fixed || ret=1
267
    cmp -s dig.out.fixed dig.out.fixed.good || ret=1
Evan Hunt's avatar
Evan Hunt committed
268 269 270 271
    done
    if [ $ret != 0 ]; then echo "I:failed"; fi
    status=`expr $status + $ret`
fi
272 273 274 275

#
#
#
276
echo "I: Checking order cyclic (slave + additional, loaded from disk)"
277
ret=0
278 279
matches=0
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
280
do
281
    j=`expr $i % 4`
282
    $DIGCMD @10.53.0.2 cyclic.example > dig.out.cyclic || ret=1
283 284 285 286 287
    if [ $i -le 4 ]; then
        cp dig.out.cyclic dig.out.$j
    else
        cmp -s dig.out.cyclic dig.out.$j && matches=`expr $matches + 1`
    fi
288
done
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
cmp -s dig.out.0 dig.out.1 && ret=1
cmp -s dig.out.0 dig.out.2 && ret=1
cmp -s dig.out.0 dig.out.3 && ret=1
cmp -s dig.out.1 dig.out.2 && ret=1
cmp -s dig.out.1 dig.out.3 && ret=1
cmp -s dig.out.2 dig.out.3 && ret=1
if [ $matches -ne 16 ]; then ret=1; fi
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

#
#
#
echo "I: Checking order cyclic (slave loaded from disk)"
ret=0
matches=0
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
306
do
307
    j=`expr $i % 4`
308
    $DIGCMD @10.53.0.2 cyclic2.example > dig.out.cyclic2 || ret=1
309 310 311 312 313
    if [ $i -le 4 ]; then
        cp dig.out.cyclic2 dig.out.$j
    else
        cmp -s dig.out.cyclic2 dig.out.$j && matches=`expr $matches + 1`
    fi
314
done
315 316 317 318 319 320 321
cmp -s dig.out.0 dig.out.1 && ret=1
cmp -s dig.out.0 dig.out.2 && ret=1
cmp -s dig.out.0 dig.out.3 && ret=1
cmp -s dig.out.1 dig.out.2 && ret=1
cmp -s dig.out.1 dig.out.3 && ret=1
cmp -s dig.out.2 dig.out.3 && ret=1
if [ $matches -ne 16 ]; then ret=1; fi
322 323 324
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

325
echo "I: Checking order random (slave loaded from disk)"
326 327 328 329 330 331 332
ret=0
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
do
	eval match$i=0
done
for 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
do
333
	$DIGCMD @10.53.0.2 random.example > dig.out.random || ret=1
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354
	match=0
	for j in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
	do
		eval "cmp -s dig.out.random dig.out.random.good$j && match$j=1 match=1"
		if [ $match -eq 1 ]; then break; fi
	done
	if [ $match -eq 0 ]; then ret=1; fi
done
match=0
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
do
eval "match=\`expr \$match + \$match$i\`"
done
echo "I: Random selection return $match of 24 possible orders in 36 samples"
if [ $match -lt 8 ]; then echo ret=1; fi
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

#
#
#
Evan Hunt's avatar
Evan Hunt committed
355
if $test_fixed; then
356
    echo "I: Checking order fixed (cache)"
Evan Hunt's avatar
Evan Hunt committed
357 358 359
    ret=0
    for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
    do
360
    $DIGCMD @10.53.0.3 fixed.example > dig.out.fixed || ret=1
361
    cmp -s dig.out.fixed dig.out.fixed.good || ret=1
Evan Hunt's avatar
Evan Hunt committed
362 363 364 365
    done
    if [ $ret != 0 ]; then echo "I:failed"; fi
    status=`expr $status + $ret`
fi
366 367 368 369

#
#
#
370
echo "I: Checking order cyclic (cache + additional)"
371
ret=0
372
# prime acache
373
$DIGCMD @10.53.0.3 cyclic.example > dig.out.cyclic || ret=1
374 375
matches=0
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
376
do
377
    j=`expr $i % 4`
378
    $DIGCMD @10.53.0.3 cyclic.example > dig.out.cyclic || ret=1
379 380 381 382 383
    if [ $i -le 4 ]; then
        cp dig.out.cyclic dig.out.$j
    else
        cmp -s dig.out.cyclic dig.out.$j && matches=`expr $matches + 1`
    fi
384
done
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400
cmp -s dig.out.0 dig.out.1 && ret=1
cmp -s dig.out.0 dig.out.2 && ret=1
cmp -s dig.out.0 dig.out.3 && ret=1
cmp -s dig.out.1 dig.out.2 && ret=1
cmp -s dig.out.1 dig.out.3 && ret=1
cmp -s dig.out.2 dig.out.3 && ret=1
if [ $matches -ne 16 ]; then ret=1; fi
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

#
#
#
echo "I: Checking order cyclic (cache)"
ret=0
# prime acache
401
$DIGCMD @10.53.0.3 cyclic2.example > dig.out.cyclic2 || ret=1
402 403
matches=0
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
404
do
405
    j=`expr $i % 4`
406
    $DIGCMD @10.53.0.3 cyclic2.example > dig.out.cyclic2 || ret=1
407 408 409 410 411
    if [ $i -le 4 ]; then
        cp dig.out.cyclic2 dig.out.$j
    else
        cmp -s dig.out.cyclic2 dig.out.$j && matches=`expr $matches + 1`
    fi
412
done
413 414 415 416 417 418 419
cmp -s dig.out.0 dig.out.1 && ret=1
cmp -s dig.out.0 dig.out.2 && ret=1
cmp -s dig.out.0 dig.out.3 && ret=1
cmp -s dig.out.1 dig.out.2 && ret=1
cmp -s dig.out.1 dig.out.3 && ret=1
cmp -s dig.out.2 dig.out.3 && ret=1
if [ $matches -ne 16 ]; then ret=1; fi
420 421 422
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`

423
echo "I: Checking order random (cache)"
424 425 426 427 428 429 430
ret=0
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
do
	eval match$i=0
done
for 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
do
431
	$DIGCMD @10.53.0.3 random.example > dig.out.random || ret=1
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448
	match=0
	for j in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
	do
		eval "cmp -s dig.out.random dig.out.random.good$j && match$j=1 match=1"
		if [ $match -eq 1 ]; then break; fi
	done
	if [ $match -eq 0 ]; then ret=1; fi
done
match=0
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
do
eval "match=\`expr \$match + \$match$i\`"
done
echo "I: Random selection return $match of 24 possible orders in 36 samples"
if [ $match -lt 8 ]; then echo ret=1; fi
if [ $ret != 0 ]; then echo "I:failed"; fi

449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475
echo "I: Checking default order no match in rrset-order (random)"
ret=0
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
do
	eval match$i=0
done
for 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
do
$DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \
	-p 5300 @10.53.0.4 random.example > dig.out.random|| ret=1
	match=0
	for j in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
	do
		eval "cmp -s dig.out.random dig.out.random.good$j && match$j=1 match=1"
		if [ $match -eq 1 ]; then break; fi
	done
	if [ $match -eq 0 ]; then ret=1; fi
done
match=0
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
do
eval "match=\`expr \$match + \$match$i\`"
done
echo "I: Random selection return $match of 24 possible orders in 36 samples"
if [ $match -lt 8 ]; then echo ret=1; fi
if [ $ret != 0 ]; then echo "I:failed"; fi

476 477
status=`expr $status + $ret`
echo "I:exit status: $status"
478
[ $status -eq 0 ] || exit 1