Use jinja2 templates in logfileconf test

- Replace all named*.in files with jinja2 templates.
- Rename the config files to named.*.conf convention.
- Rename named.plain.in to named.plain.conf.j2 and symlink it as te
  default config.
- Rename named.plainconf.in to named.plainlog.conf.j2 (there is a slight
  difference from named.plain, despite the similar name)

(cherry picked from commit 3f953266fb)
This commit is contained in:
Nicki Křížek 2025-12-05 14:50:55 +01:00
parent ce00f2d059
commit 28e1910a59
15 changed files with 18 additions and 33 deletions

View file

@ -0,0 +1 @@
named.plain.conf.j2

View file

@ -1,16 +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/named.plain.in ns1/named.conf

View file

@ -36,7 +36,7 @@ n=$((n + 1))
echo_i "testing log file validity (only plain files allowed) ($n)"
ret=0
cat /dev/null >ns1/named_log
copy_setports ns1/named.plainconf.in ns1/named.conf
cp ns1/named.plainlog.conf ns1/named.conf
nextpart ns1/named.run >/dev/null
rndc_reconfig ns1 10.53.0.1 >rndc.out.test$n
wait_for_log 5 "reloading configuration succeeded" ns1/named.run || ret=1
@ -48,7 +48,7 @@ n=$((n + 1))
echo_i "testing directory as log file ($n)"
ret=0
nextpart ns1/named.run >/dev/null
copy_setports ns1/named.dirconf.in ns1/named.conf
cp ns1/named.dir.conf ns1/named.conf
rndc_reconfig ns1 10.53.0.1 >rndc.out.test$n
wait_for_log 5 "reloading configuration failed: invalid file" ns1/named.run || ret=1
if [ "$ret" -ne 0 ]; then echo_i "failed"; fi
@ -61,7 +61,7 @@ ret=0
nextpart ns1/named.run >/dev/null
rm -f ns1/named_pipe
if mkfifo ns1/named_pipe >/dev/null 2>&1; then
copy_setports ns1/named.pipeconf.in ns1/named.conf
cp ns1/named.pipe.conf ns1/named.conf
rndc_reconfig ns1 10.53.0.1 >rndc.out.test$n
wait_for_log 5 "reloading configuration failed: invalid file" ns1/named.run || ret=1
if [ "$ret" -ne 0 ]; then echo_i "failed"; fi
@ -78,7 +78,7 @@ rm -f ns1/named_log ns1/named_sym
touch ns1/named_log
if ln -s $(pwd)/ns1/named_log $(pwd)/ns1/named_sym >/dev/null 2>&1; then
nextpart ns1/named.run >/dev/null
copy_setports ns1/named.symconf.in ns1/named.conf
cp ns1/named.sym.conf ns1/named.conf
rndc_reconfig ns1 10.53.0.1 >rndc.out.test$n
wait_for_log 5 "reloading configuration succeeded" ns1/named.run || ret=1
if [ "$ret" -ne 0 ]; then echo_i "failed"; fi
@ -88,7 +88,7 @@ else
fi
echo_i "repeat previous tests without named -g"
copy_setports ns1/named.plain.in ns1/named.conf
cp ns1/named.plain.conf ns1/named.conf
stop_server --use-rndc --port ${CONTROLPORT} ns1
cp named1.args ns1/named.args
start_server --noclean --restart --port ${PORT} ns1
@ -97,7 +97,7 @@ n=$((n + 1))
echo_i "testing log file validity (only plain files allowed) ($n)"
ret=0
cat /dev/null >ns1/named_log
copy_setports ns1/named.plainconf.in ns1/named.conf
cp ns1/named.plainlog.conf ns1/named.conf
nextpart ns1/named.run >/dev/null
rndc_reconfig ns1 10.53.0.1 >rndc.out.test$n
wait_for_log 5 "reloading configuration succeeded" ns1/named.run || ret=1
@ -109,7 +109,7 @@ n=$((n + 1))
echo_i "testing directory as log file ($n)"
ret=0
nextpart ns1/named.run >/dev/null
copy_setports ns1/named.dirconf.in ns1/named.conf
cp ns1/named.dir.conf ns1/named.conf
rndc_reconfig ns1 10.53.0.1 >rndc.out.test$n
wait_for_log 5 "reloading configuration failed: invalid file" ns1/named.run || ret=1
if [ "$ret" -ne 0 ]; then echo_i "failed"; fi
@ -122,7 +122,7 @@ ret=0
nextpart ns1/named.run >/dev/null
rm -f ns1/named_pipe
if mkfifo ns1/named_pipe >/dev/null 2>&1; then
copy_setports ns1/named.pipeconf.in ns1/named.conf
cp ns1/named.pipe.conf ns1/named.conf
rndc_reconfig ns1 10.53.0.1 >rndc.out.test$n
wait_for_log 5 "reloading configuration failed: invalid file" ns1/named.run || ret=1
if [ "$ret" -ne 0 ]; then echo_i "failed"; fi
@ -139,7 +139,7 @@ rm -f ns1/named_log ns1/named_sym
touch ns1/named_log
if ln -s $(pwd)/ns1/named_log $(pwd)/ns1/named_sym >/dev/null 2>&1; then
nextpart ns1/named.run >/dev/null
copy_setports ns1/named.symconf.in ns1/named.conf
cp ns1/named.sym.conf ns1/named.conf
rndc_reconfig ns1 10.53.0.1 >rndc.out.test$n
wait_for_log 5 "reloading configuration succeeded" ns1/named.run || ret=1
if [ "$ret" -ne 0 ]; then echo_i "failed"; fi
@ -152,7 +152,7 @@ echo_i "testing logging functionality"
n=$((n + 1))
ret=0
echo_i "testing iso8601 timestamp ($n)"
copy_setports ns1/named.iso8601.in ns1/named.conf
cp ns1/named.iso8601.conf ns1/named.conf
rndc_reconfig ns1 10.53.0.1 >rndc.out.test$n
grep '^....-..-..T..:..:..\.... ' ns1/named_iso8601 >/dev/null || ret=1
if [ "$ret" -ne 0 ]; then echo_i "failed"; fi
@ -161,7 +161,7 @@ status=$((status + ret))
n=$((n + 1))
echo_i "testing iso8601-utc timestamp ($n)"
ret=0
copy_setports ns1/named.iso8601-utc.in ns1/named.conf
cp ns1/named.iso8601-utc.conf ns1/named.conf
rndc_reconfig ns1 10.53.0.1 >rndc.out.test$n
grep '^....-..-..T..:..:..\....Z' ns1/named_iso8601_utc >/dev/null || ret=1
if [ "$ret" -ne 0 ]; then echo_i "failed"; fi
@ -170,7 +170,7 @@ status=$((status + ret))
n=$((n + 1))
echo_i "testing explicit versions ($n)"
ret=0
copy_setports ns1/named.versconf.in ns1/named.conf
cp ns1/named.vers.conf ns1/named.conf
# a seconds since epoch version number
touch ns1/named_vers.1480039317
rndc_reconfig ns1 10.53.0.1 >rndc.out.test$n
@ -188,7 +188,7 @@ status=$((status + ret))
n=$((n + 1))
echo_i "testing timestamped versions ($n)"
ret=0
copy_setports ns1/named.tsconf.in ns1/named.conf
cp ns1/named.ts.conf ns1/named.conf
# a seconds since epoch version number
touch ns1/named_ts.1480039317
# a timestamp version number
@ -213,7 +213,7 @@ status=$((status + ret))
n=$((n + 1))
echo_i "testing incremented versions ($n)"
ret=0
copy_setports ns1/named.incconf.in ns1/named.conf
cp ns1/named.inc.conf ns1/named.conf
try=0
while test $try -lt 12; do
touch ns1/named_inc.$try
@ -239,7 +239,7 @@ status=$((status + ret))
n=$((n + 1))
echo_i "testing absolute file path versions ($n)"
ret=0
copy_setports ns1/named.abspathconf.in ns1/named.conf
cp ns1/named.abspath.conf ns1/named.conf
try=0
while test $try -lt 12; do
touch $TMPDIR/example.log.$try
@ -265,7 +265,7 @@ status=$((status + ret))
n=$((n + 1))
echo_i "testing unlimited versions ($n)"
ret=0
copy_setports ns1/named.unlimited.in ns1/named.conf
cp ns1/named.unlimited.conf ns1/named.conf
# a seconds since epoch version number
touch ns1/named_unlimited.1480039317
rndc_reconfig ns1 10.53.0.1 >rndc.out.test$n
@ -283,7 +283,7 @@ stop_server ns1
cp named2.args ns1/named.args
test -f ns1/named.pid && ret=1
rm -f ns1/named_deflog
copy_setports ns1/named.plainconf.in ns1/named.conf
cp ns1/named.plainlog.conf ns1/named.conf
start_server --noclean --restart --port ${PORT} ns1
[ -f "ns1/named_deflog" ] || ret=1
if [ "$ret" -ne 0 ]; then echo_i "failed"; fi