From 439376edb56460713c3480d5cdc3b498090c5c30 Mon Sep 17 00:00:00 2001 From: Deezzir Date: Thu, 12 Sep 2024 20:42:23 -0400 Subject: [PATCH] Refine --- tests/functional/conftest.py | 21 +++++++++------------ tests/functional/test_snap_dcgm.py | 1 + 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/tests/functional/conftest.py b/tests/functional/conftest.py index cac57c3..56b80a0 100644 --- a/tests/functional/conftest.py +++ b/tests/functional/conftest.py @@ -1,23 +1,20 @@ import subprocess import pytest -import yaml @pytest.fixture(scope="session", autouse=True) def install_dcgm_snap(): """Install the snap and enable dcgm-exporter service for testing.""" - with open("snap/snapcraft.yaml") as f: - snapcraft = yaml.safe_load(f) - snap_build_name = f"{snapcraft['name']}_*.snap" + snap_build_name = "dcgm_*.snap" - subprocess.run( - f"sudo snap install --devmode {snap_build_name}", - check=True, - capture_output=True, - shell=True, - ) + subprocess.run( + f"sudo snap install --dangerous {snap_build_name}", + check=True, + capture_output=True, + shell=True, + ) - yield + yield - subprocess.run("sudo snap remove --purge dcgm".split(), check=True) + subprocess.run("sudo snap remove --purge dcgm".split(), check=True) diff --git a/tests/functional/test_snap_dcgm.py b/tests/functional/test_snap_dcgm.py index 2d30f66..842d6df 100644 --- a/tests/functional/test_snap_dcgm.py +++ b/tests/functional/test_snap_dcgm.py @@ -22,6 +22,7 @@ def test_dcgm_exporter(): ) assert " active" in result.stdout.strip(), "dcgm-exporter service is not active" + # Check the exporter endpoint, will raise an exception if the endpoint is not reachable urllib.request.urlopen(endpoint)