1# #-- fast_reload_fwd.test --# 2# source the master var file when it's there 3[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 4# use .tpkg.var.test for in test variable passing 5[ -f .tpkg.var.test ] && source .tpkg.var.test 6 7PRE="../.." 8. ../common.sh 9 10echo "> unbound-control status" 11$PRE/unbound-control -c ub.conf status 12if test $? -ne 0; then 13 echo "wrong exit value." 14 exit 1 15else 16 echo "exit value: OK" 17fi 18 19# test that the forwards and stubs point to the right upstream. 20for x in example1.org example2.org example3.org stub1.org stub2.org stub3.org; do 21 echo "" 22 echo "dig www.$x [upstream is NS1]" 23 dig @127.0.0.1 -p $UNBOUND_PORT www.$x A 2>&1 | tee outfile 24 if grep "1.2.3.1" outfile; then 25 echo "response OK" 26 else 27 echo "www.$x got the wrong answer" 28 exit 1 29 fi 30done 31 32for x in example4.org example5.org example6.org stub4.org stub5.org stub6.org; do 33 echo "" 34 echo "dig www.$x [upstream is NS2]" 35 dig @127.0.0.1 -p $UNBOUND_PORT www.$x A 2>&1 | tee outfile 36 if grep "1.2.3.2" outfile; then 37 echo "response OK" 38 else 39 echo "www.$x got the wrong answer" 40 exit 1 41 fi 42done 43 44for x in auth1.org auth2.org auth3.org auth5.org auth6.org auth7.org; do 45 echo "" 46 echo "dig www.$x [auth is 1.2.3.4]" 47 dig @127.0.0.1 -p $UNBOUND_PORT www.$x A 2>&1 | tee outfile 48 if grep "1.2.3.4" outfile; then 49 echo "response OK" 50 else 51 echo "www.$x got the wrong answer" 52 exit 1 53 fi 54done 55 56echo "" 57echo "> list_insecure" 58$PRE/unbound-control -c ub.conf list_insecure 2>&1 | tee output 59if test $? -ne 0; then 60 echo "wrong exit value." 61 exit 1 62fi 63if grep "insec1.ta1.example.com" output >/dev/null; then :; else 64 echo "wrong output" 65 exit 1 66fi 67if grep "insec2.ta1.example.com" output >/dev/null; then :; else 68 echo "wrong output" 69 exit 1 70fi 71if grep "insec3.ta1.example.com" output >/dev/null; then :; else 72 echo "wrong output" 73 exit 1 74fi 75echo "" 76echo "> trustanchor.unbound" 77dig @127.0.0.1 -p $UNBOUND_PORT trustanchor.unbound CH TXT 2>&1 | tee outfile 78if grep "ta1.example.com. 55566" outfile >/dev/null; then :; else 79 echo "wrong output ta1" 80 exit 1 81fi 82if grep "ta2.example.com. 55566" outfile >/dev/null; then :; else 83 echo "wrong output" 84 exit 1 85fi 86if grep "ta3.example.com. 55566" outfile >/dev/null; then :; else 87 echo "wrong output" 88 exit 1 89fi 90 91echo "" 92echo "> replace config file ub.conf" 93mv ub.conf ub.conf.orig 94mv ub.conf2 ub.conf 95echo "" 96echo "> unbound-control fast_reload" 97$PRE/unbound-control -c ub.conf fast_reload +vv 2>&1 | tee output 98if test $? -ne 0; then 99 echo "wrong exit value." 100 exit 1 101else 102 echo "exit value: OK" 103fi 104 105# for the previous digs to www.x the cached value should remain the same 106# but for new lookups, to www2.x the new upstream should be used. 107for x in example1.org example2.org example3.org stub1.org stub2.org stub3.org; do 108 echo "" 109 echo "dig www.$x [upstream is NS1]" 110 dig @127.0.0.1 -p $UNBOUND_PORT www.$x A 2>&1 | tee outfile 111 if grep "1.2.3.1" outfile; then 112 echo "response OK" 113 else 114 echo "www.$x got the wrong answer" 115 exit 1 116 fi 117done 118 119for x in example4.org example5.org example6.org stub4.org stub5.org stub6.org; do 120 echo "" 121 echo "dig www.$x [upstream is NS2]" 122 dig @127.0.0.1 -p $UNBOUND_PORT www.$x A 2>&1 | tee outfile 123 if grep "1.2.3.2" outfile; then 124 echo "response OK" 125 else 126 echo "www.$x got the wrong answer" 127 exit 1 128 fi 129done 130 131# new lookups for www2 go to the upstream. 132for x in example2.org example4.org example6.org stub2.org stub4.org stub6.org; do 133 echo "" 134 echo "dig www2.$x [upstream is NS1]" 135 dig @127.0.0.1 -p $UNBOUND_PORT www2.$x A 2>&1 | tee outfile 136 if grep "1.2.3.1" outfile; then 137 echo "response OK" 138 else 139 echo "www2.$x got the wrong answer" 140 exit 1 141 fi 142done 143 144for x in example1.org example3.org example5.org stub1.org stub3.org stub5.org; do 145 echo "" 146 echo "dig www2.$x [upstream is NS2]" 147 dig @127.0.0.1 -p $UNBOUND_PORT www2.$x A 2>&1 | tee outfile 148 if grep "1.2.3.2" outfile; then 149 echo "response OK" 150 else 151 echo "www2.$x got the wrong answer" 152 exit 1 153 fi 154done 155 156# auth is unchanged, or at ns1. 157for x in auth1.org auth5.org auth8.org; do 158 echo "" 159 echo "dig www.$x [auth is 1.2.3.4]" 160 dig @127.0.0.1 -p $UNBOUND_PORT www.$x A 2>&1 | tee outfile 161 if grep "1.2.3.4" outfile; then 162 echo "response OK" 163 else 164 echo "www.$x got the wrong answer" 165 exit 1 166 fi 167done 168 169# deleted auth 170for x in auth2.org auth6.org; do 171 echo "" 172 echo "dig www.$x [auth is deleted]" 173 dig @127.0.0.1 -p $UNBOUND_PORT www.$x A 2>&1 | tee outfile 174 if grep "SERVFAIL" outfile; then 175 echo "response OK" 176 else 177 echo "www.$x got the wrong answer" 178 exit 1 179 fi 180done 181 182# changed and added auth 183for x in auth3.org auth4.org auth7.org; do 184 echo "" 185 echo "dig www.$x [auth is 1.2.3.5]" 186 dig @127.0.0.1 -p $UNBOUND_PORT www.$x A 2>&1 | tee outfile 187 if grep "1.2.3.5" outfile; then 188 echo "response OK" 189 else 190 echo "www.$x got the wrong answer" 191 exit 1 192 fi 193done 194 195echo "" 196echo "> list_insecure" 197$PRE/unbound-control -c ub.conf list_insecure 2>&1 | tee output 198if test $? -ne 0; then 199 echo "wrong exit value." 200 exit 1 201fi 202if grep "insec1.ta1.example.com" output >/dev/null; then :; else 203 echo "wrong output" 204 exit 1 205fi 206if grep "insec2.ta1.example.com" output >/dev/null; then 207 echo "wrong output" 208 exit 1 209fi 210if grep "insec3.ta1.example.com" output >/dev/null; then :; else 211 echo "wrong output" 212 exit 1 213fi 214if grep "insec4.ta1.example.com" output >/dev/null; then :; else 215 echo "wrong output" 216 exit 1 217fi 218echo "" 219echo "> trustanchor.unbound" 220dig @127.0.0.1 -p $UNBOUND_PORT trustanchor.unbound CH TXT 2>&1 | tee outfile 221if grep "ta1.example.com. 55566" outfile >/dev/null; then :; else 222 echo "wrong output" 223 exit 1 224fi 225if grep "ta2.example.com. 55566" outfile >/dev/null; then 226 echo "wrong output" 227 exit 1 228fi 229if grep "ta3.example.com. 55566" outfile >/dev/null; then 230 echo "wrong output" 231 exit 1 232fi 233if grep "ta3.example.com. 55567" outfile >/dev/null; then :; else 234 echo "wrong output" 235 exit 1 236fi 237if grep "ta4.example.com. 55566" outfile >/dev/null; then :; else 238 echo "wrong output" 239 exit 1 240fi 241 242echo "" 243echo "> test change: add tag1 tag2" 244cp ub.conf ub.conf.orig2 245echo "server:" >> ub.conf 246echo ' define-tag: "tag1 tag2"' >> ub.conf 247echo "> unbound-control fast_reload" 248$PRE/unbound-control -c ub.conf fast_reload +vv 2>&1 | tee output 249if test $? -ne 0; then 250 echo "wrong exit value." 251 exit 1 252else 253 echo "exit value: OK" 254fi 255 256echo "" 257echo "> test change: change to tag2 tag3" 258cp ub.conf.orig2 ub.conf 259echo "server:" >> ub.conf 260echo ' define-tag: "tag2 tag3"' >> ub.conf 261echo "> unbound-control fast_reload" 262$PRE/unbound-control -c ub.conf fast_reload +vv 2>&1 | tee output 263if test $? -ne 0; then 264 echo "wrong exit value." 265 exit 1 266else 267 echo "exit value: OK" 268fi 269if grep "tags have changed" output; then 270 echo "output OK" 271else 272 echo "wrong output" 273 exit 1 274fi 275 276echo "" 277echo "> test change: change cache size" 278cp ub.conf.orig2 ub.conf 279echo "server:" >> ub.conf 280echo " msg-cache-size: 10m" >> ub.conf 281echo " rrset-cache-size: 5m" >> ub.conf 282echo "> unbound-control fast_reload" 283$PRE/unbound-control -c ub.conf fast_reload +vv 2>&1 | tee output 284if test $? -ne 0; then 285 echo "wrong exit value." 286 exit 1 287else 288 echo "exit value: OK" 289fi 290 291echo "" 292echo "> test change: change nothing, +p too" 293$PRE/unbound-control -c ub.conf fast_reload +vv +p 2>&1 | tee output 294if test $? -ne 0; then 295 echo "wrong exit value." 296 exit 1 297else 298 echo "exit value: OK" 299fi 300 301echo "" 302echo "> stop unbound" 303kill_pid $UNBOUND_PID 304if test -f unbound.pid; then sleep 1; fi 305if test -f unbound.pid; then sleep 1; fi 306if test -f unbound.pid; then sleep 1; fi 307if test -f unbound.pid; then echo "unbound.pid still there"; fi 308# check the locks. 309function locktest() { 310 if test -x $PRE/lock-verify -a -f ublocktrace.0; then 311 $PRE/lock-verify ublocktrace.* 312 if test $? -ne 0; then 313 echo "lock-verify error" 314 exit 1 315 fi 316 fi 317} 318locktest 319 320exit 0 321