From e50edc909078ac6279d8b6e6d621ab16140f6c01 Mon Sep 17 00:00:00 2001 From: Colin Vidal Date: Fri, 7 Nov 2025 10:45:09 +0100 Subject: [PATCH] rewrite views/addzone in loop system test 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. --- .../ns2/{named3.conf.in => named.conf.j2} | 10 ++++- bin/tests/system/views/ns2/zone.db.in | 21 +++++++++ bin/tests/system/views/tests.sh | 43 ------------------- .../system/views/tests_views_addzones.py | 25 +++++++++++ 4 files changed, 55 insertions(+), 44 deletions(-) rename bin/tests/system/views/ns2/{named3.conf.in => named.conf.j2} (80%) create mode 100644 bin/tests/system/views/ns2/zone.db.in create mode 100644 bin/tests/system/views/tests_views_addzones.py diff --git a/bin/tests/system/views/ns2/named3.conf.in b/bin/tests/system/views/ns2/named.conf.j2 similarity index 80% rename from bin/tests/system/views/ns2/named3.conf.in rename to bin/tests/system/views/ns2/named.conf.j2 index 4c25f30c75..d9d852f82f 100644 --- a/bin/tests/system/views/ns2/named3.conf.in +++ b/bin/tests/system/views/ns2/named.conf.j2 @@ -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 index 0000000000..c8d05540cb --- /dev/null +++ b/bin/tests/system/views/ns2/zone.db.in @@ -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 diff --git a/bin/tests/system/views/tests.sh b/bin/tests/system/views/tests.sh index 7b6f28986f..4684f82249 100644 --- a/bin/tests/system/views/tests.sh +++ b/bin/tests/system/views/tests.sh @@ -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 index 0000000000..c362b47721 --- /dev/null +++ b/bin/tests/system/views/tests_views_addzones.py @@ -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)