Skip to content

Commit

Permalink
Use nvidia flag instead of collector
Browse files Browse the repository at this point in the history
  • Loading branch information
Deezzir committed Nov 29, 2024
1 parent c57ab4b commit ac14150
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
12 changes: 11 additions & 1 deletion tests/functional/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ def pytest_addoption(parser):
help="Set base for the applications.",
)

parser.addoption(
"--nvidia",
action="store_true",
help="Enable NVIDIA GPU support for testing with real hardware.",
)

parser.addoption(
"--collectors",
nargs="+",
Expand All @@ -33,7 +39,6 @@ def pytest_addoption(parser):
"poweredge_raid",
"lsi_sas_2",
"lsi_sas_3",
"dcgm",
],
help="Provide space-separated list of collectors for testing with real hardware.",
)
Expand All @@ -44,6 +49,11 @@ def base(request):
return request.config.getoption("--base")


@pytest.fixture(scope="module")
def nvidia_present(request):
return request.config.getoption("--nvidia")


@pytest.fixture(scope="module")
def architecture():
machine = platform.machine()
Expand Down
8 changes: 4 additions & 4 deletions tests/functional/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ async def test_required_resources(ops_test: OpsTest, provided_collectors, requir


@pytest.mark.abort_on_fail
async def test_nvidia_driver_installation(ops_test: OpsTest, provided_collectors, unit):
async def test_nvidia_driver_installation(ops_test: OpsTest, nvidia_present, unit):
"""Test nvidia driver installation."""
if "dcgm" not in provided_collectors:
if not nvidia_present:
pytest.skip("dcgm not in provided collectors, skipping test")

check_nvidia_driver_cmd = "cat /proc/driver/nvidia/version"
Expand Down Expand Up @@ -392,9 +392,9 @@ async def test_smarctl_exporter_snap_available(self, ops_test, app, unit):
assert results.get("return-code") == 0
assert results.get("stdout").strip() == "active"

async def test_dcgm_exporter_snap_available(self, ops_test, app, unit, provided_collectors):
async def test_dcgm_exporter_snap_available(self, ops_test, app, unit, nvidia_present):
"""Test if dcgm exporter snap is installed and ranning on the unit."""
if "dcgm" not in provided_collectors:
if not nvidia_present:
pytest.skip("dcgm not in provided collectors, skipping test")

snap_name = "dcgm"
Expand Down

0 comments on commit ac14150

Please sign in to comment.