- Fix that alloc stats for forwards and hints are printed, and when

alloc stats is enabled, the unit test for unbound control waits for
  reloads to complete.
This commit is contained in:
W.C.A. Wijngaards 2024-08-02 15:51:40 +02:00
parent 3cbf554e3b
commit 0f2f6025e7
3 changed files with 55 additions and 18 deletions

View File

@ -162,9 +162,9 @@ worker_mem_report(struct worker* ATTR_UNUSED(worker),
+ sizeof(*worker->env.scratch_buffer) + sizeof(*worker->env.scratch_buffer)
+ sldns_buffer_capacity(worker->env.scratch_buffer); + sldns_buffer_capacity(worker->env.scratch_buffer);
if(worker->daemon->env->fwds) if(worker->daemon->env->fwds)
me += forwards_get_mem(worker->env.fwds); log_info("forwards=%u", (unsigned)forwards_get_mem(worker->env.fwds));
if(worker->daemon->env->hints) if(worker->daemon->env->hints)
me += hints_get_mem(worker->env.hints); log_info("hints=%u", (unsigned)hints_get_mem(worker->env.hints));
if(worker->thread_num == 0) if(worker->thread_num == 0)
me += acl_list_get_mem(worker->daemon->acl); me += acl_list_get_mem(worker->daemon->acl);
if(cur_serv) { if(cur_serv) {

View File

@ -8,6 +8,9 @@
add_cookie_secret, activate_cookie_secret and drop_cookie_secret add_cookie_secret, activate_cookie_secret and drop_cookie_secret
commands can be used for rollover, the command print_cookie_secrets commands can be used for rollover, the command print_cookie_secrets
shows the values in use. shows the values in use.
- Fix that alloc stats for forwards and hints are printed, and when
alloc stats is enabled, the unit test for unbound control waits for
reloads to complete.
1 August 2024: Wouter 1 August 2024: Wouter
- Fix dnstap test program, cleans up to have clean memory on exit, - Fix dnstap test program, cleans up to have clean memory on exit,

View File

@ -73,12 +73,53 @@ control_command () {
$PRE/unbound-control $@ > outfile $PRE/unbound-control $@ > outfile
} }
# Reload the server and check the reload has finished processing
# when a lot of debug is enabled, a lot of log needs to be printed.
control_reload () {
prelines=`wc -l unbound.log | awk '{print $1;}'`
cmd="$1"
if test -z "$cmd"; then cmd="reload"; fi
control_command -c ub.conf $cmd
expect_exit_value 0
# see if the reload has completed.
lines1=`wc -l unbound.log | awk '{print $1;}'`
count=0
lines2=`wc -l unbound.log | awk '{print $1;}'`
# See if the log finishes up without sleeping too long.
while test "$lines1" -ne "$lines2"; do
lines1=`wc -l unbound.log | awk '{print $1;}'`
# There is no sleep here. The add and compare are a
# brief wait.
count=`expr "$count" + 1`
if test "$count" -gt 30; then
break;
fi
lines2=`wc -l unbound.log | awk '{print $1;}'`
done
if test "$lines1" -ne "$lines2"; then
count=0
while test "$lines1" -ne "$lines2"; do
tail -1 unbound.log
lines1=`wc -l unbound.log | awk '{print $1;}'`
sleep 1
count=`expr "$count" + 1`
if test "$count" -gt 30; then
echo "reload is taking too long"
exit 1
fi
lines2=`wc -l unbound.log | awk '{print $1;}'`
done
if test "$count" -ne "0"; then
echo "reload done with $count sec"
fi
fi
}
# Reload the server for a clean state # Reload the server for a clean state
clean_reload () { clean_reload () {
echo "> Reloading the server for a clean state" echo "> Reloading the server for a clean state"
cp main.conf ub.conf cp main.conf ub.conf
control_command -c ub.conf reload control_reload
expect_exit_value 0
} }
# Reload the server for a clean state and populate the cache # Reload the server for a clean state and populate the cache
@ -175,8 +216,7 @@ expect_exit_value 1
# local-data element in the server. # local-data element in the server.
teststep "reload the server" teststep "reload the server"
echo "server: local-data: 'afterreload. IN A 5.6.7.8'" >> ub.conf echo "server: local-data: 'afterreload. IN A 5.6.7.8'" >> ub.conf
control_command -c ub.conf reload control_reload
expect_exit_value 0
query afterreload. query afterreload.
expect_answer "5.6.7.8" expect_answer "5.6.7.8"
@ -336,16 +376,14 @@ fi
clean_reload_and_fill_cache clean_reload_and_fill_cache
teststep "reload and check cache - should be empty" teststep "reload and check cache - should be empty"
control_command -c ub.conf reload control_reload
expect_exit_value 0
query www.example.com +nordflag query www.example.com +nordflag
fail_answer "10.20.30.40" fail_answer "10.20.30.40"
clean_reload_and_fill_cache clean_reload_and_fill_cache
teststep "reload_keep_cache and check cache - should not be empty" teststep "reload_keep_cache and check cache - should not be empty"
control_command -c ub.conf reload_keep_cache control_reload reload_keep_cache
expect_exit_value 0
query www.example.com +nordflag query www.example.com +nordflag
expect_answer "10.20.30.40" expect_answer "10.20.30.40"
@ -353,8 +391,7 @@ clean_reload_and_fill_cache
teststep "change msg-cache-size and reload_keep_cache - should be empty" teststep "change msg-cache-size and reload_keep_cache - should be empty"
echo "server: msg-cache-size: 2m" >> ub.conf echo "server: msg-cache-size: 2m" >> ub.conf
control_command -c ub.conf reload_keep_cache control_reload reload_keep_cache
expect_exit_value 0
query www.example.com +nordflag query www.example.com +nordflag
fail_answer "10.20.30.40" fail_answer "10.20.30.40"
@ -362,8 +399,7 @@ clean_reload_and_fill_cache
teststep "change rrset-cache-size and reload_keep_cache - should be empty" teststep "change rrset-cache-size and reload_keep_cache - should be empty"
echo "server: rrset-cache-size: 2m" >> ub.conf echo "server: rrset-cache-size: 2m" >> ub.conf
control_command -c ub.conf reload_keep_cache control_reload reload_keep_cache
expect_exit_value 0
query www.example.com +nordflag query www.example.com +nordflag
fail_answer "10.20.30.40" fail_answer "10.20.30.40"
@ -375,8 +411,7 @@ clean_reload_and_fill_cache
teststep "change num-threads and reload_keep_cache - should be empty" teststep "change num-threads and reload_keep_cache - should be empty"
echo "server: num-threads: 2" >> ub.conf echo "server: num-threads: 2" >> ub.conf
control_command -c ub.conf reload_keep_cache control_reload reload_keep_cache
expect_exit_value 0
query www.example.com +nordflag query www.example.com +nordflag
fail_answer "10.20.30.40" fail_answer "10.20.30.40"
@ -384,8 +419,7 @@ clean_reload_and_fill_cache
teststep "change minimal-responses and reload_keep_cache - should not be empty" teststep "change minimal-responses and reload_keep_cache - should not be empty"
echo "server: minimal-responses: no" >> ub.conf echo "server: minimal-responses: no" >> ub.conf
control_command -c ub.conf reload_keep_cache control_reload reload_keep_cache
expect_exit_value 0
query www.example.com +nordflag query www.example.com +nordflag
expect_answer "10.20.30.40" expect_answer "10.20.30.40"