mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-20 23:00:56 -05:00
- cachedb-no-store, unit test cachedb_no_store.tdir.
This commit is contained in:
parent
ae96aa0a6d
commit
935bc162e1
7 changed files with 252 additions and 0 deletions
29
testdata/cachedb_no_store.tdir/cachedb_no_store.conf
vendored
Normal file
29
testdata/cachedb_no_store.tdir/cachedb_no_store.conf
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
server:
|
||||||
|
verbosity: 4
|
||||||
|
interface: 127.0.0.1
|
||||||
|
port: @PORT@
|
||||||
|
use-syslog: no
|
||||||
|
directory: ""
|
||||||
|
pidfile: "unbound.pid"
|
||||||
|
chroot: ""
|
||||||
|
username: ""
|
||||||
|
module-config: "cachedb iterator"
|
||||||
|
do-not-query-localhost: no
|
||||||
|
qname-minimisation: no
|
||||||
|
|
||||||
|
forward-zone:
|
||||||
|
name: "."
|
||||||
|
forward-addr: 127.0.0.1@@TOPORT@
|
||||||
|
|
||||||
|
stub-zone:
|
||||||
|
name: "example.com"
|
||||||
|
stub-addr: 127.0.0.1@@TOPORT@
|
||||||
|
|
||||||
|
remote-control:
|
||||||
|
control-enable: yes
|
||||||
|
control-interface: @CONTROL_PATH@/controlpipe.@CONTROL_PID@
|
||||||
|
control-use-cert: no
|
||||||
|
|
||||||
|
cachedb:
|
||||||
|
backend: "testframe"
|
||||||
|
secret-seed: "testvalue"
|
||||||
16
testdata/cachedb_no_store.tdir/cachedb_no_store.dsc
vendored
Normal file
16
testdata/cachedb_no_store.tdir/cachedb_no_store.dsc
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
BaseName: cachedb_no_store
|
||||||
|
Version: 1.0
|
||||||
|
Description: cachedb test the cachedb-no-store option
|
||||||
|
CreationDate: Wed 11 Oct 11:00:00 CEST 2023
|
||||||
|
Maintainer: dr. W.C.A. Wijngaards
|
||||||
|
Category:
|
||||||
|
Component:
|
||||||
|
CmdDepends:
|
||||||
|
Depends:
|
||||||
|
Help:
|
||||||
|
Pre: cachedb_no_store.pre
|
||||||
|
Post: cachedb_no_store.post
|
||||||
|
Test: cachedb_no_store.test
|
||||||
|
AuxFiles:
|
||||||
|
Passed:
|
||||||
|
Failure:
|
||||||
21
testdata/cachedb_no_store.tdir/cachedb_no_store.post
vendored
Normal file
21
testdata/cachedb_no_store.tdir/cachedb_no_store.post
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
# #-- cachedb_no_store.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
|
||||||
|
PRE="../.."
|
||||||
|
. ../common.sh
|
||||||
|
if grep "define USE_CACHEDB 1" $PRE/config.h; then echo test enabled; else skip_test "test skipped"; fi
|
||||||
|
|
||||||
|
echo "> cat logfiles"
|
||||||
|
cat fwd.log
|
||||||
|
if test -f fwd2.log; then cat fwd2.log; else echo "no fwd2.log"; fi
|
||||||
|
if test -f fwd3.log; then cat fwd3.log; else echo "no fwd3.log"; fi
|
||||||
|
if test -f fwd4.log; then cat fwd4.log; else echo "no fwd4.log"; fi
|
||||||
|
cat unbound.log
|
||||||
|
if test -f unbound2.log; then cat unbound2.log; else echo "no unbound2.log"; fi
|
||||||
|
kill_pid $FWD_PID
|
||||||
|
kill_pid `cat unbound.pid`
|
||||||
|
rm -f $CONTROL_PATH/controlpipe.$CONTROL_PID
|
||||||
36
testdata/cachedb_no_store.tdir/cachedb_no_store.pre
vendored
Normal file
36
testdata/cachedb_no_store.tdir/cachedb_no_store.pre
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
# #-- cachedb_no_store.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
|
||||||
|
if grep "define USE_CACHEDB 1" $PRE/config.h; then echo test enabled; else skip_test "test skipped"; fi
|
||||||
|
|
||||||
|
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 cachedb_no_store.testns >fwd.log 2>&1 &
|
||||||
|
FWD_PID=$!
|
||||||
|
echo "FWD_PID=$FWD_PID" >> .tpkg.var.test
|
||||||
|
|
||||||
|
# make config file
|
||||||
|
CONTROL_PATH=/tmp
|
||||||
|
CONTROL_PID=$$
|
||||||
|
sed -e 's/@PORT\@/'$UNBOUND_PORT'/' -e 's/@TOPORT\@/'$FWD_PORT'/' -e 's?@CONTROL_PATH\@?'$CONTROL_PATH'?' -e 's/@CONTROL_PID@/'$CONTROL_PID'/' < cachedb_no_store.conf > ub.conf
|
||||||
|
# start unbound in the background
|
||||||
|
$PRE/unbound -d -c ub.conf >unbound.log 2>&1 &
|
||||||
|
UNBOUND_PID=$!
|
||||||
|
echo "UNBOUND_PID=$UNBOUND_PID" >> .tpkg.var.test
|
||||||
|
echo "CONTROL_PATH=$CONTROL_PATH" >> .tpkg.var.test
|
||||||
|
echo "CONTROL_PID=$CONTROL_PID" >> .tpkg.var.test
|
||||||
|
|
||||||
|
cat .tpkg.var.test
|
||||||
|
wait_ldns_testns_up fwd.log
|
||||||
|
wait_unbound_up unbound.log
|
||||||
8
testdata/cachedb_no_store.tdir/cachedb_no_store.servfail.testns
vendored
Normal file
8
testdata/cachedb_no_store.tdir/cachedb_no_store.servfail.testns
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
ENTRY_BEGIN
|
||||||
|
MATCH opcode
|
||||||
|
ADJUST copy_id copy_query
|
||||||
|
REPLY QR AA SERVFAIL
|
||||||
|
SECTION QUESTION
|
||||||
|
txt1.example.com. IN TXT
|
||||||
|
SECTION ANSWER
|
||||||
|
ENTRY_END
|
||||||
133
testdata/cachedb_no_store.tdir/cachedb_no_store.test
vendored
Normal file
133
testdata/cachedb_no_store.tdir/cachedb_no_store.test
vendored
Normal file
|
|
@ -0,0 +1,133 @@
|
||||||
|
# #-- cachedb_no_store.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
|
||||||
|
if grep "define USE_CACHEDB 1" $PRE/config.h; then echo test enabled; else skip_test "test skipped"; fi
|
||||||
|
|
||||||
|
# do the test
|
||||||
|
get_ldns_testns
|
||||||
|
|
||||||
|
# query for a text record that is stored by unbound's cache and cachedb
|
||||||
|
# in the testframe cache.
|
||||||
|
echo "> dig txt1.example.com."
|
||||||
|
dig @localhost -p $UNBOUND_PORT txt1.example.com. TXT | tee outfile
|
||||||
|
if grep "example text message" outfile; then
|
||||||
|
echo "OK"
|
||||||
|
else
|
||||||
|
echo "Not OK"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# stop the forwarder with servfail, to check the answer came from the cache
|
||||||
|
echo "> stop ldns-testns"
|
||||||
|
kill_pid $FWD_PID
|
||||||
|
echo "> start ldns-testns with servfails"
|
||||||
|
$LDNS_TESTNS -p $FWD_PORT cachedb_no_store.servfail.testns >fwd2.log 2>&1 &
|
||||||
|
FWD_PID=$!
|
||||||
|
echo "FWD_PID=$FWD_PID" >> .tpkg.var.test
|
||||||
|
wait_ldns_testns_up fwd2.log
|
||||||
|
|
||||||
|
echo "> dig txt1.example.com. from unbound cache"
|
||||||
|
dig @localhost -p $UNBOUND_PORT txt1.example.com. TXT | tee outfile
|
||||||
|
if grep "example text message" outfile; then
|
||||||
|
echo "OK"
|
||||||
|
else
|
||||||
|
echo "Not OK"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# clear the cache of unbound, but not cachedb testframe cache
|
||||||
|
echo "> unbound-control flush"
|
||||||
|
$PRE/unbound-control -c ub.conf flush_type txt1.example.com. TXT
|
||||||
|
if test $? -ne 0; then
|
||||||
|
echo "wrong exit value."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "exit value: OK"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "> dig txt1.example.com. from cachedb"
|
||||||
|
dig @localhost -p $UNBOUND_PORT txt1.example.com. TXT | tee outfile
|
||||||
|
if grep "example text message" outfile; then
|
||||||
|
echo "OK"
|
||||||
|
else
|
||||||
|
echo "Not OK"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# start the forwarder again.
|
||||||
|
echo "> stop ldns-testns"
|
||||||
|
kill_pid $FWD_PID
|
||||||
|
echo "> start ldns-testns"
|
||||||
|
$LDNS_TESTNS -p $FWD_PORT cachedb_no_store.testns >fwd3.log 2>&1 &
|
||||||
|
FWD_PID=$!
|
||||||
|
echo "FWD_PID=$FWD_PID" >> .tpkg.var.test
|
||||||
|
wait_ldns_testns_up fwd3.log
|
||||||
|
|
||||||
|
# stop unbound to flush the cachedb cache
|
||||||
|
echo "> stop unbound"
|
||||||
|
kill_pid `cat unbound.pid`
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "> config unbound with cachedb-no-store: yes"
|
||||||
|
echo "cachedb: cachedb-no-store: yes" >> ub.conf
|
||||||
|
|
||||||
|
# start unbound again.
|
||||||
|
echo "> start unbound"
|
||||||
|
$PRE/unbound -d -c ub.conf >unbound2.log 2>&1 &
|
||||||
|
UNBOUND_PID=$!
|
||||||
|
echo "UNBOUND_PID=$UNBOUND_PID" >> .tpkg.var.test
|
||||||
|
wait_unbound_up unbound2.log
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "> dig txt1.example.com."
|
||||||
|
dig @localhost -p $UNBOUND_PORT txt1.example.com. TXT | tee outfile
|
||||||
|
if grep "example text message" outfile; then
|
||||||
|
echo "OK"
|
||||||
|
else
|
||||||
|
echo "Not OK"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# stop the forwarder with servfail, to check the answer came from the cache
|
||||||
|
echo "> stop ldns-testns"
|
||||||
|
kill_pid $FWD_PID
|
||||||
|
echo "> start ldns-testns with servfails"
|
||||||
|
$LDNS_TESTNS -p $FWD_PORT cachedb_no_store.servfail.testns >fwd4.log 2>&1 &
|
||||||
|
FWD_PID=$!
|
||||||
|
echo "FWD_PID=$FWD_PID" >> .tpkg.var.test
|
||||||
|
wait_ldns_testns_up fwd4.log
|
||||||
|
|
||||||
|
echo "> dig txt1.example.com. from unbound cache"
|
||||||
|
dig @localhost -p $UNBOUND_PORT txt1.example.com. TXT | tee outfile
|
||||||
|
if grep "example text message" outfile; then
|
||||||
|
echo "OK"
|
||||||
|
else
|
||||||
|
echo "Not OK"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# clear the cache of unbound, but not cachedb testframe cache
|
||||||
|
echo "> unbound-control flush"
|
||||||
|
$PRE/unbound-control -c ub.conf flush_type txt1.example.com. TXT
|
||||||
|
if test $? -ne 0; then
|
||||||
|
echo "wrong exit value."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "exit value: OK"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "> dig txt1.example.com. from cachedb, but that has no message stored"
|
||||||
|
dig @localhost -p $UNBOUND_PORT txt1.example.com. TXT | tee outfile
|
||||||
|
if grep "SERVFAIL" outfile; then
|
||||||
|
echo "OK"
|
||||||
|
else
|
||||||
|
echo "Not OK"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
9
testdata/cachedb_no_store.tdir/cachedb_no_store.testns
vendored
Normal file
9
testdata/cachedb_no_store.tdir/cachedb_no_store.testns
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
ENTRY_BEGIN
|
||||||
|
MATCH opcode qtype qname
|
||||||
|
ADJUST copy_id
|
||||||
|
REPLY QR AA NOERROR
|
||||||
|
SECTION QUESTION
|
||||||
|
txt1.example.com. IN TXT
|
||||||
|
SECTION ANSWER
|
||||||
|
txt1.example.com. IN TXT "example text message"
|
||||||
|
ENTRY_END
|
||||||
Loading…
Reference in a new issue