Skip to content

Commit 94a60ba

Browse files
authored
Merge branch 'main' into feat/mr_upg
2 parents d00c15b + 9fe8c0e commit 94a60ba

File tree

40 files changed

+2712
-6
lines changed

40 files changed

+2712
-6
lines changed

conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ def pytest_addoption(parser: Parser) -> None:
106106
default=os.environ.get("VLLM_RUNTIME_IMAGE"),
107107
help="Specify the runtime image to use for the tests",
108108
)
109+
runtime_group.addoption(
110+
"--mlserver-runtime-image",
111+
default=os.environ.get("MLSERVER_RUNTIME_IMAGE"),
112+
help="Specify the runtime image to use for the tests",
113+
)
109114

110115
# Upgrade options
111116
upgrade_group.addoption(

tests/conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,14 @@ def vllm_runtime_image(pytestconfig: pytest.Config) -> str | None:
221221
return runtime_image
222222

223223

224+
@pytest.fixture(scope="session")
225+
def mlserver_runtime_image(pytestconfig: pytest.Config) -> str | None:
226+
runtime_image = pytestconfig.option.mlserver_runtime_image
227+
if not runtime_image:
228+
return None
229+
return runtime_image
230+
231+
224232
@pytest.fixture(scope="session")
225233
def use_unprivileged_client(pytestconfig: pytest.Config) -> bool:
226234
_use_unprivileged_client = py_config.get("use_unprivileged_client")

tests/model_registry/conftest.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
MODEL_REGISTRY_DB_SECRET_ANNOTATIONS,
3535
OAUTH_PROXY_CONFIG_DICT,
3636
MODEL_REGISTRY_STANDARD_LABELS,
37+
ISTIO_CONFIG_DICT,
3738
)
3839
from utilities.constants import Labels
3940
from tests.model_registry.utils import (
@@ -189,21 +190,29 @@ def model_registry_instance(
189190
model_registry_namespace: str,
190191
model_registry_mysql_config: dict[str, Any],
191192
teardown_resources: bool,
193+
is_model_registry_oauth: bool,
192194
) -> Generator[ModelRegistry, Any, Any]:
193195
"""Creates a model registry instance with oauth proxy configuration."""
194196
if pytestconfig.option.post_upgrade:
195197
mr_instance = ModelRegistry(name=MR_INSTANCE_NAME, namespace=model_registry_namespace, ensure_exists=True)
196198
yield mr_instance
197199
mr_instance.delete(wait=True)
198200
else:
199-
oauth_config = OAUTH_PROXY_CONFIG_DICT
201+
istio_config = None
202+
oauth_config = None
203+
if is_model_registry_oauth:
204+
LOGGER.warning("Requested Ouath Proxy configuration:")
205+
oauth_config = OAUTH_PROXY_CONFIG_DICT
206+
else:
207+
LOGGER.warning("Requested OSSM configuration:")
208+
istio_config = ISTIO_CONFIG_DICT
200209
with ModelRegistry(
201210
name=MR_INSTANCE_NAME,
202211
namespace=model_registry_namespace,
203212
label=MODEL_REGISTRY_STANDARD_LABELS,
204213
grpc={},
205214
rest={},
206-
istio=None,
215+
istio=istio_config,
207216
oauth_proxy=oauth_config,
208217
mysql=model_registry_mysql_config,
209218
wait_for_resource=True,
@@ -478,6 +487,11 @@ def model_registry_instance_pod(admin_client: DynamicClient) -> Generator[Pod, A
478487
)[0]
479488

480489

490+
@pytest.fixture(scope="class")
491+
def is_model_registry_oauth(request: FixtureRequest) -> bool:
492+
return getattr(request, "param", {}).get("use_oauth_proxy", True)
493+
494+
481495
@pytest.fixture(scope="session")
482496
def api_server_url(admin_client: DynamicClient) -> str:
483497
infrastructure = Infrastructure(client=admin_client, name="cluster", ensure_exists=True)

tests/model_registry/rest_api/test_model_registry_rest_api.py

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from typing import Self, Any
22
import pytest
33
from pytest_testconfig import config as py_config
4-
4+
from ocp_resources.model_registry_modelregistry_opendatahub_io import ModelRegistry
55
from tests.model_registry.rest_api.constants import MODEL_REGISTER, MODEL_ARTIFACT, MODEL_VERSION, MODEL_REGISTER_DATA
6-
from tests.model_registry.rest_api.utils import validate_resource_attributes
6+
from tests.model_registry.rest_api.utils import validate_resource_attributes, ModelRegistryV1Alpha1
77
from utilities.constants import DscComponents
88
from simple_logger.logger import get_logger
99

@@ -25,7 +25,7 @@
2525

2626

2727
@pytest.mark.parametrize(
28-
"updated_dsc_component_state_scope_class, registered_model_rest_api",
28+
"updated_dsc_component_state_scope_class, is_model_registry_oauth, registered_model_rest_api",
2929
[
3030
pytest.param(
3131
{
@@ -36,12 +36,27 @@
3636
},
3737
},
3838
},
39+
{"use_oauth_proxy": False},
40+
MODEL_REGISTER_DATA,
41+
),
42+
pytest.param(
43+
{
44+
"component_patch": {
45+
DscComponents.MODELREGISTRY: {
46+
"managementState": DscComponents.ManagementState.MANAGED,
47+
"registriesNamespace": py_config["model_registry_namespace"],
48+
},
49+
},
50+
},
51+
{},
3952
MODEL_REGISTER_DATA,
4053
),
4154
],
4255
indirect=True,
4356
)
44-
@pytest.mark.usefixtures("updated_dsc_component_state_scope_class", "registered_model_rest_api")
57+
@pytest.mark.usefixtures(
58+
"updated_dsc_component_state_scope_class", "is_model_registry_oauth", "registered_model_rest_api"
59+
)
4560
class TestModelRegistryCreationRest:
4661
"""
4762
Tests the creation of a model registry. If the component is set to 'Removed' it will be switched to 'Managed'
@@ -80,6 +95,27 @@ def test_validate_model_registry_resource(
8095
resource_name=data_key,
8196
)
8297

98+
def test_model_registry_validate_api_version(self: Self, model_registry_instance):
99+
api_version = model_registry_instance.instance.apiVersion
100+
LOGGER.info(f"Validating apiversion {api_version} for model registry")
101+
expected_version = f"{ModelRegistry.ApiGroup.MODELREGISTRY_OPENDATAHUB_IO}/{ModelRegistry.ApiVersion.V1BETA1}"
102+
assert api_version == expected_version
103+
104+
def test_model_registry_validate_oauthproxy_enabled(self: Self, model_registry_instance):
105+
model_registry_instance_spec = model_registry_instance.instance.spec
106+
LOGGER.info(f"Validating that MR is using oauth proxy {model_registry_instance_spec}")
107+
assert not model_registry_instance_spec.istio
108+
assert model_registry_instance_spec.oauthProxy.serviceRoute == "enabled"
109+
110+
def test_model_registry_validate_mr_status_v1alpha1(self: Self, model_registry_instance):
111+
mr_instance = ModelRegistryV1Alpha1(
112+
name=model_registry_instance.name, namespace=model_registry_instance.namespace, ensure_exists=True
113+
).instance
114+
status = mr_instance.status.to_dict()
115+
LOGGER.info(f"Validating MR status {status}")
116+
if not status:
117+
pytest.fail(f"Empty status found for {mr_instance}")
118+
83119
@pytest.mark.parametrize(
84120
"updated_model_registry_resource, expected_param",
85121
[

tests/model_registry/rest_api/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from utilities.exceptions import ResourceValueMismatch
1515
from ocp_resources.model_registry_modelregistry_opendatahub_io import ModelRegistry
1616

17+
1718
LOGGER = get_logger(name=__name__)
1819

1920

tests/model_serving/model_runtime/mlserver/__init__.py

Whitespace-only changes.

tests/model_serving/model_runtime/mlserver/basic_model_deployment/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"modelName": "catboost",
3+
"modelVersion": "v0.1.0",
4+
"outputs": [
5+
{
6+
"contents": {
7+
"int64Contents": [
8+
"0"
9+
]
10+
},
11+
"datatype": "INT64",
12+
"name": "predict",
13+
"parameters": {
14+
"content_type": {
15+
"stringParam": "np"
16+
}
17+
},
18+
"shape": [
19+
"1",
20+
"1"
21+
]
22+
}
23+
]
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"id": "catboost",
3+
"model_name": "catboost",
4+
"model_version": "v0.1.0",
5+
"outputs": [
6+
{
7+
"data": [
8+
0
9+
],
10+
"datatype": "INT64",
11+
"name": "predict",
12+
"parameters": {
13+
"content_type": "np"
14+
},
15+
"shape": [
16+
1,
17+
1
18+
]
19+
}
20+
],
21+
"parameters": {}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"modelName": "catboost",
3+
"modelVersion": "v0.1.0",
4+
"outputs": [
5+
{
6+
"contents": {
7+
"int64Contents": [
8+
"0"
9+
]
10+
},
11+
"datatype": "INT64",
12+
"name": "predict",
13+
"parameters": {
14+
"content_type": {
15+
"stringParam": "np"
16+
}
17+
},
18+
"shape": [
19+
"1",
20+
"1"
21+
]
22+
}
23+
]
24+
}

0 commit comments

Comments
 (0)