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.
This commit is contained in:
Nicki Křížek 2025-12-05 17:04:33 +01:00
parent 6114444007
commit a8713fdcf8
19 changed files with 123 additions and 31 deletions

View file

@ -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 %}

View file

@ -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" %}

View file

@ -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" %}

View file

@ -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" %}

View file

@ -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

View file

@ -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))