diff --git a/tests/conftest.py b/tests/conftest.py index f8186a5934821cc917c19aa710149b5d424a3f44..531dcad07c7eda5b6f73141c4c5f30b393dc151f 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")