1# #-- dnstap.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 7. ../common.sh 8PRE="../.." 9 10# test if the server is up. 11echo "> dig www.example.com." 12dig @127.0.0.1 -p $UNBOUND_PORT www.example.com. | tee outfile 13echo "> check answer" 14if grep "10.20.30.40" outfile; then 15 echo "OK" 16else 17 echo "> cat logfiles" 18 cat tap.log 19 cat tap.errlog 20 cat fwd.log 21 cat unbound.log 22 echo "Not OK" 23 exit 1 24fi 25 26echo "> wait for log to happen on timer" 27sleep 3 28echo "> check tap.log for dnstap info" 29# see if it logged the information in tap.log 30# wait for a moment for filesystem to catch up. 31if grep "www.example.com" tap.log >/dev/null; then :; else sleep 1; fi 32if grep "www.example.com" tap.log >/dev/null; then :; else sleep 1; fi 33if grep "www.example.com" tap.log >/dev/null; then :; else sleep 1; fi 34if grep "www.example.com" tap.log >/dev/null; then :; else sleep 1; fi 35if grep "www.example.com" tap.log >/dev/null; then :; else sleep 1; fi 36if grep "www.example.com" tap.log >/dev/null; then :; else sleep 10; fi 37if grep "www.example.com" tap.log; then echo "yes it is in tap.log"; 38else 39 echo "information not in tap.log" 40 echo "failed" 41 echo "> cat logfiles" 42 cat tap.log 43 cat tap.errlog 44 cat fwd.log 45 cat unbound.log 46 echo "Not OK" 47 exit 1 48fi 49 50echo "> make 10 queries to spread them over threads" 51dig @127.0.0.1 -p $UNBOUND_PORT q1.example.net. 52dig @127.0.0.1 -p $UNBOUND_PORT q2.example.net. 53dig @127.0.0.1 -p $UNBOUND_PORT q3.example.net. 54dig @127.0.0.1 -p $UNBOUND_PORT q4.example.net. 55dig @127.0.0.1 -p $UNBOUND_PORT q5.example.net. 56dig @127.0.0.1 -p $UNBOUND_PORT q6.example.net. 57dig @127.0.0.1 -p $UNBOUND_PORT q7.example.net. 58dig @127.0.0.1 -p $UNBOUND_PORT q8.example.net. 59dig @127.0.0.1 -p $UNBOUND_PORT q9.example.net. 60dig @127.0.0.1 -p $UNBOUND_PORT q10.example.net. 61echo "> wait for log to happen on timer" 62sleep 3 63for x in q1 q2 q3 q4 5 q6 q7 q8 q9 q10; do 64 if grep "$x.example.net" tap.log >/dev/null; then :; else sleep 1; fi 65 if grep "$x.example.net" tap.log >/dev/null; then :; else sleep 1; fi 66 if grep "$x.example.net" tap.log >/dev/null; then :; else sleep 1; fi 67 if grep "$x.example.net" tap.log >/dev/null; then :; else sleep 1; fi 68 if grep "$x.example.net" tap.log >/dev/null; then :; else sleep 1; fi 69 if grep "$x.example.net" tap.log >/dev/null; then :; else sleep 10; fi 70 if grep "$x.example.net" tap.log; then echo "yes it is in tap.log"; 71 else 72 echo "$x.example.net. information not in tap.log" 73 echo "failed" 74 echo "> cat logfiles" 75 cat tap.log 76 cat tap.errlog 77 cat fwd.log 78 cat unbound.log 79 echo "Not OK" 80 exit 1 81 fi 82done 83 84echo "> cat logfiles" 85cat tap.log 86cat tap.errlog 87cat fwd.log 88echo "> OK" 89exit 0 90