]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Refactor configloading test
authorNicki Křížek <nicki@isc.org>
Thu, 26 Jun 2025 15:28:11 +0000 (17:28 +0200)
committerNicki Křížek <nicki@isc.org>
Fri, 18 Jul 2025 10:13:30 +0000 (12:13 +0200)
- Use WatchLog.wait_for_sequence() for the configloading test.
- Omit artifacts check, as it seems quite useless for this test case.
- Join all the tests together. The test case is fairly simple here and
  this is the easiest way to ensure the log will be in a predictable
  state for all tests. Previously, there was no way to ensure
  test_configloading_loading() won't be executed after the other tests,
  which would render the check moot. It could also be separated into
  its own module, but that seems excessive for a simple test case like
  this.
- Use jinja2 template for named.conf and remove setup.sh.
- Remove README and put the relevent comment directly next to the test.
- Remove _sh_ from the test filename to uphold the naming convention.

bin/tests/system/configloading/README [deleted file]
bin/tests/system/configloading/ns1/named.conf.j2 [moved from bin/tests/system/configloading/ns1/named.conf.in with 100% similarity]
bin/tests/system/configloading/setup.sh [deleted file]
bin/tests/system/configloading/tests_configloading.py [new file with mode: 0644]
bin/tests/system/configloading/tests_sh_configloading.py [deleted file]

diff --git a/bin/tests/system/configloading/README b/bin/tests/system/configloading/README
deleted file mode 100644 (file)
index 4721751..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-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/setup.sh b/bin/tests/system/configloading/setup.sh
deleted file mode 100644 (file)
index 7c9de7a..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/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_configloading.py b/bin/tests/system/configloading/tests_configloading.py
new file mode 100644 (file)
index 0000000..12aa2dc
--- /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.
+
+
+def test_configloading_log(servers):
+    """
+    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.
+    """
+
+    server = servers["ns1"]
+    log_sequence = [
+        "load_configuration",
+        "parsing user configuration from ",
+        "apply_configuration",
+        "loop exclusive mode: starting",
+    ]
+
+    with server.watch_log_from_start() as watcher:
+        watcher.wait_for_sequence(log_sequence)
+
+    with server.watch_log_from_here() as watcher:
+        server.rndc("reconfig")
+        watcher.wait_for_sequence(log_sequence)
+
+    with server.watch_log_from_here() as watcher:
+        server.rndc("reload")
+        watcher.wait_for_sequence(log_sequence)
diff --git a/bin/tests/system/configloading/tests_sh_configloading.py b/bin/tests/system/configloading/tests_sh_configloading.py
deleted file mode 100644 (file)
index 2aeb17a..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-# 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"))