1 1.1 christos #!/bin/sh 2 1.1.1.6 christos 3 1.1 christos # Copyright (C) Internet Systems Consortium, Inc. ("ISC") 4 1.1 christos # 5 1.1.1.6 christos # SPDX-License-Identifier: MPL-2.0 6 1.1.1.6 christos # 7 1.1 christos # This Source Code Form is subject to the terms of the Mozilla Public 8 1.1.1.6 christos # License, v. 2.0. If a copy of the MPL was not distributed with this 9 1.1.1.5 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.8 christos set -e 15 1.1 christos 16 1.1.1.8 christos # shellcheck disable=SC2034 17 1.1.1.8 christos . ../conf.sh 18 1.1.1.8 christos 19 1.1.1.8 christos dig_plus_opts() { 20 1.1.1.8 christos $DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd -p "${PORT}" "$@" 21 1.1.1.8 christos } 22 1.1 christos 23 1.1 christos status=0 24 1.1 christos n=0 25 1.1 christos 26 1.1.1.8 christos test_start() { 27 1.1.1.8 christos n=$((n + 1)) 28 1.1.1.8 christos echo_i "$* ($n)" 29 1.1.1.8 christos ret=0 30 1.1.1.8 christos } 31 1.1.1.8 christos 32 1.1.1.8 christos test_end() { 33 1.1.1.8 christos [ $ret = 0 ] || echo_i "failed" 34 1.1.1.8 christos status=$((status + ret)) 35 1.1.1.8 christos } 36 1.1.1.8 christos 37 1.1 christos # 38 1.1 christos # Wait up to 10 seconds for the servers to finish starting before testing. 39 1.1 christos # 40 1.1.1.8 christos for i in 1 2 3 4 5 6 7 8 9 10; do 41 1.1.1.8 christos ret=0 42 1.1.1.8 christos $DIG +tcp -p "${PORT}" example @10.53.0.2 soa >dig.out.ns2.test$n || ret=1 43 1.1.1.8 christos grep "status: NOERROR" dig.out.ns2.test$n >/dev/null || ret=1 44 1.1.1.8 christos grep "flags:.* aa[ ;]" dig.out.ns2.test$n >/dev/null || ret=1 45 1.1.1.8 christos $DIG +tcp -p "${PORT}" example @10.53.0.3 soa >dig.out.ns3.test$n || ret=1 46 1.1.1.8 christos grep "status: NOERROR" dig.out.ns3.test$n >/dev/null || ret=1 47 1.1.1.8 christos grep "flags:.* aa[ ;]" dig.out.ns3.test$n >/dev/null || ret=1 48 1.1.1.8 christos nr=$(grep -c 'x[0-9].*sending notify to' ns2/named.run) 49 1.1.1.12 christos [ "$nr" -ge 22 ] || ret=1 50 1.1.1.8 christos [ $ret = 0 ] && break 51 1.1.1.8 christos sleep 1 52 1.1 christos done 53 1.1 christos 54 1.1.1.8 christos test_start "checking initial status" 55 1.1 christos 56 1.1.1.8 christos dig_plus_opts a.example. @10.53.0.2 a >dig.out.ns2.test$n || ret=1 57 1.1.1.8 christos grep "10.0.0.1" dig.out.ns2.test$n >/dev/null || ret=1 58 1.1.1.8 christos 59 1.1.1.8 christos dig_plus_opts a.example. @10.53.0.3 a >dig.out.ns3.test$n || ret=1 60 1.1.1.8 christos grep "10.0.0.1" dig.out.ns3.test$n >/dev/null || ret=1 61 1.1 christos 62 1.1 christos digcomp dig.out.ns2.test$n dig.out.ns3.test$n || ret=1 63 1.1 christos 64 1.1.1.8 christos test_end 65 1.1 christos 66 1.1.1.8 christos test_start "checking startup notify rate limit" 67 1.1.1.3 christos awk '/x[0-9].*sending notify to/ { 68 1.1.1.3 christos split($2, a, ":"); 69 1.1.1.3 christos this = a[1] * 3600 + a[2] * 60 + a[3]; 70 1.1.1.3 christos if (lasta1 && lasta1 > a[1]) { 71 1.1.1.3 christos fix = 3600 * 24; 72 1.1.1.3 christos } 73 1.1.1.3 christos this += fix; 74 1.1.1.3 christos if (last) { 75 1.1.1.3 christos delta = this - last; 76 1.1.1.3 christos print delta; 77 1.1.1.3 christos 78 1.1.1.3 christos total += delta; 79 1.1.1.3 christos if (!maxdelta || delta > maxdelta) { 80 1.1.1.3 christos maxdelta = delta; 81 1.1.1.3 christos } 82 1.1.1.3 christos if (!mindelta || delta < mindelta) { 83 1.1.1.3 christos mindelta = delta; 84 1.1.1.3 christos } 85 1.1.1.3 christos } 86 1.1.1.3 christos lasta1 = a[1]; 87 1.1.1.3 christos last = this; 88 1.1.1.3 christos count++; 89 1.1.1.3 christos } 90 1.1.1.3 christos END { 91 1.1.1.3 christos average = total / count; 92 1.1.1.3 christos print "mindelta:", mindelta; 93 1.1.1.3 christos print "maxdelta:" maxdelta; 94 1.1.1.3 christos print "count:", count; 95 1.1.1.3 christos print "average:", average; 96 1.1.1.3 christos if (average < 0.180) exit(1); 97 1.1.1.12 christos if (count < 22) exit(1); 98 1.1.1.8 christos }' ns2/named.run >awk.out.ns2.test$n || ret=1 99 1.1.1.8 christos test_end 100 1.1 christos 101 1.1.1.9 christos # See [GL#4689] 102 1.1.1.9 christos test_start "checking server behaviour with invalid notify-source-v6 address" 103 1.1.1.9 christos grep "zone ./IN: sending notify to fd92:7065:b8e:fffe::a35:4#" ns1/named.run >/dev/null || ret=1 104 1.1.1.9 christos grep "dns_request_create: failed address not available" ns1/named.run >/dev/null || ret=1 105 1.1.1.9 christos test_end 106 1.1.1.9 christos 107 1.1.1.8 christos nextpart ns3/named.run >/dev/null 108 1.1 christos 109 1.1 christos sleep 1 # make sure filesystem time stamp is newer for reload. 110 1.1 christos rm -f ns2/example.db 111 1.1 christos cp -f ns2/example2.db ns2/example.db 112 1.1.1.8 christos echo_i "reloading with example2 using HUP and waiting up to 45 seconds" 113 1.1.1.8 christos kill -HUP "$(cat ns2/named.pid)" 114 1.1.1.8 christos wait_for_log_re 45 "transfer of 'example/IN' from 10.53.0.2#.*success" ns3/named.run 115 1.1.1.8 christos 116 1.1.1.8 christos test_start "checking notify message was logged" 117 1.1.1.8 christos grep 'notify from 10.53.0.2#[0-9][0-9]*: serial 2$' ns3/named.run >/dev/null || ret=1 118 1.1.1.10 christos grep 'refused notify from non-primary: fd92:7065:b8e:ffff::2#[0-9][0-9]*$' ns3/named.run >/dev/null || ret=1 119 1.1.1.8 christos test_end 120 1.1.1.8 christos 121 1.1.1.10 christos if $FEATURETEST --have-fips-dh; then 122 1.1.1.10 christos test_start "checking notify over TLS successful" 123 1.1.1.10 christos grep "zone tls-x1/IN: notify to 10.53.0.2#${TLSPORT} successful" ns3/named.run >/dev/null || ret=1 124 1.1.1.10 christos grep "zone tls-x2/IN: notify to 10.53.0.2#${EXTRAPORT1} successful" ns3/named.run >/dev/null || ret=1 125 1.1.1.10 christos grep "zone tls-x3/IN: notify to 10.53.0.2#${EXTRAPORT1} successful" ns3/named.run >/dev/null || ret=1 126 1.1.1.10 christos grep "zone tls-x5/IN: notify to 10.53.0.2#${EXTRAPORT3} successful" ns3/named.run >/dev/null || ret=1 127 1.1.1.10 christos test_end 128 1.1.1.10 christos 129 1.1.1.10 christos test_start "checking notify over TLS failed" 130 1.1.1.10 christos grep "zone tls-x4/IN: notify to 10.53.0.2#${EXTRAPORT1} failed: TLS peer certificate verification failed" ns3/named.run >/dev/null || ret=1 131 1.1.1.10 christos grep "zone tls-x6/IN: notify to 10.53.0.2#${EXTRAPORT4} failed: TLS peer certificate verification failed" ns3/named.run >/dev/null || ret=1 132 1.1.1.10 christos test_end 133 1.1.1.10 christos fi 134 1.1.1.10 christos 135 1.1.1.8 christos test_start "checking example2 loaded" 136 1.1.1.8 christos dig_plus_opts a.example. @10.53.0.2 a >dig.out.ns2.test$n || ret=1 137 1.1.1.8 christos grep "10.0.0.2" dig.out.ns2.test$n >/dev/null || ret=1 138 1.1.1.8 christos test_end 139 1.1 christos 140 1.1.1.8 christos test_start "checking example2 contents have been transferred after HUP reload" 141 1.1 christos 142 1.1.1.8 christos dig_plus_opts a.example. @10.53.0.2 a >dig.out.ns2.test$n || ret=1 143 1.1.1.8 christos grep "10.0.0.2" dig.out.ns2.test$n >/dev/null || ret=1 144 1.1.1.8 christos 145 1.1.1.8 christos dig_plus_opts a.example. @10.53.0.3 a >dig.out.ns3.test$n || ret=1 146 1.1.1.8 christos grep "10.0.0.2" dig.out.ns3.test$n >/dev/null || ret=1 147 1.1 christos 148 1.1 christos digcomp dig.out.ns2.test$n dig.out.ns3.test$n || ret=1 149 1.1 christos 150 1.1.1.8 christos test_end 151 1.1 christos 152 1.1.1.8 christos echo_i "stopping primary and restarting with example4 then waiting up to 45 seconds" 153 1.1.1.7 christos stop_server ns2 154 1.1 christos 155 1.1 christos rm -f ns2/example.db 156 1.1 christos cp -f ns2/example4.db ns2/example.db 157 1.1 christos 158 1.1.1.7 christos start_server --noclean --restart --port "${PORT}" ns2 159 1.1.1.8 christos wait_for_log_re 45 "transfer of 'example/IN' from 10.53.0.2#.*success" ns3/named.run 160 1.1 christos 161 1.1.1.8 christos test_start "checking notify message was logged" 162 1.1.1.8 christos grep 'notify from 10.53.0.2#[0-9][0-9]*: serial 4$' ns3/named.run >/dev/null || ret=1 163 1.1.1.8 christos test_end 164 1.1.1.8 christos 165 1.1.1.8 christos test_start "checking example4 loaded" 166 1.1.1.8 christos dig_plus_opts a.example. @10.53.0.2 a >dig.out.ns2.test$n || ret=1 167 1.1.1.8 christos grep "10.0.0.4" dig.out.ns2.test$n >/dev/null || ret=1 168 1.1.1.8 christos test_end 169 1.1.1.8 christos 170 1.1.1.8 christos test_start "checking example4 contents have been transferred after restart" 171 1.1 christos 172 1.1.1.8 christos dig_plus_opts a.example. @10.53.0.2 a >dig.out.ns2.test$n || ret=1 173 1.1.1.8 christos grep "10.0.0.4" dig.out.ns2.test$n >/dev/null || ret=1 174 1.1 christos 175 1.1.1.8 christos dig_plus_opts a.example. @10.53.0.3 a >dig.out.ns3.test$n || ret=1 176 1.1.1.8 christos grep "10.0.0.4" dig.out.ns3.test$n >/dev/null || ret=1 177 1.1 christos 178 1.1 christos digcomp dig.out.ns2.test$n dig.out.ns3.test$n || ret=1 179 1.1 christos 180 1.1.1.8 christos test_end 181 1.1 christos 182 1.1.1.8 christos test_start "checking notify to alternate port with primary server inheritance" 183 1.1.1.8 christos $NSUPDATE <<EOF 184 1.1 christos server 10.53.0.2 ${PORT} 185 1.1 christos zone x21 186 1.1 christos update add added.x21 0 in txt "test string" 187 1.1 christos send 188 1.1 christos EOF 189 1.1.1.8 christos fn="dig.out.ns4.test$n" 190 1.1.1.8 christos for i in 1 2 3 4 5 6 7 8 9; do 191 1.1.1.8 christos dig_plus_opts added.x21. @10.53.0.4 txt -p "$EXTRAPORT1" >"$fn" || ret=1 192 1.1.1.8 christos grep "test string" "$fn" >/dev/null && break 193 1.1.1.8 christos sleep 1 194 1.1 christos done 195 1.1.1.8 christos grep "test string" "$fn" >/dev/null || ret=1 196 1.1.1.8 christos test_end 197 1.1 christos 198 1.1.1.8 christos test_start "checking notify to multiple views using tsig" 199 1.1.1.8 christos $NSUPDATE <<EOF 200 1.1 christos server 10.53.0.5 ${PORT} 201 1.1 christos zone x21 202 1.1.1.10 christos key $DEFAULT_HMAC:a aaaaaaaaaaaaaaaaaaaa 203 1.1 christos update add added.x21 0 in txt "test string" 204 1.1 christos send 205 1.1 christos EOF 206 1.1.1.8 christos fnb="dig.out.b.ns5.test$n" 207 1.1.1.8 christos fnc="dig.out.c.ns5.test$n" 208 1.1.1.8 christos for i in 1 2 3 4 5 6 7 8 9; do 209 1.1.1.10 christos dig_plus_opts added.x21. -y "${DEFAULT_HMAC}:b:bbbbbbbbbbbbbbbbbbbb" @10.53.0.5 \ 210 1.1.1.8 christos txt >"$fnb" || ret=1 211 1.1.1.10 christos dig_plus_opts added.x21. -y "${DEFAULT_HMAC}:c:cccccccccccccccccccc" @10.53.0.5 \ 212 1.1.1.8 christos txt >"$fnc" || ret=1 213 1.1.1.8 christos grep "test string" "$fnb" >/dev/null \ 214 1.1.1.8 christos && grep "test string" "$fnc" >/dev/null \ 215 1.1.1.8 christos && break 216 1.1.1.8 christos sleep 1 217 1.1 christos done 218 1.1.1.8 christos grep "test string" "$fnb" >/dev/null || ret=1 219 1.1.1.8 christos grep "test string" "$fnc" >/dev/null || ret=1 220 1.1.1.8 christos grep "sending notify to 10.53.0.5#[0-9]* : TSIG (b)" ns5/named.run >/dev/null || ret=1 221 1.1.1.8 christos grep "sending notify to 10.53.0.5#[0-9]* : TSIG (c)" ns5/named.run >/dev/null || ret=1 222 1.1.1.8 christos test_end 223 1.1.1.8 christos 224 1.1.1.8 christos test_start "checking notify-source uses port option correctly" 225 1.1.1.8 christos grep "10.53.0.3#${EXTRAPORT2}: received notify for zone 'notify-source-port-test'" ns2/named.run >/dev/null || ret=1 226 1.1.1.8 christos test_end 227 1.1.1.8 christos 228 1.1.1.8 christos # notify messages were sent to unresponsive 10.53.10.53 during the tests 229 1.1.1.8 christos # above, which should time out at some point; we need to wait for them to 230 1.1.1.8 christos # appear in the logs in case the tests run faster than the notify timeouts 231 1.1.1.8 christos 232 1.1.1.10 christos test_start "checking notify to retry over TCP within 45 seconds" 233 1.1.1.10 christos nextpartreset ns3/named.run 234 1.1.1.10 christos wait_for_log 45 'retrying over TCP' ns3/named.run || ret=1 235 1.1.1.10 christos test_end 236 1.1.1.10 christos 237 1.1.1.10 christos # the TCP timeout is set to 15 seconds, double that for some leeway 238 1.1.1.10 christos test_start "checking notify retries expire within 30 seconds" 239 1.1.1.8 christos nextpartreset ns3/named.run 240 1.1.1.10 christos wait_for_log 30 'retries exceeded' ns3/named.run || ret=1 241 1.1.1.8 christos test_end 242 1.1 christos 243 1.1 christos echo_i "exit status: $status" 244 1.1 christos [ $status -eq 0 ] || exit 1 245