Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/model_registry/model_catalog/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ def labels_configmap_patch(
"name": "test-dynamic",
"displayName": "Dynamic Test Label",
"description": "A label added during test execution",
"assetType": "models",
},
{
"name": "mcp-test-label",
Expand Down
18 changes: 18 additions & 0 deletions tests/model_registry/model_catalog/metadata/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from typing import Any

import pytest
from kubernetes.dynamic import DynamicClient

from tests.model_registry.model_catalog.metadata.utils import get_labels_from_configmaps


@pytest.fixture()
def expected_labels_by_asset_type(
request: pytest.FixtureRequest,
admin_client: DynamicClient,
model_registry_namespace: str,
) -> list[dict[str, Any]]:
"""Get expected labels from ConfigMaps, filtered by asset type from the test's parametrize."""
asset_type = request.param
all_labels = get_labels_from_configmaps(admin_client=admin_client, namespace=model_registry_namespace)
return [label for label in all_labels if label.get("assetType") == asset_type]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any
from typing import Any, Literal

import pytest
import structlog
Expand All @@ -19,27 +19,28 @@ class TestLabelsEndpoint:
"""Test class for the model catalog labels endpoint."""

@pytest.mark.smoke
@pytest.mark.parametrize(
"expected_labels_by_asset_type, asset_type",
[
pytest.param("models", "models", id="test_models"),
pytest.param("mcp_servers", "mcp_servers", id="test_mcp_servers"),
],
indirect=["expected_labels_by_asset_type"],
)
Comment on lines +22 to +29
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably we should test the case when no asset type is passed. It should return model labels if we are consistent with the other endpoints that have asset_type

def test_labels_endpoint_default_data(
self,
admin_client: DynamicClient,
model_registry_namespace: str,
model_catalog_rest_url: list[str],
expected_labels_by_asset_type: list[dict[str, Any]],
asset_type: Literal["models", "mcp_servers"],
Comment thread
coderabbitai[bot] marked this conversation as resolved.
):
Comment thread
dbasunag marked this conversation as resolved.
"""
Smoke test: Validate default labels from ConfigMaps are returned by the endpoint.
"""
LOGGER.info("Testing labels endpoint with default data")

# Get expected labels from ConfigMaps
expected_labels = get_labels_from_configmaps(admin_client=admin_client, namespace=model_registry_namespace)

# Get labels from API
LOGGER.info(f"Testing labels endpoint with default data for asset type: {asset_type}")
api_labels = get_labels_from_api(
model_catalog_rest_url=model_catalog_rest_url[0], user_token=get_openshift_token()
model_catalog_rest_url=model_catalog_rest_url[0], user_token=get_openshift_token(), asset_type=asset_type
)

# Verify they match
verify_labels_match(expected_labels=expected_labels, api_labels=api_labels)
verify_labels_match(expected_labels=expected_labels_by_asset_type, api_labels=api_labels)

@pytest.mark.tier1
def test_labels_endpoint_configmap_updates(
Expand All @@ -65,7 +66,7 @@ def _check_updated_labels():

# Split expected labels by asset type
mcp_expected_labels = [label for label in all_expected_labels if label.get("assetType") == "mcp_servers"]
model_expected_labels = [label for label in all_expected_labels if label not in mcp_expected_labels]
model_expected_labels = [label for label in all_expected_labels if label.get("assetType") == "models"]

# Verify default /labels returns only model labels (no MCP cross-contamination)
api_labels = get_labels_from_api(model_catalog_rest_url=url, user_token=token)
Expand Down
Loading