]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add a check for the 'first refresh' data in the stats channel
authorAram Sargsyan <aram@isc.org>
Fri, 10 Nov 2023 11:14:58 +0000 (11:14 +0000)
committerAram Sargsyan <aram@isc.org>
Mon, 5 Feb 2024 17:41:14 +0000 (17:41 +0000)
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.

bin/tests/system/statschannel/ns1/example-new.db [new file with mode: 0644]
bin/tests/system/statschannel/ns1/named.conf.in
bin/tests/system/statschannel/ns3/named.conf.in
bin/tests/system/statschannel/tests.sh

diff --git a/bin/tests/system/statschannel/ns1/example-new.db b/bin/tests/system/statschannel/ns1/example-new.db
new file mode 100644 (file)
index 0000000..e258bd5
--- /dev/null
@@ -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
index 5bdfdf0cb64ce6088d7cdb60030fc4550d0e3615..b70c871da464f975405627dcbc81444954c6a1ca 100644 (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; };
+};
index 4fa2adeb40ff60cd519348ef252c4a04543dc3b7..901dc84764c540001312ddc36369bcb4852c9626 100644 (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; }; };
index c871120e36186499671748c3badab13c75fac392..f8ba35cf367121dfa851313252ae6ffc95c5c2fa 100644 (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