mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-20 23:00:56 -05:00
add test for tcp reuse
This commit is contained in:
parent
d9afcae346
commit
7b46067029
6 changed files with 179 additions and 0 deletions
17
testdata/tcp_reuse.tdir/tcp_reuse.conf
vendored
Normal file
17
testdata/tcp_reuse.tdir/tcp_reuse.conf
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
server:
|
||||
verbosity: 5
|
||||
# num-threads: 1
|
||||
interface: 127.0.0.1
|
||||
port: @PORT@
|
||||
use-syslog: no
|
||||
directory: .
|
||||
pidfile: "unbound.pid"
|
||||
chroot: ""
|
||||
username: ""
|
||||
do-not-query-localhost: no
|
||||
|
||||
tcp-upstream: yes
|
||||
|
||||
forward-zone:
|
||||
name: "."
|
||||
forward-addr: "127.0.0.1@@TOPORT@"
|
||||
29
testdata/tcp_reuse.tdir/tcp_reuse.conf2
vendored
Normal file
29
testdata/tcp_reuse.tdir/tcp_reuse.conf2
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# this is the upstream server that has pipelining and responds to queries.
|
||||
server:
|
||||
verbosity: 1
|
||||
# num-threads: 1
|
||||
interface: 127.0.0.1
|
||||
port: @PORT@
|
||||
use-syslog: no
|
||||
directory: .
|
||||
pidfile: "unbound2.pid"
|
||||
chroot: ""
|
||||
username: ""
|
||||
do-not-query-localhost: no
|
||||
|
||||
log-queries: yes
|
||||
log-replies: yes
|
||||
log-identity: "upstream"
|
||||
|
||||
local-zone: "." refuse
|
||||
local-zone: "example.com" static
|
||||
local-data: "www.example.com A 10.20.30.40"
|
||||
local-data: "www1.example.com A 10.20.30.41"
|
||||
local-data: "www2.example.com A 10.20.30.42"
|
||||
local-data: "www3.example.com A 10.20.30.43"
|
||||
local-data: "www4.example.com A 10.20.30.44"
|
||||
|
||||
# if queries escape, send them to localhost
|
||||
forward-zone:
|
||||
name: "."
|
||||
forward-addr: "127.0.0.1@@TOPORT@"
|
||||
16
testdata/tcp_reuse.tdir/tcp_reuse.dsc
vendored
Normal file
16
testdata/tcp_reuse.tdir/tcp_reuse.dsc
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
BaseName: tcp_reuse
|
||||
Version: 1.0
|
||||
Description: Test tcp stream reuse.
|
||||
CreationDate: Wed Jun 03 09:37:00 CET 2020
|
||||
Maintainer: Wouter Wijngaards
|
||||
Category:
|
||||
Component:
|
||||
CmdDepends:
|
||||
Depends:
|
||||
Help:
|
||||
Pre: tcp_reuse.pre
|
||||
Post: tcp_reuse.post
|
||||
Test: tcp_reuse.test
|
||||
AuxFiles:
|
||||
Passed:
|
||||
Failure:
|
||||
18
testdata/tcp_reuse.tdir/tcp_reuse.post
vendored
Normal file
18
testdata/tcp_reuse.tdir/tcp_reuse.post
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# #-- tcp_reuse.post --#
|
||||
# source the master var file when it's there
|
||||
[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
|
||||
# source the test var file when it's there
|
||||
[ -f .tpkg.var.test ] && source .tpkg.var.test
|
||||
#
|
||||
# do your teardown here
|
||||
. ../common.sh
|
||||
kill_pid $UPSTREAM_PID
|
||||
kill_pid $UNBOUND_PID
|
||||
if test -f unbound2.log; then
|
||||
echo ">>> upstream log"
|
||||
cat unbound2.log
|
||||
fi
|
||||
if test -f unbound.log; then
|
||||
echo ">>> unbound log"
|
||||
cat unbound.log
|
||||
fi
|
||||
34
testdata/tcp_reuse.tdir/tcp_reuse.pre
vendored
Normal file
34
testdata/tcp_reuse.tdir/tcp_reuse.pre
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
# #-- tcp_reuse.pre--#
|
||||
# source the master var file when it's there
|
||||
[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
|
||||
# use .tpkg.var.test for in test variable passing
|
||||
[ -f .tpkg.var.test ] && source .tpkg.var.test
|
||||
|
||||
PRE="../.."
|
||||
. ../common.sh
|
||||
get_random_port 2
|
||||
UNBOUND_PORT=$RND_PORT
|
||||
UPSTREAM_PORT=$(($RND_PORT + 1))
|
||||
echo "UNBOUND_PORT=$UNBOUND_PORT" >> .tpkg.var.test
|
||||
echo "UPSTREAM_PORT=$UPSTREAM_PORT" >> .tpkg.var.test
|
||||
|
||||
# make config file
|
||||
sed -e 's/@PORT\@/'$UNBOUND_PORT'/' -e 's/@TOPORT\@/'$UPSTREAM_PORT'/' < tcp_reuse.conf > ub.conf
|
||||
# start unbound in the background
|
||||
#$PRE/unbound -d -c ub.conf >unbound.log 2>&1 &
|
||||
$PRE/unbound -d -c ub.conf 2>&1 | tee unbound.log &
|
||||
UNBOUND_PID=$!
|
||||
echo "UNBOUND_PID=$UNBOUND_PID" >> .tpkg.var.test
|
||||
wait_unbound_up unbound.log
|
||||
|
||||
# make upstream config file
|
||||
sed -e 's/@PORT\@/'$UPSTREAM_PORT'/' -e 's/@TOPORT\@/'$UPSTREAM_PORT'/' < tcp_reuse.conf2 > ub2.conf
|
||||
# start upstream unbound in the background
|
||||
#$PRE/unbound -d -c ub2.conf >unbound2.log 2>&1 &
|
||||
$PRE/unbound -d -c ub2.conf 2>&1 | tee unbound2.log &
|
||||
UPSTREAM_PID=$!
|
||||
echo "UPSTREAM_PID=$UPSTREAM_PID" >> .tpkg.var.test
|
||||
wait_unbound_up unbound2.log
|
||||
|
||||
cat .tpkg.var.test
|
||||
|
||||
65
testdata/tcp_reuse.tdir/tcp_reuse.test
vendored
Normal file
65
testdata/tcp_reuse.tdir/tcp_reuse.test
vendored
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
# #-- tcp_reuse.test --#
|
||||
# source the master var file when it's there
|
||||
[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
|
||||
# use .tpkg.var.test for in test variable passing
|
||||
[ -f .tpkg.var.test ] && source .tpkg.var.test
|
||||
|
||||
PRE="../.."
|
||||
. ../common.sh
|
||||
|
||||
get_make
|
||||
(cd $PRE; $MAKE streamtcp)
|
||||
|
||||
echo "> query www1.example.com."
|
||||
$PRE/streamtcp -f 127.0.0.1@$UNBOUND_PORT www1.example.com. A IN >outfile 2>&1
|
||||
cat outfile
|
||||
if test "$?" -ne 0; then
|
||||
echo "exit status not OK"
|
||||
echo "> cat logfiles"
|
||||
cat outfile
|
||||
cat unbound2.log
|
||||
cat unbound.log
|
||||
echo "Not OK"
|
||||
exit 1
|
||||
fi
|
||||
if grep "www1.example.com" outfile | grep "10.20.30.41"; then
|
||||
echo "content OK"
|
||||
else
|
||||
echo "result contents not OK"
|
||||
echo "> cat logfiles"
|
||||
cat outfile
|
||||
cat unbound2.log
|
||||
cat unbound.log
|
||||
echo "result contents not OK"
|
||||
exit 1
|
||||
fi
|
||||
echo "OK"
|
||||
echo ""
|
||||
|
||||
# this should be reused on the same tcp stream:
|
||||
echo "> query www2.example.com."
|
||||
$PRE/streamtcp -f 127.0.0.1@$UNBOUND_PORT www2.example.com. A IN >outfile 2>&1
|
||||
cat outfile
|
||||
if test "$?" -ne 0; then
|
||||
echo "exit status not OK"
|
||||
echo "> cat logfiles"
|
||||
cat outfile
|
||||
cat unbound2.log
|
||||
cat unbound.log
|
||||
echo "Not OK"
|
||||
exit 1
|
||||
fi
|
||||
if grep "www2.example.com" outfile | grep "10.20.30.42"; then
|
||||
echo "content OK"
|
||||
else
|
||||
echo "result contents not OK"
|
||||
echo "> cat logfiles"
|
||||
cat outfile
|
||||
cat unbound2.log
|
||||
cat unbound.log
|
||||
echo "result contents not OK"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "OK"
|
||||
exit 0
|
||||
Loading…
Reference in a new issue