xref: /netbsd-src/external/bsd/unbound/dist/testdata/dnstap_reconnect.tdir/dnstap_reconnect.pre (revision 91f7d55fb697b5e0475da4718fa34c3a3ebeac85)
1# #-- dnstap_reconnect.pre--#
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
9PRE="../.."
10if grep "define USE_DNSTAP 1" $PRE/config.h; then echo test enabled; else skip_test "test skipped"; fi
11
12get_random_port 3
13UNBOUND_PORT=$RND_PORT
14FWD_PORT=$(($RND_PORT + 1))
15CONTROL_PORT=$(($RND_PORT + 2))
16echo "UNBOUND_PORT=$UNBOUND_PORT" >> .tpkg.var.test
17echo "FWD_PORT=$FWD_PORT" >> .tpkg.var.test
18echo "CONTROL_PORT=$CONTROL_PORT" >> .tpkg.var.test
19
20# start forwarder
21get_ldns_testns
22$LDNS_TESTNS -p $FWD_PORT dnstap_reconnect.testns >fwd.log 2>&1 &
23FWD_PID=$!
24echo "FWD_PID=$FWD_PID" >> .tpkg.var.test
25
26# start the dnstap log server
27# the -vvvv flag prints protocol and connection information from the
28# unbound-dnstap-socket server.
29# the -l flag prints the DNS info in the DNSTAP packet in multiline output.
30# stderr is the '-vvvv' server logs and errors.
31# stdout is the one-line packet logs (or with -l, multiline).
32$PRE/unbound-dnstap-socket -u dnstap.socket -l -vvvv 2>tap.errlog >tap.log &
33if test $? -ne 0; then
34	echo "could not start unbound-dnstap-socket server"
35	exit 1
36fi
37DNSTAP_SOCKET_PID=$!
38echo "DNSTAP_SOCKET_PID=$DNSTAP_SOCKET_PID" >> .tpkg.var.test
39# wait for the server to go up and make the dnstap.socket file
40wait_server_up "tap.errlog" "creating unix socket"
41if test ! -S dnstap.socket; then
42	echo "the dnstap.socket file does not exist!"
43fi
44
45# make config file
46sed -e 's/@PORT\@/'$UNBOUND_PORT'/' -e 's/@TOPORT\@/'$FWD_PORT'/' -e 's/@CONTROL_PORT\@/'$CONTROL_PORT'/' < dnstap_reconnect.conf > ub.conf
47# start unbound in the background
48$PRE/unbound -d -c ub.conf >unbound.log 2>&1 &
49UNBOUND_PID=$!
50echo "UNBOUND_PID=$UNBOUND_PID" >> .tpkg.var.test
51
52cat .tpkg.var.test
53wait_ldns_testns_up fwd.log
54wait_unbound_up unbound.log
55
56