From: Nicki Křížek Date: Fri, 5 Dec 2025 16:04:33 +0000 (+0100) Subject: Use jinja2 templates in serve-stale test X-Git-Tag: v9.21.17~46^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a8713fdcf882091c920bf8e25a22361cb68ef156;p=thirdparty%2Fbind9.git Use jinja2 templates in serve-stale test The ns1 named.conf files were sufficiently similar to allow for de-duplication. No attempt to de-duplicate ns3 was made due to significant differences among the config files. --- diff --git a/bin/tests/system/serve-stale/ns1/named.conf.j2 b/bin/tests/system/serve-stale/ns1/named.conf.j2 new file mode 100644 index 00000000000..a34c24fb32f --- /dev/null +++ b/bin/tests/system/serve-stale/ns1/named.conf.j2 @@ -0,0 +1,59 @@ +/* + * 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 max_stale_ttl = max_stale_ttl | default(3600) %} +{% set stale_answer_ttl = stale_answer_ttl | default(4) %} +{% set stale_refresh_time = stale_refresh_time | default(30) %} +{% set stale_test_zone = stale_test_zone | default(False) %} + +key rndc_key { + secret "1234abcd8765"; + algorithm @DEFAULT_HMAC@; +}; + +controls { + inet 10.53.0.1 port @CONTROLPORT@ allow { any; } keys { rndc_key; }; +}; + +options { + query-source address 10.53.0.1; + notify-source 10.53.0.1; + transfer-source 10.53.0.1; + port @PORT@; + pid-file "named.pid"; + listen-on { 10.53.0.1; }; + listen-on-v6 { none; }; + allow-transfer { any; }; + recursion yes; + dnssec-validation no; + max-stale-ttl @max_stale_ttl@; + stale-answer-ttl @stale_answer_ttl@; + stale-answer-enable yes; + stale-cache-enable yes; +{% if stale_refresh_time is not none %} + stale-refresh-time @stale_refresh_time@; +{% endif %} + servfail-ttl 0; +}; + +zone "." { + type primary; + file "root.db"; +}; + +{% if stale_test_zone %} +zone "stale.test" { + type primary; + file "stale.test.db"; +}; +{% endif %} diff --git a/bin/tests/system/serve-stale/ns1/named2.conf.j2 b/bin/tests/system/serve-stale/ns1/named2.conf.j2 new file mode 100644 index 00000000000..f936c252583 --- /dev/null +++ b/bin/tests/system/serve-stale/ns1/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 stale_refresh_time = 0 %} + +{% include "ns1/named.conf.j2" %} diff --git a/bin/tests/system/serve-stale/ns1/named3.conf.j2 b/bin/tests/system/serve-stale/ns1/named3.conf.j2 new file mode 100644 index 00000000000..28c2f89a451 --- /dev/null +++ b/bin/tests/system/serve-stale/ns1/named3.conf.j2 @@ -0,0 +1,18 @@ +/* + * 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 max_stale_ttl = 20 %} +{% set stale_answer_ttl = 3 %} +{% set stale_refresh_time = None %} + +{% include "ns1/named.conf.j2" %} diff --git a/bin/tests/system/serve-stale/ns1/named4.conf.j2 b/bin/tests/system/serve-stale/ns1/named4.conf.j2 new file mode 100644 index 00000000000..6ec4e056653 --- /dev/null +++ b/bin/tests/system/serve-stale/ns1/named4.conf.j2 @@ -0,0 +1,19 @@ +/* + * 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 max_stale_ttl = 20 %} +{% set stale_answer_ttl = 3 %} +{% set stale_refresh_time = 0 %} +{% set stale_test_zone = True %} + +{% include "ns1/named.conf.j2" %} diff --git a/bin/tests/system/serve-stale/ns3/named.conf.in b/bin/tests/system/serve-stale/ns3/named.conf.j2 similarity index 100% rename from bin/tests/system/serve-stale/ns3/named.conf.in rename to bin/tests/system/serve-stale/ns3/named.conf.j2 diff --git a/bin/tests/system/serve-stale/ns3/named1.conf.in b/bin/tests/system/serve-stale/ns3/named1.conf.j2 similarity index 100% rename from bin/tests/system/serve-stale/ns3/named1.conf.in rename to bin/tests/system/serve-stale/ns3/named1.conf.j2 diff --git a/bin/tests/system/serve-stale/ns3/named2.conf.in b/bin/tests/system/serve-stale/ns3/named2.conf.j2 similarity index 100% rename from bin/tests/system/serve-stale/ns3/named2.conf.in rename to bin/tests/system/serve-stale/ns3/named2.conf.j2 diff --git a/bin/tests/system/serve-stale/ns3/named3.conf.in b/bin/tests/system/serve-stale/ns3/named3.conf.j2 similarity index 100% rename from bin/tests/system/serve-stale/ns3/named3.conf.in rename to bin/tests/system/serve-stale/ns3/named3.conf.j2 diff --git a/bin/tests/system/serve-stale/ns3/named4.conf.in b/bin/tests/system/serve-stale/ns3/named4.conf.j2 similarity index 100% rename from bin/tests/system/serve-stale/ns3/named4.conf.in rename to bin/tests/system/serve-stale/ns3/named4.conf.j2 diff --git a/bin/tests/system/serve-stale/ns3/named5.conf.in b/bin/tests/system/serve-stale/ns3/named5.conf.j2 similarity index 100% rename from bin/tests/system/serve-stale/ns3/named5.conf.in rename to bin/tests/system/serve-stale/ns3/named5.conf.j2 diff --git a/bin/tests/system/serve-stale/ns3/named6.conf.in b/bin/tests/system/serve-stale/ns3/named6.conf.j2 similarity index 100% rename from bin/tests/system/serve-stale/ns3/named6.conf.in rename to bin/tests/system/serve-stale/ns3/named6.conf.j2 diff --git a/bin/tests/system/serve-stale/ns3/named7.conf.in b/bin/tests/system/serve-stale/ns3/named7.conf.j2 similarity index 100% rename from bin/tests/system/serve-stale/ns3/named7.conf.in rename to bin/tests/system/serve-stale/ns3/named7.conf.j2 diff --git a/bin/tests/system/serve-stale/ns3/named8.conf.in b/bin/tests/system/serve-stale/ns3/named8.conf.j2 similarity index 100% rename from bin/tests/system/serve-stale/ns3/named8.conf.in rename to bin/tests/system/serve-stale/ns3/named8.conf.j2 diff --git a/bin/tests/system/serve-stale/ns3/named9.conf.in b/bin/tests/system/serve-stale/ns3/named9.conf.j2 similarity index 100% rename from bin/tests/system/serve-stale/ns3/named9.conf.in rename to bin/tests/system/serve-stale/ns3/named9.conf.j2 diff --git a/bin/tests/system/serve-stale/ns4/named.conf.in b/bin/tests/system/serve-stale/ns4/named.conf.j2 similarity index 100% rename from bin/tests/system/serve-stale/ns4/named.conf.in rename to bin/tests/system/serve-stale/ns4/named.conf.j2 diff --git a/bin/tests/system/serve-stale/ns5/named.conf.in b/bin/tests/system/serve-stale/ns5/named.conf.j2 similarity index 100% rename from bin/tests/system/serve-stale/ns5/named.conf.in rename to bin/tests/system/serve-stale/ns5/named.conf.j2 diff --git a/bin/tests/system/serve-stale/ns6/named.conf.in b/bin/tests/system/serve-stale/ns6/named.conf.j2 similarity index 100% rename from bin/tests/system/serve-stale/ns6/named.conf.in rename to bin/tests/system/serve-stale/ns6/named.conf.j2 diff --git a/bin/tests/system/serve-stale/setup.sh b/bin/tests/system/serve-stale/setup.sh deleted file mode 100644 index ad6073a793a..00000000000 --- a/bin/tests/system/serve-stale/setup.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -# 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. - -. ../conf.sh - -copy_setports ns1/named1.conf.in ns1/named.conf -copy_setports ns3/named.conf.in ns3/named.conf -copy_setports ns4/named.conf.in ns4/named.conf -copy_setports ns5/named.conf.in ns5/named.conf -copy_setports ns6/named.conf.in ns6/named.conf diff --git a/bin/tests/system/serve-stale/tests.sh b/bin/tests/system/serve-stale/tests.sh index 24603844127..52949efefe2 100755 --- a/bin/tests/system/serve-stale/tests.sh +++ b/bin/tests/system/serve-stale/tests.sh @@ -291,7 +291,7 @@ status=$((status + ret)) n=$((n + 1)) echo_i "updating ns1/named.conf ($n)" ret=0 -copy_setports ns1/named2.conf.in ns1/named.conf +cp ns1/named2.conf ns1/named.conf if [ $ret != 0 ]; then echo_i "failed"; fi status=$((status + ret)) @@ -537,7 +537,7 @@ echo_i "test server with serve-stale options set, low max-stale-ttl" n=$((n + 1)) echo_i "updating ns1/named.conf ($n)" ret=0 -copy_setports ns1/named3.conf.in ns1/named.conf +cp ns1/named3.conf ns1/named.conf if [ $ret != 0 ]; then echo_i "failed"; fi status=$((status + ret)) @@ -897,7 +897,7 @@ status=$((status + ret)) n=$((n + 1)) echo_i "updating ns1/named.conf ($n)" ret=0 -copy_setports ns1/named4.conf.in ns1/named.conf +cp ns1/named4.conf ns1/named.conf if [ $ret != 0 ]; then echo_i "failed"; fi status=$((status + ret)) @@ -999,7 +999,7 @@ echo_i "test server with no serve-stale options set" n=$((n + 1)) echo_i "updating ns3/named1.conf ($n)" ret=0 -copy_setports ns3/named1.conf.in ns3/named.conf +cp ns3/named1.conf ns3/named.conf if [ $ret != 0 ]; then echo_i "failed"; fi status=$((status + ret)) @@ -1724,7 +1724,7 @@ echo_i "test stale-answer-client-timeout (off)" n=$((n + 1)) echo_i "updating ns3/named3.conf ($n)" ret=0 -copy_setports ns3/named3.conf.in ns3/named.conf +cp ns3/named3.conf ns3/named.conf if [ $ret != 0 ]; then echo_i "failed"; fi status=$((status + ret)) @@ -1851,7 +1851,7 @@ echo_i "test stale-answer-client-timeout (0)" n=$((n + 1)) echo_i "updating ns3/named4.conf ($n)" ret=0 -copy_setports ns3/named4.conf.in ns3/named.conf +cp ns3/named4.conf ns3/named.conf if [ $ret != 0 ]; then echo_i "failed"; fi status=$((status + ret)) @@ -2172,7 +2172,7 @@ echo_i "test stale-answer-client-timeout (0) and stale-refresh-time (4)" n=$((n + 1)) echo_i "updating ns3/named5.conf ($n)" ret=0 -copy_setports ns3/named5.conf.in ns3/named.conf +cp ns3/named5.conf ns3/named.conf if [ $ret != 0 ]; then echo_i "failed"; fi status=$((status + ret)) @@ -2357,7 +2357,7 @@ echo_i "test serve-stale's interaction with fetch-limits (cache only)" n=$((n + 1)) echo_i "updating ns3/named6.conf ($n)" ret=0 -copy_setports ns3/named6.conf.in ns3/named.conf +cp ns3/named6.conf ns3/named.conf if [ $ret != 0 ]; then echo_i "failed"; fi status=$((status + ret)) @@ -2467,7 +2467,7 @@ echo_i "test serve-stale's interaction with fetch limits (dual-mode)" n=$((n + 1)) echo_i "updating ns3/named7.conf ($n)" ret=0 -copy_setports ns3/named7.conf.in ns3/named.conf +cp ns3/named7.conf ns3/named.conf if [ $ret != 0 ]; then echo_i "failed"; fi status=$((status + ret)) @@ -2549,7 +2549,7 @@ n=$((n + 1)) echo_i "check DNS64 processing of a stale negative answer ($n)" ret=0 # configure ns3 with dns64 -copy_setports ns3/named8.conf.in ns3/named.conf +cp ns3/named8.conf ns3/named.conf rndc_reload ns3 10.53.0.3 # flush cache, enable ans2 responses, make sure serve-stale is on $RNDCCMD 10.53.0.3 flush >rndc.out.test$n.1 2>&1 || ret=1 @@ -2575,7 +2575,7 @@ if [ $ret != 0 ]; then echo_i "failed"; fi status=$((status + ret)) # configure ns3 with stale-answer-client-timeout 0 and a delegated zone -copy_setports ns3/named9.conf.in ns3/named.conf +cp ns3/named9.conf ns3/named.conf rndc_reload ns3 10.53.0.3 n=$((n + 1))