mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 06:25:31 +00:00
Implement Python helpers for using RNDC in tests
Controlling named instances using RNDC is a common action in BIND 9 system tests. However, there is currently no standardized way of doing that from Python-based system tests, which leads to code duplication. Add a set of Python classes and pytest fixtures which intend to simplify and standardize use of RNDC in Python-based system tests. For now, RNDC commands are sent to servers by invoking the rndc binary. However, a switch to a native Python module able to send RNDC commands without executing external binaries is expected to happen soon. Even when that happens, though, having the capability to invoke the rndc binary (in order to test it) will remain useful. Define a common Python interface that such "RNDC executors" should implement (RNDCExecutor), in order to make switching between them convenient. Co-authored-by: Štěpán Balážik <stepan@isc.org>
This commit is contained in:
committed by
Štěpán Balážik
parent
e997a738d6
commit
c38c29e84d
@@ -22,9 +22,10 @@ from typing import Any, Dict, List, Optional
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
pytest.register_assert_rewrite("isctest")
|
||||
|
||||
import isctest
|
||||
|
||||
|
||||
# Silence warnings caused by passing a pytest fixture to another fixture.
|
||||
# pylint: disable=redefined-outer-name
|
||||
@@ -647,3 +648,21 @@ def system_test( # pylint: disable=too-many-arguments,too-many-statements
|
||||
stop_servers()
|
||||
get_core_dumps()
|
||||
request.node.stash[FIXTURE_OK] = True
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def servers(ports, logger, system_test_dir):
|
||||
instances = {}
|
||||
for entry in system_test_dir.rglob("*"):
|
||||
if entry.is_dir():
|
||||
try:
|
||||
dir_name = entry.name
|
||||
# LATER: Make ports fixture return NamedPorts directly
|
||||
named_ports = isctest.instance.NamedPorts(
|
||||
dns=int(ports["PORT"]), rndc=int(ports["CONTROLPORT"])
|
||||
)
|
||||
instance = isctest.instance.NamedInstance(dir_name, named_ports, logger)
|
||||
instances[dir_name] = instance
|
||||
except ValueError:
|
||||
continue
|
||||
return instances
|
||||
|
Reference in New Issue
Block a user