]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix that alloc stats for forwards and hints are printed, and when
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Fri, 2 Aug 2024 13:51:40 +0000 (15:51 +0200)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Fri, 2 Aug 2024 13:51:40 +0000 (15:51 +0200)
  alloc stats is enabled, the unit test for unbound control waits for
  reloads to complete.

daemon/worker.c
doc/Changelog
testdata/09-unbound-control.tdir/09-unbound-control.test

index 84e18f2d018fed3be2693aa187dced0494eaf030..5e6b2a656e2c26ffa5f5b0309e4e1c997e4b3199 100644 (file)
@@ -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) {
index 0c0e376afe3fc1f6e048f76e681603c08827f258..cec04793f964ce1400a3ed144cfb224f34f1511f 100644 (file)
@@ -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,
index 597487290acdea84a136747dd2b32781376ad639..8bd2220f34299dde7483e1efb3baca325f9e03d0 100644 (file)
@@ -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
@@ -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"
 
@@ -336,16 +376,14 @@ 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"
 
@@ -353,8 +391,7 @@ 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"
 
@@ -362,8 +399,7 @@ 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"
 
@@ -375,8 +411,7 @@ 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"
 
@@ -384,8 +419,7 @@ 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"