forked from opendatahub-io/opendatahub-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
47 lines (38 loc) · 1.38 KB
/
utils.py
File metadata and controls
47 lines (38 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import requests
from tests.model_explainability.evalhub.constants import (
EVALHUB_HEALTH_PATH,
EVALHUB_HEALTH_STATUS_HEALTHY,
)
from utilities.guardrails import get_auth_headers
from utilities.opendatahub_logger import get_logger
LOGGER = get_logger(name=__name__)
def validate_evalhub_health(
host: str,
token: str,
ca_bundle_file: str,
) -> None:
"""Validate that the EvalHub service health endpoint returns healthy status.
Args:
host: Route host for the EvalHub service.
token: Bearer token for authentication.
ca_bundle_file: Path to CA bundle for TLS verification.
Raises:
AssertionError: If the health check fails.
requests.HTTPError: If the request fails.
"""
url = f"https://{host}{EVALHUB_HEALTH_PATH}"
LOGGER.info(f"Checking EvalHub health at {url}")
response = requests.get(
url=url,
headers=get_auth_headers(token=token),
verify=ca_bundle_file,
timeout=10,
)
response.raise_for_status()
data = response.json()
LOGGER.info(f"EvalHub health response: {data}")
assert "status" in data, "Health response missing 'status' field"
assert data["status"] == EVALHUB_HEALTH_STATUS_HEALTHY, (
f"Expected status '{EVALHUB_HEALTH_STATUS_HEALTHY}', got '{data['status']}'"
)
assert "timestamp" in data, "Health response missing 'timestamp' field"