1# #-- cachedb_no_store.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 10# do the test 11get_ldns_testns 12 13# query for a text record that is stored by unbound's cache and cachedb 14# in the testframe cache. 15echo "> dig txt1.example.com." 16dig @localhost -p $UNBOUND_PORT txt1.example.com. TXT | tee outfile 17if grep "example text message" outfile; then 18 echo "OK" 19else 20 echo "Not OK" 21 exit 1 22fi 23 24# stop the forwarder with servfail, to check the answer came from the cache 25echo "> stop ldns-testns" 26kill_pid $FWD_PID 27echo "> start ldns-testns with servfails" 28$LDNS_TESTNS -p $FWD_PORT cachedb_no_store.servfail.testns >fwd2.log 2>&1 & 29FWD_PID=$! 30echo "FWD_PID=$FWD_PID" >> .tpkg.var.test 31wait_ldns_testns_up fwd2.log 32 33echo "> dig txt1.example.com. from unbound cache" 34dig @localhost -p $UNBOUND_PORT txt1.example.com. TXT | tee outfile 35if grep "example text message" outfile; then 36 echo "OK" 37else 38 echo "Not OK" 39 exit 1 40fi 41 42# clear the cache of unbound, but not cachedb testframe cache 43echo "> unbound-control flush" 44$PRE/unbound-control -c ub.conf flush_type txt1.example.com. TXT 45if test $? -ne 0; then 46 echo "wrong exit value." 47 exit 1 48else 49 echo "exit value: OK" 50fi 51 52echo "> dig txt1.example.com. from cachedb" 53dig @localhost -p $UNBOUND_PORT txt1.example.com. TXT | tee outfile 54if grep "example text message" outfile; then 55 echo "OK" 56else 57 echo "Not OK" 58 exit 1 59fi 60 61# start the forwarder again. 62echo "> stop ldns-testns" 63kill_pid $FWD_PID 64echo "> start ldns-testns" 65$LDNS_TESTNS -p $FWD_PORT cachedb_no_store.testns >fwd3.log 2>&1 & 66FWD_PID=$! 67echo "FWD_PID=$FWD_PID" >> .tpkg.var.test 68wait_ldns_testns_up fwd3.log 69 70# stop unbound to flush the cachedb cache 71echo "> stop unbound" 72kill_pid `cat unbound.pid` 73 74echo "" 75echo "> config unbound with cachedb-no-store: yes" 76echo "cachedb: cachedb-no-store: yes" >> ub.conf 77 78# start unbound again. 79echo "> start unbound" 80$PRE/unbound -d -c ub.conf >unbound2.log 2>&1 & 81UNBOUND_PID=$! 82echo "UNBOUND_PID=$UNBOUND_PID" >> .tpkg.var.test 83wait_unbound_up unbound2.log 84 85echo "" 86echo "> dig txt1.example.com." 87dig @localhost -p $UNBOUND_PORT txt1.example.com. TXT | tee outfile 88if grep "example text message" outfile; then 89 echo "OK" 90else 91 echo "Not OK" 92 exit 1 93fi 94 95# stop the forwarder with servfail, to check the answer came from the cache 96echo "> stop ldns-testns" 97kill_pid $FWD_PID 98echo "> start ldns-testns with servfails" 99$LDNS_TESTNS -p $FWD_PORT cachedb_no_store.servfail.testns >fwd4.log 2>&1 & 100FWD_PID=$! 101echo "FWD_PID=$FWD_PID" >> .tpkg.var.test 102wait_ldns_testns_up fwd4.log 103 104echo "> dig txt1.example.com. from unbound cache" 105dig @localhost -p $UNBOUND_PORT txt1.example.com. TXT | tee outfile 106if grep "example text message" outfile; then 107 echo "OK" 108else 109 echo "Not OK" 110 exit 1 111fi 112 113# clear the cache of unbound, but not cachedb testframe cache 114echo "> unbound-control flush" 115$PRE/unbound-control -c ub.conf flush_type txt1.example.com. TXT 116if test $? -ne 0; then 117 echo "wrong exit value." 118 exit 1 119else 120 echo "exit value: OK" 121fi 122 123echo "> dig txt1.example.com. from cachedb, but that has no message stored" 124dig @localhost -p $UNBOUND_PORT txt1.example.com. TXT | tee outfile 125if grep "SERVFAIL" outfile; then 126 echo "OK" 127else 128 echo "Not OK" 129 exit 1 130fi 131 132exit 0 133