2025-06-26 11:28:11 -04:00
|
|
|
# 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.
|
|
|
|
|
|
2025-10-02 05:47:56 -04:00
|
|
|
from re import compile as Re
|
2025-09-26 08:54:42 -04:00
|
|
|
|
2025-06-26 11:28:11 -04:00
|
|
|
|
2025-07-08 09:26:09 -04:00
|
|
|
def test_configloading_log(ns1):
|
2025-06-26 11:28:11 -04:00
|
|
|
"""
|
|
|
|
|
This test is a "guard/warning" to make sure the named.conf loading
|
2025-09-10 09:17:11 -04:00
|
|
|
(parsing), keystore building, kasplist building and view creation is done
|
|
|
|
|
outside of the exclusive mode (so, named is still able to answer queries
|
|
|
|
|
and operating normally in case of configuration reload). It
|
2025-06-26 11:28:11 -04:00
|
|
|
is currently based on logging, so it's quite brittle.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
log_sequence = [
|
|
|
|
|
"load_configuration",
|
|
|
|
|
"parsing user configuration from ",
|
|
|
|
|
"apply_configuration",
|
2025-09-10 09:17:11 -04:00
|
|
|
"apply_configuration: configure_keystores",
|
|
|
|
|
"apply_configuration: configure_kasplist",
|
|
|
|
|
"apply_configuration: create_views",
|
2025-06-26 11:28:11 -04:00
|
|
|
"loop exclusive mode: starting",
|
2025-11-10 06:07:18 -05:00
|
|
|
"running",
|
2025-06-26 11:28:11 -04:00
|
|
|
]
|
|
|
|
|
|
2025-07-08 09:26:09 -04:00
|
|
|
with ns1.watch_log_from_start() as watcher:
|
2025-06-26 11:28:11 -04:00
|
|
|
watcher.wait_for_sequence(log_sequence)
|
|
|
|
|
|
2025-07-08 09:26:09 -04:00
|
|
|
with ns1.watch_log_from_here() as watcher:
|
Refactor NamedInstance.rndc() to use EnvCmd() interface
To unify the command handling, utilize EnvCmd() to handle rndc commands:
1. Remove isctest.rndc abstractions. They were intended for an upcoming
python-only implementation. A couple of years later, it doesn't seem
to be coming any time soon, so let's stick with the interface that
makes sense today, i.e. use the same command handling interface
everywhere.
2. Remove the specialized rndc.log in favor of the generic logging
already implemented by isctest.run.cmd(). I believe the cause of the
many rndc(log=False) invocations was that nobody wanted this extra
file. Yet, logging everything by default makes sense for debugging,
unless there's a good reason not to. In almost all cases, logging was
switched to the default (enabled).
3. With the NamedInstance.rndc() call now returning CmdResult rather
than combined stdout+stderr string, adjust all the invocations to use
`.out` or `.err` as necessary.
4. Replace some manual rndc invocation and its base argument
construction with the standardized nsX.rndc() call.
5. In cases where rndc is expected to fail, utilize
raise_on_exception=False and check the `.rc` from the result, rather
than handling an exception.
6. In addzone/tests_rndc_deadlock.py, refactor the test slightly to
avoid using EnvCmd() entirely to avoid spamming the logs. This test
calls rndc in a loop from multiple threads and such test case is an
exception which doesn't warrant changing the `isctest.run.cmd()`
implementation.
2025-10-23 09:08:35 -04:00
|
|
|
ns1.rndc("reconfig")
|
2025-06-26 11:28:11 -04:00
|
|
|
watcher.wait_for_sequence(log_sequence)
|
|
|
|
|
|
2025-07-08 09:26:09 -04:00
|
|
|
with ns1.watch_log_from_here() as watcher:
|
Refactor NamedInstance.rndc() to use EnvCmd() interface
To unify the command handling, utilize EnvCmd() to handle rndc commands:
1. Remove isctest.rndc abstractions. They were intended for an upcoming
python-only implementation. A couple of years later, it doesn't seem
to be coming any time soon, so let's stick with the interface that
makes sense today, i.e. use the same command handling interface
everywhere.
2. Remove the specialized rndc.log in favor of the generic logging
already implemented by isctest.run.cmd(). I believe the cause of the
many rndc(log=False) invocations was that nobody wanted this extra
file. Yet, logging everything by default makes sense for debugging,
unless there's a good reason not to. In almost all cases, logging was
switched to the default (enabled).
3. With the NamedInstance.rndc() call now returning CmdResult rather
than combined stdout+stderr string, adjust all the invocations to use
`.out` or `.err` as necessary.
4. Replace some manual rndc invocation and its base argument
construction with the standardized nsX.rndc() call.
5. In cases where rndc is expected to fail, utilize
raise_on_exception=False and check the `.rc` from the result, rather
than handling an exception.
6. In addzone/tests_rndc_deadlock.py, refactor the test slightly to
avoid using EnvCmd() entirely to avoid spamming the logs. This test
calls rndc in a loop from multiple threads and such test case is an
exception which doesn't warrant changing the `isctest.run.cmd()`
implementation.
2025-10-23 09:08:35 -04:00
|
|
|
ns1.rndc("reload")
|
2025-06-26 11:28:11 -04:00
|
|
|
watcher.wait_for_sequence(log_sequence)
|
2025-09-26 08:54:42 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_reload_fails_log(ns1, templates):
|
|
|
|
|
"""
|
|
|
|
|
This test ensures that when a reconfig fails during view configuration (or
|
|
|
|
|
after), views/zones (which are newly created view/zones which won't be used
|
|
|
|
|
and local of apply_configuration) are detached (and freed) before the
|
|
|
|
|
exclusive mode is released
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
log_sequence = [
|
|
|
|
|
"apply_configuration",
|
|
|
|
|
"loop exclusive mode: starting",
|
|
|
|
|
"apply_configuration: configure_views",
|
2025-10-02 05:47:56 -04:00
|
|
|
Re(r".*port '9999999' out of range"),
|
2025-09-26 08:54:42 -04:00
|
|
|
"apply_configuration: detaching views",
|
|
|
|
|
"loop exclusive mode: ending",
|
2025-11-10 06:07:18 -05:00
|
|
|
"reloading configuration failed",
|
2025-09-26 08:54:42 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
with ns1.watch_log_from_here() as watcher:
|
|
|
|
|
templates.render("ns1/named.conf", {"wrongoption": True})
|
Refactor NamedInstance.rndc() to use EnvCmd() interface
To unify the command handling, utilize EnvCmd() to handle rndc commands:
1. Remove isctest.rndc abstractions. They were intended for an upcoming
python-only implementation. A couple of years later, it doesn't seem
to be coming any time soon, so let's stick with the interface that
makes sense today, i.e. use the same command handling interface
everywhere.
2. Remove the specialized rndc.log in favor of the generic logging
already implemented by isctest.run.cmd(). I believe the cause of the
many rndc(log=False) invocations was that nobody wanted this extra
file. Yet, logging everything by default makes sense for debugging,
unless there's a good reason not to. In almost all cases, logging was
switched to the default (enabled).
3. With the NamedInstance.rndc() call now returning CmdResult rather
than combined stdout+stderr string, adjust all the invocations to use
`.out` or `.err` as necessary.
4. Replace some manual rndc invocation and its base argument
construction with the standardized nsX.rndc() call.
5. In cases where rndc is expected to fail, utilize
raise_on_exception=False and check the `.rc` from the result, rather
than handling an exception.
6. In addzone/tests_rndc_deadlock.py, refactor the test slightly to
avoid using EnvCmd() entirely to avoid spamming the logs. This test
calls rndc in a loop from multiple threads and such test case is an
exception which doesn't warrant changing the `isctest.run.cmd()`
implementation.
2025-10-23 09:08:35 -04:00
|
|
|
cmd = ns1.rndc("reload", raise_on_exception=False)
|
|
|
|
|
assert cmd.rc != 0
|
|
|
|
|
watcher.wait_for_sequence(log_sequence)
|