mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-21 15:21:05 -05:00
- Unit test for tcp request reorder and timeouts.
git-svn-id: file:///svn/unbound/trunk@5041 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
9087b18234
commit
f7d63b0927
7 changed files with 281 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
21 January 2018: Wouter
|
21 January 2018: Wouter
|
||||||
- Fix tcp idle timeout test, for difference in the tcp reply code.
|
- Fix tcp idle timeout test, for difference in the tcp reply code.
|
||||||
|
- Unit test for tcp request reorder and timeouts.
|
||||||
|
|
||||||
17 January 2018: Wouter
|
17 January 2018: Wouter
|
||||||
- For caps-for-id fallback, use the whitelist to avoid timeout
|
- For caps-for-id fallback, use the whitelist to avoid timeout
|
||||||
|
|
|
||||||
22
testdata/tcp_req_timeout.tdir/tcp_req_timeout.conf
vendored
Normal file
22
testdata/tcp_req_timeout.tdir/tcp_req_timeout.conf
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
server:
|
||||||
|
verbosity: 2
|
||||||
|
# num-threads: 1
|
||||||
|
interface: 127.0.0.1
|
||||||
|
port: @PORT@
|
||||||
|
use-syslog: no
|
||||||
|
directory: .
|
||||||
|
pidfile: "unbound.pid"
|
||||||
|
chroot: ""
|
||||||
|
username: ""
|
||||||
|
do-not-query-localhost: no
|
||||||
|
|
||||||
|
local-zone: "example.net" static
|
||||||
|
local-data: "www1.example.net. IN A 1.2.3.1"
|
||||||
|
local-data: "www2.example.net. IN A 1.2.3.2"
|
||||||
|
local-data: "www3.example.net. IN A 1.2.3.3"
|
||||||
|
tcp-idle-timeout: 2000
|
||||||
|
local-zone: "drop.net" deny
|
||||||
|
|
||||||
|
forward-zone:
|
||||||
|
name: "."
|
||||||
|
forward-addr: "127.0.0.1@@TOPORT@"
|
||||||
16
testdata/tcp_req_timeout.tdir/tcp_req_timeout.dsc
vendored
Normal file
16
testdata/tcp_req_timeout.tdir/tcp_req_timeout.dsc
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
BaseName: tcp_req_order
|
||||||
|
Version: 1.0
|
||||||
|
Description: Test tcp request order timeouts.
|
||||||
|
CreationDate: Mon Jan 21 11:23:00 CET 2018
|
||||||
|
Maintainer: Wouter Wijngaards
|
||||||
|
Category:
|
||||||
|
Component:
|
||||||
|
CmdDepends:
|
||||||
|
Depends:
|
||||||
|
Help:
|
||||||
|
Pre: tcp_req_order.pre
|
||||||
|
Post: tcp_req_order.post
|
||||||
|
Test: tcp_req_order.test
|
||||||
|
AuxFiles:
|
||||||
|
Passed:
|
||||||
|
Failure:
|
||||||
12
testdata/tcp_req_timeout.tdir/tcp_req_timeout.post
vendored
Normal file
12
testdata/tcp_req_timeout.tdir/tcp_req_timeout.post
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
# #-- tcp_req_timeout.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 $FWD_PID
|
||||||
|
kill_pid $UNBOUND_PID
|
||||||
|
cat fwd.log
|
||||||
|
cat unbound.log
|
||||||
31
testdata/tcp_req_timeout.tdir/tcp_req_timeout.pre
vendored
Normal file
31
testdata/tcp_req_timeout.tdir/tcp_req_timeout.pre
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
# #-- tcp_req_timeout.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
|
||||||
|
|
||||||
|
. ../common.sh
|
||||||
|
get_random_port 2
|
||||||
|
UNBOUND_PORT=$RND_PORT
|
||||||
|
FWD_PORT=$(($RND_PORT + 1))
|
||||||
|
echo "UNBOUND_PORT=$UNBOUND_PORT" >> .tpkg.var.test
|
||||||
|
echo "FWD_PORT=$FWD_PORT" >> .tpkg.var.test
|
||||||
|
|
||||||
|
# start forwarder
|
||||||
|
get_ldns_testns
|
||||||
|
$LDNS_TESTNS -p $FWD_PORT tcp_req_timeout.testns >fwd.log 2>&1 &
|
||||||
|
FWD_PID=$!
|
||||||
|
echo "FWD_PID=$FWD_PID" >> .tpkg.var.test
|
||||||
|
|
||||||
|
# make config file
|
||||||
|
sed -e 's/@PORT\@/'$UNBOUND_PORT'/' -e 's/@TOPORT\@/'$FWD_PORT'/' < tcp_req_timeout.conf > ub.conf
|
||||||
|
# start unbound in the background
|
||||||
|
PRE="../.."
|
||||||
|
$PRE/unbound -vvvv -d -c ub.conf >unbound.log 2>&1 &
|
||||||
|
UNBOUND_PID=$!
|
||||||
|
echo "UNBOUND_PID=$UNBOUND_PID" >> .tpkg.var.test
|
||||||
|
|
||||||
|
cat .tpkg.var.test
|
||||||
|
wait_ldns_testns_up fwd.log
|
||||||
|
wait_unbound_up unbound.log
|
||||||
|
|
||||||
136
testdata/tcp_req_timeout.tdir/tcp_req_timeout.test
vendored
Normal file
136
testdata/tcp_req_timeout.tdir/tcp_req_timeout.test
vendored
Normal file
|
|
@ -0,0 +1,136 @@
|
||||||
|
# #-- tcp_req_timeout.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)
|
||||||
|
# check what sort of netcat we have
|
||||||
|
if nc -h 2>&1 | grep "q secs"; then
|
||||||
|
ncopt="-q 3 -i 4"
|
||||||
|
else
|
||||||
|
ncopt="-i 4"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# this test query should just work (server is up)
|
||||||
|
echo "> query www1.example.net."
|
||||||
|
$PRE/streamtcp -f 127.0.0.1@$UNBOUND_PORT www1.example.net. A IN >outfile 2>&1
|
||||||
|
cat outfile
|
||||||
|
if test "$?" -ne 0; then
|
||||||
|
echo "exit status not OK"
|
||||||
|
echo "> cat logfiles"
|
||||||
|
cat outfile
|
||||||
|
cat fwd.log
|
||||||
|
cat unbound.log
|
||||||
|
echo "Not OK"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if grep "www1.example.net" outfile | grep "1.2.3.1"; then
|
||||||
|
echo "content OK"
|
||||||
|
else
|
||||||
|
echo "result contents not OK"
|
||||||
|
echo "> cat logfiles"
|
||||||
|
cat outfile
|
||||||
|
cat fwd.log
|
||||||
|
cat unbound.log
|
||||||
|
echo "result contents not OK"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "OK"
|
||||||
|
|
||||||
|
# multiple requests that are answered immediately and then the timeout
|
||||||
|
echo "> query www1.example.net. www2.example.net. www3.example.net. www.example.com."
|
||||||
|
$PRE/streamtcp -a -f 127.0.0.1@$UNBOUND_PORT www1.example.net. A IN www2.example.net A IN www3.example.net A IN www.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 fwd.log
|
||||||
|
cat unbound.log
|
||||||
|
echo "Not OK"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if grep "www1.example.net" outfile | grep "1.2.3.1"; then
|
||||||
|
echo "content OK"
|
||||||
|
else
|
||||||
|
echo "result contents not OK"
|
||||||
|
echo "> cat logfiles"
|
||||||
|
cat outfile
|
||||||
|
cat fwd.log
|
||||||
|
cat unbound.log
|
||||||
|
echo "result contents not OK"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if grep "www2.example.net" outfile | grep "1.2.3.2"; then
|
||||||
|
echo "content OK"
|
||||||
|
else
|
||||||
|
echo "result contents not OK"
|
||||||
|
echo "> cat logfiles"
|
||||||
|
cat outfile
|
||||||
|
cat fwd.log
|
||||||
|
cat unbound.log
|
||||||
|
echo "result contents not OK"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if grep "www3.example.net" outfile | grep "1.2.3.3"; then
|
||||||
|
echo "content OK"
|
||||||
|
else
|
||||||
|
echo "result contents not OK"
|
||||||
|
echo "> cat logfiles"
|
||||||
|
cat outfile
|
||||||
|
cat fwd.log
|
||||||
|
cat unbound.log
|
||||||
|
echo "result contents not OK"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if grep "stream closed" outfile; then
|
||||||
|
echo "content OK"
|
||||||
|
else
|
||||||
|
echo "result contents not OK"
|
||||||
|
echo "> cat logfiles"
|
||||||
|
cat outfile
|
||||||
|
cat fwd.log
|
||||||
|
cat unbound.log
|
||||||
|
echo "result contents not OK"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# multiple requests that are waiting for answers and then the timeout
|
||||||
|
echo "> query www2.example.com. www2.example.com. www3.example.com."
|
||||||
|
$PRE/streamtcp -a -f 127.0.0.1@$UNBOUND_PORT www2.example.com. A IN www2.example.com A IN www3.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 fwd.log
|
||||||
|
cat unbound.log
|
||||||
|
echo "Not OK"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if grep "stream closed" outfile; then
|
||||||
|
echo "content OK"
|
||||||
|
else
|
||||||
|
echo "result contents not OK"
|
||||||
|
echo "> cat logfiles"
|
||||||
|
cat outfile
|
||||||
|
cat fwd.log
|
||||||
|
cat unbound.log
|
||||||
|
echo "result contents not OK"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# wait a bit
|
||||||
|
sleep 2
|
||||||
|
|
||||||
|
# echo a couple requests to the other side and then wait for the timeout.
|
||||||
|
# this creates waiting answers in the reply queue.
|
||||||
|
echo "> nc www.example.net www2.example.net www3.example.net"
|
||||||
|
( echo "0021eb410100000100000000000003777777076578616d706c65036e657400000100010022eb41010000010000000000000477777732076578616d706c65036e657400000100010022eb41010000010000000000000477777733076578616d706c65036e65740000010001" | xxd -r -p ; sleep 10 ; echo "") | nc $ncopt 127.0.0.1 $UNBOUND_PORT | xxd | tee outfile
|
||||||
|
|
||||||
|
echo "OK"
|
||||||
|
exit 0
|
||||||
63
testdata/tcp_req_timeout.tdir/tcp_req_timeout.testns
vendored
Normal file
63
testdata/tcp_req_timeout.tdir/tcp_req_timeout.testns
vendored
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
; nameserver test file
|
||||||
|
$ORIGIN example.com.
|
||||||
|
$TTL 3600
|
||||||
|
|
||||||
|
ENTRY_BEGIN
|
||||||
|
MATCH opcode qtype qname
|
||||||
|
REPLY QR AA NOERROR
|
||||||
|
ADJUST copy_id sleep=4
|
||||||
|
SECTION QUESTION
|
||||||
|
www IN A
|
||||||
|
SECTION ANSWER
|
||||||
|
www IN A 10.20.30.40
|
||||||
|
ENTRY_END
|
||||||
|
|
||||||
|
ENTRY_BEGIN
|
||||||
|
MATCH opcode qtype qname
|
||||||
|
REPLY QR AA NOERROR
|
||||||
|
ADJUST copy_id sleep=4
|
||||||
|
SECTION QUESTION
|
||||||
|
www2 IN A
|
||||||
|
SECTION ANSWER
|
||||||
|
www2 IN A 10.20.30.42
|
||||||
|
ENTRY_END
|
||||||
|
|
||||||
|
ENTRY_BEGIN
|
||||||
|
MATCH opcode qtype qname
|
||||||
|
REPLY QR AA NOERROR
|
||||||
|
ADJUST copy_id sleep=4
|
||||||
|
SECTION QUESTION
|
||||||
|
www3 IN A
|
||||||
|
SECTION ANSWER
|
||||||
|
www3 IN A 10.20.30.43
|
||||||
|
ENTRY_END
|
||||||
|
|
||||||
|
ENTRY_BEGIN
|
||||||
|
MATCH opcode qtype qname
|
||||||
|
REPLY QR AA NOERROR
|
||||||
|
ADJUST copy_id sleep=2
|
||||||
|
SECTION QUESTION
|
||||||
|
www4 IN A
|
||||||
|
SECTION ANSWER
|
||||||
|
www4 IN A 10.20.30.44
|
||||||
|
ENTRY_END
|
||||||
|
|
||||||
|
ENTRY_BEGIN
|
||||||
|
MATCH opcode qtype qname
|
||||||
|
REPLY QR AA NOERROR
|
||||||
|
ADJUST copy_id sleep=2
|
||||||
|
SECTION QUESTION
|
||||||
|
www5 IN A
|
||||||
|
SECTION ANSWER
|
||||||
|
www5 IN A 10.20.30.45
|
||||||
|
ENTRY_END
|
||||||
|
|
||||||
|
ENTRY_BEGIN
|
||||||
|
MATCH opcode qtype qname
|
||||||
|
REPLY QR AA NOERROR
|
||||||
|
ADJUST copy_id sleep=2
|
||||||
|
SECTION QUESTION
|
||||||
|
www6 IN A
|
||||||
|
SECTION ANSWER
|
||||||
|
www6 IN A 10.20.30.46
|
||||||
|
ENTRY_END
|
||||||
Loading…
Reference in a new issue