From 507b8f269b254c0b18701e7775e14d20b74cc31c Mon Sep 17 00:00:00 2001 From: Xuhui Zhu Date: Tue, 16 Jul 2024 16:52:20 -0400 Subject: [PATCH] update subprocess --- tests/integration/test_cos_integration.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/integration/test_cos_integration.py b/tests/integration/test_cos_integration.py index 05e3137d..f0bd4365 100644 --- a/tests/integration/test_cos_integration.py +++ b/tests/integration/test_cos_integration.py @@ -40,8 +40,12 @@ async def test_alerts(ops_test: OpsTest, lxd_model, k8s_model): # model_status = await k8s_model.get_status() command = ["juju", "run", "--format", "json", "traefik/0", "show-proxied-endpoints"] - result = subprocess.run(command, capture_output=True, text=True) - output = json.loads(result.stdout) + try: + result = subprocess.check_output(command) + except subprocess.CalledProcessError: + logger.error("Failed to fetch traefik endpoint") + raise + output = json.loads(result) proxied_endpoints = json.loads(output["traefik/0"]["results"]["proxied-endpoints"]) prometheus_url = proxied_endpoints["prometheus/0"]["url"] prometheus_alerts_endpoint = f"{prometheus_url}/api/v1/alerts"