Skip to content

Commit 87f0268

Browse files
author
Milind Waykole
committed
test: Raw-kserve clusteripnone changes
Signed-off-by: Milind Waykole <mwaykole@mwaykole-thinkpadp1gen4i.bengluru.csb>
1 parent 309a94f commit 87f0268

File tree

4 files changed

+29
-58
lines changed

4 files changed

+29
-58
lines changed

tests/model_serving/model_server/components/kserve_dsc_deployment_mode/conftest.py

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -56,49 +56,14 @@ def patched_default_deployment_mode_in_dsc(
5656

5757

5858
@pytest.fixture(scope="class")
59-
def default_deployment_serviceconfig_in_dsc(
59+
def patched_default_deployment_serviceconfig_in_dsc(
6060
request: FixtureRequest,
6161
default_deployment_mode_in_dsc: DataScienceCluster,
6262
inferenceservice_config_cm: ConfigMap,
6363
) -> Generator[DataScienceCluster, Any, Any]:
64-
"""
65-
Fixture to set the default deployment service configuration in DSC.
66-
67-
Args:
68-
request: Fixture request object
69-
default_deployment_mode_in_dsc: DataScienceCluster resource with deployment mode set
70-
inferenceservice_config_cm: ConfigMap for inference service configuration
71-
72-
Yields:
73-
DataScienceCluster: The DSC resource with updated service configuration
74-
"""
7564
yield from patch_raw_default_deployment_config(
7665
dsc_resource=default_deployment_mode_in_dsc,
7766
inferenceservice_config_cm=inferenceservice_config_cm,
78-
request_default_deployment_config=request.param["default-deployment-config"],
79-
)
80-
81-
82-
@pytest.fixture(scope="class")
83-
def patched_default_deployment_serviceconfig_in_dsc(
84-
request: FixtureRequest,
85-
default_deployment_serviceconfig_in_dsc: DataScienceCluster,
86-
inferenceservice_config_cm: ConfigMap,
87-
) -> Generator[DataScienceCluster, Any, Any]:
88-
"""
89-
Fixture to patch the default deployment service configuration in DSC.
90-
91-
Args:
92-
request: Fixture request object
93-
default_deployment_serviceconfig_in_dsc: DSC resource with initial service configuration
94-
inferenceservice_config_cm: ConfigMap for inference service configuration
95-
96-
Yields:
97-
DataScienceCluster: The DSC resource with patched service configuration
98-
"""
99-
yield from patch_raw_default_deployment_config(
100-
dsc_resource=default_deployment_serviceconfig_in_dsc,
101-
inferenceservice_config_cm=inferenceservice_config_cm,
10267
request_default_deployment_config=request.param["updated-deployment-config"],
10368
)
10469

tests/model_serving/model_server/components/kserve_dsc_deployment_mode/test_kserve_dsc_default_deployment_mode.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
ModelStoragePath,
1212
ModelVersion,
1313
Protocols,
14+
DscComponents,
1415
)
1516
from utilities.inference_utils import Inference
1617
from utilities.manifests.openvino import OPENVINO_KSERVE_INFERENCE_CONFIG
@@ -184,19 +185,17 @@ def test_default_service_config_is_headless(
184185
)
185186

186187
@pytest.mark.parametrize(
187-
"patched_default_deployment_serviceconfig_in_dsc,default_deployment_serviceconfig_in_dsc",
188+
"patched_default_deployment_serviceconfig_in_dsc",
188189
[
189190
pytest.param(
190-
{"updated-deployment-config": "Headed"},
191-
{"default-deployment-config": "Headless"},
191+
{"updated-deployment-config": DscComponents.RawDeploymentServiceConfig.HEADED},
192192
)
193193
],
194194
indirect=True,
195195
)
196196
def test_service_config_can_be_updated_to_headed(
197197
self,
198198
default_deployment_mode_in_dsc,
199-
default_deployment_serviceconfig_in_dsc,
200199
patched_default_deployment_serviceconfig_in_dsc,
201200
ovms_inference_service,
202201
admin_client,

tests/model_serving/model_server/components/kserve_dsc_deployment_mode/utils.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
from timeout_sampler import TimeoutSampler
99

1010
from kubernetes.dynamic import DynamicClient
11-
from utilities.constants import Timeout
11+
from utilities.constants import Timeout, DscComponents
12+
from pytest_testconfig import config as py_config
13+
from kubernetes.dynamic.exceptions import ResourceNotFoundError
1214

1315
LOGGER = get_logger(name=__name__)
1416

@@ -82,21 +84,18 @@ def wait_for_service_config_in_cm(config_map: ConfigMap, service_config: str) ->
8284
TimeoutExpiredError: If service config value is not set in configmap
8385
"""
8486
LOGGER.info(f"Waiting for {service_config} service config to be set in {config_map.name} configmap")
85-
expected_value = service_config == "Headless"
87+
expected_value = service_config == DscComponents.RawDeploymentServiceConfig.HEADLESS
8688
for sample in TimeoutSampler(
8789
wait_timeout=Timeout.TIMEOUT_5MIN,
8890
sleep=5,
8991
func=lambda: config_map.instance.data,
9092
):
9193
if sample:
92-
try:
93-
cm_service_config = json.loads(sample.service)["serviceClusterIPNone"]
94-
if cm_service_config == expected_value:
95-
LOGGER.info(f"Service config successfully set to {service_config}")
96-
break
97-
except (KeyError, json.JSONDecodeError) as e:
98-
LOGGER.warning(f"Error reading service config: {e}")
99-
continue
94+
service_data = json.loads(sample.get("service", "{}"))
95+
cm_service_config = service_data.get("serviceClusterIPNone")
96+
if cm_service_config == expected_value:
97+
LOGGER.info(f"Service config successfully set to {service_config}")
98+
break
10099

101100

102101
def patch_raw_default_deployment_config(
@@ -137,17 +136,20 @@ def get_service_cluster_ip(admin_client: DynamicClient) -> bool:
137136
Get the service cluster IP configuration from the inferenceservice-config configmap.
138137
139138
Args:
140-
admin_client: Admin client for accessing the cluster
139+
admin_client (DynamicClient): Admin client for accessing the cluster
141140
142141
Returns:
143-
dict: Service configuration from the configmap
142+
bool: True if service is Headless (serviceClusterIPNone=True), False if Headed
144143
145144
Raises:
146-
ValueError: If the configmap or service configuration cannot be read
145+
ResourceNotFoundError: If the configmap or service configuration cannot be read
147146
"""
148147
try:
149-
config_map = ConfigMap(client=admin_client, namespace="redhat-ods-applications", name="inferenceservice-config")
150-
config_map = json.loads(config_map.instance["data"]["service"])
151-
return config_map["serviceClusterIPNone"]
148+
config_map = ConfigMap(
149+
client=admin_client, namespace=py_config["applications_namespace"], name="inferenceservice-config"
150+
)
151+
service_data = json.loads(config_map.instance.get("data", {}).get("service", "{}"))
152+
service_cluster_ip = service_data.get("serviceClusterIPNone")
153+
return service_cluster_ip
152154
except (KeyError, json.JSONDecodeError) as e:
153-
raise ValueError(f"Failed to read service configuration: {e}")
155+
raise ResourceNotFoundError(f"Failed to read service configuration: {e} from inferenceservice-config")

utilities/constants.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ class ConditionType:
163163
MODELREGISTRY: ConditionType.MODEL_REGISTRY_READY,
164164
}
165165

166+
class RawDeploymentServiceConfig:
167+
HEADLESS = "Headless"
168+
HEADED = "Headed"
169+
166170

167171
class Labels:
168172
class OpenDataHub:
@@ -227,7 +231,8 @@ class Buckets:
227231

228232
class PodConfig:
229233
KSERVE_MINIO_IMAGE: str = (
230-
"quay.io/jooholee/model-minio@sha256:b50aa0fbfea740debb314ece8e925b3e8e761979f345b6cd12a6833efd04e2c2" # noqa: E501
234+
"quay.io/jooholee/model-minio@sha256:b50aa0fbfea740debb314ece8e925b3e8e761979f345b6cd12a6833efd04e2c2"
235+
# noqa: E501
231236
)
232237

233238
MINIO_BASE_CONFIG: dict[str, Any] = {

0 commit comments

Comments
 (0)