Add a check for the 'first refresh' data in the stats channel

Currently we test the incoming zone transfers data in the statistics
channel by retransfering the zones in slow mode and capturing the XML
and JSON outputs in the meantime to check their validity. Add a new
transfer to the test, and check that the XML and JSON files correctly
indicate that we have 3 retransfers and 1 new (first time) transfer.
This commit is contained in:
Aram Sargsyan
2023-11-10 11:14:58 +00:00
parent 2ec041b719
commit 0b6ee6b953
4 changed files with 74 additions and 2 deletions

View File

@@ -0,0 +1,49 @@
; 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.
$ORIGIN .
$TTL 300 ; 5 minutes
example-new IN SOA mname1. . (
1 ; serial
20 ; refresh (20 seconds)
20 ; retry (20 seconds)
1814400 ; expire (3 weeks)
3600 ; minimum (1 hour)
)
example-new. NS ns2.example-new.
ns2.example-new. A 10.53.0.2
$ORIGIN example-new.
a A 10.0.0.1
MX 10 mail.example-new.
short TXT "short text"
long TXT (
"longlonglonglonglonglonglonglonglonglong"
"longlonglonglonglonglonglonglonglonglong"
"longlonglonglonglonglonglonglonglonglong"
"longlonglonglonglonglonglonglonglonglong"
"longlonglonglonglonglonglonglonglonglong"
"longlonglonglonglonglonglonglonglonglong"
"longlonglonglonglonglonglonglonglonglong"
"longlonglonglonglonglonglonglonglonglong"
"longlonglonglonglonglonglonglonglonglong"
"longlonglonglonglonglonglonglonglonglong"
"longlonglonglonglonglonglonglonglonglong"
"longlonglonglonglonglonglonglonglonglong"
"longlonglonglonglonglonglonglonglonglong"
"longlonglonglonglonglonglonglonglonglong"
"longlonglonglonglonglonglonglonglonglong"
"longlonglonglonglonglonglonglonglonglong"
"longlonglonglonglonglonglonglonglonglong"
"longlonglonglonglonglonglonglonglonglong"
)
mail A 10.0.0.2

View File

@@ -67,3 +67,9 @@ zone "example-tls" {
file "example-tls.db";
allow-transfer { any; };
};
zone "example-new" {
type primary;
file "example-new.db";
allow-transfer { any; };
};

View File

@@ -28,6 +28,7 @@ options {
notify no;
minimal-responses no;
version none; // make statistics independent of the version number
allow-new-zones yes;
};
statistics-channels { inet 10.53.0.3 port @EXTRAPORT1@ allow { localhost; }; };

View File

@@ -689,7 +689,7 @@ 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)"
echo_i "Transfering zones 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
@@ -700,6 +700,7 @@ nextpart ns3/named.run >/dev/null
$RNDCCMD 10.53.0.3 retransfer example | sed "s/^/ns3 /" | cat_i
$RNDCCMD 10.53.0.3 retransfer example-tcp | sed "s/^/ns3 /" | cat_i
$RNDCCMD 10.53.0.3 retransfer example-tls | sed "s/^/ns3 /" | cat_i
$RNDCCMD 10.53.0.3 addzone 'example-new { type secondary; primaries { 10.53.0.1; }; file "example-new.db"; };' 2>&1 | 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))
@@ -708,11 +709,26 @@ n=$((n + 1))
_wait_for_transfers() {
getxfrins xml x$n || return 1
getxfrins json j$n || return 1
# XML is encoded in one line, use awk to separate each transfer with a newline
# We expect 4 transfers
count=$(awk '{ gsub("<xfrin ", "\n<xfrin ") } 1' xfrins.xml.x$n | grep -c -E '<state>(Zone Transfer Request|First Data|Receiving AXFR Data)</state>')
if [ $count != 3 ]; then return 1; fi
if [ $count != 4 ]; then return 1; fi
count=$(grep -c -E '"state":"(Zone Transfer Request|First Data|Receiving AXFR Data)"' xfrins.json.j$n)
if [ $count != 4 ]; then return 1; fi
# We expect 3 of 4 to be retransfers
count=$(awk '{ gsub("<xfrin ", "\n<xfrin ") } 1' xfrins.xml.x$n | grep -c -F '<firstrefresh>No</firstrefresh>')
if [ $count != 3 ]; then return 1; fi
count=$(grep -c -F '"firstrefresh":"No"' xfrins.json.j$n)
if [ $count != 3 ]; then return 1; fi
# We expect 1 of 4 to be a new transfer
count=$(awk '{ gsub("<xfrin ", "\n<xfrin ") } 1' xfrins.xml.x$n | grep -c -F '<firstrefresh>Yes</firstrefresh>')
if [ $count != 1 ]; then return 1; fi
count=$(grep -c -F '"firstrefresh":"Yes"' xfrins.json.j$n)
if [ $count != 1 ]; then return 1; fi
}
# We have now less than one second to catch the zone transfers in progress