]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix dnstap system test on FreeBSD
authorDiego Fronza <diego@isc.org>
Thu, 1 Oct 2020 17:04:05 +0000 (14:04 -0300)
committerDiego Fronza <diego@isc.org>
Tue, 20 Oct 2020 13:18:28 +0000 (10:18 -0300)
This commit ensures that dnstap output files captured
by fstrm_capture are properly flushed before any attempt
on reading them with dnstap-read is done.

By reading fstrm-capture source code it was noticed that
signal SIGHUP is used to flush the capture file.

bin/tests/system/dnstap/tests.sh

index 5f237d7a3836f1e2e1f553aa8ed8721e82df7fe0..ceaf30df5f764e8928f6174a8a20737cf324931a 100644 (file)
@@ -16,6 +16,24 @@ RNDCCMD="$RNDC -p ${CONTROLPORT} -c ../common/rndc.conf"
 
 status=0
 
+# dnstap_data_ready <fstrm_capture_PID> <capture_file> <min_file_size>
+# Flushes capture_file and checks wheter its size is >= min_file_size.
+dnstap_data_ready() {
+       # Process id of running fstrm_capture.
+       fstrm_capture_pid=$1
+       # Output file provided to fstrm_capture via -w switch.
+       capture_file=$2
+       # Minimum expected file size.
+       min_size_expected=$3
+
+       kill -HUP $fstrm_capture_pid
+       file_size=`wc -c < "$capture_file" | tr -d ' '`
+       if [ $file_size -lt $min_size_expected ]; then
+               return 1
+       fi
+}
+
+
 for bad in bad-*.conf
 do
        ret=0
@@ -536,6 +554,7 @@ EOF
 
        echo_i "checking unix socket message counts"
        sleep 2
+       retry_quiet 5 dnstap_data_ready $fstrm_capture_pid dnstap.out 470
        kill $fstrm_capture_pid
        wait
        udp4=`$DNSTAPREAD dnstap.out | grep "UDP " | wc -l`
@@ -647,6 +666,7 @@ EOF
 
        echo_i "checking reopened unix socket message counts"
        sleep 2
+       retry_quiet 5 dnstap_data_ready $fstrm_capture_pid dnstap.out 270
        kill $fstrm_capture_pid
        wait
        udp4=`$DNSTAPREAD dnstap.out | grep "UDP " | wc -l`