From fee8de1d8417cfc3dbb941a36cb96e99989f722d Mon Sep 17 00:00:00 2001 From: Robert Rosca <robert.rosca@xfel.eu> Date: Thu, 10 Jun 2021 11:41:41 +0200 Subject: [PATCH] Add rough check that caldb is available Doesn't really check that though, just sees if max-exfl017 is reachable --- tests/conftest.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index f8186a593..531dcad07 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,8 @@ +import subprocess from pathlib import Path import pytest +import subprocess def pytest_addoption(parser): @@ -11,10 +13,23 @@ def pytest_addoption(parser): help="Skips tests marked as requiring GPFS access", ) + parser.addoption( + "--no-caldb", + action="store_true", + default=False, + help="Skips tests marked as requiring calDBs", + ) + def pytest_configure(config): config.addinivalue_line( - "markers", "requires_gpfs(): marks skips for tests that require GPFS access" + "markers", + "requires_gpfs(): marks skips for tests that require GPFS access", + ) + + config.addinivalue_line( + "markers", + "requires_caldb(): marks skips for tests that require calDB access", ) @@ -23,3 +38,14 @@ def pytest_runtest_setup(item): not Path("/gpfs").is_dir() or item.config.getoption("--no-gpfs") ): pytest.skip("gpfs not available") + + server_available = True + try: + subprocess.check_output("ping max-exfl017 -c 1", shell=True) + except subprocess.CalledProcessError: + server_available = False + + if ( + list(item.iter_markers(name="requires_caldb")) and not server_available + ) or item.config.getoption("--no-caldb"): + pytest.skip("caldb not available") -- GitLab