Skip to content

Commit e170900

Browse files
committed
add error handling to gorch ssl cert fixture
1 parent 58bc804 commit e170900

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tests/model_explainability/guardrails/conftest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,12 @@ def guardrails_orchestrator_ssl_cert(guardrails_orchestrator_route: Route):
387387
input="",
388388
capture_output=True,
389389
text=True,
390+
timeout=30,
390391
)
391392

393+
if result.returncode != 0 and "CONNECTED" not in result.stdout:
394+
raise RuntimeError(f"Failed to connect to {hostname}: {result.stderr}")
395+
392396
cert_lines = []
393397
in_cert = False
394398
for line in result.stdout.splitlines():
@@ -399,6 +403,9 @@ def guardrails_orchestrator_ssl_cert(guardrails_orchestrator_route: Route):
399403
if "-----END CERTIFICATE-----" in line:
400404
in_cert = False
401405

406+
if not cert_lines:
407+
raise RuntimeError(f"No certificate found in response from {hostname}")
408+
402409
filepath = os.path.join(py_config["tmp_base_dir"], "gorch_cert.crt")
403410
with open(filepath, "w") as f:
404411
f.write("\n".join(cert_lines))

0 commit comments

Comments
 (0)