]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
log-based test for load/apply config
authorColin Vidal <colin@isc.org>
Thu, 5 Jun 2025 16:28:22 +0000 (18:28 +0200)
committerEvan Hunt <each@isc.org>
Mon, 23 Jun 2025 17:45:31 +0000 (10:45 -0700)
Add a new system test which checks named output when starting,
reconfiguring and reloading the server. It checks that the steps where
configuration is loaded, when named enters exclusive mode, and when the
configuration is applied are all logged, and that they occur in the
correct order. This adds a guard/warning to keep the parsing of the
named.conf outside of the exclusive mode.

bin/tests/system/configloading/README [new file with mode: 0644]
bin/tests/system/configloading/ns1/example.db [new file with mode: 0644]
bin/tests/system/configloading/ns1/named.conf.in [new file with mode: 0644]
bin/tests/system/configloading/setup.sh [new file with mode: 0644]
bin/tests/system/configloading/tests_sh_configloading.py [new file with mode: 0644]

diff --git a/bin/tests/system/configloading/README b/bin/tests/system/configloading/README
new file mode 100644 (file)
index 0000000..4721751
--- /dev/null
@@ -0,0 +1,15 @@
+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.
+
+This test is a "guard/warning" to make sure the named.conf loading (parsing) is
+done outside of the exclusive mode (so, named is still able to answer queries
+and operating normally in case of configuration reload). It is currently based
+on logging, so it's quite brittle.
diff --git a/bin/tests/system/configloading/ns1/example.db b/bin/tests/system/configloading/ns1/example.db
new file mode 100644 (file)
index 0000000..abad6ab
--- /dev/null
@@ -0,0 +1,21 @@
+; 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.
+
+example.               IN SOA  mname1. . (
+                               2          ; serial
+                               20         ; refresh (20 seconds)
+                               20         ; retry (20 seconds)
+                               1814400    ; expire (3 weeks)
+                               3600       ; minimum (1 hour)
+                               )
+                       IN NS   ns.example.
+ns                     IN A    10.0.0.1
+a                      IN A    10.0.0.2
diff --git a/bin/tests/system/configloading/ns1/named.conf.in b/bin/tests/system/configloading/ns1/named.conf.in
new file mode 100644 (file)
index 0000000..6c85c1d
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+// NS2
+
+options {
+       port @PORT@;
+       pid-file "named.pid";
+       listen-on { 10.53.0.1; };
+       listen-on-v6 { none; };
+       recursion no;
+};
+
+key rndc_key {
+       secret "1234abcd8765";
+       algorithm @DEFAULT_HMAC@;
+};
+
+controls {
+       inet 10.53.0.1 port @CONTROLPORT@ allow { any; } keys { rndc_key; };
+};
+
+
+zone "example." {
+       type primary;
+       file "example.db";
+};
+
diff --git a/bin/tests/system/configloading/setup.sh b/bin/tests/system/configloading/setup.sh
new file mode 100644 (file)
index 0000000..7c9de7a
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh -e
+
+# 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.
+
+# shellcheck source=conf.sh
+. ../conf.sh
+
+set -e
+
+copy_setports ns1/named.conf.in ns1/named.conf
diff --git a/bin/tests/system/configloading/tests_sh_configloading.py b/bin/tests/system/configloading/tests_sh_configloading.py
new file mode 100644 (file)
index 0000000..2aeb17a
--- /dev/null
@@ -0,0 +1,47 @@
+# 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 pytest
+
+pytestmark = pytest.mark.extra_artifacts(
+    [
+        "ns1/managed-keys.bind.jnl",
+    ]
+)
+
+
+def assert_log_sequence(server, fnname, scopefn):
+    triggers = {
+        "load_configuration": 0,
+        "parsing user configuration from ": 1,
+        "apply_configuration": 2,
+        "loop exclusive mode: starting": 3,
+    }
+    fn = getattr(server, fnname)
+    for i in range(len(triggers.items())):
+        with fn() as watcher:
+            scopefn()
+            assert watcher.wait_for_lines(dict(list(triggers.items())[i:])) == i
+
+
+def test_configloading_loading(servers):
+    server = servers["ns1"]
+    assert_log_sequence(server, "watch_log_from_start", lambda: ())
+
+
+def test_configloading_reconfig(servers):
+    server = servers["ns1"]
+    assert_log_sequence(server, "watch_log_from_here", lambda: server.rndc("reconfig"))
+
+
+def test_configloading_reload(servers):
+    server = servers["ns1"]
+    assert_log_sequence(server, "watch_log_from_here", lambda: server.rndc("reload"))