From 88d222577446559770acadb6702b254403981775 Mon Sep 17 00:00:00 2001 From: jenkins Date: Wed, 22 Apr 2026 15:31:36 -0300 Subject: [PATCH] test(titan-iac): cover dashboard generator contract --- scripts/tests/test_dashboards_render_atlas.py | 39 ++++++++++++++++++- testing/quality_contract.json | 1 + 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/scripts/tests/test_dashboards_render_atlas.py b/scripts/tests/test_dashboards_render_atlas.py index 865aa685..c77fb5b1 100644 --- a/scripts/tests/test_dashboards_render_atlas.py +++ b/scripts/tests/test_dashboards_render_atlas.py @@ -4,7 +4,7 @@ import pathlib def load_module(): path = pathlib.Path(__file__).resolve().parents[1] / "dashboards_render_atlas.py" - spec = importlib.util.spec_from_file_location("dashboards_render_atlas", path) + spec = importlib.util.spec_from_file_location("scripts.dashboards_render_atlas", path) module = importlib.util.module_from_spec(spec) assert spec.loader is not None spec.loader.exec_module(module) @@ -56,3 +56,40 @@ def test_render_configmap_writes(tmp_path): content = (tmp_path / "cm.yaml").read_text() assert "kind: ConfigMap" in content assert f"{uid}.json" in content + + +def test_testing_suite_variable_uses_canonical_values_only(): + mod = load_module() + variable = mod.testing_suite_variable() + canonical_matcher = "|".join(mod.PLATFORM_TEST_SUITE_NAMES) + legacy_names = {"bstein-home", "data-prepper", "titan-iac", "pegasus-health"} + + assert variable["allValue"] == canonical_matcher + assert not any(alias in variable["query"] for alias in legacy_names) + assert not any(alias in variable["allValue"] for alias in legacy_names) + assert [option["value"] for option in variable["options"]] == mod.PLATFORM_TEST_SUITE_NAMES + + +def test_jobs_dashboard_separates_current_gate_health_from_reliability(): + mod = load_module() + dashboard = mod.build_jobs_dashboard() + panels_by_title = {panel["title"]: panel for panel in dashboard["panels"]} + + assert "Current Gate Health by Suite" in panels_by_title + assert "Run Reliability by Suite (24h)" in panels_by_title + assert "Run Reliability History by Suite" in panels_by_title + assert "Failures by Suite (24h)" not in panels_by_title + assert "Success Rate by Suite (24h)" not in panels_by_title + + current_gate_expr = panels_by_title["Current Gate Health by Suite"]["targets"][0]["expr"] + assert 'check)' in current_gate_expr + assert 'result=~"ok|passed|success|not_applicable|skipped|na|n/a"' in current_gate_expr + + reliability_panel = panels_by_title["Run Reliability by Suite (24h)"] + reliability_expr = reliability_panel["targets"][0]["expr"] + assert "platform_quality_gate_runs_total" in reliability_expr + assert "> 0" in reliability_expr + assert "- 1" in reliability_expr + assert reliability_panel["fieldConfig"]["defaults"]["mappings"] == [ + {"type": "value", "options": {"-1": {"text": "no runs"}}} + ] diff --git a/testing/quality_contract.json b/testing/quality_contract.json index bb0d85dd..83086c4c 100644 --- a/testing/quality_contract.json +++ b/testing/quality_contract.json @@ -54,6 +54,7 @@ "junit": "build/junit-unit.xml", "coverage_sources": [ "ci/scripts", + "scripts.dashboards_render_atlas", "services/mailu/scripts", "testing" ],