|
1 | 1 | from typing import Self |
2 | 2 | import pytest |
| 3 | +from kubernetes.dynamic import DynamicClient |
| 4 | + |
| 5 | +from ocp_resources.config_map import ConfigMap |
3 | 6 | from ocp_resources.model_registry_modelregistry_opendatahub_io import ModelRegistry |
| 7 | +from ocp_resources.pod import Pod |
4 | 8 |
|
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 |
6 | 10 | from tests.model_registry.rest_api.utils import ( |
7 | 11 | validate_resource_attributes, |
8 | 12 | get_register_model_data, |
|
29 | 33 | "model_registry_instance", |
30 | 34 | ) |
31 | 35 | 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 | + ): |
33 | 39 | for num in range(0, NUM_RESOURCES["num_resources"]): |
34 | 40 | mr = ModelRegistry( |
35 | 41 | name=f"{MR_INSTANCE_BASE_NAME}{num}", namespace=model_registry_namespace, ensure_exists=True |
36 | 42 | ) |
37 | 43 | LOGGER.info(f"{mr.name} found") |
38 | 44 |
|
| 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 | + |
39 | 69 | def test_validate_register_models_multiple_registries( |
40 | 70 | self: Self, model_registry_rest_url: list[str], model_registry_rest_headers: dict[str, str] |
41 | 71 | ): |
|
0 commit comments