1e2b1b9c0Schristos#!/bin/sh 2e2b1b9c0Schristos# 3e2b1b9c0Schristos# Copyright (C) Internet Systems Consortium, Inc. ("ISC") 4e2b1b9c0Schristos# 5e2b1b9c0Schristos# This Source Code Form is subject to the terms of the Mozilla Public 6e2b1b9c0Schristos# License, v. 2.0. If a copy of the MPL was not distributed with this 7*8260f9a8Schristos# file, you can obtain one at https://mozilla.org/MPL/2.0/. 8e2b1b9c0Schristos# 9e2b1b9c0Schristos# See the COPYRIGHT file distributed with this work for additional 10e2b1b9c0Schristos# information regarding copyright ownership. 11e2b1b9c0Schristos 12e2b1b9c0SchristosSYSTEMTESTTOP=.. 13e2b1b9c0Schristos. $SYSTEMTESTTOP/conf.sh 14e2b1b9c0Schristos 15e2b1b9c0SchristosDIGOPTS="+nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short +nocookie" 16e2b1b9c0SchristosDIGCMD="$DIG $DIGOPTS -p ${PORT}" 17e2b1b9c0Schristos 18e2b1b9c0Schristosstatus=0 19e2b1b9c0Schristos 203daf698fSchristosGOOD_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" 213daf698fSchristosGOOD_RANDOM_NO=24 223daf698fSchristos 23e2b1b9c0Schristosif grep "^#define DNS_RDATASET_FIXED" $TOP/config.h > /dev/null 2>&1 ; then 24e2b1b9c0Schristos test_fixed=true 25e2b1b9c0Schristoselse 26e2b1b9c0Schristos echo_i "Order 'fixed' disabled at compile time" 27e2b1b9c0Schristos test_fixed=false 28e2b1b9c0Schristosfi 29e2b1b9c0Schristos 30e2b1b9c0Schristos# 31e2b1b9c0Schristos# 32e2b1b9c0Schristos# 33e2b1b9c0Schristosif $test_fixed; then 34*8260f9a8Schristos echo_i "Checking order fixed (primary)" 35e2b1b9c0Schristos ret=0 36e2b1b9c0Schristos for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 37e2b1b9c0Schristos do 38e2b1b9c0Schristos $DIGCMD @10.53.0.1 fixed.example > dig.out.fixed || ret=1 39e2b1b9c0Schristos $DIFF dig.out.fixed dig.out.fixed.good >/dev/null || ret=1 40e2b1b9c0Schristos done 41e2b1b9c0Schristos if [ $ret != 0 ]; then echo_i "failed"; fi 42e2b1b9c0Schristos status=`expr $status + $ret` 43e2b1b9c0Schristoselse 44*8260f9a8Schristos echo_i "Checking order fixed behaves as cyclic when disabled (primary)" 45e2b1b9c0Schristos ret=0 46e2b1b9c0Schristos matches=0 47e2b1b9c0Schristos for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 48e2b1b9c0Schristos do 49e2b1b9c0Schristos j=`expr $i % 4` 50e2b1b9c0Schristos $DIGCMD @10.53.0.1 fixed.example > dig.out.fixed || ret=1 51e2b1b9c0Schristos if [ $i -le 4 ]; then 52e2b1b9c0Schristos cp dig.out.fixed dig.out.$j 53e2b1b9c0Schristos else 54e2b1b9c0Schristos $DIFF dig.out.fixed dig.out.$j >/dev/null && matches=`expr $matches + 1` 55e2b1b9c0Schristos fi 56e2b1b9c0Schristos done 57e2b1b9c0Schristos $DIFF dig.out.0 dig.out.1 >/dev/null && ret=1 58e2b1b9c0Schristos $DIFF dig.out.0 dig.out.2 >/dev/null && ret=1 59e2b1b9c0Schristos $DIFF dig.out.0 dig.out.3 >/dev/null && ret=1 60e2b1b9c0Schristos $DIFF dig.out.1 dig.out.2 >/dev/null && ret=1 61e2b1b9c0Schristos $DIFF dig.out.1 dig.out.3 >/dev/null && ret=1 62e2b1b9c0Schristos $DIFF dig.out.2 dig.out.3 >/dev/null && ret=1 63e2b1b9c0Schristos if [ $matches -ne 16 ]; then ret=1; fi 64e2b1b9c0Schristos if [ $ret != 0 ]; then echo_i "failed"; fi 65e2b1b9c0Schristos status=`expr $status + $ret` 66e2b1b9c0Schristosfi 67e2b1b9c0Schristos 68e2b1b9c0Schristos# 69e2b1b9c0Schristos# 70e2b1b9c0Schristos# 71*8260f9a8Schristosecho_i "Checking order cyclic (primary + additional)" 72e2b1b9c0Schristosret=0 73e2b1b9c0Schristosmatches=0 74e2b1b9c0Schristosfor i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 75e2b1b9c0Schristosdo 76e2b1b9c0Schristos j=`expr $i % 4` 77e2b1b9c0Schristos $DIGCMD @10.53.0.1 cyclic.example > dig.out.cyclic || ret=1 78e2b1b9c0Schristos if [ $i -le 4 ]; then 79e2b1b9c0Schristos cp dig.out.cyclic dig.out.$j 80e2b1b9c0Schristos else 81e2b1b9c0Schristos $DIFF dig.out.cyclic dig.out.$j >/dev/null && matches=`expr $matches + 1` 82e2b1b9c0Schristos fi 83e2b1b9c0Schristosdone 84e2b1b9c0Schristos$DIFF dig.out.0 dig.out.1 >/dev/null && ret=1 85e2b1b9c0Schristos$DIFF dig.out.0 dig.out.2 >/dev/null && ret=1 86e2b1b9c0Schristos$DIFF dig.out.0 dig.out.3 >/dev/null && ret=1 87e2b1b9c0Schristos$DIFF dig.out.1 dig.out.2 >/dev/null && ret=1 88e2b1b9c0Schristos$DIFF dig.out.1 dig.out.3 >/dev/null && ret=1 89e2b1b9c0Schristos$DIFF dig.out.2 dig.out.3 >/dev/null && ret=1 90e2b1b9c0Schristosif [ $matches -ne 16 ]; then ret=1; fi 91e2b1b9c0Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 92e2b1b9c0Schristosstatus=`expr $status + $ret` 93e2b1b9c0Schristos 94e2b1b9c0Schristos# 95e2b1b9c0Schristos# 96e2b1b9c0Schristos# 97*8260f9a8Schristosecho_i "Checking order cyclic (primary)" 98e2b1b9c0Schristosret=0 99e2b1b9c0Schristosmatches=0 100e2b1b9c0Schristosfor i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 101e2b1b9c0Schristosdo 102e2b1b9c0Schristos j=`expr $i % 4` 103e2b1b9c0Schristos $DIGCMD @10.53.0.1 cyclic2.example > dig.out.cyclic2 || ret=1 104e2b1b9c0Schristos if [ $i -le 4 ]; then 105e2b1b9c0Schristos cp dig.out.cyclic2 dig.out.$j 106e2b1b9c0Schristos else 107e2b1b9c0Schristos $DIFF dig.out.cyclic2 dig.out.$j >/dev/null && matches=`expr $matches + 1` 108e2b1b9c0Schristos fi 109e2b1b9c0Schristosdone 110e2b1b9c0Schristos$DIFF dig.out.0 dig.out.1 >/dev/null && ret=1 111e2b1b9c0Schristos$DIFF dig.out.0 dig.out.2 >/dev/null && ret=1 112e2b1b9c0Schristos$DIFF dig.out.0 dig.out.3 >/dev/null && ret=1 113e2b1b9c0Schristos$DIFF dig.out.1 dig.out.2 >/dev/null && ret=1 114e2b1b9c0Schristos$DIFF dig.out.1 dig.out.3 >/dev/null && ret=1 115e2b1b9c0Schristos$DIFF dig.out.2 dig.out.3 >/dev/null && ret=1 116e2b1b9c0Schristosif [ $matches -ne 16 ]; then ret=1; fi 117e2b1b9c0Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 118e2b1b9c0Schristosstatus=`expr $status + $ret` 119*8260f9a8Schristosecho_i "Checking order random (primary)" 120e2b1b9c0Schristosret=0 1213daf698fSchristosfor i in $GOOD_RANDOM 122e2b1b9c0Schristosdo 123e2b1b9c0Schristos eval match$i=0 124e2b1b9c0Schristosdone 125e2b1b9c0Schristosfor 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 126e2b1b9c0Schristosdo 127e2b1b9c0Schristos $DIGCMD @10.53.0.1 random.example > dig.out.random || ret=1 128e2b1b9c0Schristos match=0 1293daf698fSchristos for j in $GOOD_RANDOM 130e2b1b9c0Schristos do 131e2b1b9c0Schristos eval "$DIFF dig.out.random dig.out.random.good$j >/dev/null && match$j=1 match=1" 132e2b1b9c0Schristos if [ $match -eq 1 ]; then break; fi 133e2b1b9c0Schristos done 134e2b1b9c0Schristos if [ $match -eq 0 ]; then ret=1; fi 135e2b1b9c0Schristosdone 136e2b1b9c0Schristosmatch=0 1373daf698fSchristosfor i in $GOOD_RANDOM 138e2b1b9c0Schristosdo 139e2b1b9c0Schristos eval "match=\`expr \$match + \$match$i\`" 140e2b1b9c0Schristosdone 1413daf698fSchristosecho_i "Random selection return $match of ${GOOD_RANDOM_NO} possible orders in 36 samples" 1423daf698fSchristosif [ $match -lt `expr ${GOOD_RANDOM_NO} / 3` ]; then ret=1; fi 143e2b1b9c0Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 144e2b1b9c0Schristosstatus=`expr $status + $ret` 145e2b1b9c0Schristos 146*8260f9a8Schristosecho_i "Checking order none (primary)" 147*8260f9a8Schristosret=0 148*8260f9a8Schristos# Fetch the "reference" response and ensure it contains the expected records. 149*8260f9a8Schristos$DIGCMD @10.53.0.1 none.example > dig.out.none || ret=1 150*8260f9a8Schristosfor i in 1 2 3 4; do 151*8260f9a8Schristos grep -F -q 1.2.3.$i dig.out.none || ret=1 152*8260f9a8Schristosdone 153*8260f9a8Schristos# Ensure 20 further queries result in the same response as the "reference" one. 154*8260f9a8Schristosfor i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do 155*8260f9a8Schristos $DIGCMD @10.53.0.1 none.example > dig.out.test$i || ret=1 156*8260f9a8Schristos $DIFF dig.out.none dig.out.test$i >/dev/null || ret=1 157*8260f9a8Schristosdone 158*8260f9a8Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 159*8260f9a8Schristosstatus=`expr $status + $ret` 160*8260f9a8Schristos 161e2b1b9c0Schristos# 162e2b1b9c0Schristos# 163e2b1b9c0Schristos# 164e2b1b9c0Schristosif $test_fixed; then 165*8260f9a8Schristos echo_i "Checking order fixed (secondary)" 166e2b1b9c0Schristos ret=0 167e2b1b9c0Schristos for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 168e2b1b9c0Schristos do 169e2b1b9c0Schristos $DIGCMD @10.53.0.2 fixed.example > dig.out.fixed || ret=1 170e2b1b9c0Schristos $DIFF dig.out.fixed dig.out.fixed.good || ret=1 171e2b1b9c0Schristos done 172e2b1b9c0Schristos if [ $ret != 0 ]; then echo_i "failed"; fi 173e2b1b9c0Schristos status=`expr $status + $ret` 174e2b1b9c0Schristosfi 175e2b1b9c0Schristos 176e2b1b9c0Schristos# 177e2b1b9c0Schristos# 178e2b1b9c0Schristos# 179*8260f9a8Schristosecho_i "Checking order cyclic (secondary + additional)" 180e2b1b9c0Schristosret=0 181e2b1b9c0Schristosmatches=0 182e2b1b9c0Schristosfor i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 183e2b1b9c0Schristosdo 184e2b1b9c0Schristos j=`expr $i % 4` 185e2b1b9c0Schristos $DIGCMD @10.53.0.2 cyclic.example > dig.out.cyclic || ret=1 186e2b1b9c0Schristos if [ $i -le 4 ]; then 187e2b1b9c0Schristos cp dig.out.cyclic dig.out.$j 188e2b1b9c0Schristos else 189e2b1b9c0Schristos $DIFF dig.out.cyclic dig.out.$j >/dev/null && matches=`expr $matches + 1` 190e2b1b9c0Schristos fi 191e2b1b9c0Schristosdone 192e2b1b9c0Schristos$DIFF dig.out.0 dig.out.1 >/dev/null && ret=1 193e2b1b9c0Schristos$DIFF dig.out.0 dig.out.2 >/dev/null && ret=1 194e2b1b9c0Schristos$DIFF dig.out.0 dig.out.3 >/dev/null && ret=1 195e2b1b9c0Schristos$DIFF dig.out.1 dig.out.2 >/dev/null && ret=1 196e2b1b9c0Schristos$DIFF dig.out.1 dig.out.3 >/dev/null && ret=1 197e2b1b9c0Schristos$DIFF dig.out.2 dig.out.3 >/dev/null && ret=1 198e2b1b9c0Schristosif [ $matches -ne 16 ]; then ret=1; fi 199e2b1b9c0Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 200e2b1b9c0Schristosstatus=`expr $status + $ret` 201e2b1b9c0Schristos 202e2b1b9c0Schristos# 203e2b1b9c0Schristos# 204e2b1b9c0Schristos# 205*8260f9a8Schristosecho_i "Checking order cyclic (secondary)" 206e2b1b9c0Schristosret=0 207e2b1b9c0Schristosmatches=0 208e2b1b9c0Schristosfor i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 209e2b1b9c0Schristosdo 210e2b1b9c0Schristos j=`expr $i % 4` 211e2b1b9c0Schristos $DIGCMD @10.53.0.2 cyclic2.example > dig.out.cyclic2 || ret=1 212e2b1b9c0Schristos if [ $i -le 4 ]; then 213e2b1b9c0Schristos cp dig.out.cyclic2 dig.out.$j 214e2b1b9c0Schristos else 215e2b1b9c0Schristos $DIFF dig.out.cyclic2 dig.out.$j >/dev/null && matches=`expr $matches + 1` 216e2b1b9c0Schristos fi 217e2b1b9c0Schristosdone 218e2b1b9c0Schristos$DIFF dig.out.0 dig.out.1 >/dev/null && ret=1 219e2b1b9c0Schristos$DIFF dig.out.0 dig.out.2 >/dev/null && ret=1 220e2b1b9c0Schristos$DIFF dig.out.0 dig.out.3 >/dev/null && ret=1 221e2b1b9c0Schristos$DIFF dig.out.1 dig.out.2 >/dev/null && ret=1 222e2b1b9c0Schristos$DIFF dig.out.1 dig.out.3 >/dev/null && ret=1 223e2b1b9c0Schristos$DIFF dig.out.2 dig.out.3 >/dev/null && ret=1 224e2b1b9c0Schristosif [ $matches -ne 16 ]; then ret=1; fi 225e2b1b9c0Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 226e2b1b9c0Schristosstatus=`expr $status + $ret` 227e2b1b9c0Schristos 228*8260f9a8Schristosecho_i "Checking order random (secondary)" 229e2b1b9c0Schristosret=0 2303daf698fSchristosfor i in $GOOD_RANDOM 231e2b1b9c0Schristosdo 232e2b1b9c0Schristos eval match$i=0 233e2b1b9c0Schristosdone 234e2b1b9c0Schristosfor 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 235e2b1b9c0Schristosdo 236e2b1b9c0Schristos $DIGCMD @10.53.0.2 random.example > dig.out.random || ret=1 237e2b1b9c0Schristos match=0 2383daf698fSchristos for j in $GOOD_RANDOM 239e2b1b9c0Schristos do 240e2b1b9c0Schristos eval "$DIFF dig.out.random dig.out.random.good$j >/dev/null && match$j=1 match=1" 241e2b1b9c0Schristos if [ $match -eq 1 ]; then break; fi 242e2b1b9c0Schristos done 243e2b1b9c0Schristos if [ $match -eq 0 ]; then ret=1; fi 244e2b1b9c0Schristosdone 245e2b1b9c0Schristosmatch=0 2463daf698fSchristosfor i in $GOOD_RANDOM 247e2b1b9c0Schristosdo 248e2b1b9c0Schristoseval "match=\`expr \$match + \$match$i\`" 249e2b1b9c0Schristosdone 2503daf698fSchristosecho_i "Random selection return $match of ${GOOD_RANDOM_NO} possible orders in 36 samples" 2513daf698fSchristosif [ $match -lt `expr ${GOOD_RANDOM_NO} / 3` ]; then ret=1; fi 252e2b1b9c0Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 253e2b1b9c0Schristosstatus=`expr $status + $ret` 254e2b1b9c0Schristos 255*8260f9a8Schristosecho_i "Checking order none (secondary)" 256*8260f9a8Schristosret=0 257*8260f9a8Schristos# Fetch the "reference" response and ensure it contains the expected records. 258*8260f9a8Schristos$DIGCMD @10.53.0.2 none.example > dig.out.none || ret=1 259*8260f9a8Schristosfor i in 1 2 3 4; do 260*8260f9a8Schristos grep -F -q 1.2.3.$i dig.out.none || ret=1 261*8260f9a8Schristosdone 262*8260f9a8Schristos# Ensure 20 further queries result in the same response as the "reference" one. 263*8260f9a8Schristosfor i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do 264*8260f9a8Schristos $DIGCMD @10.53.0.2 none.example > dig.out.test$i || ret=1 265*8260f9a8Schristos $DIFF dig.out.none dig.out.test$i >/dev/null || ret=1 266*8260f9a8Schristosdone 267*8260f9a8Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 268*8260f9a8Schristosstatus=`expr $status + $ret` 269*8260f9a8Schristos 270*8260f9a8Schristosecho_i "Shutting down secondary" 271e2b1b9c0Schristos 272e2b1b9c0Schristos(cd ..; $SHELL stop.sh rrsetorder ns2 ) 273e2b1b9c0Schristos 274*8260f9a8Schristosecho_i "Checking for secondary's on disk copy of zone" 275e2b1b9c0Schristos 276e2b1b9c0Schristosif [ ! -f ns2/root.bk ] 277e2b1b9c0Schristosthen 278e2b1b9c0Schristos echo_i "failed"; 279e2b1b9c0Schristos status=`expr $status + 1` 280e2b1b9c0Schristosfi 281e2b1b9c0Schristos 282*8260f9a8Schristosecho_i "Re-starting secondary" 283e2b1b9c0Schristos 2843daf698fSchristos$PERL $SYSTEMTESTTOP/start.pl --noclean --port ${PORT} rrsetorder ns2 285e2b1b9c0Schristos 286e2b1b9c0Schristos# 287e2b1b9c0Schristos# 288e2b1b9c0Schristos# 289e2b1b9c0Schristosif $test_fixed; then 290*8260f9a8Schristos echo_i "Checking order fixed (secondary loaded from disk)" 291e2b1b9c0Schristos ret=0 292e2b1b9c0Schristos for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 293e2b1b9c0Schristos do 294e2b1b9c0Schristos $DIGCMD @10.53.0.2 fixed.example > dig.out.fixed || ret=1 295e2b1b9c0Schristos $DIFF dig.out.fixed dig.out.fixed.good || ret=1 296e2b1b9c0Schristos done 297e2b1b9c0Schristos if [ $ret != 0 ]; then echo_i "failed"; fi 298e2b1b9c0Schristos status=`expr $status + $ret` 299e2b1b9c0Schristosfi 300e2b1b9c0Schristos 301e2b1b9c0Schristos# 302e2b1b9c0Schristos# 303e2b1b9c0Schristos# 304*8260f9a8Schristosecho_i "Checking order cyclic (secondary + additional, loaded from disk)" 305e2b1b9c0Schristosret=0 306e2b1b9c0Schristosmatches=0 307e2b1b9c0Schristosfor i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 308e2b1b9c0Schristosdo 309e2b1b9c0Schristos j=`expr $i % 4` 310e2b1b9c0Schristos $DIGCMD @10.53.0.2 cyclic.example > dig.out.cyclic || ret=1 311e2b1b9c0Schristos if [ $i -le 4 ]; then 312e2b1b9c0Schristos cp dig.out.cyclic dig.out.$j 313e2b1b9c0Schristos else 314e2b1b9c0Schristos $DIFF dig.out.cyclic dig.out.$j >/dev/null && matches=`expr $matches + 1` 315e2b1b9c0Schristos fi 316e2b1b9c0Schristosdone 317e2b1b9c0Schristos$DIFF dig.out.0 dig.out.1 >/dev/null && ret=1 318e2b1b9c0Schristos$DIFF dig.out.0 dig.out.2 >/dev/null && ret=1 319e2b1b9c0Schristos$DIFF dig.out.0 dig.out.3 >/dev/null && ret=1 320e2b1b9c0Schristos$DIFF dig.out.1 dig.out.2 >/dev/null && ret=1 321e2b1b9c0Schristos$DIFF dig.out.1 dig.out.3 >/dev/null && ret=1 322e2b1b9c0Schristos$DIFF dig.out.2 dig.out.3 >/dev/null && ret=1 323e2b1b9c0Schristosif [ $matches -ne 16 ]; then ret=1; fi 324e2b1b9c0Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 325e2b1b9c0Schristosstatus=`expr $status + $ret` 326e2b1b9c0Schristos 327e2b1b9c0Schristos# 328e2b1b9c0Schristos# 329e2b1b9c0Schristos# 330*8260f9a8Schristosecho_i "Checking order cyclic (secondary loaded from disk)" 331e2b1b9c0Schristosret=0 332e2b1b9c0Schristosmatches=0 333e2b1b9c0Schristosfor i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 334e2b1b9c0Schristosdo 335e2b1b9c0Schristos j=`expr $i % 4` 336e2b1b9c0Schristos $DIGCMD @10.53.0.2 cyclic2.example > dig.out.cyclic2 || ret=1 337e2b1b9c0Schristos if [ $i -le 4 ]; then 338e2b1b9c0Schristos cp dig.out.cyclic2 dig.out.$j 339e2b1b9c0Schristos else 340e2b1b9c0Schristos $DIFF dig.out.cyclic2 dig.out.$j >/dev/null && matches=`expr $matches + 1` 341e2b1b9c0Schristos fi 342e2b1b9c0Schristosdone 343e2b1b9c0Schristos$DIFF dig.out.0 dig.out.1 >/dev/null && ret=1 344e2b1b9c0Schristos$DIFF dig.out.0 dig.out.2 >/dev/null && ret=1 345e2b1b9c0Schristos$DIFF dig.out.0 dig.out.3 >/dev/null && ret=1 346e2b1b9c0Schristos$DIFF dig.out.1 dig.out.2 >/dev/null && ret=1 347e2b1b9c0Schristos$DIFF dig.out.1 dig.out.3 >/dev/null && ret=1 348e2b1b9c0Schristos$DIFF dig.out.2 dig.out.3 >/dev/null && ret=1 349e2b1b9c0Schristosif [ $matches -ne 16 ]; then ret=1; fi 350e2b1b9c0Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 351e2b1b9c0Schristosstatus=`expr $status + $ret` 352e2b1b9c0Schristos 353*8260f9a8Schristosecho_i "Checking order random (secondary loaded from disk)" 354e2b1b9c0Schristosret=0 3553daf698fSchristosfor i in $GOOD_RANDOM 356e2b1b9c0Schristosdo 357e2b1b9c0Schristos eval match$i=0 358e2b1b9c0Schristosdone 359e2b1b9c0Schristosfor 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 360e2b1b9c0Schristosdo 361e2b1b9c0Schristos $DIGCMD @10.53.0.2 random.example > dig.out.random || ret=1 362e2b1b9c0Schristos match=0 3633daf698fSchristos for j in $GOOD_RANDOM 364e2b1b9c0Schristos do 365e2b1b9c0Schristos eval "$DIFF dig.out.random dig.out.random.good$j >/dev/null && match$j=1 match=1" 366e2b1b9c0Schristos if [ $match -eq 1 ]; then break; fi 367e2b1b9c0Schristos done 368e2b1b9c0Schristos if [ $match -eq 0 ]; then ret=1; fi 369e2b1b9c0Schristosdone 370e2b1b9c0Schristosmatch=0 3713daf698fSchristosfor i in $GOOD_RANDOM 372e2b1b9c0Schristosdo 373e2b1b9c0Schristoseval "match=\`expr \$match + \$match$i\`" 374e2b1b9c0Schristosdone 3753daf698fSchristosecho_i "Random selection return $match of ${GOOD_RANDOM_NO} possible orders in 36 samples" 3763daf698fSchristosif [ $match -lt `expr ${GOOD_RANDOM_NO} / 3` ]; then ret=1; fi 377e2b1b9c0Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 378e2b1b9c0Schristosstatus=`expr $status + $ret` 379e2b1b9c0Schristos 380*8260f9a8Schristosecho_i "Checking order none (secondary loaded from disk)" 381*8260f9a8Schristosret=0 382*8260f9a8Schristos# Fetch the "reference" response and ensure it contains the expected records. 383*8260f9a8Schristos$DIGCMD @10.53.0.2 none.example > dig.out.none || ret=1 384*8260f9a8Schristosfor i in 1 2 3 4; do 385*8260f9a8Schristos grep -F -q 1.2.3.$i dig.out.none || ret=1 386*8260f9a8Schristosdone 387*8260f9a8Schristos# Ensure 20 further queries result in the same response as the "reference" one. 388*8260f9a8Schristosfor i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do 389*8260f9a8Schristos $DIGCMD @10.53.0.2 none.example > dig.out.test$i || ret=1 390*8260f9a8Schristos $DIFF dig.out.none dig.out.test$i >/dev/null || ret=1 391*8260f9a8Schristosdone 392*8260f9a8Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 393*8260f9a8Schristosstatus=`expr $status + $ret` 394*8260f9a8Schristos 395e2b1b9c0Schristos# 396e2b1b9c0Schristos# 397e2b1b9c0Schristos# 398e2b1b9c0Schristosif $test_fixed; then 399e2b1b9c0Schristos echo_i "Checking order fixed (cache)" 400e2b1b9c0Schristos ret=0 401e2b1b9c0Schristos for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 402e2b1b9c0Schristos do 403e2b1b9c0Schristos $DIGCMD @10.53.0.3 fixed.example > dig.out.fixed || ret=1 404e2b1b9c0Schristos $DIFF dig.out.fixed dig.out.fixed.good || ret=1 405e2b1b9c0Schristos done 406e2b1b9c0Schristos if [ $ret != 0 ]; then echo_i "failed"; fi 407e2b1b9c0Schristos status=`expr $status + $ret` 408e2b1b9c0Schristosfi 409e2b1b9c0Schristos 410e2b1b9c0Schristos# 411e2b1b9c0Schristos# 412e2b1b9c0Schristos# 413e2b1b9c0Schristosecho_i "Checking order cyclic (cache + additional)" 414e2b1b9c0Schristosret=0 415e2b1b9c0Schristos# prime acache 416e2b1b9c0Schristos$DIGCMD @10.53.0.3 cyclic.example > dig.out.cyclic || ret=1 417e2b1b9c0Schristosmatches=0 418e2b1b9c0Schristosfor i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 419e2b1b9c0Schristosdo 420e2b1b9c0Schristos j=`expr $i % 4` 421e2b1b9c0Schristos $DIGCMD @10.53.0.3 cyclic.example > dig.out.cyclic || ret=1 422e2b1b9c0Schristos if [ $i -le 4 ]; then 423e2b1b9c0Schristos cp dig.out.cyclic dig.out.$j 424e2b1b9c0Schristos else 425e2b1b9c0Schristos $DIFF dig.out.cyclic dig.out.$j >/dev/null && matches=`expr $matches + 1` 426e2b1b9c0Schristos fi 427e2b1b9c0Schristosdone 428e2b1b9c0Schristos$DIFF dig.out.0 dig.out.1 >/dev/null && ret=1 429e2b1b9c0Schristos$DIFF dig.out.0 dig.out.2 >/dev/null && ret=1 430e2b1b9c0Schristos$DIFF dig.out.0 dig.out.3 >/dev/null && ret=1 431e2b1b9c0Schristos$DIFF dig.out.1 dig.out.2 >/dev/null && ret=1 432e2b1b9c0Schristos$DIFF dig.out.1 dig.out.3 >/dev/null && ret=1 433e2b1b9c0Schristos$DIFF dig.out.2 dig.out.3 >/dev/null && ret=1 434e2b1b9c0Schristosif [ $matches -ne 16 ]; then ret=1; fi 435e2b1b9c0Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 436e2b1b9c0Schristosstatus=`expr $status + $ret` 437e2b1b9c0Schristos 438e2b1b9c0Schristos# 439e2b1b9c0Schristos# 440e2b1b9c0Schristos# 441e2b1b9c0Schristosecho_i "Checking order cyclic (cache)" 442e2b1b9c0Schristosret=0 443e2b1b9c0Schristos# prime acache 444e2b1b9c0Schristos$DIGCMD @10.53.0.3 cyclic2.example > dig.out.cyclic2 || ret=1 445e2b1b9c0Schristosmatches=0 446e2b1b9c0Schristosfor i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 447e2b1b9c0Schristosdo 448e2b1b9c0Schristos j=`expr $i % 4` 449e2b1b9c0Schristos $DIGCMD @10.53.0.3 cyclic2.example > dig.out.cyclic2 || ret=1 450e2b1b9c0Schristos if [ $i -le 4 ]; then 451e2b1b9c0Schristos cp dig.out.cyclic2 dig.out.$j 452e2b1b9c0Schristos else 453e2b1b9c0Schristos $DIFF dig.out.cyclic2 dig.out.$j >/dev/null && matches=`expr $matches + 1` 454e2b1b9c0Schristos fi 455e2b1b9c0Schristosdone 456e2b1b9c0Schristos$DIFF dig.out.0 dig.out.1 >/dev/null && ret=1 457e2b1b9c0Schristos$DIFF dig.out.0 dig.out.2 >/dev/null && ret=1 458e2b1b9c0Schristos$DIFF dig.out.0 dig.out.3 >/dev/null && ret=1 459e2b1b9c0Schristos$DIFF dig.out.1 dig.out.2 >/dev/null && ret=1 460e2b1b9c0Schristos$DIFF dig.out.1 dig.out.3 >/dev/null && ret=1 461e2b1b9c0Schristos$DIFF dig.out.2 dig.out.3 >/dev/null && ret=1 462e2b1b9c0Schristosif [ $matches -ne 16 ]; then ret=1; fi 463e2b1b9c0Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 464e2b1b9c0Schristosstatus=`expr $status + $ret` 465e2b1b9c0Schristos 466e2b1b9c0Schristosecho_i "Checking order random (cache)" 467e2b1b9c0Schristosret=0 4683daf698fSchristosfor i in $GOOD_RANDOM 469e2b1b9c0Schristosdo 470e2b1b9c0Schristos eval match$i=0 471e2b1b9c0Schristosdone 472e2b1b9c0Schristosfor 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 473e2b1b9c0Schristosdo 474e2b1b9c0Schristos $DIGCMD @10.53.0.3 random.example > dig.out.random || ret=1 475e2b1b9c0Schristos match=0 4763daf698fSchristos for j in $GOOD_RANDOM 477e2b1b9c0Schristos do 478e2b1b9c0Schristos eval "$DIFF dig.out.random dig.out.random.good$j >/dev/null && match$j=1 match=1" 479e2b1b9c0Schristos if [ $match -eq 1 ]; then break; fi 480e2b1b9c0Schristos done 481e2b1b9c0Schristos if [ $match -eq 0 ]; then ret=1; fi 482e2b1b9c0Schristosdone 483e2b1b9c0Schristosmatch=0 4843daf698fSchristosfor i in $GOOD_RANDOM 485e2b1b9c0Schristosdo 486e2b1b9c0Schristoseval "match=\`expr \$match + \$match$i\`" 487e2b1b9c0Schristosdone 4883daf698fSchristosecho_i "Random selection return $match of ${GOOD_RANDOM_NO} possible orders in 36 samples" 4893daf698fSchristosif [ $match -lt `expr ${GOOD_RANDOM_NO} / 3` ]; then ret=1; fi 490e2b1b9c0Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 491e2b1b9c0Schristos 492*8260f9a8Schristosecho_i "Checking order none (cache)" 493*8260f9a8Schristosret=0 494*8260f9a8Schristos# Fetch the "reference" response and ensure it contains the expected records. 495*8260f9a8Schristos$DIGCMD @10.53.0.3 none.example > dig.out.none || ret=1 496*8260f9a8Schristosfor i in 1 2 3 4; do 497*8260f9a8Schristos grep -F -q 1.2.3.$i dig.out.none || ret=1 498*8260f9a8Schristosdone 499*8260f9a8Schristos# Ensure 20 further queries result in the same response as the "reference" one. 500*8260f9a8Schristosfor i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do 501*8260f9a8Schristos $DIGCMD @10.53.0.3 none.example > dig.out.test$i || ret=1 502*8260f9a8Schristos $DIFF dig.out.none dig.out.test$i >/dev/null || ret=1 503*8260f9a8Schristosdone 504*8260f9a8Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 505*8260f9a8Schristosstatus=`expr $status + $ret` 506*8260f9a8Schristos 507e2b1b9c0Schristosecho_i "Checking default order (cache)" 508e2b1b9c0Schristosret=0 5093daf698fSchristosfor i in $GOOD_RANDOM 510e2b1b9c0Schristosdo 511e2b1b9c0Schristos eval match$i=0 512e2b1b9c0Schristosdone 513e2b1b9c0Schristosfor 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 514e2b1b9c0Schristosdo 515e2b1b9c0Schristos $DIGCMD @10.53.0.5 random.example > dig.out.random || ret=1 516e2b1b9c0Schristos match=0 5173daf698fSchristos for j in $GOOD_RANDOM 518e2b1b9c0Schristos do 519e2b1b9c0Schristos eval "$DIFF dig.out.random dig.out.random.good$j >/dev/null && match$j=1 match=1" 520e2b1b9c0Schristos if [ $match -eq 1 ]; then break; fi 521e2b1b9c0Schristos done 522e2b1b9c0Schristos if [ $match -eq 0 ]; then ret=1; fi 523e2b1b9c0Schristosdone 524e2b1b9c0Schristosmatch=0 5253daf698fSchristosfor i in $GOOD_RANDOM 526e2b1b9c0Schristosdo 527e2b1b9c0Schristoseval "match=\`expr \$match + \$match$i\`" 528e2b1b9c0Schristosdone 5293daf698fSchristosecho_i "Default selection return $match of ${GOOD_RANDOM_NO} possible orders in 36 samples" 5303daf698fSchristosif [ $match -lt `expr ${GOOD_RANDOM_NO} / 3` ]; then ret=1; fi 531e2b1b9c0Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 532e2b1b9c0Schristosstatus=`expr $status + $ret` 533*8260f9a8Schristos 534*8260f9a8Schristosecho_i "Checking default order no match in rrset-order (cache)" 535*8260f9a8Schristosret=0 536*8260f9a8Schristos# Fetch the "reference" response and ensure it contains the expected records. 537*8260f9a8Schristos$DIGCMD @10.53.0.4 nomatch.example > dig.out.nomatch || ret=1 538*8260f9a8Schristosfor i in 1 2 3 4; do 539*8260f9a8Schristos grep -F -q 1.2.3.$i dig.out.nomatch || ret=1 540*8260f9a8Schristosdone 541*8260f9a8Schristos# Ensure 20 further queries result in the same response as the "reference" one. 542*8260f9a8Schristosfor i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do 543*8260f9a8Schristos $DIGCMD @10.53.0.4 nomatch.example > dig.out.test$i || ret=1 544*8260f9a8Schristos $DIFF dig.out.nomatch dig.out.test$i >/dev/null || ret=1 545*8260f9a8Schristosdone 546*8260f9a8Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 547*8260f9a8Schristosstatus=`expr $status + $ret` 548*8260f9a8Schristos 549e2b1b9c0Schristosecho_i "exit status: $status" 550e2b1b9c0Schristos[ $status -eq 0 ] || exit 1 551