Add more log/tap rotation tests

Add more tests to the dnstap system test to roll with different values.
Touch some files to make sure the number of existing files exceed the
number that we want to keep.

Add a test to the logfileconfig system test for the increment suffix.

(cherry picked from commit 9fb9670ebc)
This commit is contained in:
Matthijs Mekking 2023-04-06 09:21:09 +02:00
parent 33ad117166
commit eb37fd2f13
4 changed files with 109 additions and 13 deletions

View file

@ -787,28 +787,42 @@ lines=`$DNSTAPREAD -y large-answer.fstrm | grep -c "opcode: QUERY"`
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
test_dnstap_roll() (
_test_dnstap_roll() (
ip="$1"
ns="$2"
n="$3"
$RNDCCMD -s "${ip}" dnstap -roll "${n}" | sed "s/^/${ns} /" | cat_i &&
files=$(find "$ns" -name "dnstap.out.[0-9]" | wc -l) &&
test "$files" -le "${n}" && test "$files" -ge "1"
test "$files" -eq "${n}" && test "$files" -ge "1"
)
echo_i "checking 'rndc -roll <value>' (no versions)"
ret=0
start_server --noclean --restart --port "${PORT}" ns3
_repeat 5 test_dnstap_roll 10.53.0.3 ns3 3 || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status+ret))
echo_i "checking 'rndc -roll <value>' (versions)"
ret=0
test_dnstap_roll() {
echo_i "checking 'rndc -roll $4' ($1)"
ret=0
try=0
while test $try -lt 12
do
touch "$3/dnstap.out.$try"
try=`expr $try + 1`
done
_repeat 10 _test_dnstap_roll $2 $3 $4 || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status+ret))
}
start_server --noclean --restart --port "${PORT}" ns3
test_dnstap_roll "no versions" 10.53.0.3 ns3 6
test_dnstap_roll "no versions" 10.53.0.3 ns3 3
test_dnstap_roll "no versions" 10.53.0.3 ns3 1
start_server --noclean --restart --port "${PORT}" ns2
_repeat 5 test_dnstap_roll 10.53.0.2 ns2 3 || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status+ret))
test_dnstap_roll "versions" 10.53.0.2 ns2 6
test_dnstap_roll "versions" 10.53.0.2 ns2 3
test_dnstap_roll "versions" 10.53.0.2 ns2 1
echo_i "exit status: $status"
[ "$status" -eq 0 ] || exit 1

View file

@ -31,6 +31,8 @@ rm -f ns1/named_vers
rm -f ns1/named_vers.*
rm -f ns1/named_ts
rm -f ns1/named_ts.*
rm -f ns1/named_inc
rm -f ns1/named_inc.*
rm -f ns1/named_unlimited
rm -f ns1/named_unlimited.*
rm -f ns*/managed-keys.bind*

View file

@ -0,0 +1,52 @@
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* SPDX-License-Identifier: MPL-2.0
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
options {
query-source address 10.53.0.1;
notify-source 10.53.0.1;
transfer-source 10.53.0.1;
port @PORT@;
pid-file "named.pid";
listen-on { 10.53.0.1; };
listen-on-v6 { none; };
dnssec-validation no;
recursion no;
notify yes;
};
logging {
channel default_log {
buffered no;
file "named_inc" versions 1 size 1k suffix increment; # small size
severity debug 100;
print-time yes;
};
category default { default_log; default_debug; };
category lame-servers { null; };
channel query_log {
file "query_log";
print-time yes;
buffered yes;
};
category queries { query_log; };
};
controls {
inet 10.53.0.1 port @CONTROLPORT@ allow { any; } keys { "rndc-key"; };
};
key rndc-key {
secret "1234abcd8765";
algorithm hmac-sha256;
};

View file

@ -208,6 +208,34 @@ retry_quiet 5 _found2 || ret=1
if [ "$ret" -ne 0 ]; then echo_i "failed"; fi
status=$((status+ret))
n=$((n+1))
echo_i "testing incremented versions ($n)"
ret=0
copy_setports ns1/named.incconf.in ns1/named.conf
try=0
while test $try -lt 12
do
touch ns1/named_inc.$try
try=`expr $try + 1`
done
rndc_reconfig ns1 10.53.0.1 > rndc.out.test$n
_found2() (
$DIG version.bind txt ch @10.53.0.1 -p ${PORT} > dig.out.test$n
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
try=1
while test $try -lt 12
do
[ -f ns1/named_inc.$try ] && return 1
try=`expr $try + 1`
done
set -- ns1/named_inc.*
[ "$#" -eq 1 ] || return 1
)
retry_quiet 5 _found2 || ret=1
if [ "$ret" -ne 0 ]; then echo_i "failed"; fi
status=$((status+ret))
n=$((n+1))
echo_i "testing unlimited versions ($n)"
ret=0