From: Nicki Křížek Date: Fri, 5 Dec 2025 16:03:24 +0000 (+0100) Subject: Use jinja2 templates in catz test X-Git-Tag: v9.21.17~46^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=61144440073876515788e119b059a2b6d6df75f0;p=thirdparty%2Fbind9.git Use jinja2 templates in catz test - 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. --- diff --git a/bin/tests/system/catz/ns1/named.conf.in b/bin/tests/system/catz/ns1/named.conf.j2 similarity index 100% rename from bin/tests/system/catz/ns1/named.conf.in rename to bin/tests/system/catz/ns1/named.conf.j2 diff --git a/bin/tests/system/catz/ns2/named1.conf.in b/bin/tests/system/catz/ns2/named.conf.j2 similarity index 84% rename from bin/tests/system/catz/ns2/named1.conf.in rename to bin/tests/system/catz/ns2/named.conf.j2 index e35ba791742..a61a42cc03a 100644 --- a/bin/tests/system/catz/ns2/named1.conf.in +++ b/bin/tests/system/catz/ns2/named.conf.j2 @@ -11,6 +11,12 @@ * 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 index 00000000000..a6a0a9679fd --- /dev/null +++ b/bin/tests/system/catz/ns2/named1.conf.j2 @@ -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 index 00000000000..4c725307fa7 --- /dev/null +++ b/bin/tests/system/catz/ns2/named2.conf.j2 @@ -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 index 00000000000..2f63837f434 --- /dev/null +++ b/bin/tests/system/catz/ns2/named3.conf.j2 @@ -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 index 00000000000..07586f0b878 --- /dev/null +++ b/bin/tests/system/catz/ns2/named4.conf.j2 @@ -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 index 00000000000..6d5e997bcce --- /dev/null +++ b/bin/tests/system/catz/ns2/named5.conf.j2 @@ -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 index 00000000000..4f855c70ec8 --- /dev/null +++ b/bin/tests/system/catz/ns2/named6.conf.j2 @@ -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" %} diff --git a/bin/tests/system/catz/ns2/named2.conf.in b/bin/tests/system/catz/ns2/named7.conf.j2 similarity index 100% rename from bin/tests/system/catz/ns2/named2.conf.in rename to bin/tests/system/catz/ns2/named7.conf.j2 diff --git a/bin/tests/system/catz/ns3/named.conf.in b/bin/tests/system/catz/ns3/named.conf.j2 similarity index 100% rename from bin/tests/system/catz/ns3/named.conf.in rename to bin/tests/system/catz/ns3/named.conf.j2 diff --git a/bin/tests/system/catz/ns4/named.conf.in b/bin/tests/system/catz/ns4/named.conf.j2 similarity index 100% rename from bin/tests/system/catz/ns4/named.conf.in rename to bin/tests/system/catz/ns4/named.conf.j2 diff --git a/bin/tests/system/catz/setup.sh b/bin/tests/system/catz/setup.sh index 38339e2bd8f..5a169dbb249 100644 --- a/bin/tests/system/catz/setup.sh +++ b/bin/tests/system/catz/setup.sh @@ -13,11 +13,6 @@ . ../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 diff --git a/bin/tests/system/catz/tests.sh b/bin/tests/system/catz/tests.sh index b1d965b2476..120be787302 100644 --- a/bin/tests/system/catz/tests.sh +++ b/bin/tests/system/catz/tests.sh @@ -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/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/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/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/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/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))