diff options
Diffstat (limited to 'tests/topotests/munet/testing/fixtures.py')
-rw-r--r-- | tests/topotests/munet/testing/fixtures.py | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/tests/topotests/munet/testing/fixtures.py b/tests/topotests/munet/testing/fixtures.py index 3c6d946..3c6ddf9 100644 --- a/tests/topotests/munet/testing/fixtures.py +++ b/tests/topotests/munet/testing/fixtures.py @@ -25,7 +25,6 @@ from ..base import BaseMunet from ..base import Bridge from ..base import get_event_loop from ..cleanup import cleanup_current -from ..cleanup import cleanup_previous from ..native import L3NodeMixin from ..parser import async_build_topology from ..parser import get_config @@ -130,9 +129,12 @@ def session_autouse(): else: is_worker = True - if not is_worker: - # This is unfriendly to multi-instance - cleanup_previous() + # We dont want to kill all munet and we don't have the rundir here yet + # This was more useful back when we used to leave processes around a lot + # more. + # if not is_worker: + # # This is unfriendly to multi-instance + # cleanup_previous() # We never pop as we want to keep logging _push_log_handler("session", "/tmp/unet-test/pytest-session.log") @@ -150,8 +152,9 @@ def session_autouse(): @pytest.fixture(autouse=True, scope="module") def module_autouse(request): - logpath = get_test_logdir(request.node.name, True) - logpath = os.path.join("/tmp/unet-test", logpath, "pytest-exec.log") + root_path = os.environ.get("MUNET_RUNDIR", "/tmp/unet-test") + logpath = get_test_logdir(request.node.nodeid, True) + logpath = os.path.join(root_path, logpath, "pytest-exec.log") with log_handler("module", logpath): sdir = os.path.dirname(os.path.realpath(request.fspath)) with chdir(sdir, "module autouse fixture"): @@ -161,7 +164,7 @@ def module_autouse(request): raise Exception("Base Munet was not cleaned up/deleted") -@pytest.fixture(scope="module") +@pytest.fixture(scope="session") def event_loop(): """Create an instance of the default event loop for the session.""" loop = get_event_loop() @@ -174,7 +177,8 @@ def event_loop(): @pytest.fixture(scope="module") def rundir_module(): - d = os.path.join("/tmp/unet-test", get_test_logdir(module=True)) + root_path = os.environ.get("MUNET_RUNDIR", "/tmp/unet-test") + d = os.path.join(root_path, get_test_logdir(module=True)) logging.debug("conftest: test module rundir %s", d) return d @@ -213,18 +217,14 @@ async def _unet_impl( param, exc_info=True, ) - pytest.skip( - f"unet fixture: unet build failed: {error}", allow_module_level=True - ) - raise + pytest.fail(f"unet fixture: unet build failed: {error}") try: tasks = await _unet.run() except Exception as error: logging.debug("unet fixture: unet run failed: %s", error, exc_info=True) await _unet.async_delete() - pytest.skip(f"unet fixture: unet run failed: {error}", allow_module_level=True) - raise + pytest.fail(f"unet fixture: unet run failed: {error}") logging.debug("unet fixture: containers running") @@ -379,7 +379,8 @@ async def astepf(pytestconfig): @pytest.fixture(scope="function") def rundir(): - d = os.path.join("/tmp/unet-test", get_test_logdir(module=False)) + root_path = os.environ.get("MUNET_RUNDIR", "/tmp/unet-test") + d = os.path.join(root_path, get_test_logdir(module=False)) logging.debug("conftest: test function rundir %s", d) return d @@ -387,9 +388,8 @@ def rundir(): # Configure logging @pytest.hookimpl(hookwrapper=True, tryfirst=True) def pytest_runtest_setup(item): - d = os.path.join( - "/tmp/unet-test", get_test_logdir(nodeid=item.nodeid, module=False) - ) + root_path = os.environ.get("MUNET_RUNDIR", "/tmp/unet-test") + d = os.path.join(root_path, get_test_logdir(nodeid=item.nodeid, module=False)) config = item.config logging_plugin = config.pluginmanager.get_plugin("logging-plugin") filename = Path(d, "pytest-exec.log") |