diff --git a/testdata/auth_load_tree.tdir/auth_load_tree.conf b/testdata/auth_load_tree.tdir/auth_load_tree.conf new file mode 100644 index 000000000..e3b038fdd --- /dev/null +++ b/testdata/auth_load_tree.tdir/auth_load_tree.conf @@ -0,0 +1,21 @@ +server: + verbosity: 8 + num-threads: 1 + interface: 127.0.0.1 + port: @PORT@ + use-syslog: no + directory: "" + pidfile: "unbound.pid" + chroot: "" + username: "" + do-not-query-localhost: no + auth-task-threads: 2 + log-time-ascii: yes + log-time-iso: yes + +remote-control: + control-enable: yes + control-interface: @CONTROL_PATH@/controlpipe.@CONTROL_PID@ + control-use-cert: no + +include: "auth.zonelist" diff --git a/testdata/auth_load_tree.tdir/auth_load_tree.dsc b/testdata/auth_load_tree.tdir/auth_load_tree.dsc new file mode 100644 index 000000000..97eca3af6 --- /dev/null +++ b/testdata/auth_load_tree.tdir/auth_load_tree.dsc @@ -0,0 +1,16 @@ +BaseName: auth_load_tree +Version: 1.0 +Description: Exercise the auth load thread tree in the worker +CreationDate: Thu 15 Oct 09:00:00 CEST 2026 +Maintainer: dr. W.C.A. Wijngaards +Category: +Component: +CmdDepends: +Depends: +Help: +Pre: auth_load_tree.pre +Post: auth_load_tree.post +Test: auth_load_tree.test +AuxFiles: +Passed: +Failure: diff --git a/testdata/auth_load_tree.tdir/auth_load_tree.post b/testdata/auth_load_tree.tdir/auth_load_tree.post new file mode 100644 index 000000000..e68b4ffed --- /dev/null +++ b/testdata/auth_load_tree.tdir/auth_load_tree.post @@ -0,0 +1,13 @@ +# #-- auth_load_tree.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 $UNBOUND_PID +kill_pid $FWD_PID +rm -f $CONTROL_PATH/controlpipe.$CONTROL_PID +cat fwd.log +cat unbound.log diff --git a/testdata/auth_load_tree.tdir/auth_load_tree.pre b/testdata/auth_load_tree.tdir/auth_load_tree.pre new file mode 100644 index 000000000..73e8e50d5 --- /dev/null +++ b/testdata/auth_load_tree.tdir/auth_load_tree.pre @@ -0,0 +1,108 @@ +# #-- auth_load_tree.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 no threads; exit +if grep -e "define HAVE_PTHREAD 1" -e "define HAVE_SOLARIS_THREADS 1" -e "define HAVE_WINDOWS_THREADS 1" $PRE/config.h; then + echo "have threads" +else + skip_test "no threads" +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 + +NUM_AUTH=120 +echo "NUM_AUTH=$NUM_AUTH" >> .tpkg.var.test +echo "" > auth.zonelist + +# start forwarder +# create auth_load_tree.testns +for((i=1; i<=$NUM_AUTH; i++)); do +cat >>auth_load_tree.testns <>auth.zonelist <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'/' \ + < auth_load_tree.conf > ub.conf +# start unbound in the background +$PRE/unbound -d -c ub.conf >unbound.log 2>&1 & +#valgrind --leak-check=full --show-reachable=yes $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 + diff --git a/testdata/auth_load_tree.tdir/auth_load_tree.test b/testdata/auth_load_tree.tdir/auth_load_tree.test new file mode 100644 index 000000000..8b1573572 --- /dev/null +++ b/testdata/auth_load_tree.tdir/auth_load_tree.test @@ -0,0 +1,32 @@ +# #-- auth_load_tree.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 + +# While the updates are in progress, +# perform: +# - reload +# - stop +# This exercises the auth load thread tree in the worker that keeps +# track of the connected auth load threads to the worker thread. + +# do the test +echo "> unbound-control reload" +$PRE/unbound-control -c ub.conf reload +if test $? -ne 0; then + echo "wrong exit value." + exit 1 +else + echo "exit value: OK" +fi + +# wait enough to have the reload cause re-fetch to happen during the exit. +# for valgrind .4, without .04 +#sleep .4 +sleep 0.04 + +exit 0 diff --git a/testdata/auth_load_tree.tdir/authload.diff b/testdata/auth_load_tree.tdir/authload.diff new file mode 100644 index 000000000..fd9d52ead --- /dev/null +++ b/testdata/auth_load_tree.tdir/authload.diff @@ -0,0 +1,18 @@ +diff --git a/services/authload.c b/services/authload.c +index 314d1d40b..b0c7336ea 100644 +--- a/services/authload.c ++++ b/services/authload.c +@@ -709,6 +709,13 @@ auth_load_thread_process(struct auth_load_thread* thr) + if(gettimeofday(&start, NULL) < 0) + log_err("gettimeofday: %s", strerror(errno)); + ++ if(1) { ++ struct timespec dur; ++ dur.tv_sec = 1; ++ dur.tv_nsec = 500ULL * 1000000ULL; ++ nanosleep(&dur, NULL); ++ } ++ + /* apply data */ + if(task->task_type == AUTH_LOAD_TASK_ZONEFILE_WRITE) { + if(!auth_load_process_write(thr))