Skip to content

Commit 4526098

Browse files
committed
updates! 2c9819d
1 parent 99468f5 commit 4526098

File tree

9 files changed

+45
-38
lines changed

9 files changed

+45
-38
lines changed

tests/model_registry/conftest.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from ocp_resources.infrastructure import Infrastructure
1414
from ocp_resources.oauth import OAuth
1515
from ocp_resources.pod import Pod
16+
from ocp_resources.route import Route
1617
from ocp_resources.secret import Secret
1718
from ocp_resources.namespace import Namespace
1819
from ocp_resources.service import Service
@@ -597,3 +598,23 @@ def user_credentials_rbac() -> dict[str, str]:
597598
@pytest.fixture(scope="class")
598599
def catalog_config_map(admin_client: DynamicClient, model_registry_namespace: str) -> ConfigMap:
599600
return ConfigMap(name=DEFAULT_CUSTOM_MODEL_CATALOG, client=admin_client, namespace=model_registry_namespace)
601+
602+
603+
@pytest.fixture(scope="class")
604+
def model_catalog_routes(admin_client: DynamicClient, model_registry_namespace: str) -> list[Route]:
605+
return list(
606+
Route.get(namespace=model_registry_namespace, label_selector="component=model-catalog", dyn_client=admin_client)
607+
)
608+
609+
610+
@pytest.fixture(scope="class")
611+
def model_catalog_rest_url(model_registry_namespace: str, model_catalog_routes: list[Route]) -> list[str]:
612+
assert model_catalog_routes, f"Model catalog routes does not exist in {model_registry_namespace}"
613+
route_urls = [
614+
f"https://{route.instance.spec.host}:443/api/model_catalog/v1alpha1/" for route in model_catalog_routes
615+
]
616+
assert route_urls, (
617+
"Model catalog routes information could not be found from "
618+
f"routes:{[route.name for route in model_catalog_routes]}"
619+
)
620+
return route_urls

tests/model_registry/model_catalog/conftest.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from ocp_resources.config_map import ConfigMap
1111
from ocp_resources.resource import ResourceEditor
1212

13-
from ocp_resources.route import Route
1413
from ocp_resources.service_account import ServiceAccount
1514
from tests.model_registry.model_catalog.constants import (
1615
SAMPLE_MODEL_NAME3,
@@ -44,26 +43,6 @@ def model_catalog_config_map(
4443
return ConfigMap(name=configmap_name, client=admin_client, namespace=model_registry_namespace, ensure_exists=True)
4544

4645

47-
@pytest.fixture(scope="class")
48-
def model_catalog_routes(admin_client: DynamicClient, model_registry_namespace: str) -> list[Route]:
49-
return list(
50-
Route.get(namespace=model_registry_namespace, label_selector="component=model-catalog", dyn_client=admin_client)
51-
)
52-
53-
54-
@pytest.fixture(scope="class")
55-
def model_catalog_rest_url(model_registry_namespace: str, model_catalog_routes: list[Route]) -> list[str]:
56-
assert model_catalog_routes, f"Model catalog routes does not exist in {model_registry_namespace}"
57-
route_urls = [
58-
f"https://{route.instance.spec.host}:443/api/model_catalog/v1alpha1/" for route in model_catalog_routes
59-
]
60-
assert route_urls, (
61-
"Model catalog routes information could not be found from "
62-
f"routes:{[route.name for route in model_catalog_routes]}"
63-
)
64-
return route_urls
65-
66-
6746
@pytest.fixture(scope="class")
6847
def updated_catalog_config_map(
6948
request: pytest.FixtureRequest,

tests/model_registry/model_catalog/test_custom_model_catalog.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010
import pytest
1111
from simple_logger.logger import get_logger
1212
from typing import Self
13+
from kubernetes.dynamic.exceptions import ResourceNotFoundError
1314

14-
from tests.model_registry.model_catalog.utils import (
15-
ResourceNotFoundError,
16-
)
1715
from tests.model_registry.utils import execute_get_command, get_sample_yaml_str, get_catalog_str
1816

1917
LOGGER = get_logger(name=__name__)

tests/model_registry/model_catalog/test_default_model_catalog.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import pytest
22
import random
3+
4+
import yaml
35
from kubernetes.dynamic import DynamicClient
46
from dictdiffer import diff
57
from ocp_resources.deployment import Deployment
@@ -18,7 +20,7 @@
1820
validate_model_catalog_resource,
1921
get_validate_default_model_catalog_source,
2022
extract_schema_fields,
21-
validate_model_catalog_configmap_data,
23+
validate_default_catalog,
2224
)
2325
from tests.model_registry.utils import get_rest_headers, get_model_catalog_pod, execute_get_command
2426
from utilities.user_utils import UserTestSession
@@ -60,8 +62,16 @@ class TestModelCatalogGeneral:
6062
],
6163
indirect=["model_catalog_config_map"],
6264
)
63-
def test_config_map_exists(self: Self, model_catalog_config_map: ConfigMap, expected_catalogs: int):
64-
validate_model_catalog_configmap_data(configmap=model_catalog_config_map, num_catalogs=expected_catalogs)
65+
def test_config_map_exists(
66+
self: Self, model_catalog_config_map: ConfigMap, expected_catalogs: int, validate_catalog: bool
67+
) -> None:
68+
assert model_catalog_config_map.exists, f"{model_catalog_config_map.name} does not exist"
69+
catalogs = yaml.safe_load(model_catalog_config_map.instance.data["sources.yaml"])["catalogs"]
70+
assert len(catalogs) == expected_catalogs, (
71+
f"{model_catalog_config_map.name} should have {expected_catalogs} catalog"
72+
)
73+
if validate_catalog:
74+
validate_default_catalog(catalogs=catalogs)
6575

