]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Use jinja2 templates in catz test
authorNicki Křížek <nicki@isc.org>
Fri, 5 Dec 2025 16:03:24 +0000 (17:03 +0100)
committerNicki Křížek <nicki@isc.org>
Tue, 9 Dec 2025 13:23:17 +0000 (14:23 +0100)
- Use a common ns2/named.conf.j2 template for all the "#TN"
  replacements. Instead of commenting out with sed, render the template
  differently into ns/namedX.conf using variables.
- Keep the final ns2/named7.conf.j2 (formerly ns2/named2.conf.in) as a
  separate template for readability due to significant differences.

13 files changed:
bin/tests/system/catz/ns1/named.conf.j2 [moved from bin/tests/system/catz/ns1/named.conf.in with 100% similarity]
bin/tests/system/catz/ns2/named.conf.j2 [moved from bin/tests/system/catz/ns2/named1.conf.in with 84% similarity]
bin/tests/system/catz/ns2/named1.conf.j2 [new file with mode: 0644]
bin/tests/system/catz/ns2/named2.conf.j2 [new file with mode: 0644]
bin/tests/system/catz/ns2/named3.conf.j2 [new file with mode: 0644]
bin/tests/system/catz/ns2/named4.conf.j2 [new file with mode: 0644]
bin/tests/system/catz/ns2/named5.conf.j2 [new file with mode: 0644]
bin/tests/system/catz/ns2/named6.conf.j2 [new file with mode: 0644]
bin/tests/system/catz/ns2/named7.conf.j2 [moved from bin/tests/system/catz/ns2/named2.conf.in with 100% similarity]
bin/tests/system/catz/ns3/named.conf.j2 [moved from bin/tests/system/catz/ns3/named.conf.in with 100% similarity]
bin/tests/system/catz/ns4/named.conf.j2 [moved from bin/tests/system/catz/ns4/named.conf.in with 100% similarity]
bin/tests/system/catz/setup.sh
bin/tests/system/catz/tests.sh

similarity index 84%
rename from bin/tests/system/catz/ns2/named1.conf.in
rename to bin/tests/system/catz/ns2/named.conf.j2
index e35ba7917420cd8d7ce359aae4abce608c8a2207..a61a42cc03a0573cccddf351d4dc141a17682f2a 100644 (file)
  * information regarding copyright ownership.
  */
 
