Skip to content

Commit

Permalink
- Fix that alloc stats for forwards and hints are printed, and when
Browse files Browse the repository at this point in the history
  alloc stats is enabled, the unit test for unbound control waits for
  reloads to complete.
  • Loading branch information
wcawijngaards committed Aug 2, 2024
1 parent 3cbf554 commit 0f2f602
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 18 deletions.
4 changes: 2 additions & 2 deletions daemon/worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ worker_mem_report(struct worker* ATTR_UNUSED(worker),
+ sizeof(*worker->env.scratch_buffer)
+ sldns_buffer_capacity(worker->env.scratch_buffer);
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)
me += hints_get_mem(worker->env.hints);
log_info("hints=%u", (unsigned)hints_get_mem(worker->env.hints));
if(worker->thread_num == 0)
me += acl_list_get_mem(worker->daemon->acl);
if(cur_serv) {
Expand Down
3 changes: 3 additions & 0 deletions doc/Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
add_cookie_secret, activate_cookie_secret and drop_cookie_secret
commands can be used for rollover, the command print_cookie_secrets
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
- Fix dnstap test program, cleans up to have clean memory on exit,
Expand Down
66 changes: 50 additions & 16 deletions testdata/09-unbound-control.tdir/09-unbound-control.test
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,53 @@ control_command () {
$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
clean_reload () {
echo "> Reloading the server for a clean state"
cp main.conf ub.conf
control_command -c ub.conf reload
expect_exit_value 0
control_reload
}

# Reload the server for a clean state and populate the cache
Expand Down Expand Up @@ -175,8 +216,7 @@ expect_exit_value 1
# local-data element in the server.
teststep "reload the server"
echo "server: local-data: 'afterreload. IN A 5.6.7.8'" >> ub.conf
control_command -c ub.conf reload
expect_exit_value 0
control_reload
query afterreload.
expect_answer "5.6.7.8"

Expand Down Expand Up @@ -336,34 +376,30 @@ fi
clean_reload_and_fill_cache

teststep "reload and check cache - should be empty"
control_command -c ub.conf reload
expect_exit_value 0
control_reload
query www.example.com +nordflag
fail_answer "10.20.30.40"

clean_reload_and_fill_cache

teststep "reload_keep_cache and check cache - should not be empty"
control_command -c ub.conf reload_keep_cache
expect_exit_value 0
control_reload reload_keep_cache
query www.example.com +nordflag
expect_answer "10.20.30.40"

clean_reload_and_fill_cache

teststep "change msg-cache-size and reload_keep_cache - should be empty"
echo "server: msg-cache-size: 2m" >> ub.conf
control_command -c ub.conf reload_keep_cache
expect_exit_value 0
control_reload reload_keep_cache
query www.example.com +nordflag
fail_answer "10.20.30.40"

clean_reload_and_fill_cache

teststep "change rrset-cache-size and reload_keep_cache - should be empty"
echo "server: rrset-cache-size: 2m" >> ub.conf
control_command -c ub.conf reload_keep_cache
expect_exit_value 0
control_reload reload_keep_cache
query www.example.com +nordflag
fail_answer "10.20.30.40"

Expand All @@ -375,17 +411,15 @@ clean_reload_and_fill_cache

teststep "change num-threads and reload_keep_cache - should be empty"
echo "server: num-threads: 2" >> ub.conf
control_command -c ub.conf reload_keep_cache
expect_exit_value 0
control_reload reload_keep_cache
query www.example.com +nordflag
fail_answer "10.20.30.40"

clean_reload_and_fill_cache

teststep "change minimal-responses and reload_keep_cache - should not be empty"
echo "server: minimal-responses: no" >> ub.conf
control_command -c ub.conf reload_keep_cache
expect_exit_value 0
control_reload reload_keep_cache
query www.example.com +nordflag
expect_answer "10.20.30.40"

Expand Down

0 comments on commit 0f2f602

Please sign in to comment.