Skip to content

Commit

Permalink
Use function to get dashboards
Browse files Browse the repository at this point in the history
  • Loading branch information
rgildein committed Aug 14, 2024
1 parent 4e88228 commit 94fa718
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/test_cos_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@
assert_metrics_endpoint,
deploy_and_assert_grafana_agent,
get_alert_rules,
get_grafana_dashboards,
)
from pytest_operator.plugin import OpsTest

log = logging.getLogger(__name__)

ISTIO_PILOT = "istio-pilot"
ISTIO_PILOT_ALER_RULES = Path("./charms/istio-pilot/src/prometheus_alert_rules")
ISTIO_PILOT_DASHBOARDS = Path("./charms/istio-pilot/src/grafana_dashboards")
ISTIO_GATEWAY_APP_NAME = "istio-ingressgateway"
ISTIO_GATEWAY_ALER_RULES = Path("./charms/istio-gateway/src/prometheus_alert_rules")
ISTIO_PILOT_DASHBOARDS = {"istio_control_plane.json"}


@pytest.mark.abort_on_fail
Expand Down Expand Up @@ -99,8 +100,10 @@ async def test_alert_rules(charm, path_to_alert_rules, ops_test):
await assert_alert_rules(app, alert_rules)


@pytest.mark.parametrize("charm, dashboards", [(ISTIO_PILOT, ISTIO_PILOT_DASHBOARDS)])
async def test_grafana_dashboards(charm, dashboards, ops_test):
@pytest.mark.parametrize("charm, path_to_dashboards", [(ISTIO_PILOT, ISTIO_PILOT_DASHBOARDS)])
async def test_grafana_dashboards(charm, path_to_dashboards, ops_test):
"""Test Grafana dashboards are defined in relation data bag."""
app = ops_test.model.applications[charm]
dashboards = get_grafana_dashboards(path_to_dashboards)
log.info("found dashboards: %s", dashboards)
await assert_grafana_dashboards(app, dashboards)

0 comments on commit 94fa718

Please sign in to comment.