6676
@pytest.mark.parametrize(
6777
"resource_name, expected_resource_count",

tests/model_registry/model_catalog/test_model_catalog_negative.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
from ocp_resources.config_map import ConfigMap
88
from ocp_resources.pod import Pod
99
from ocp_resources.resource import ResourceEditor
10-
from tests.model_registry.constants import DEFAULT_MODEL_CATALOG_CFG
10+
from tests.model_registry.constants import DEFAULT_MODEL_CATALOG_CM
1111
from tests.model_registry.model_catalog.constants import DEFAULT_CATALOGS, CATALOG_CONTAINER
12-
from tests.model_registry.model_catalog.utils import validate_model_catalog_configmap_data, is_model_catalog_ready
13-
from tests.model_registry.utils import get_model_catalog_pod
12+
from tests.model_registry.model_catalog.utils import validate_model_catalog_configmap_data
13+
from tests.model_registry.utils import get_model_catalog_pod, is_model_catalog_ready
1414
from timeout_sampler import TimeoutExpiredError
1515

1616
from utilities.general import wait_for_container_status
@@ -102,7 +102,7 @@ class TestDefaultCatalogNegative:
102102
"model_catalog_config_map, modified_sources_yaml",
103103
[
104104
pytest.param(
105-
{"configmap_name": DEFAULT_MODEL_CATALOG_CFG},
105+
{"configmap_name": DEFAULT_MODEL_CATALOG_CM},
106106
"""
107107
catalogs:
108108
- name: Modified Catalog

tests/model_registry/model_catalog/test_model_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
REDHAT_AI_CATALOG_ID,
1010
VALIDATED_CATALOG_ID,
1111
)
12-
from tests.model_registry.model_catalog.utils import (
12+
from tests.model_registry.utils import (
1313
execute_get_command,
1414
)
1515

tests/model_registry/model_catalog/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from typing import Any
2-
import time
32
import yaml
43

54
from kubernetes.dynamic import DynamicClient

tests/model_registry/upgrade/test_model_catalog_upgrade.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def pre_upgrade_config_map_update(
3939
for key in request.param["sample_yaml"]:
4040
patches["data"][key] = request.param["sample_yaml"][key]
4141

42-
ResourceEditor(patches=patches).update()
42+
ResourceEditor(patches={catalog_config_map: patches}).update()
4343
is_model_catalog_ready(client=admin_client, model_registry_namespace=model_registry_namespace)
4444
wait_for_model_catalog_api(url=model_catalog_rest_url[0], headers=model_registry_rest_headers)
4545
return catalog_config_map
@@ -80,8 +80,8 @@ def test_validate_sources(
8080
self: Self,
8181
pre_upgrade_config_map_update: ConfigMap,
8282
):
83-
# check that the configmap was updated:
84-
assert len(yaml.safe_load(pre_upgrade_config_map_update.instance.data["sources.yaml"])["catalogs"]) == 2
83+
# check that the custom source configmap was updated:
84+
assert len(yaml.safe_load(pre_upgrade_config_map_update.instance.data["sources.yaml"])["catalogs"]) == 1
8585
LOGGER.info("Testing model catalog validation")
8686

8787

@@ -93,6 +93,6 @@ def test_validate_sources(
9393
self: Self,
9494
post_upgrade_config_map_update: ConfigMap,
9595
):
96-
# check that the configmap was updated:
96+
# check that the configmap was still updated:
9797
assert len(yaml.safe_load(post_upgrade_config_map_update.instance.data["sources.yaml"])["catalogs"]) == 1
9898
LOGGER.info("Testing model catalog validation")

tests/model_registry/upgrade/test_model_registry_upgrade.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def test_model_registry_instance_spec_post_upgrade(
7474
):
7575
model_registry_instance_spec = model_registry_instance[0].instance.spec
7676
assert not model_registry_instance_spec.istio
77-
assert model_registry_instance_spec.oauthProxy.serviceRoute == "enabled"
77+
assert model_registry_instance_spec.kubeRBACProxy.serviceRoute == "enabled"
7878

7979
@pytest.mark.post_upgrade
8080
def test_model_registry_grpc_container_removal_post_upgrade(

0 commit comments

Comments
 (0)