2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

Reuse common port-related test fixtures

Most Python-based system tests need to know which ports were assigned to
a given test by bin/tests/system/get_ports.sh.  This is currently
handled by inspecting the values of various environment variables (set
by bin/tests/system/run.sh) and passing the port numbers to Python
scripts via pytest fixtures.  However, this glue code has so far been
copy-pasted into each system test using it, rather than reused.

Since pytest also looks for conftest.py files in parent directories,
move commonly used fixtures to bin/tests/system/conftest.py.  Set the
scope of all the moved fixtures to "session" as their return values are
only based on environment variables, so there is no point in recreating
them for every test requesting them.  Adjust test code accordingly.
This commit is contained in:
Michał Kępień
2022-03-14 08:59:32 +01:00
parent 342c06c335
commit 53ef8835c1
15 changed files with 43 additions and 160 deletions

View File

@@ -0,0 +1,31 @@
#!/usr/bin/python3
# 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 os
import pytest
@pytest.fixture(scope='session')
def named_port():
return int(os.environ.get('PORT', default=5300))
@pytest.fixture(scope='session')
def named_tlsport():
return int(os.environ.get('TLSPORT', default=8853))
@pytest.fixture(scope='session')
def control_port():
return int(os.environ.get('CONTROLPORT', default=9953))