1 1.1 christos #!/bin/sh 2 1.1.1.5 christos 3 1.1 christos # Copyright (C) Internet Systems Consortium, Inc. ("ISC") 4 1.1 christos # 5 1.1.1.5 christos # SPDX-License-Identifier: MPL-2.0 6 1.1.1.5 christos # 7 1.1 christos # This Source Code Form is subject to the terms of the Mozilla Public 8 1.1.1.5 christos # License, v. 2.0. If a copy of the MPL was not distributed with this 9 1.1.1.4 christos # file, you can obtain one at https://mozilla.org/MPL/2.0/. 10 1.1 christos # 11 1.1 christos # See the COPYRIGHT file distributed with this work for additional 12 1.1 christos # information regarding copyright ownership. 13 1.1 christos 14 1.1.1.7 christos set -e 15 1.1.1.7 christos 16 1.1.1.7 christos . ../conf.sh 17 1.1 christos 18 1.1 christos status=0 19 1.1.1.5 christos n=0 20 1.1 christos 21 1.1 christos DIGOPTS="-p ${PORT}" 22 1.1 christos 23 1.1.1.7 christos dig_cmd() { 24 1.1.1.7 christos # shellcheck disable=SC2086 25 1.1.1.7 christos "$DIG" $DIGOPTS "$@" | grep -v '^;' 26 1.1.1.7 christos } 27 1.1.1.7 christos 28 1.1.1.7 christos n=$((n + 1)) 29 1.1.1.5 christos echo_i "querying for various representations of an IN A record ($n)" 30 1.1.1.7 christos for i in 1 2 3 4 5 6 7 8 9 10 11 12; do 31 1.1.1.7 christos ret=0 32 1.1.1.7 christos dig_cmd +short @10.53.0.1 a$i.example a in >dig.out.$i.test$n 33 1.1.1.7 christos echo 10.0.0.1 | diff - dig.out.$i.test$n || ret=1 34 1.1.1.7 christos if [ $ret != 0 ]; then 35 1.1.1.7 christos echo_i "#$i failed" 36 1.1.1.7 christos fi 37 1.1.1.7 christos status=$((status + ret)) 38 1.1 christos done 39 1.1 christos 40 1.1.1.7 christos n=$((n + 1)) 41 1.1.1.5 christos echo_i "querying for various representations of an IN TXT record ($n)" 42 1.1.1.7 christos for i in 1 2 3 4 5 6 7; do 43 1.1.1.7 christos ret=0 44 1.1.1.7 christos dig_cmd +short @10.53.0.1 txt$i.example txt in >dig.out.$i.test$n 45 1.1.1.7 christos echo '"hello"' | diff - dig.out.$i.test$n || ret=1 46 1.1.1.7 christos if [ $ret != 0 ]; then 47 1.1.1.7 christos echo_i "#$i failed" 48 1.1.1.7 christos fi 49 1.1.1.7 christos status=$((status + ret)) 50 1.1 christos done 51 1.1 christos 52 1.1.1.7 christos n=$((n + 1)) 53 1.1.1.5 christos echo_i "querying for various representations of an IN TYPE123 record ($n)" 54 1.1.1.7 christos for i in 1 2 3; do 55 1.1.1.7 christos ret=0 56 1.1.1.7 christos dig_cmd +short @10.53.0.1 unk$i.example type123 in >dig.out.$i.test$n 57 1.1.1.7 christos echo '\# 1 00' | diff - dig.out.$i.test$n || ret=1 58 1.1.1.7 christos if [ $ret != 0 ]; then 59 1.1.1.7 christos echo_i "#$i failed" 60 1.1.1.7 christos fi 61 1.1.1.7 christos status=$((status + ret)) 62 1.1 christos done 63 1.1 christos 64 1.1.1.7 christos n=$((n + 1)) 65 1.1.1.5 christos echo_i "querying for NULL record ($n)" 66 1.1 christos ret=0 67 1.1.1.7 christos dig_cmd +short @10.53.0.1 null.example null in >dig.out.test$n 68 1.1.1.7 christos echo '\# 1 00' | diff - dig.out.test$n || ret=1 69 1.1 christos [ $ret = 0 ] || echo_i "failed" 70 1.1.1.7 christos status=$((status + ret)) 71 1.1 christos 72 1.1.1.7 christos n=$((n + 1)) 73 1.1.1.5 christos echo_i "querying for empty NULL record ($n)" 74 1.1 christos ret=0 75 1.1.1.7 christos dig_cmd +short @10.53.0.1 empty.example null in >dig.out.test$n 76 1.1.1.7 christos echo '\# 0' | diff - dig.out.test$n || ret=1 77 1.1 christos [ $ret = 0 ] || echo_i "failed" 78 1.1.1.7 christos status=$((status + ret)) 79 1.1 christos 80 1.1.1.7 christos n=$((n + 1)) 81 1.1.1.5 christos echo_i "querying for various representations of a CLASS10 TYPE1 record ($n)" 82 1.1.1.7 christos for i in 1 2; do 83 1.1.1.7 christos ret=0 84 1.1.1.7 christos dig_cmd +short @10.53.0.1 a$i.example a class10 >dig.out.$i.test$n 85 1.1.1.7 christos echo '\# 4 0A000001' | diff - dig.out.$i.test$n || ret=1 86 1.1.1.7 christos if [ $ret != 0 ]; then 87 1.1.1.7 christos echo_i "#$i failed" 88 1.1.1.7 christos fi 89 1.1.1.7 christos status=$((status + ret)) 90 1.1 christos done 91 1.1 christos 92 1.1.1.7 christos n=$((n + 1)) 93 1.1.1.5 christos echo_i "querying for various representations of a CLASS10 TXT record ($n)" 94 1.1.1.7 christos for i in 1 2 3 4; do 95 1.1.1.7 christos ret=0 96 1.1.1.7 christos dig_cmd +short @10.53.0.1 txt$i.example txt class10 >dig.out.$i.test$n 97 1.1.1.7 christos echo '"hello"' | diff - dig.out.$i.test$n || ret=1 98 1.1.1.7 christos if [ $ret != 0 ]; then 99 1.1.1.7 christos echo_i "#$i failed" 100 1.1.1.7 christos fi 101 1.1.1.7 christos status=$((status + ret)) 102 1.1 christos done 103 1.1 christos 104 1.1.1.7 christos n=$((n + 1)) 105 1.1.1.5 christos echo_i "querying for various representations of a CLASS10 TYPE123 record ($n)" 106 1.1.1.7 christos for i in 1 2; do 107 1.1.1.7 christos ret=0 108 1.1.1.7 christos dig_cmd +short @10.53.0.1 unk$i.example type123 class10 >dig.out.$i.test$n 109 1.1.1.7 christos echo '\# 1 00' | diff - dig.out.$i.test$n || ret=1 110 1.1.1.7 christos if [ $ret != 0 ]; then 111 1.1.1.7 christos echo_i "#$i failed" 112 1.1.1.7 christos fi 113 1.1.1.7 christos status=$((status + ret)) 114 1.1 christos done 115 1.1 christos 116 1.1.1.7 christos n=$((n + 1)) 117 1.1.1.5 christos echo_i "querying for SOAs of zone that should have failed to load ($n)" 118 1.1.1.7 christos for i in 1 2 3 4; do 119 1.1.1.7 christos ret=0 120 1.1.1.7 christos $DIG $DIGOPTS @10.53.0.1 broken$i. soa in >dig.out.$i.test$n || ret=1 121 1.1.1.7 christos grep "SERVFAIL" dig.out.$i.test$n >/dev/null || ret=1 122 1.1.1.7 christos if [ $ret != 0 ]; then 123 1.1.1.7 christos echo_i "#$i failed" 124 1.1.1.7 christos fi 125 1.1.1.7 christos status=$((status + ret)) 126 1.1 christos done 127 1.1 christos 128 1.1.1.7 christos n=$((n + 1)) 129 1.1.1.5 christos echo_i "checking large unknown record loading on primary ($n)" 130 1.1.1.3 christos for try in 0 1 2 3 4 5 6 7 8 9; do 131 1.1.1.7 christos ret=0 132 1.1.1.7 christos dig_cmd @10.53.0.1 +tcp +short large.example TYPE45234 >dig.out.$i.test$n 133 1.1.1.7 christos diff -s large.out dig.out.$i.test$n >/dev/null || { 134 1.1.1.7 christos ret=1 135 1.1.1.7 christos echo_i "diff failed" 136 1.1.1.7 christos } 137 1.1.1.7 christos [ "$ret" -eq 0 ] && break 138 1.1.1.7 christos sleep 1 139 1.1.1.3 christos done 140 1.1 christos [ $ret = 0 ] || echo_i "failed" 141 1.1.1.7 christos status=$((status + ret)) 142 1.1 christos 143 1.1.1.7 christos n=$((n + 1)) 144 1.1.1.5 christos echo_i "checking large unknown record loading on secondary ($n)" 145 1.1.1.3 christos for try in 0 1 2 3 4 5 6 7 8 9; do 146 1.1.1.7 christos ret=0 147 1.1.1.7 christos dig_cmd @10.53.0.2 +tcp +short large.example TYPE45234 >dig.out.$i.test$n 148 1.1.1.7 christos diff -s large.out dig.out.$i.test$n >/dev/null || { 149 1.1.1.7 christos ret=1 150 1.1.1.7 christos echo_i "diff failed" 151 1.1.1.7 christos } 152 1.1.1.7 christos [ "$ret" -eq 0 ] && break 153 1.1.1.7 christos sleep 1 154 1.1.1.3 christos done 155 1.1 christos [ $ret = 0 ] || echo_i "failed" 156 1.1.1.7 christos status=$((status + ret)) 157 1.1 christos 158 1.1.1.4 christos echo_i "stop and restart secondary" 159 1.1.1.6 christos stop_server ns2 160 1.1.1.6 christos start_server --noclean --restart --port ${PORT} ns2 161 1.1 christos 162 1.1.1.3 christos # server may be answering queries before zones are loaded, 163 1.1.1.3 christos # so retry a few times if this query fails 164 1.1.1.7 christos n=$((n + 1)) 165 1.1.1.5 christos echo_i "checking large unknown record loading on secondary ($n)" 166 1.1.1.3 christos for try in 0 1 2 3 4 5 6 7 8 9; do 167 1.1.1.7 christos ret=0 168 1.1.1.7 christos dig_cmd @10.53.0.2 +tcp +short large.example TYPE45234 >dig.out.$i.test$n 169 1.1.1.7 christos diff -s large.out dig.out.$i.test$n >/dev/null || { 170 1.1.1.7 christos ret=1 171 1.1.1.7 christos echo_i "diff failed" 172 1.1.1.7 christos } 173 1.1.1.7 christos [ "$ret" -eq 0 ] && break 174 1.1.1.7 christos sleep 1 175 1.1.1.3 christos done 176 1.1 christos [ $ret = 0 ] || echo_i "failed" 177 1.1.1.7 christos status=$((status + ret)) 178 1.1 christos 179 1.1.1.7 christos n=$((n + 1)) 180 1.1.1.5 christos echo_i "checking large unknown record loading on inline secondary ($n)" 181 1.1 christos ret=0 182 1.1.1.7 christos dig_cmd @10.53.0.3 +tcp +short large.example TYPE45234 >dig.out.test$n 183 1.1.1.7 christos diff large.out dig.out.test$n >/dev/null || { 184 1.1.1.7 christos ret=1 185 1.1.1.7 christos echo_i "diff failed" 186 1.1.1.7 christos } 187 1.1 christos [ $ret = 0 ] || echo_i "failed" 188 1.1.1.7 christos status=$((status + ret)) 189 1.1 christos 190 1.1.1.4 christos echo_i "stop and restart inline secondary" 191 1.1.1.6 christos stop_server ns3 192 1.1.1.6 christos start_server --noclean --restart --port ${PORT} ns3 193 1.1 christos 194 1.1.1.3 christos # server may be answering queries before zones are loaded, 195 1.1.1.3 christos # so retry a few times if this query fails 196 1.1.1.7 christos n=$((n + 1)) 197 1.1.1.5 christos echo_i "checking large unknown record loading on inline secondary ($n)" 198 1.1.1.3 christos for try in 0 1 2 3 4 5 6 7 8 9; do 199 1.1.1.7 christos ret=0 200 1.1.1.7 christos dig_cmd @10.53.0.3 +tcp +short large.example TYPE45234 >dig.out.$i.test$n 201 1.1.1.7 christos diff large.out dig.out.$i.test$n >/dev/null || { 202 1.1.1.7 christos ret=1 203 1.1.1.7 christos echo_i "diff failed" 204 1.1.1.7 christos } 205 1.1.1.7 christos [ "$ret" -eq 0 ] && break 206 1.1.1.7 christos sleep 1 207 1.1.1.3 christos done 208 1.1 christos [ $ret = 0 ] || echo_i "failed" 209 1.1.1.7 christos status=$((status + ret)) 210 1.1 christos 211 1.1.1.7 christos n=$((n + 1)) 212 1.1.1.5 christos echo_i "check that '"'"\\#"'"' is not treated as the unknown escape sequence ($n)" 213 1.1 christos ret=0 214 1.1.1.7 christos dig_cmd @10.53.0.1 +tcp +short txt8.example txt >dig.out.test$n 215 1.1.1.7 christos echo '"#" "2" "0145"' | diff - dig.out.test$n || ret=1 216 1.1 christos [ $ret = 0 ] || echo_i "failed" 217 1.1.1.7 christos status=$((status + ret)) 218 1.1 christos 219 1.1.1.7 christos n=$((n + 1)) 220 1.1.1.5 christos echo_i "check that 'TXT \# text' is not treated as the unknown escape sequence ($n)" 221 1.1 christos ret=0 222 1.1.1.7 christos dig_cmd @10.53.0.1 +tcp +short txt9.example txt >dig.out.test$n 223 1.1.1.7 christos echo '"#" "text"' | diff - dig.out.test$n || ret=1 224 1.1 christos [ $ret = 0 ] || echo_i "failed" 225 1.1.1.7 christos status=$((status + ret)) 226 1.1 christos 227 1.1.1.7 christos n=$((n + 1)) 228 1.1.1.5 christos echo_i "check that 'TYPE353 \# cat' produces 'not a valid number' ($n)" 229 1.1 christos ret=0 230 1.1.1.7 christos $CHECKZONE nan.bad zones/nan.bad >check.out 2>&1 && ret=1 231 1.1.1.7 christos grep "not a valid number" check.out >/dev/null || ret=1 232 1.1 christos [ $ret = 0 ] || echo_i "failed" 233 1.1.1.7 christos status=$((status + ret)) 234 1.1 christos 235 1.1 christos echo_i "exit status: $status" 236 1.1 christos [ $status -eq 0 ] || exit 1 237