]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - testdata/dnstap_tls.tdir/dnstap_tls.test
Vendor import of Unbound 1.11.0.
[FreeBSD/FreeBSD.git] / testdata / dnstap_tls.tdir / dnstap_tls.test
1 # #-- dnstap_tls.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
8 PRE="../.."
9 if grep "define USE_DNSTAP 1" $PRE/config.h; then echo test enabled; else echo test skipped; exit 0; fi
10
11 # test if the server is up.
12 echo "> dig www.example.com."
13 dig @127.0.0.1 -p $UNBOUND_PORT www.example.com. | tee outfile
14 echo "> check answer"
15 if grep "10.20.30.40" outfile; then
16         echo "OK"
17 else
18         echo "> cat logfiles"
19         cat tap.log
20         cat tap.errlog
21         cat fwd.log
22         cat unbound.log
23         echo "Not OK"
24         exit 1
25 fi
26
27 echo "> check tap.log for dnstap info"
28 # see if it logged the information in tap.log
29 # wait for a moment for filesystem to catch up.
30 if grep "www.example.com" tap.log >/dev/null; then :; else sleep 1; fi
31 if grep "www.example.com" tap.log >/dev/null; then :; else sleep 1; fi
32 if grep "www.example.com" tap.log >/dev/null; then :; else sleep 1; fi
33 if grep "www.example.com" tap.log >/dev/null; then :; else sleep 1; fi
34 if grep "www.example.com" tap.log >/dev/null; then :; else sleep 1; fi
35 if grep "www.example.com" tap.log >/dev/null; then :; else sleep 10; fi
36 if grep "www.example.com" tap.log; then echo "yes it is in tap.log";
37 else
38         echo "information not in tap.log"
39         echo "failed"
40         echo "> cat logfiles"
41         cat tap.log
42         cat tap.errlog
43         cat fwd.log
44         cat unbound.log
45         echo "Not OK"
46         exit 1
47 fi
48
49 echo ""
50 echo "> test disconnect from the upstream server"
51
52 kill_pid $DNSTAP_SOCKET_PID
53 dig @127.0.0.1 -p $UNBOUND_PORT down.example.net.
54
55 # bring log socket back up
56 $PRE/unbound-dnstap-socket -t "127.0.0.1@$TAP_PORT" -x unbound_server.key -y unbound_server.pem -l -vvvv 2>tap2.errlog >tap2.log &
57 if test $? -ne 0; then
58         echo "could not start (again) unbound-dnstap-socket server"
59         exit 1
60 fi
61 DNSTAP_SOCKET_PID=$!
62 echo "DNSTAP_SOCKET_PID=$DNSTAP_SOCKET_PID" >> .tpkg.var.test
63 # wait for the server to go up
64 wait_server_up "tap2.errlog" "start of service"
65
66 dig @127.0.0.1 -p $UNBOUND_PORT up.example.net.
67 sleep 2
68 dig @127.0.0.1 -p $UNBOUND_PORT up2.example.net.
69
70 for x in down up up2; do
71         if grep "$x.example.net" tap2.log >/dev/null; then :; else sleep 1; fi
72         if grep "$x.example.net" tap2.log >/dev/null; then :; else sleep 1; fi
73         if grep "$x.example.net" tap2.log >/dev/null; then :; else sleep 1; fi
74         if grep "$x.example.net" tap2.log >/dev/null; then :; else sleep 1; fi
75         if grep "$x.example.net" tap2.log >/dev/null; then :; else sleep 1; fi
76         if grep "$x.example.net" tap2.log >/dev/null; then :; else sleep 10; fi
77         if grep "$x.example.net" tap2.log; then echo "yes it is in tap2.log";
78         else
79                 echo "$x.example.net. information not in tap2.log"
80                 echo "failed"
81                 echo "> cat logfiles"
82                 cat tap.log
83                 cat tap.errlog
84                 echo "> tap2 logfiles"
85                 cat tap2.log
86                 cat tap2.errlog
87                 cat fwd.log
88                 cat unbound.log
89                 echo "Not OK"
90                 exit 1
91         fi
92 done
93
94 echo "> OK"
95 exit 0