From fe54104adddbc1aa44b24b2f741fb3ab18abac1b Mon Sep 17 00:00:00 2001 From: Deezzir Date: Tue, 17 Sep 2024 16:04:32 -0400 Subject: [PATCH] Use an empty test metric file --- .github/workflows/check.yaml | 2 +- tests/functional/test_snap_dcgm.py | 13 +++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index dc0ac8f..08d17a4 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -90,4 +90,4 @@ jobs: python -m pip install 'tox<5' - name: Run unit tests - run: sudo tox -e func + run: tox -e func diff --git a/tests/functional/test_snap_dcgm.py b/tests/functional/test_snap_dcgm.py index af3ad2b..02e8d3f 100644 --- a/tests/functional/test_snap_dcgm.py +++ b/tests/functional/test_snap_dcgm.py @@ -81,6 +81,7 @@ def check_config_exists(cls, config: str) -> str: return str(dcgm_snap_config[config]) @classmethod + @retry(wait=wait_fixed(2), stop=stop_after_delay(10)) def check_metric_config(cls, metric_file: str) -> None: dcgm_exporter_service = "snap.dcgm.dcgm-exporter" @@ -125,14 +126,7 @@ def test_dcgm_metric_config(self) -> None: self.check_config_exists(config) - with open(metric_file_path, "w") as f: - print(f"Wrote test metrics to {metric_file_path}") - f.writelines( - [ - "# VGPU License status", - "DCGM_FI_DEV_VGPU_LICENSE_STATUS, gauge, vGPU License status", - ] - ) + subprocess.check_call(f"sudo touch {metric_file_path}".split()) self.set_config(service, config, metric_file) self.check_metric_config(metric_file_path) @@ -141,5 +135,4 @@ def test_dcgm_metric_config(self) -> None: self.set_config(service, config) self.check_metric_config("/etc/dcgm-exporter/default-counters.csv") - if os.path.exists(metric_file_path): - os.remove(metric_file_path) + subprocess.check_call(f"sudo rm {metric_file_path}".split())