Add a test case for checking zone transfers in statschannel

Use the named -T transferslowly test options to slow down a zone
transfer from the primary server, and test that it's correctly
exposed in the statistics channel of the secondary server, while
it's in-progress.
This commit is contained in:
Aram Sargsyan
2023-05-30 15:00:33 +00:00
parent 3e65dc12f7
commit c929127b73
2 changed files with 67 additions and 0 deletions

View File

@@ -32,4 +32,5 @@ rm -f traffic traffic.out.* traffic.json.* traffic.xml.*
rm -f xml.*mem json.*mem
rm -f xml.*stats json.*stats
rm -f zones zones.out.* zones.json.* zones.xml.* zones.expect.*
rm -f xfrins xfrins.json.* xfrins.xml.*
rm -rf ./__pycache__

View File

@@ -18,6 +18,7 @@ set -e
DIGCMD="$DIG @10.53.0.2 -p ${PORT}"
RNDCCMD="$RNDC -c ../_common/rndc.conf -p ${CONTROLPORT} -s"
NS_PARAMS="-X named.lock -m record -c named.conf -d 99 -g -U 4 -T maxcachesize=2097152"
if ! $FEATURETEST --have-json-c
then
@@ -48,6 +49,32 @@ if [ ! "$PERL_JSON" ] && [ ! "$PERL_XML" ]; then
exit 0
fi
retry_quiet_fast() {
__retries="${1}"
shift
while :; do
if "$@"; then
return 0
fi
__retries=$((__retries-1))
if [ "${__retries}" -gt 0 ]; then
# sleep for 0.1 seconds
perl -e 'select(undef, undef, undef, .1)'
else
return 1
fi
done
}
wait_for_log_fast() (
timeout="$1"
msg="$2"
file="$3"
retry_quiet_fast "$timeout" _search_log "$msg" "$file" && return 0
echo_i "exceeded time limit waiting for literal '$msg' in $file"
return 1
)
getzones() {
sleep 1
@@ -63,6 +90,19 @@ getzones() {
return $result
}
getxfrins() {
echo_i "... using $1"
case $1 in
xml) path='xml/v3/xfrins' ;;
json) path='json/v1/xfrins' ;;
*) return 1 ;;
esac
file=`$PERL fetch.pl -s 10.53.0.3 -p ${EXTRAPORT1} $path`
cp $file $file.$1.$3
result=$?
return $result
}
# TODO: Move loadkeys_on to conf.sh.common
loadkeys_on() {
nsidx=$1
@@ -655,5 +695,31 @@ if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status + ret))
n=$((n + 1))
echo_i "Retransfering 'example' from ns1 to ns3 in slow mode ($n)"
ret=0
i=0
# Restart ns1 with '-T transferslowly' to see the xfrins information in ns3's statschannel while it's ongoing
stop_server ns1
start_server --noclean --restart --port ${PORT} ns1 -- "-D statschannel-ns1 $NS_PARAMS -T transferslowly"
# Request a retransfer of the "example" zone
nextpart ns3/named.run > /dev/null
$RNDCCMD 10.53.0.3 retransfer example | sed "s/^/ns3 /" | cat_i
wait_for_log_fast 200 "zone example/IN: Transfer started" ns3/named.run || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status + ret))
n=$((n + 1))
# We have now less than one second to catch the zone transfer in process
echo_i "Checking zone transfer information in the statistics channel ($n)"
ret=0
i=0
getxfrins xml example x$n || ret=1
getxfrins json example j$n || ret=1
grep -F '<state>Initial SOA</state>' xfrins.xml.x$n >/dev/null || ret=1
grep -F '"state":"Initial SOA"' xfrins.json.j$n >/dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status + ret))
n=$((n + 1))
echo_i "exit status: $status"
[ $status -eq 0 ] || exit 1