Files
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

121 lines
4.7 KiB
Python

"""
4.3 Integration Tests
======================
Validates Prometheus exporter, Grafana dashboard JSON, and RAS/ECC readiness.
"""
import json
import os
import subprocess
import sys
import pytest
# ---------------------------------------------------------------------------
# Prometheus exporter
# ---------------------------------------------------------------------------
class TestPrometheusExporter:
"""Verify the Prometheus exporter script and config."""
def test_prometheus_script_exists(self, python_binding_dir):
script = os.path.join(python_binding_dir, "rdc_prometheus.py")
assert os.path.isfile(script), "rdc_prometheus.py not found"
def test_prometheus_help(self, python_binding_dir):
script = os.path.join(python_binding_dir, "rdc_prometheus.py")
r = subprocess.run(
[sys.executable, script, "--help"],
capture_output=True,
text=True,
timeout=10,
cwd=python_binding_dir,
)
combined = (r.stdout + r.stderr).lower()
assert r.returncode == 0, r.stderr
assert "listen_port" in combined or "usage" in combined
def test_prometheus_config_valid_json(self, python_binding_dir):
cfg = os.path.join(python_binding_dir, "prometheus_targets.json")
if not os.path.isfile(cfg):
pytest.skip("prometheus_targets.json not present")
with open(cfg) as f:
data = json.load(f)
assert isinstance(data, (list, dict)), "Unexpected JSON structure"
def test_prometheus_example_yml_exists(self, python_binding_dir):
cfg = os.path.join(python_binding_dir, "rdc_prometheus_example.yml")
assert os.path.isfile(cfg), "rdc_prometheus_example.yml not found"
# ---------------------------------------------------------------------------
# Grafana dashboard
# ---------------------------------------------------------------------------
class TestGrafanaDashboard:
"""Verify the Grafana dashboard JSON is valid and well-formed."""
def test_dashboard_json_valid(self, python_binding_dir):
path = os.path.join(python_binding_dir, "rdc_grafana_dashboard_example.json")
if not os.path.isfile(path):
pytest.skip("Grafana dashboard JSON not found")
with open(path) as f:
data = json.load(f)
assert "panels" in data or "rows" in data or "title" in data, (
"Dashboard JSON missing expected Grafana keys"
)
def test_dashboard_has_panels(self, python_binding_dir):
path = os.path.join(python_binding_dir, "rdc_grafana_dashboard_example.json")
if not os.path.isfile(path):
pytest.skip("Grafana dashboard JSON not found")
with open(path) as f:
data = json.load(f)
panels = data.get("panels", [])
assert len(panels) > 0, "Dashboard has no panels"
# ---------------------------------------------------------------------------
# RAS / ECC field support
# ---------------------------------------------------------------------------
class TestRASFields:
"""Verify RAS/ECC field IDs are defined in the Python bindings."""
def test_ecc_fields_defined(self, python_binding_dir):
sys.path.insert(0, python_binding_dir)
try:
from rdc_bootstrap import rdc_field_t
ecc_fields = [attr for attr in dir(rdc_field_t) if "ECC" in attr]
assert len(ecc_fields) > 0, "No ECC field IDs found in rdc_field_t"
finally:
sys.path.pop(0)
def test_xgmi_fields_defined(self, python_binding_dir):
sys.path.insert(0, python_binding_dir)
try:
from rdc_bootstrap import rdc_field_t
xgmi_fields = [attr for attr in dir(rdc_field_t) if "XGMI" in attr]
assert len(xgmi_fields) > 0, "No XGMI field IDs found in rdc_field_t"
finally:
sys.path.pop(0)
# ---------------------------------------------------------------------------
# Collectd plugin
# ---------------------------------------------------------------------------
class TestCollectdPlugin:
"""Verify collectd plugin files are present and syntactically valid."""
def test_collectd_script_exists(self, python_binding_dir):
script = os.path.join(python_binding_dir, "rdc_collectd.py")
assert os.path.isfile(script), "rdc_collectd.py not found"
def test_collectd_config_exists(self, python_binding_dir):
conf = os.path.join(python_binding_dir, "rdc_collectd.conf")
assert os.path.isfile(conf), "rdc_collectd.conf not found"
def test_collectd_script_compiles(self, python_binding_dir):
script = os.path.join(python_binding_dir, "rdc_collectd.py")
with open(script) as f:
compile(f.read(), script, "exec")