mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-10 15:29:59 -04:00
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.
31 lines
1 KiB
Python
31 lines
1 KiB
Python
# 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
|
|
|
|
|
|
# Test that `rndc showzone` can print any zone, including those statically
|
|
# defined in named.conf, and not only those added dynamically.
|
|
@pytest.mark.parametrize(
|
|
"allow",
|
|
[
|
|
pytest.param(True, id="allow-new-zones-yes"),
|
|
pytest.param(False, id="allow-new-zones-no"),
|
|
],
|
|
)
|
|
def test_showzone_static(ns1, templates, allow):
|
|
templates.render("ns1/named.conf", {"allownewzones": allow})
|
|
ns1.rndc("reload")
|
|
response = ns1.rndc("showzone inlinesec.example")
|
|
assert (
|
|
'zone "inlinesec.example" { type primary; file "inlinesec.db"; };'
|
|
in response.out
|
|
)
|