+++ /dev/null
-#!/usr/bin/perl
-
-# 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 up test data for zone transfer quota tests.
-#
-use FileHandle;
-
-my $priconf = new FileHandle("ns1/zones.conf", "w") or die;
-my $secconf = new FileHandle("ns2/zones.conf", "w") or die;
-
-for ($z = 0; $z < 300; $z++) {
- my $zn = sprintf("zone%06d.example", $z);
- print $priconf "zone \"$zn\" { type primary; file \"$zn.db\"; };\n";
- print $secconf "zone \"$zn\" { type secondary; file \"$zn.bk\"; masterfile-format text; primaries { 10.53.0.1; }; };\n";
- my $fn = "ns1/$zn.db";
- my $f = new FileHandle($fn, "w") or die "open: $fn: $!";
- print $f "\$TTL 300
-\@ IN SOA ns1 . 1 300 120 3600 86400
- NS ns1
- NS ns2
-ns1 A 10.53.0.1
-ns2 A 10.53.0.2
- MX 10 mail1.isp.example.
- MX 20 mail2.isp.example.
-www A 10.0.0.1
-xyzzy A 10.0.0.2
-";
- $f->close;
-}
--- /dev/null
+#!/usr/bin/python3
+
+# 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 up test data for zone transfer quota tests.
+#
+
+zones = 300
+
+for z in range(zones):
+ zn = f"zone{z:06d}.example"
+ with open(f"ns1/{zn}.db", "w", encoding="utf-8") as f:
+ f.write(
+ """$TTL 300
+@ IN SOA ns1 . 1 300 120 3600 86400
+ NS ns1
+ NS ns2
+ns1 A 10.53.0.1
+ns2 A 10.53.0.2
+ MX 10 mail1.isp.example.
+ MX 20 mail2.isp.example.
+www A 10.0.0.1
+xyzzy A 10.0.0.2
+"""
+ )
+
+with open("ns1/zones.conf", "w", encoding="utf-8") as priconf, open(
+ "ns2/zones.conf", "w", encoding="utf-8"
+) as secconf:
+ for z in range(zones):
+ zn = f"zone{z:06d}.example"
+ priconf.write(f'zone "{zn}" {{ type primary; file "{zn}.db"; }};\n')
+ secconf.write(
+ f'zone "{zn}" {{ type secondary; file "{zn}.bk"; '
+ f"masterfile-format text; primaries {{ 10.53.0.1; }}; }};\n"
+ )
. ../conf.sh
-$PERL setup.pl
+$PYTHON setup.py
cp -f ns1/changing1.db ns1/changing.db
+++ /dev/null
-#!/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.
-
-set -e
-
-. ../conf.sh
-
-DIGOPTS="+tcp +noadd +nosea +nostat +noquest +nocomm +nocmd -p ${PORT}"
-RNDCCMD="$RNDC -c ../_common/rndc.conf -p ${CONTROLPORT} -s"
-
-#
-# Perform tests
-#
-
-count=0
-ticks=0
-while [ $count != 300 ]; do
- if [ $ticks = 1 ]; then
- echo_i "Changing test zone..."
- cp -f ns1/changing2.db ns1/changing.db
- kill -HUP $(cat ns1/named.pid)
- fi
- sleep 1
- ticks=$((ticks + 1))
- seconds=$((ticks * 1))
- if [ $ticks = 360 ]; then
- echo_i "Took too long to load zones"
- exit 1
- fi
- count=$(cat ns2/zone*.bk | grep xyzzy | wc -l)
- echo_i "Have $count zones up in $seconds seconds"
-done
-
-status=0
-
-$DIG $DIGOPTS zone000099.example. @10.53.0.1 axfr >dig.out.ns1 || status=1
-
-$DIG $DIGOPTS zone000099.example. @10.53.0.2 axfr >dig.out.ns2 || status=1
-
-digcomp dig.out.ns1 dig.out.ns2 || status=1
-
-sleep 15
-
-$DIG $DIGOPTS a.changing. @10.53.0.1 a >dig.out.ns1 || status=1
-
-$DIG $DIGOPTS a.changing. @10.53.0.2 a >dig.out.ns2 || status=1
-
-digcomp dig.out.ns1 dig.out.ns2 || status=1
-
-echo_i "exit status: $status"
-[ $status -eq 0 ] || exit 1
+++ /dev/null
-# 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.
-
-
-def test_xferquota(run_tests_sh):
- run_tests_sh()
--- /dev/null
+# 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.
+
+import glob
+import os
+import re
+import shutil
+import signal
+
+import isctest
+
+import dns.message
+
+
+def test_xferquota(named_port, servers):
+ # Changing test zone
+ shutil.copyfile("ns1/changing2.db", "ns1/changing.db")
+ with open("ns1/named.pid", "r", encoding="utf-8") as pidfile:
+ pid = int(pidfile.read())
+ os.kill(pid, signal.SIGHUP)
+ with servers["ns1"].watch_log_from_start() as watcher:
+ watcher.wait_for_line("received SIGHUP signal to reload zones")
+
+ def check_line_count():
+ matching_line_count = 0
+ # Iterate through zone files and count matching lines
+ for file_path in glob.glob("ns2/zone000*.example.bk"):
+ with open(file_path, "r", encoding="utf-8") as zonefile:
+ # Count the number of lines containing the search string
+ for line in zonefile:
+ if "xyzzy A 10.0.0.2" in line:
+ matching_line_count += 1
+ return matching_line_count == 300
+
+ isctest.run.retry_with_timeout(check_line_count, timeout=360)
+
+ axfr_msg = dns.message.make_query("zone000099.example.", "AXFR")
+ a_msg = dns.message.make_query("a.changing.", "A")
+
+ def query_and_compare(msg):
+ ns1response = isctest.query.tcp(msg, "10.53.0.1")
+ ns2response = isctest.query.tcp(msg, "10.53.0.2")
+ isctest.check.noerror(ns1response)
+ isctest.check.noerror(ns2response)
+ isctest.check.rrsets_equal(ns1response.answer, ns2response.answer)
+
+ query_and_compare(axfr_msg)
+ pattern = re.compile(
+ f"transfer of 'changing/IN' from 10.53.0.1#{named_port}: "
+ f"Transfer completed: .*\\(serial 2\\)"
+ )
+ with servers["ns2"].watch_log_from_start() as watcher:
+ watcher.wait_for_line(
+ pattern,
+ timeout=30,
+ )
+ query_and_compare(a_msg)