+{% set allow_query_blackhole = allow_query_blackhole | default(False) %}
+{% set bad_dlz = bad_dlz | default(False) %}
+{% set catalog4 = catalog4 | default(False) %}
+{% set catalog5 = catalog5 | default(False) %}
+{% set duplicate_zone = duplicate_zone | default(False) %}
+
 include "../../_common/rndc.key";
 
 controls {
@@ -29,9 +35,13 @@ options {
        notify no;
        notify-delay 0;
        recursion no;
-#T5    allow-query { 10.53.0.99; };
        serial-query-rate 100;
        dnssec-validation no;
+
+{% if allow_query_blackhole %}
+       allow-query { 10.53.0.99; };
+{% endif %}
+
 };
 
 /*
@@ -59,12 +69,19 @@ view "default" {
                        default-masters { 10.53.0.1; }
                        min-update-interval 1s
                        zone-directory "nonexistent";
-#T1            zone "catalog4.example"
-#T1                    min-update-interval 1s
-#T1                    default-masters { 10.53.0.1; };
-#T2            zone "catalog5.example"
-#T2                    min-update-interval 1s
-#T2                    default-primaries { 10.53.0.1; };
+
+{% if catalog4 %}
+               zone "catalog4.example"
+                       min-update-interval 1s
+                       default-masters { 10.53.0.1; };
+{% endif %}
+
+{% if catalog5 %}
+               zone "catalog5.example"
+                       min-update-interval 1s
+                       default-primaries { 10.53.0.1; };
+{% endif %}
+
                zone "catalog6.example"
                        min-update-interval 1s
                        default-primaries { 10.53.0.1; };
@@ -86,13 +103,15 @@ view "default" {
                        in-memory yes;
        };
 
+{% if bad_dlz %}
        # A faulty dlz configuration to check if named and catz survive a certain class
        # of failed configuration attempts (see GL #3060).
        # We use "dlz" because the dlz processing code is located in an ideal place in
        # the view configuration function for the test to cover the view reverting code.
-#T3    dlz "bad-dlz" {
-#T3            database "dlopen bad-dlz.so example.org";
-#T3    };
+       dlz "bad-dlz" {
+               database "dlopen bad-dlz.so example.org";
+       };
+{% endif %}
 
        zone "dom-existing.example" {
            type primary;
@@ -147,14 +166,16 @@ view "default" {
                primaries { 10.53.0.1; };
        };
 
+{% if duplicate_zone %}
        # When the following zone configuration is enabled, "dom3.example" should
        # already exist as a member of "catalog1.example", and named should be able
        # to deal with that situation (see GL #3911). Make sure that this duplicate
        # zone comes after the the "catalog1.example" zone in the configuration file.
-#T4    zone "dom3.example" {
-#T4        type secondary;
-#T4        file "dom2.example.db";
-#T4    };
+       zone "dom3.example" {
+           type secondary;
+           file "dom2.example.db";
+       };
+{% endif %}
 
        # No "version" property
        zone "catalog-bad1.example" {
diff --git a/bin/tests/system/catz/ns2/named1.conf.j2 b/bin/tests/system/catz/ns2/named1.conf.j2
new file mode 100644 (file)
index 0000000..a6a0a96
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * 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.
+ */
+
+{% include "ns2/named.conf.j2" %}
diff --git a/bin/tests/system/catz/ns2/named2.conf.j2 b/bin/tests/system/catz/ns2/named2.conf.j2
new file mode 100644 (file)
index 0000000..4c72530
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * 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.
+ */
+
+{% set bad_dlz = True %}
+
+{% include "ns2/named.conf.j2" %}
diff --git a/bin/tests/system/catz/ns2/named3.conf.j2 b/bin/tests/system/catz/ns2/named3.conf.j2
new file mode 100644 (file)
index 0000000..2f63837
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * 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.
+ */
+
+{% set duplicate_zone = True %}
+
+{% include "ns2/named.conf.j2" %}
diff --git a/bin/tests/system/catz/ns2/named4.conf.j2 b/bin/tests/system/catz/ns2/named4.conf.j2
new file mode 100644 (file)
index 0000000..07586f0
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * 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.
+ */
+
+{% set allow_query_blackhole = True %}
+
+{% include "ns2/named.conf.j2" %}
diff --git a/bin/tests/system/catz/ns2/named5.conf.j2 b/bin/tests/system/catz/ns2/named5.conf.j2
new file mode 100644 (file)
index 0000000..6d5e997
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * 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.
+ */
+
+{% set catalog4 = True %}
+
+{% include "ns2/named.conf.j2" %}
diff --git a/bin/tests/system/catz/ns2/named6.conf.j2 b/bin/tests/system/catz/ns2/named6.conf.j2
new file mode 100644 (file)
index 0000000..4f855c7
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * 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.
+ */
+
+{% set catalog5 = True %}
+
+{% include "ns2/named.conf.j2" %}
index 38339e2bd8fee70a8dc77a4e937c11602bf19ed9..5a169dbb249cd93802affc7fe3c46043fab42656 100644 (file)
 
 . ../conf.sh
 
-copy_setports ns1/named.conf.in ns1/named.conf
-copy_setports ns2/named1.conf.in ns2/named.conf
-copy_setports ns3/named.conf.in ns3/named.conf
-copy_setports ns4/named.conf.in ns4/named.conf
-
 cp -f ns1/catalog.example.db.in ns1/catalog0.example.db
 cp -f ns1/catalog.example.db.in ns1/catalog1.example.db
 cp -f ns3/catalog.example.db.in ns3/catalog2.example.db
index b1d965b2476df949f7ab07f2120b688b1cc3550d..120be78730203f8a36780a62de0aa7325a5a5d2b 100644 (file)
@@ -650,8 +650,7 @@ nextpart ns2/named.run >/dev/null
 n=$((n + 1))
 echo_i "reconfiguring secondary - checking if catz survives a certain class of failed reconfiguration attempts ($n)"
 ret=0
-sed -e "s/^#T3//" <ns2/named1.conf.in >ns2/named.conf.tmp
-copy_setports ns2/named.conf.tmp ns2/named.conf
+cp ns2/named2.conf ns2/named.conf
 $RNDC -c ../_common/rndc.conf -s 10.53.0.2 -p "${CONTROLPORT}" reconfig >/dev/null 2>&1 && ret=1
 if [ $ret -ne 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
@@ -666,7 +665,7 @@ status=$((status + ret))
 n=$((n + 1))
 echo_i "reconfiguring secondary - reverting the bad configuration ($n)"
 ret=0
-copy_setports ns2/named1.conf.in ns2/named.conf
+cp ns2/named1.conf ns2/named.conf
 rndccmd 10.53.0.2 reconfig || ret=1
 if [ $ret -ne 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
@@ -677,8 +676,7 @@ nextpart ns2/named.run >/dev/null
 n=$((n + 1))
 echo_i "reconfiguring secondary - checking if catz survives another type of failed reconfiguration attempts ($n)"
 ret=0
-sed -e "s/^#T4//" <ns2/named1.conf.in >ns2/named.conf.tmp
-copy_setports ns2/named.conf.tmp ns2/named.conf
+cp ns2/named3.conf ns2/named.conf
 $RNDC -c ../_common/rndc.conf -s 10.53.0.2 -p "${CONTROLPORT}" reconfig >/dev/null 2>&1 && ret=1
 if [ $ret -ne 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
@@ -697,8 +695,7 @@ status=$((status + ret))
 n=$((n + 1))
 echo_i "reconfiguring secondary - checking if catz member zones are reconfigured ($n)"
 ret=0
-sed -e "s/^#T5//" <ns2/named1.conf.in >ns2/named.conf.tmp
-copy_setports ns2/named.conf.tmp ns2/named.conf
+cp ns2/named4.conf ns2/named.conf
 rndccmd 10.53.0.2 reconfig || ret=1
 if [ $ret -ne 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
@@ -713,7 +710,7 @@ status=$((status + ret))
 n=$((n + 1))
 echo_i "reconfiguring secondary - reverting the bad configuration ($n)"
 ret=0
-copy_setports ns2/named1.conf.in ns2/named.conf
+cp ns2/named1.conf ns2/named.conf
 rndccmd 10.53.0.2 reconfig || ret=1
 if [ $ret -ne 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
@@ -1714,8 +1711,7 @@ status=$((status + ret))
 n=$((n + 1))
 echo_i "reconfiguring secondary - adding catalog4 catalog zone ($n)"
 ret=0
-sed -e "s/^#T1//g" <ns2/named1.conf.in >ns2/named.conf.tmp
-copy_setports ns2/named.conf.tmp ns2/named.conf
+cp ns2/named5.conf ns2/named.conf
 rndccmd 10.53.0.2 reconfig || ret=1
 if [ $ret -ne 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
@@ -1745,8 +1741,7 @@ status=$((status + ret))
 n=$((n + 1))
 echo_i "reconfiguring secondary - removing catalog4 catalog zone, adding non-existent catalog5 catalog zone ($n)"
 ret=0
-sed -e "s/^#T2//" <ns2/named1.conf.in >ns2/named.conf.tmp
-copy_setports ns2/named.conf.tmp ns2/named.conf
+cp ns2/named6.conf ns2/named.conf
 $RNDC -c ../_common/rndc.conf -s 10.53.0.2 -p "${CONTROLPORT}" reconfig >/dev/null 2>&1 && ret=1
 if [ $ret -ne 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
@@ -1754,7 +1749,7 @@ status=$((status + ret))
 n=$((n + 1))
 echo_i "reconfiguring secondary - removing non-existent catalog5 catalog zone ($n)"
 ret=0
-copy_setports ns2/named1.conf.in ns2/named.conf
+cp ns2/named1.conf ns2/named.conf
 rndccmd 10.53.0.2 reconfig || ret=1
 if [ $ret -ne 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
@@ -2545,9 +2540,9 @@ status=$((status + ret))
 n=$((n + 1))
 echo_i "checking that reconfig can delete and restore catalog zone configuration ($n)"
 ret=0
-copy_setports ns2/named2.conf.in ns2/named.conf
+cp ns2/named7.conf ns2/named.conf
 rndccmd 10.53.0.2 reconfig || ret=1
-copy_setports ns2/named1.conf.in ns2/named.conf
+cp ns2/named1.conf ns2/named.conf
 rndccmd 10.53.0.2 reconfig || ret=1
 if [ $ret -ne 0 ]; then echo_i "failed"; fi
 status=$((status + ret))