]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
rewrite views/addzone in loop system test
authorColin Vidal <colin@isc.org>
Fri, 7 Nov 2025 09:45:09 +0000 (10:45 +0100)
committerColin Vidal <colin@isc.org>
Fri, 7 Nov 2025 14:07:56 +0000 (15:07 +0100)
A part of the `views` system test attempts to add multiples zones in a
loop, and after each zone being added, reconfig the server.

However, the test didn't take into account the fact that the server
might take a bit more time to reload than the script to move to the next
iteration, and in some case the test was re-requesting the server reload
when it was still reloading.

Since `b49f83a3`, `named` explicitly fails to reload when a load/reload
is pending, which is (unless proved otherwise) the reason of the test
was now randomly failing.

That part of the test is now waiting for the server log message saying
the server has added the new zone and is running. Also, that part of the
test has been rewrote in Python.

bin/tests/system/views/ns2/named.conf.j2 [moved from bin/tests/system/views/ns2/named3.conf.in with 80% similarity]
bin/tests/system/views/ns2/zone.db.in [new file with mode: 0644]
bin/tests/system/views/tests.sh
bin/tests/system/views/tests_views_addzones.py [new file with mode: 0644]

similarity index 80%
rename from bin/tests/system/views/ns2/named3.conf.in
rename to bin/tests/system/views/ns2/named.conf.j2
index 4c25f30c75da4d32c4087fc4a97c8b4dbf7c66cb..d9d852f82f570efeeb04b4bf657cc8282d81c95d 100644 (file)
@@ -10,6 +10,7 @@
  * See the COPYRIGHT file distributed with this work for additional
  * information regarding copyright ownership.
  */
+{% set zone_names = zone_names | default([]) %}
 
 options {
        query-source address 10.53.0.2;
@@ -34,4 +35,11 @@ controls {
        inet 10.53.0.2 port @CONTROLPORT@ allow { any; } keys { rndc_key; };
 };
 
-include "zones.conf";
+{% for name in zone_names %}
+zone "@name@" {
+    type primary;
+    file "@name@.db";
+    dnssec-policy default;
+    inline-signing yes;
+};
+{% endfor %}
diff --git a/bin/tests/system/views/ns2/zone.db.in b/bin/tests/system/views/ns2/zone.db.in
new file mode 100644 (file)
index 0000000..c8d0554
--- /dev/null
@@ -0,0 +1,21 @@
+; 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.
+
+$TTL 86400
+@         IN SOA localhost. hostmaster.localhost (
+               1612542642 ; serial
+               12H ; refresh
+               1H  ; retry
+               2w  ; expiry
+              1h  ; minimum
+          )
+@         IN NS localhost
+localhost IN A  127.0.0.1
index 7b6f28986fdb6d075b1670ad066af632c5110cc5..4684f82249b270cdfb79d71749c7fc4903c383b0 100644 (file)
@@ -148,48 +148,5 @@ test "$int" != "$ext" || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
 
-echo_i "verifying adding of multiple inline zones followed by reconfiguration works"
-
-[ ! -f ns2/zones.conf ] && touch ns2/zones.conf
-copy_setports ns2/named3.conf.in ns2/named.conf
-
-i=1
-while [ $i -lt 50 ]; do
-  ret=0
-  zone_name=$(printf "example%03d.com" $i)
-
-  # Add a new zone to the configuration.
-  cat >>ns2/zones.conf <<-EOF
-       zone "${zone_name}" {
-           type primary;
-           file "db.${zone_name}";
-           dnssec-policy default;
-           inline-signing yes;
-       };
-       EOF
-
-  # Create a master file for the zone.
-  cat >"ns2/db.${zone_name}" <<-EOF
-       \$TTL 86400
-       @               IN      SOA     localhost. hostmaster.localhost (
-                                               1612542642 ; serial
-                                               12H ; refresh
-                                               1H  ; retry
-                                               2w  ; expiry
-                                               1h  ; minimum
-                                       )
-       @               IN      NS      localhost
-       localhost       IN      A       127.0.0.1
-       EOF
-
-  $RNDCCMD 10.53.0.2 reconfig || ret=1
-  if [ $ret != 0 ]; then
-    echo_i "failed"
-    break
-  fi
-  i=$((i + 1))
-done
-status=$((status + ret))
-
 echo_i "exit status: $status"
 [ "$status" -eq 0 ] || exit 1
diff --git a/bin/tests/system/views/tests_views_addzones.py b/bin/tests/system/views/tests_views_addzones.py
new file mode 100644 (file)
index 0000000..c362b47
--- /dev/null
@@ -0,0 +1,25 @@
+# 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.
+
+import shutil
+
+
+def test_views_add_zones(ns2, templates):
+    zone_names = []
+    for i in range(50):
+        name = f"example{i:03}.com"
+        zone_names.append(name)
+        templates.render("ns2/named.conf", {"zone_names": zone_names})
+        shutil.copyfile("ns2/zone.db.in", f"ns2/{name}.db")
+        with ns2.watch_log_from_here() as watcher:
+            ns2.rndc("reconfig", log=False)
+            log_seq = ["any newly configured zones are now loaded", "running"]
+            watcher.wait_for_sequence(log_seq)