From 2e0ae767abb00e8eb874c3c659bdfcc0dc641ff3 Mon Sep 17 00:00:00 2001 From: Xuhui Zhu Date: Mon, 22 Jul 2024 09:43:57 -0400 Subject: [PATCH] Fix integration test (#279) --- tests/integration/test_cos_integration.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/integration/test_cos_integration.py b/tests/integration/test_cos_integration.py index 24dafa2e..6499d72a 100644 --- a/tests/integration/test_cos_integration.py +++ b/tests/integration/test_cos_integration.py @@ -36,12 +36,19 @@ async def test_alerts(ops_test: OpsTest, lxd_model, k8s_model): await _disable_hardware_exporter(ops_test, lxd_model) await _export_mock_metrics(lxd_model) - model_name = ops_test.model_name - - model_status = await k8s_model.get_status() - traefik_ip = model_status["applications"]["traefik"].public_address - - prometheus_alerts_endpoint = f"http://{traefik_ip}/{model_name}-prometheus-0/api/v1/alerts" + # Run juju action to get the ip address that traefik is configured to serve on + returncode, stdout, stderr = await ops_test.run( + "juju", + "run", + "--format", + "json", + "traefik/0", + "show-proxied-endpoints", + ) + json_data = json.loads(stdout) + proxied_endpoints = json.loads(json_data["traefik/0"]["results"]["proxied-endpoints"]) + prometheus_url = proxied_endpoints["prometheus/0"]["url"] + prometheus_alerts_endpoint = f"{prometheus_url}/api/v1/alerts" cmd = ["curl", prometheus_alerts_endpoint]