Skip to content

Commit d05353a

Browse files
RHOAIENG-36714 - Model server upgrade tests (#811)
* update model server ugrade tests to use kserve-ovms * fix bug * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 6ac78ea commit d05353a

File tree

3 files changed

+59
-58
lines changed

3 files changed

+59
-58
lines changed

tests/model_serving/model_server/upgrade/conftest.py

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
from ocp_resources.secret import Secret
88
from ocp_resources.serving_runtime import ServingRuntime
99
from simple_logger.logger import get_logger
10-
1110
from utilities.constants import (
1211
KServeDeploymentType,
12+
ModelAndFormat,
13+
ModelFormat,
1314
ModelStoragePath,
15+
ModelVersion,
1416
RuntimeTemplates,
1517
)
1618
from utilities.inference_utils import create_isvc
@@ -20,15 +22,17 @@
2022

2123
LOGGER = get_logger(name=__name__)
2224

25+
UPGRADE_NAMESPACE = "upgrade-model-server"
26+
S3_CONNECTION = "upgrade-connection"
27+
2328

2429
@pytest.fixture(scope="session")
25-
def model_namespace_scope_session(
30+
def namespace_fixture(
2631
pytestconfig: pytest.Config,
2732
admin_client: DynamicClient,
2833
teardown_resources: bool,
2934
) -> Generator[Namespace, Any, Any]:
30-
name = "upgrade-model-server"
31-
ns = Namespace(client=admin_client, name=name)
35+
ns = Namespace(client=admin_client, name=UPGRADE_NAMESPACE)
3236

3337
if pytestconfig.option.post_upgrade:
3438
yield ns
@@ -37,7 +41,7 @@ def model_namespace_scope_session(
3741
else:
3842
with create_ns(
3943
admin_client=admin_client,
40-
name=name,
44+
name=UPGRADE_NAMESPACE,
4145
model_mesh_enabled=False,
4246
add_dashboard_label=True,
4347
teardown=teardown_resources,
@@ -46,10 +50,10 @@ def model_namespace_scope_session(
4650

4751

4852
@pytest.fixture(scope="session")
49-
def models_endpoint_s3_secret_scope_session(
53+
def s3_connection_fixture(
5054
pytestconfig: pytest.Config,
5155
admin_client: DynamicClient,
52-
model_namespace_scope_session: Namespace,
56+
namespace_fixture: Namespace,
5357
aws_access_key_id: str,
5458
aws_secret_access_key: str,
5559
models_s3_bucket_name: str,
@@ -59,8 +63,8 @@ def models_endpoint_s3_secret_scope_session(
5963
) -> Generator[Secret, Any, Any]:
6064
secret_kwargs = {
6165
"client": admin_client,
62-
"name": "models-bucket-secret",
63-
"namespace": model_namespace_scope_session.name,
66+
"name": S3_CONNECTION,
67+
"namespace": namespace_fixture.name,
6468
}
6569

6670
secret = Secret(**secret_kwargs)
@@ -83,16 +87,16 @@ def models_endpoint_s3_secret_scope_session(
8387

8488

8589
@pytest.fixture(scope="session")
86-
def caikit_raw_serving_runtime_scope_session(
90+
def serving_runtime_fixture(
8791
pytestconfig: pytest.Config,
8892
admin_client: DynamicClient,
89-
model_namespace_scope_session: Namespace,
93+
namespace_fixture: Namespace,
9094
teardown_resources: bool,
9195
) -> Generator[ServingRuntime, Any, Any]:
9296
runtime_kwargs = {
9397
"client": admin_client,
94-
"name": "caikit-raw",
95-
"namespace": model_namespace_scope_session.name,
98+
"name": "upgrade-runtime",
99+
"namespace": namespace_fixture.name,
96100
}
97101

98102
model_runtime = ServingRuntime(**runtime_kwargs)
@@ -104,26 +108,32 @@ def caikit_raw_serving_runtime_scope_session(
104108
else:
105109
with ServingRuntimeFromTemplate(
106110
**runtime_kwargs,
107-
template_name=RuntimeTemplates.CAIKIT_STANDALONE_SERVING,
111+
template_name=RuntimeTemplates.OVMS_KSERVE,
108112
multi_model=False,
109113
enable_http=True,
110114
teardown=teardown_resources,
115+
resources={
116+
ModelFormat.OVMS: {
117+
"requests": {"cpu": "1", "memory": "4Gi"},
118+
"limits": {"cpu": "2", "memory": "8Gi"},
119+
}
120+
},
111121
) as model_runtime:
112122
yield model_runtime
113123

114124

115125
@pytest.fixture(scope="session")
116-
def caikit_raw_inference_service_scope_session(
126+
def inference_service_fixture(
117127
pytestconfig: pytest.Config,
118128
admin_client: DynamicClient,
119-
caikit_raw_serving_runtime_scope_session: ServingRuntime,
120-
models_endpoint_s3_secret_scope_session: Secret,
129+
serving_runtime_fixture: ServingRuntime,
130+
s3_connection_fixture: Secret,
121131
teardown_resources: bool,
122132
) -> Generator[InferenceService, Any, Any]:
123133
isvc_kwargs = {
124134
"client": admin_client,
125-
"name": caikit_raw_serving_runtime_scope_session.name,
126-
"namespace": caikit_raw_serving_runtime_scope_session.namespace,
135+
"name": "upgrade-isvc",
136+
"namespace": serving_runtime_fixture.namespace,
127137
}
128138

129139
isvc = InferenceService(**isvc_kwargs)
@@ -135,11 +145,12 @@ def caikit_raw_inference_service_scope_session(
135145

136146
else:
137147
with create_isvc(
138-
runtime=caikit_raw_serving_runtime_scope_session.name,
139-
model_format=caikit_raw_serving_runtime_scope_session.instance.spec.supportedModelFormats[0].name,
148+
runtime=serving_runtime_fixture.name,
149+
model_format=ModelAndFormat.OPENVINO_IR,
140150
deployment_mode=KServeDeploymentType.RAW_DEPLOYMENT,
141-
storage_key=models_endpoint_s3_secret_scope_session.name,
142-
storage_path=ModelStoragePath.EMBEDDING_MODEL,
151+
storage_key=s3_connection_fixture.name,
152+
storage_path=ModelStoragePath.OPENVINO_EXAMPLE_MODEL,
153+
model_version=ModelVersion.OPSET13,
143154
external_route=False,
144155
teardown=teardown_resources,
145156
**isvc_kwargs,

tests/model_serving/model_server/upgrade/test_upgrade.py

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,63 @@
11
import pytest
22

3+
from utilities.manifests.openvino import OPENVINO_KSERVE_INFERENCE_CONFIG
34
from tests.model_serving.model_server.upgrade.utils import (
45
verify_inference_generation,
56
verify_pod_containers_not_restarted,
67
verify_serving_runtime_generation,
78
)
89
from tests.model_serving.model_server.utils import verify_inference_response
9-
from utilities.constants import ModelName, Protocols
10-
from utilities.manifests.caikit_standalone import CAIKIT_STANDALONE_INFERENCE_CONFIG
10+
from utilities.constants import Protocols
1111

1212

13-
TEST_RAW_CAIKIT_BGE_POST_UPGRADE_INFERENCE_EXISTS: str = "test_raw_caikit_bge_post_upgrade_inference_exists"
13+
pytestmark = [pytest.mark.rawdeployment, pytest.mark.usefixtures("valid_aws_config")]
1414

1515

16-
@pytest.mark.usefixtures("valid_aws_config")
1716
class TestPreUpgradeModelServer:
1817
@pytest.mark.pre_upgrade
19-
@pytest.mark.rawdeployment
20-
def test_raw_caikit_bge_pre_upgrade_inference(self, caikit_raw_inference_service_scope_session):
21-
"""Test Caikit bge-large-en embedding model inference using internal route before upgrade"""
18+
def test_raw_deployment_pre_upgrade_inference(self, inference_service_fixture):
19+
"""Test raw deployment model inference using internal route before upgrade"""
2220
verify_inference_response(
23-
inference_service=caikit_raw_inference_service_scope_session,
24-
inference_config=CAIKIT_STANDALONE_INFERENCE_CONFIG,
25-
inference_type="embedding",
21+
inference_service=inference_service_fixture,
22+
inference_config=OPENVINO_KSERVE_INFERENCE_CONFIG,
23+
inference_type="infer",
2624
protocol=Protocols.HTTP,
27-
model_name=ModelName.CAIKIT_BGE_LARGE_EN,
2825
use_default_query=True,
2926
)
3027

3128

3229
class TestPostUpgradeModelServer:
3330
@pytest.mark.post_upgrade
34-
@pytest.mark.rawdeployment
35-
@pytest.mark.dependency(name=TEST_RAW_CAIKIT_BGE_POST_UPGRADE_INFERENCE_EXISTS)
36-
def test_raw_caikit_bge_post_upgrade_inference_exists(self, caikit_raw_inference_service_scope_session):
31+
@pytest.mark.dependency(name="isvc_exists")
32+
def test_raw_deployment_post_upgrade_inference_exists(self, inference_service_fixture):
3733
"""Test that raw deployment inference service exists after upgrade"""
38-
assert caikit_raw_inference_service_scope_session.exists
34+
assert inference_service_fixture.exists
3935

4036
@pytest.mark.post_upgrade
41-
@pytest.mark.rawdeployment
42-
@pytest.mark.dependency(depends=[TEST_RAW_CAIKIT_BGE_POST_UPGRADE_INFERENCE_EXISTS])
43-
def test_raw_caikit_bge_post_upgrade_inference_not_modified(self, caikit_raw_inference_service_scope_session):
37+
@pytest.mark.dependency(depends=["isvc_exists"])
38+
def test_raw_deployment_post_upgrade_inference_not_modified(self, inference_service_fixture):
4439
"""Test that the raw deployment inference service is not modified in upgrade"""
45-
verify_inference_generation(isvc=caikit_raw_inference_service_scope_session, expected_generation=1)
40+
verify_inference_generation(isvc=inference_service_fixture, expected_generation=1)
4641

4742
@pytest.mark.post_upgrade
48-
@pytest.mark.rawdeployment
49-
@pytest.mark.dependency(depends=[TEST_RAW_CAIKIT_BGE_POST_UPGRADE_INFERENCE_EXISTS])
50-
def test_raw_caikit_bge_post_upgrade_runtime_not_modified(self, caikit_raw_inference_service_scope_session):
43+
@pytest.mark.dependency(depends=["isvc_exists"])
44+
def test_raw_deployment_post_upgrade_runtime_not_modified(self, inference_service_fixture):
5145
"""Test that the raw deployment runtime is not modified in upgrade"""
52-
verify_serving_runtime_generation(isvc=caikit_raw_inference_service_scope_session, expected_generation=1)
46+
verify_serving_runtime_generation(isvc=inference_service_fixture, expected_generation=1)
5347

5448
@pytest.mark.post_upgrade
55-
@pytest.mark.rawdeployment
56-
@pytest.mark.dependency(depends=[TEST_RAW_CAIKIT_BGE_POST_UPGRADE_INFERENCE_EXISTS])
57-
def test_raw_caikit_bge_post_upgrade_inference(self, caikit_raw_inference_service_scope_session):
58-
"""Test Caikit bge-large-en embedding model inference using internal route after upgrade"""
49+
@pytest.mark.dependency(depends=["isvc_exists"])
50+
def test_raw_deployment_post_upgrade_inference(self, inference_service_fixture):
51+
"""Test raw deployment model inference using internal route after upgrade"""
5952
verify_inference_response(
60-
inference_service=caikit_raw_inference_service_scope_session,
61-
inference_config=CAIKIT_STANDALONE_INFERENCE_CONFIG,
62-
inference_type="embedding",
53+
inference_service=inference_service_fixture,
54+
inference_config=OPENVINO_KSERVE_INFERENCE_CONFIG,
55+
inference_type="infer",
6356
protocol=Protocols.HTTP,
64-
model_name=ModelName.CAIKIT_BGE_LARGE_EN,
6557
use_default_query=True,
6658
)
6759

6860
@pytest.mark.post_upgrade
69-
@pytest.mark.rawdeployment
7061
def test_verify_odh_model_controller_pod_not_restarted_post_upgrade(self, admin_client):
7162
"""Verify that ODH Model Controller pod is not restarted after upgrade"""
7263
verify_pod_containers_not_restarted(
@@ -75,7 +66,6 @@ def test_verify_odh_model_controller_pod_not_restarted_post_upgrade(self, admin_
7566
)
7667

7768
@pytest.mark.post_upgrade
78-
@pytest.mark.rawdeployment
7969
def test_verify_kserve_pod_not_restarted_post_upgrade(self, admin_client):
8070
"""Verify that KServe pod is not restarted after upgrade"""
8171
verify_pod_containers_not_restarted(

tests/model_serving/model_server/upgrade/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def verify_inference_generation(isvc: InferenceService, expected_generation: int
4747
ResourceMismatch: If inference generation is not equal to expected generation
4848
"""
4949
if isvc.instance.status.observedGeneration != expected_generation:
50-
ResourceMismatchError(f"Inference service {isvc.name} was modified")
50+
raise ResourceMismatchError(f"Inference service {isvc.name} was modified")
5151

5252

5353
def verify_serving_runtime_generation(isvc: InferenceService, expected_generation: int) -> None:
@@ -62,4 +62,4 @@ def verify_serving_runtime_generation(isvc: InferenceService, expected_generatio
6262
"""
6363
runtime = get_inference_serving_runtime(isvc=isvc)
6464
if runtime.instance.metadata.generation != expected_generation:
65-
ResourceMismatchError(f"Serving runtime {runtime.name} was modified")
65+
raise ResourceMismatchError(f"Serving runtime {runtime.name} was modified")

0 commit comments

Comments
 (0)