1e2b1b9c0Schristos#!/bin/sh 2497bf0b8Schristos 3e2b1b9c0Schristos# Copyright (C) Internet Systems Consortium, Inc. ("ISC") 4e2b1b9c0Schristos# 5497bf0b8Schristos# SPDX-License-Identifier: MPL-2.0 6497bf0b8Schristos# 7e2b1b9c0Schristos# This Source Code Form is subject to the terms of the Mozilla Public 8e2b1b9c0Schristos# License, v. 2.0. If a copy of the MPL was not distributed with this 98260f9a8Schristos# file, you can obtain one at https://mozilla.org/MPL/2.0/. 10e2b1b9c0Schristos# 11e2b1b9c0Schristos# See the COPYRIGHT file distributed with this work for additional 12e2b1b9c0Schristos# information regarding copyright ownership. 13e2b1b9c0Schristos 14e2b1b9c0SchristosSYSTEMTESTTOP=.. 15e2b1b9c0Schristos. $SYSTEMTESTTOP/conf.sh 16e2b1b9c0Schristos 17e2b1b9c0SchristosDIGOPTS="+nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short +nocookie" 18e2b1b9c0SchristosDIGCMD="$DIG $DIGOPTS -p ${PORT}" 19e2b1b9c0Schristos 20e2b1b9c0Schristosstatus=0 21e2b1b9c0Schristos 223daf698fSchristosGOOD_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" 233daf698fSchristosGOOD_RANDOM_NO=24 243daf698fSchristos 25e2b1b9c0Schristosif grep "^#define DNS_RDATASET_FIXED" $TOP/config.h > /dev/null 2>&1 ; then 26e2b1b9c0Schristos test_fixed=true 27e2b1b9c0Schristoselse 28e2b1b9c0Schristos echo_i "Order 'fixed' disabled at compile time" 29e2b1b9c0Schristos test_fixed=false 30e2b1b9c0Schristosfi 31e2b1b9c0Schristos 32e2b1b9c0Schristos# 33e2b1b9c0Schristos# 34e2b1b9c0Schristos# 35e2b1b9c0Schristosif $test_fixed; then 368260f9a8Schristos echo_i "Checking order fixed (primary)" 37e2b1b9c0Schristos ret=0 38e2b1b9c0Schristos for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 39e2b1b9c0Schristos do 40e2b1b9c0Schristos $DIGCMD @10.53.0.1 fixed.example > dig.out.fixed || ret=1 41e2b1b9c0Schristos $DIFF dig.out.fixed dig.out.fixed.good >/dev/null || ret=1 42e2b1b9c0Schristos done 43e2b1b9c0Schristos if [ $ret != 0 ]; then echo_i "failed"; fi 44497bf0b8Schristos status=$((status + ret)) 45e2b1b9c0Schristoselse 468260f9a8Schristos echo_i "Checking order fixed behaves as cyclic when disabled (primary)" 47e2b1b9c0Schristos ret=0 48e2b1b9c0Schristos matches=0 49e2b1b9c0Schristos for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 50e2b1b9c0Schristos do 51497bf0b8Schristos j=$((i % 4)) 52e2b1b9c0Schristos $DIGCMD @10.53.0.1 fixed.example > dig.out.fixed || ret=1 53e2b1b9c0Schristos if [ $i -le 4 ]; then 54e2b1b9c0Schristos cp dig.out.fixed dig.out.$j 55e2b1b9c0Schristos else 56497bf0b8Schristos $DIFF dig.out.fixed dig.out.$j >/dev/null && matches=$((matches + 1)) 57e2b1b9c0Schristos fi 58e2b1b9c0Schristos done 59e2b1b9c0Schristos $DIFF dig.out.0 dig.out.1 >/dev/null && ret=1 60e2b1b9c0Schristos $DIFF dig.out.0 dig.out.2 >/dev/null && ret=1 61e2b1b9c0Schristos $DIFF dig.out.0 dig.out.3 >/dev/null && ret=1 62e2b1b9c0Schristos $DIFF dig.out.1 dig.out.2 >/dev/null && ret=1 63e2b1b9c0Schristos $DIFF dig.out.1 dig.out.3 >/dev/null && ret=1 64e2b1b9c0Schristos $DIFF dig.out.2 dig.out.3 >/dev/null && ret=1 65e2b1b9c0Schristos if [ $matches -ne 16 ]; then ret=1; fi 66e2b1b9c0Schristos if [ $ret != 0 ]; then echo_i "failed"; fi 67497bf0b8Schristos status=$((status + ret)) 68e2b1b9c0Schristosfi 69e2b1b9c0Schristos 70e2b1b9c0Schristos# 71e2b1b9c0Schristos# 72e2b1b9c0Schristos# 738260f9a8Schristosecho_i "Checking order cyclic (primary + additional)" 74e2b1b9c0Schristosret=0 75e2b1b9c0Schristosmatches=0 76e2b1b9c0Schristosfor i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 77e2b1b9c0Schristosdo 78497bf0b8Schristos j=$((i % 4)) 79e2b1b9c0Schristos $DIGCMD @10.53.0.1 cyclic.example > dig.out.cyclic || ret=1 80e2b1b9c0Schristos if [ $i -le 4 ]; then 81e2b1b9c0Schristos cp dig.out.cyclic dig.out.$j 82e2b1b9c0Schristos else 83497bf0b8Schristos $DIFF dig.out.cyclic dig.out.$j >/dev/null && matches=$((matches + 1)) 84e2b1b9c0Schristos fi 85e2b1b9c0Schristosdone 86e2b1b9c0Schristos$DIFF dig.out.0 dig.out.1 >/dev/null && ret=1 87e2b1b9c0Schristos$DIFF dig.out.0 dig.out.2 >/dev/null && ret=1 88e2b1b9c0Schristos$DIFF dig.out.0 dig.out.3 >/dev/null && ret=1 89e2b1b9c0Schristos$DIFF dig.out.1 dig.out.2 >/dev/null && ret=1 90e2b1b9c0Schristos$DIFF dig.out.1 dig.out.3 >/dev/null && ret=1 91e2b1b9c0Schristos$DIFF dig.out.2 dig.out.3 >/dev/null && ret=1 92e2b1b9c0Schristosif [ $matches -ne 16 ]; then ret=1; fi 93e2b1b9c0Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 94497bf0b8Schristosstatus=$((status + ret)) 95e2b1b9c0Schristos 96e2b1b9c0Schristos# 97e2b1b9c0Schristos# 98e2b1b9c0Schristos# 998260f9a8Schristosecho_i "Checking order cyclic (primary)" 100e2b1b9c0Schristosret=0 101e2b1b9c0Schristosmatches=0 102e2b1b9c0Schristosfor i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 103e2b1b9c0Schristosdo 104497bf0b8Schristos j=$((i % 4)) 105e2b1b9c0Schristos $DIGCMD @10.53.0.1 cyclic2.example > dig.out.cyclic2 || ret=1 106e2b1b9c0Schristos if [ $i -le 4 ]; then 107e2b1b9c0Schristos cp dig.out.cyclic2 dig.out.$j 108e2b1b9c0Schristos else 109497bf0b8Schristos $DIFF dig.out.cyclic2 dig.out.$j >/dev/null && matches=$((matches + 1)) 110e2b1b9c0Schristos fi 111e2b1b9c0Schristosdone 112e2b1b9c0Schristos$DIFF dig.out.0 dig.out.1 >/dev/null && ret=1 113e2b1b9c0Schristos$DIFF dig.out.0 dig.out.2 >/dev/null && ret=1 114e2b1b9c0Schristos$DIFF dig.out.0 dig.out.3 >/dev/null && ret=1 115e2b1b9c0Schristos$DIFF dig.out.1 dig.out.2 >/dev/null && ret=1 116e2b1b9c0Schristos$DIFF dig.out.1 dig.out.3 >/dev/null && ret=1 117e2b1b9c0Schristos$DIFF dig.out.2 dig.out.3 >/dev/null && ret=1 118e2b1b9c0Schristosif [ $matches -ne 16 ]; then ret=1; fi 119e2b1b9c0Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 120497bf0b8Schristosstatus=$((status + ret)) 1218260f9a8Schristosecho_i "Checking order random (primary)" 122e2b1b9c0Schristosret=0 1233daf698fSchristosfor i in $GOOD_RANDOM 124e2b1b9c0Schristosdo 125e2b1b9c0Schristos eval match$i=0 126e2b1b9c0Schristosdone 127e2b1b9c0Schristosfor 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 128e2b1b9c0Schristosdo 129e2b1b9c0Schristos $DIGCMD @10.53.0.1 random.example > dig.out.random || ret=1 130e2b1b9c0Schristos match=0 1313daf698fSchristos for j in $GOOD_RANDOM 132e2b1b9c0Schristos do 133e2b1b9c0Schristos eval "$DIFF dig.out.random dig.out.random.good$j >/dev/null && match$j=1 match=1" 134e2b1b9c0Schristos if [ $match -eq 1 ]; then break; fi 135e2b1b9c0Schristos done 136e2b1b9c0Schristos if [ $match -eq 0 ]; then ret=1; fi 137e2b1b9c0Schristosdone 138e2b1b9c0Schristosmatch=0 1393daf698fSchristosfor i in $GOOD_RANDOM 140e2b1b9c0Schristosdo 141497bf0b8Schristos eval "match=\$((match + match$i))" 142e2b1b9c0Schristosdone 1433daf698fSchristosecho_i "Random selection return $match of ${GOOD_RANDOM_NO} possible orders in 36 samples" 144497bf0b8Schristosif [ $match -lt $((GOOD_RANDOM_NO / 3)) ]; then ret=1; fi 145e2b1b9c0Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 146497bf0b8Schristosstatus=$((status + ret)) 147e2b1b9c0Schristos 1488260f9a8Schristosecho_i "Checking order none (primary)" 1498260f9a8Schristosret=0 1508260f9a8Schristos# Fetch the "reference" response and ensure it contains the expected records. 1518260f9a8Schristos$DIGCMD @10.53.0.1 none.example > dig.out.none || ret=1 1528260f9a8Schristosfor i in 1 2 3 4; do 1538260f9a8Schristos grep -F -q 1.2.3.$i dig.out.none || ret=1 1548260f9a8Schristosdone 1558260f9a8Schristos# Ensure 20 further queries result in the same response as the "reference" one. 1568260f9a8Schristosfor i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do 1578260f9a8Schristos $DIGCMD @10.53.0.1 none.example > dig.out.test$i || ret=1 1588260f9a8Schristos $DIFF dig.out.none dig.out.test$i >/dev/null || ret=1 1598260f9a8Schristosdone 1608260f9a8Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 161497bf0b8Schristosstatus=$((status + ret)) 1628260f9a8Schristos 163e2b1b9c0Schristos# 164e2b1b9c0Schristos# 165e2b1b9c0Schristos# 166e2b1b9c0Schristosif $test_fixed; then 1678260f9a8Schristos echo_i "Checking order fixed (secondary)" 168e2b1b9c0Schristos ret=0 169e2b1b9c0Schristos for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 170e2b1b9c0Schristos do 171e2b1b9c0Schristos $DIGCMD @10.53.0.2 fixed.example > dig.out.fixed || ret=1 172e2b1b9c0Schristos $DIFF dig.out.fixed dig.out.fixed.good || ret=1 173e2b1b9c0Schristos done 174e2b1b9c0Schristos if [ $ret != 0 ]; then echo_i "failed"; fi 175497bf0b8Schristos status=$((status + ret)) 176e2b1b9c0Schristosfi 177e2b1b9c0Schristos 178e2b1b9c0Schristos# 179e2b1b9c0Schristos# 180e2b1b9c0Schristos# 1818260f9a8Schristosecho_i "Checking order cyclic (secondary + additional)" 182e2b1b9c0Schristosret=0 183e2b1b9c0Schristosmatches=0 184e2b1b9c0Schristosfor i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 185e2b1b9c0Schristosdo 186497bf0b8Schristos j=$((i % 4)) 187e2b1b9c0Schristos $DIGCMD @10.53.0.2 cyclic.example > dig.out.cyclic || ret=1 188e2b1b9c0Schristos if [ $i -le 4 ]; then 189e2b1b9c0Schristos cp dig.out.cyclic dig.out.$j 190e2b1b9c0Schristos else 191497bf0b8Schristos $DIFF dig.out.cyclic dig.out.$j >/dev/null && matches=$((matches + 1)) 192e2b1b9c0Schristos fi 193e2b1b9c0Schristosdone 194e2b1b9c0Schristos$DIFF dig.out.0 dig.out.1 >/dev/null && ret=1 195e2b1b9c0Schristos$DIFF dig.out.0 dig.out.2 >/dev/null && ret=1 196e2b1b9c0Schristos$DIFF dig.out.0 dig.out.3 >/dev/null && ret=1 197e2b1b9c0Schristos$DIFF dig.out.1 dig.out.2 >/dev/null && ret=1 198e2b1b9c0Schristos$DIFF dig.out.1 dig.out.3 >/dev/null && ret=1 199e2b1b9c0Schristos$DIFF dig.out.2 dig.out.3 >/dev/null && ret=1 200e2b1b9c0Schristosif [ $matches -ne 16 ]; then ret=1; fi 201e2b1b9c0Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 202497bf0b8Schristosstatus=$((status + ret)) 203e2b1b9c0Schristos 204e2b1b9c0Schristos# 205e2b1b9c0Schristos# 206e2b1b9c0Schristos# 2078260f9a8Schristosecho_i "Checking order cyclic (secondary)" 208e2b1b9c0Schristosret=0 209e2b1b9c0Schristosmatches=0 210e2b1b9c0Schristosfor i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 211e2b1b9c0Schristosdo 212497bf0b8Schristos j=$((i % 4)) 213e2b1b9c0Schristos $DIGCMD @10.53.0.2 cyclic2.example > dig.out.cyclic2 || ret=1 214e2b1b9c0Schristos if [ $i -le 4 ]; then 215e2b1b9c0Schristos cp dig.out.cyclic2 dig.out.$j 216e2b1b9c0Schristos else 217497bf0b8Schristos $DIFF dig.out.cyclic2 dig.out.$j >/dev/null && matches=$((matches + 1)) 218e2b1b9c0Schristos fi 219e2b1b9c0Schristosdone 220e2b1b9c0Schristos$DIFF dig.out.0 dig.out.1 >/dev/null && ret=1 221e2b1b9c0Schristos$DIFF dig.out.0 dig.out.2 >/dev/null && ret=1 222e2b1b9c0Schristos$DIFF dig.out.0 dig.out.3 >/dev/null && ret=1 223e2b1b9c0Schristos$DIFF dig.out.1 dig.out.2 >/dev/null && ret=1 224e2b1b9c0Schristos$DIFF dig.out.1 dig.out.3 >/dev/null && ret=1 225e2b1b9c0Schristos$DIFF dig.out.2 dig.out.3 >/dev/null && ret=1 226e2b1b9c0Schristosif [ $matches -ne 16 ]; then ret=1; fi 227e2b1b9c0Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 228497bf0b8Schristosstatus=$((status + ret)) 229e2b1b9c0Schristos 2308260f9a8Schristosecho_i "Checking order random (secondary)" 231e2b1b9c0Schristosret=0 2323daf698fSchristosfor i in $GOOD_RANDOM 233e2b1b9c0Schristosdo 234e2b1b9c0Schristos eval match$i=0 235e2b1b9c0Schristosdone 236e2b1b9c0Schristosfor 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 237e2b1b9c0Schristosdo 238e2b1b9c0Schristos $DIGCMD @10.53.0.2 random.example > dig.out.random || ret=1 239e2b1b9c0Schristos match=0 2403daf698fSchristos for j in $GOOD_RANDOM 241e2b1b9c0Schristos do 242e2b1b9c0Schristos eval "$DIFF dig.out.random dig.out.random.good$j >/dev/null && match$j=1 match=1" 243e2b1b9c0Schristos if [ $match -eq 1 ]; then break; fi 244e2b1b9c0Schristos done 245e2b1b9c0Schristos if [ $match -eq 0 ]; then ret=1; fi 246e2b1b9c0Schristosdone 247e2b1b9c0Schristosmatch=0 2483daf698fSchristosfor i in $GOOD_RANDOM 249e2b1b9c0Schristosdo 250497bf0b8Schristos eval "match=\$((match + match$i))" 251e2b1b9c0Schristosdone 2523daf698fSchristosecho_i "Random selection return $match of ${GOOD_RANDOM_NO} possible orders in 36 samples" 253497bf0b8Schristosif [ $match -lt $((GOOD_RANDOM_NO / 3)) ]; then ret=1; fi 254e2b1b9c0Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 255497bf0b8Schristosstatus=$((status + ret)) 256e2b1b9c0Schristos 2578260f9a8Schristosecho_i "Checking order none (secondary)" 2588260f9a8Schristosret=0 2598260f9a8Schristos# Fetch the "reference" response and ensure it contains the expected records. 2608260f9a8Schristos$DIGCMD @10.53.0.2 none.example > dig.out.none || ret=1 2618260f9a8Schristosfor i in 1 2 3 4; do 2628260f9a8Schristos grep -F -q 1.2.3.$i dig.out.none || ret=1 2638260f9a8Schristosdone 2648260f9a8Schristos# Ensure 20 further queries result in the same response as the "reference" one. 2658260f9a8Schristosfor i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do 2668260f9a8Schristos $DIGCMD @10.53.0.2 none.example > dig.out.test$i || ret=1 2678260f9a8Schristos $DIFF dig.out.none dig.out.test$i >/dev/null || ret=1 2688260f9a8Schristosdone 2698260f9a8Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 270497bf0b8Schristosstatus=$((status + ret)) 2718260f9a8Schristos 2728260f9a8Schristosecho_i "Shutting down secondary" 273e2b1b9c0Schristos 274*4bcbe0a3Schristosstop_server ns2 275e2b1b9c0Schristos 2768260f9a8Schristosecho_i "Checking for secondary's on disk copy of zone" 277e2b1b9c0Schristos 278e2b1b9c0Schristosif [ ! -f ns2/root.bk ] 279e2b1b9c0Schristosthen 280e2b1b9c0Schristos echo_i "failed"; 281497bf0b8Schristos status=$((status + 1)) 282e2b1b9c0Schristosfi 283e2b1b9c0Schristos 2848260f9a8Schristosecho_i "Re-starting secondary" 285e2b1b9c0Schristos 286*4bcbe0a3Schristosstart_server --noclean --restart --port ${PORT} ns2 287e2b1b9c0Schristos 288e2b1b9c0Schristos# 289e2b1b9c0Schristos# 290e2b1b9c0Schristos# 291e2b1b9c0Schristosif $test_fixed; then 2928260f9a8Schristos echo_i "Checking order fixed (secondary loaded from disk)" 293e2b1b9c0Schristos ret=0 294e2b1b9c0Schristos for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 295e2b1b9c0Schristos do 296e2b1b9c0Schristos $DIGCMD @10.53.0.2 fixed.example > dig.out.fixed || ret=1 297e2b1b9c0Schristos $DIFF dig.out.fixed dig.out.fixed.good || ret=1 298e2b1b9c0Schristos done 299e2b1b9c0Schristos if [ $ret != 0 ]; then echo_i "failed"; fi 300497bf0b8Schristos status=$((status + ret)) 301e2b1b9c0Schristosfi 302e2b1b9c0Schristos 303e2b1b9c0Schristos# 304e2b1b9c0Schristos# 305e2b1b9c0Schristos# 3068260f9a8Schristosecho_i "Checking order cyclic (secondary + additional, loaded from disk)" 307e2b1b9c0Schristosret=0 308e2b1b9c0Schristosmatches=0 309e2b1b9c0Schristosfor i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 310e2b1b9c0Schristosdo 311497bf0b8Schristos j=$((i % 4)) 312e2b1b9c0Schristos $DIGCMD @10.53.0.2 cyclic.example > dig.out.cyclic || ret=1 313e2b1b9c0Schristos if [ $i -le 4 ]; then 314e2b1b9c0Schristos cp dig.out.cyclic dig.out.$j 315e2b1b9c0Schristos else 316497bf0b8Schristos $DIFF dig.out.cyclic dig.out.$j >/dev/null && matches=$((matches + 1)) 317e2b1b9c0Schristos fi 318e2b1b9c0Schristosdone 319e2b1b9c0Schristos$DIFF dig.out.0 dig.out.1 >/dev/null && ret=1 320e2b1b9c0Schristos$DIFF dig.out.0 dig.out.2 >/dev/null && ret=1 321e2b1b9c0Schristos$DIFF dig.out.0 dig.out.3 >/dev/null && ret=1 322e2b1b9c0Schristos$DIFF dig.out.1 dig.out.2 >/dev/null && ret=1 323e2b1b9c0Schristos$DIFF dig.out.1 dig.out.3 >/dev/null && ret=1 324e2b1b9c0Schristos$DIFF dig.out.2 dig.out.3 >/dev/null && ret=1 325e2b1b9c0Schristosif [ $matches -ne 16 ]; then ret=1; fi 326e2b1b9c0Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 327497bf0b8Schristosstatus=$((status + ret)) 328e2b1b9c0Schristos 329e2b1b9c0Schristos# 330e2b1b9c0Schristos# 331e2b1b9c0Schristos# 3328260f9a8Schristosecho_i "Checking order cyclic (secondary loaded from disk)" 333e2b1b9c0Schristosret=0 334e2b1b9c0Schristosmatches=0 335e2b1b9c0Schristosfor i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 336e2b1b9c0Schristosdo 337497bf0b8Schristos j=$((i % 4)) 338e2b1b9c0Schristos $DIGCMD @10.53.0.2 cyclic2.example > dig.out.cyclic2 || ret=1 339e2b1b9c0Schristos if [ $i -le 4 ]; then 340e2b1b9c0Schristos cp dig.out.cyclic2 dig.out.$j 341e2b1b9c0Schristos else 342497bf0b8Schristos $DIFF dig.out.cyclic2 dig.out.$j >/dev/null && matches=$((matches + 1)) 343e2b1b9c0Schristos fi 344e2b1b9c0Schristosdone 345e2b1b9c0Schristos$DIFF dig.out.0 dig.out.1 >/dev/null && ret=1 346e2b1b9c0Schristos$DIFF dig.out.0 dig.out.2 >/dev/null && ret=1 347e2b1b9c0Schristos$DIFF dig.out.0 dig.out.3 >/dev/null && ret=1 348e2b1b9c0Schristos$DIFF dig.out.1 dig.out.2 >/dev/null && ret=1 349e2b1b9c0Schristos$DIFF dig.out.1 dig.out.3 >/dev/null && ret=1 350e2b1b9c0Schristos$DIFF dig.out.2 dig.out.3 >/dev/null && ret=1 351e2b1b9c0Schristosif [ $matches -ne 16 ]; then ret=1; fi 352e2b1b9c0Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 353497bf0b8Schristosstatus=$((status + ret)) 354e2b1b9c0Schristos 3558260f9a8Schristosecho_i "Checking order random (secondary loaded from disk)" 356e2b1b9c0Schristosret=0 3573daf698fSchristosfor i in $GOOD_RANDOM 358e2b1b9c0Schristosdo 359e2b1b9c0Schristos eval match$i=0 360e2b1b9c0Schristosdone 361e2b1b9c0Schristosfor 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 362e2b1b9c0Schristosdo 363e2b1b9c0Schristos $DIGCMD @10.53.0.2 random.example > dig.out.random || ret=1 364e2b1b9c0Schristos match=0 3653daf698fSchristos for j in $GOOD_RANDOM 366e2b1b9c0Schristos do 367e2b1b9c0Schristos eval "$DIFF dig.out.random dig.out.random.good$j >/dev/null && match$j=1 match=1" 368e2b1b9c0Schristos if [ $match -eq 1 ]; then break; fi 369e2b1b9c0Schristos done 370e2b1b9c0Schristos if [ $match -eq 0 ]; then ret=1; fi 371e2b1b9c0Schristosdone 372e2b1b9c0Schristosmatch=0 3733daf698fSchristosfor i in $GOOD_RANDOM 374e2b1b9c0Schristosdo 375497bf0b8Schristos eval "match=\$((match + match$i))" 376e2b1b9c0Schristosdone 3773daf698fSchristosecho_i "Random selection return $match of ${GOOD_RANDOM_NO} possible orders in 36 samples" 378497bf0b8Schristosif [ $match -lt $((GOOD_RANDOM_NO / 3)) ]; then ret=1; fi 379e2b1b9c0Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 380497bf0b8Schristosstatus=$((status + ret)) 381e2b1b9c0Schristos 3828260f9a8Schristosecho_i "Checking order none (secondary loaded from disk)" 3838260f9a8Schristosret=0 3848260f9a8Schristos# Fetch the "reference" response and ensure it contains the expected records. 3858260f9a8Schristos$DIGCMD @10.53.0.2 none.example > dig.out.none || ret=1 3868260f9a8Schristosfor i in 1 2 3 4; do 3878260f9a8Schristos grep -F -q 1.2.3.$i dig.out.none || ret=1 3888260f9a8Schristosdone 3898260f9a8Schristos# Ensure 20 further queries result in the same response as the "reference" one. 3908260f9a8Schristosfor i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do 3918260f9a8Schristos $DIGCMD @10.53.0.2 none.example > dig.out.test$i || ret=1 3928260f9a8Schristos $DIFF dig.out.none dig.out.test$i >/dev/null || ret=1 3938260f9a8Schristosdone 3948260f9a8Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 395497bf0b8Schristosstatus=$((status + ret)) 3968260f9a8Schristos 397e2b1b9c0Schristos# 398e2b1b9c0Schristos# 399e2b1b9c0Schristos# 400e2b1b9c0Schristosif $test_fixed; then 401e2b1b9c0Schristos echo_i "Checking order fixed (cache)" 402e2b1b9c0Schristos ret=0 403e2b1b9c0Schristos for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 404e2b1b9c0Schristos do 405e2b1b9c0Schristos $DIGCMD @10.53.0.3 fixed.example > dig.out.fixed || ret=1 406e2b1b9c0Schristos $DIFF dig.out.fixed dig.out.fixed.good || ret=1 407e2b1b9c0Schristos done 408e2b1b9c0Schristos if [ $ret != 0 ]; then echo_i "failed"; fi 409497bf0b8Schristos status=$((status + ret)) 410e2b1b9c0Schristosfi 411e2b1b9c0Schristos 412e2b1b9c0Schristos# 413e2b1b9c0Schristos# 414e2b1b9c0Schristos# 415e2b1b9c0Schristosecho_i "Checking order cyclic (cache + additional)" 416e2b1b9c0Schristosret=0 417e2b1b9c0Schristos# prime acache 418e2b1b9c0Schristos$DIGCMD @10.53.0.3 cyclic.example > dig.out.cyclic || ret=1 419e2b1b9c0Schristosmatches=0 420e2b1b9c0Schristosfor i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 421e2b1b9c0Schristosdo 422497bf0b8Schristos j=$((i % 4)) 423e2b1b9c0Schristos $DIGCMD @10.53.0.3 cyclic.example > dig.out.cyclic || ret=1 424e2b1b9c0Schristos if [ $i -le 4 ]; then 425e2b1b9c0Schristos cp dig.out.cyclic dig.out.$j 426e2b1b9c0Schristos else 427497bf0b8Schristos $DIFF dig.out.cyclic dig.out.$j >/dev/null && matches=$((matches + 1)) 428e2b1b9c0Schristos fi 429e2b1b9c0Schristosdone 430e2b1b9c0Schristos$DIFF dig.out.0 dig.out.1 >/dev/null && ret=1 431e2b1b9c0Schristos$DIFF dig.out.0 dig.out.2 >/dev/null && ret=1 432e2b1b9c0Schristos$DIFF dig.out.0 dig.out.3 >/dev/null && ret=1 433e2b1b9c0Schristos$DIFF dig.out.1 dig.out.2 >/dev/null && ret=1 434e2b1b9c0Schristos$DIFF dig.out.1 dig.out.3 >/dev/null && ret=1 435e2b1b9c0Schristos$DIFF dig.out.2 dig.out.3 >/dev/null && ret=1 436e2b1b9c0Schristosif [ $matches -ne 16 ]; then ret=1; fi 437e2b1b9c0Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 438497bf0b8Schristosstatus=$((status + ret)) 439e2b1b9c0Schristos 440e2b1b9c0Schristos# 441e2b1b9c0Schristos# 442e2b1b9c0Schristos# 443e2b1b9c0Schristosecho_i "Checking order cyclic (cache)" 444e2b1b9c0Schristosret=0 445e2b1b9c0Schristos# prime acache 446e2b1b9c0Schristos$DIGCMD @10.53.0.3 cyclic2.example > dig.out.cyclic2 || ret=1 447e2b1b9c0Schristosmatches=0 448e2b1b9c0Schristosfor i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 449e2b1b9c0Schristosdo 450497bf0b8Schristos j=$((i % 4)) 451e2b1b9c0Schristos $DIGCMD @10.53.0.3 cyclic2.example > dig.out.cyclic2 || ret=1 452e2b1b9c0Schristos if [ $i -le 4 ]; then 453e2b1b9c0Schristos cp dig.out.cyclic2 dig.out.$j 454e2b1b9c0Schristos else 455497bf0b8Schristos $DIFF dig.out.cyclic2 dig.out.$j >/dev/null && matches=$((matches + 1)) 456e2b1b9c0Schristos fi 457e2b1b9c0Schristosdone 458e2b1b9c0Schristos$DIFF dig.out.0 dig.out.1 >/dev/null && ret=1 459e2b1b9c0Schristos$DIFF dig.out.0 dig.out.2 >/dev/null && ret=1 460e2b1b9c0Schristos$DIFF dig.out.0 dig.out.3 >/dev/null && ret=1 461e2b1b9c0Schristos$DIFF dig.out.1 dig.out.2 >/dev/null && ret=1 462e2b1b9c0Schristos$DIFF dig.out.1 dig.out.3 >/dev/null && ret=1 463e2b1b9c0Schristos$DIFF dig.out.2 dig.out.3 >/dev/null && ret=1 464e2b1b9c0Schristosif [ $matches -ne 16 ]; then ret=1; fi 465e2b1b9c0Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 466497bf0b8Schristosstatus=$((status + ret)) 467e2b1b9c0Schristos 468e2b1b9c0Schristosecho_i "Checking order random (cache)" 469e2b1b9c0Schristosret=0 4703daf698fSchristosfor i in $GOOD_RANDOM 471e2b1b9c0Schristosdo 472e2b1b9c0Schristos eval match$i=0 473e2b1b9c0Schristosdone 474e2b1b9c0Schristosfor 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 475e2b1b9c0Schristosdo 476e2b1b9c0Schristos $DIGCMD @10.53.0.3 random.example > dig.out.random || ret=1 477e2b1b9c0Schristos match=0 4783daf698fSchristos for j in $GOOD_RANDOM 479e2b1b9c0Schristos do 480e2b1b9c0Schristos eval "$DIFF dig.out.random dig.out.random.good$j >/dev/null && match$j=1 match=1" 481e2b1b9c0Schristos if [ $match -eq 1 ]; then break; fi 482e2b1b9c0Schristos done 483e2b1b9c0Schristos if [ $match -eq 0 ]; then ret=1; fi 484e2b1b9c0Schristosdone 485e2b1b9c0Schristosmatch=0 4863daf698fSchristosfor i in $GOOD_RANDOM 487e2b1b9c0Schristosdo 488497bf0b8Schristos eval "match=\$((match + match$i))" 489e2b1b9c0Schristosdone 4903daf698fSchristosecho_i "Random selection return $match of ${GOOD_RANDOM_NO} possible orders in 36 samples" 491497bf0b8Schristosif [ $match -lt $((GOOD_RANDOM_NO / 3)) ]; then ret=1; fi 492e2b1b9c0Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 493497bf0b8Schristosstatus=$((status + ret)) 494e2b1b9c0Schristos 4958260f9a8Schristosecho_i "Checking order none (cache)" 4968260f9a8Schristosret=0 4978260f9a8Schristos# Fetch the "reference" response and ensure it contains the expected records. 4988260f9a8Schristos$DIGCMD @10.53.0.3 none.example > dig.out.none || ret=1 4998260f9a8Schristosfor i in 1 2 3 4; do 5008260f9a8Schristos grep -F -q 1.2.3.$i dig.out.none || ret=1 5018260f9a8Schristosdone 5028260f9a8Schristos# Ensure 20 further queries result in the same response as the "reference" one. 5038260f9a8Schristosfor i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do 5048260f9a8Schristos $DIGCMD @10.53.0.3 none.example > dig.out.test$i || ret=1 5058260f9a8Schristos $DIFF dig.out.none dig.out.test$i >/dev/null || ret=1 5068260f9a8Schristosdone 5078260f9a8Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 508497bf0b8Schristosstatus=$((status + ret)) 5098260f9a8Schristos 510e2b1b9c0Schristosecho_i "Checking default order (cache)" 511e2b1b9c0Schristosret=0 5123daf698fSchristosfor i in $GOOD_RANDOM 513e2b1b9c0Schristosdo 514e2b1b9c0Schristos eval match$i=0 515e2b1b9c0Schristosdone 516e2b1b9c0Schristosfor 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 517e2b1b9c0Schristosdo 518e2b1b9c0Schristos $DIGCMD @10.53.0.5 random.example > dig.out.random || ret=1 519e2b1b9c0Schristos match=0 5203daf698fSchristos for j in $GOOD_RANDOM 521e2b1b9c0Schristos do 522e2b1b9c0Schristos eval "$DIFF dig.out.random dig.out.random.good$j >/dev/null && match$j=1 match=1" 523e2b1b9c0Schristos if [ $match -eq 1 ]; then break; fi 524e2b1b9c0Schristos done 525e2b1b9c0Schristos if [ $match -eq 0 ]; then ret=1; fi 526e2b1b9c0Schristosdone 527e2b1b9c0Schristosmatch=0 5283daf698fSchristosfor i in $GOOD_RANDOM 529e2b1b9c0Schristosdo 530497bf0b8Schristos eval "match=\$((match + match$i))" 531e2b1b9c0Schristosdone 5323daf698fSchristosecho_i "Default selection return $match of ${GOOD_RANDOM_NO} possible orders in 36 samples" 533497bf0b8Schristosif [ $match -lt $((GOOD_RANDOM_NO / 3)) ]; then ret=1; fi 534e2b1b9c0Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 535497bf0b8Schristosstatus=$((status + ret)) 5368260f9a8Schristos 5378260f9a8Schristosecho_i "Checking default order no match in rrset-order (cache)" 5388260f9a8Schristosret=0 5398260f9a8Schristos# Fetch the "reference" response and ensure it contains the expected records. 5408260f9a8Schristos$DIGCMD @10.53.0.4 nomatch.example > dig.out.nomatch || ret=1 5418260f9a8Schristosfor i in 1 2 3 4; do 5428260f9a8Schristos grep -F -q 1.2.3.$i dig.out.nomatch || ret=1 5438260f9a8Schristosdone 5448260f9a8Schristos# Ensure 20 further queries result in the same response as the "reference" one. 5458260f9a8Schristosfor i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do 5468260f9a8Schristos $DIGCMD @10.53.0.4 nomatch.example > dig.out.test$i || ret=1 5478260f9a8Schristos $DIFF dig.out.nomatch dig.out.test$i >/dev/null || ret=1 5488260f9a8Schristosdone 5498260f9a8Schristosif [ $ret != 0 ]; then echo_i "failed"; fi 550497bf0b8Schristosstatus=$((status + ret)) 5518260f9a8Schristos 552e2b1b9c0Schristosecho_i "exit status: $status" 553e2b1b9c0Schristos[ $status -eq 0 ] || exit 1 554