Skip to content

Commit fa6cc98

Browse files
committed
test: validate PostgreSQL database connection
- Add test to verify model catalog pod uses PostgreSQL database - Enhance get_model_catalog_pod utility with configurable label selector
1 parent f1777e2 commit fa6cc98

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

tests/model_registry/model_catalog/test_default_model_catalog.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111
from ocp_resources.config_map import ConfigMap
1212
from ocp_resources.route import Route
1313
from ocp_resources.service import Service
14-
from tests.model_registry.model_catalog.constants import DEFAULT_CATALOG_ID
14+
from tests.model_registry.model_catalog.constants import DEFAULT_CATALOG_ID, CATALOG_CONTAINER
1515
from tests.model_registry.model_catalog.utils import (
1616
validate_model_catalog_enabled,
1717
execute_get_command,
1818
validate_model_catalog_resource,
1919
validate_default_catalog,
2020
get_validate_default_model_catalog_source,
2121
extract_schema_fields,
22+
get_model_catalog_pod,
2223
)
2324
from tests.model_registry.utils import get_rest_headers
2425
from utilities.user_utils import UserTestSession
@@ -100,6 +101,20 @@ def test_model_catalog_resources_exists(
100101
def test_operator_pod_enabled_model_catalog(self: Self, model_registry_operator_pod: Pod):
101102
assert validate_model_catalog_enabled(pod=model_registry_operator_pod)
102103

104+
def test_model_catalog_uses_postgres(self: Self, admin_client: DynamicClient, model_registry_namespace: str):
105+
"""
106+
Validate that model catalog pod is using PostgreSQL database
107+
"""
108+
model_catalog_pods = get_model_catalog_pod(
109+
client=admin_client,
110+
model_registry_namespace=model_registry_namespace,
111+
label_selector="app.kubernetes.io/name=model-catalog",
112+
)
113+
assert len(model_catalog_pods) == 1
114+
model_catalog_pod = model_catalog_pods[0]
115+
model_catalog_pod_log = model_catalog_pod.log(container=CATALOG_CONTAINER)
116+
assert "Successfully connected to PostgreSQL database" in model_catalog_pod_log
117+
103118

104119
@pytest.mark.parametrize(
105120
"user_token_for_api_calls,",

tests/model_registry/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -649,10 +649,10 @@ def validate_mlmd_removal_in_model_registry_pod_log(
649649
assert not errors, f"Log validation failed with error(s): {errors}"
650650

651651

652-
def get_model_catalog_pod(client: DynamicClient, model_registry_namespace: str) -> list[Pod]:
653-
return list(
654-
Pod.get(namespace=model_registry_namespace, label_selector="component=model-catalog", dyn_client=client)
655-
)
652+
def get_model_catalog_pod(
653+
client: DynamicClient, model_registry_namespace: str, label_selector: str = "component=model-catalog"
654+
) -> list[Pod]:
655+
return list(Pod.get(namespace=model_registry_namespace, label_selector=label_selector, dyn_client=client))
656656

657657

658658
def get_rest_headers(token: str) -> dict[str, str]:

0 commit comments

Comments
 (0)