Skip to content

Commit d80d946

Browse files
committed
ModelCatalog Multi-tenant scenarios base PR
1 parent 2f70659 commit d80d946

File tree

5 files changed

+35
-5
lines changed

5 files changed

+35
-5
lines changed

tests/model_registry/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,4 @@ class ModelRegistryEndpoints:
6464
"mysql": 3306,
6565
}
6666
MODEL_REGISTRY_POD_FILTER: str = "component=model-registry"
67+
DEFAULT_MODEL_CATALOG: str = "model-catalog-sources"

tests/model_registry/model_catalog/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from ocp_resources.resource import ResourceEditor
88

99
from ocp_resources.route import Route
10-
from tests.model_registry.model_catalog.constants import DEFAULT_MODEL_CATALOG
10+
from tests.model_registry.constants import DEFAULT_MODEL_CATALOG
1111
from tests.model_registry.model_catalog.utils import is_model_catalog_ready, wait_for_model_catalog_api
1212

1313

tests/model_registry/model_catalog/constants.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
DEFAULT_MODEL_CATALOG: str = "model-catalog-sources"
21
CUSTOM_ECHO_CATALOG_ID: str = "sample_rhec_catalog"
32
CUSTOM_MODEL_NAME = "rhelai1/modelcar-granite-7b-starter"
43
CUSTOM_ECOSYSTEM_CATALOG: str = f"""catalogs:

tests/model_registry/rest_api/test_multiple_mr.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
from typing import Self
22
import pytest
3+
from kubernetes.dynamic import DynamicClient
4+
5+
from ocp_resources.config_map import ConfigMap
36
from ocp_resources.model_registry_modelregistry_opendatahub_io import ModelRegistry
7+
from ocp_resources.pod import Pod
48

5-
from tests.model_registry.constants import MR_INSTANCE_BASE_NAME, NUM_RESOURCES
9+
from tests.model_registry.constants import MR_INSTANCE_BASE_NAME, NUM_RESOURCES, DEFAULT_MODEL_CATALOG
610
from tests.model_registry.rest_api.utils import (
711
validate_resource_attributes,
812
get_register_model_data,
@@ -29,13 +33,39 @@
2933
"model_registry_instance",
3034
)
3135
class TestModelRegistryMultipleInstances:
32-
def test_validate_multiple_model_registry(self: Self, model_registry_instance, model_registry_namespace: str):
36+
def test_validate_multiple_model_registry(
37+
self: Self, model_registry_instance: list[ModelRegistry], model_registry_namespace: str
38+
):
3339
for num in range(0, NUM_RESOURCES["num_resources"]):
3440
mr = ModelRegistry(
3541
name=f"{MR_INSTANCE_BASE_NAME}{num}", namespace=model_registry_namespace, ensure_exists=True
3642
)
3743
LOGGER.info(f"{mr.name} found")
3844

45+
def test_validate_one_model_catalog_configmap(
46+
self: Self, admin_client: DynamicClient, model_registry_namespace: str
47+
):
48+
config_map_names: list[str] = []
49+
expected_number_config_maps: int = 1
50+
for config_map in list(ConfigMap.get(namespace=model_registry_namespace, dyn_client=admin_client)):
51+
if config_map.name.startswith(DEFAULT_MODEL_CATALOG):
52+
config_map_names.append(config_map.name)
53+
assert len(config_map_names) == expected_number_config_maps, (
54+
f"Expected {expected_number_config_maps} modelcatalog sources, found: {config_map_names}"
55+
)
56+
57+
def test_validate_one_model_catalog_pod(self: Self, admin_client: DynamicClient, model_registry_namespace: str):
58+
catalog_pods: list[Pod] = list(
59+
Pod.get(
60+
namespace=model_registry_namespace, label_selector="component=model-catalog", dyn_client=admin_client
61+
)
62+
)
63+
expected_number_pods: int = 1
64+
65+
assert len(catalog_pods) == expected_number_pods, (
66+
f"Expected {expected_number_pods} model catalog pods, found: {[pod.name for pod in catalog_pods]}"
67+
)
68+
3969
def test_validate_register_models_multiple_registries(
4070
self: Self, model_registry_rest_url: list[str], model_registry_rest_headers: dict[str, str]
4171
):

tests/model_registry/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
MARIADB_MY_CNF,
2525
PORT_MAP,
2626
MODEL_REGISTRY_POD_FILTER,
27+
DEFAULT_MODEL_CATALOG,
2728
)
2829
from tests.model_registry.exceptions import ModelRegistryResourceNotFoundError
29-
from tests.model_registry.model_catalog.constants import DEFAULT_MODEL_CATALOG
3030
from utilities.exceptions import ProtocolNotSupportedError, TooManyServicesError
3131
from utilities.constants import Protocols, Annotations, Timeout
3232
from model_registry import ModelRegistry as ModelRegistryClient

0 commit comments

Comments
 (0)