Skip to content

Commit 2f22bd2

Browse files
committed
fix IG test in smoke
1 parent 34873c6 commit 2f22bd2

File tree

1 file changed

+58
-0
lines changed
  • tests/model_serving/model_server/inference_graph

1 file changed

+58
-0
lines changed

tests/model_serving/model_server/inference_graph/conftest.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
import pytest
55
from _pytest.fixtures import FixtureRequest
66
from kubernetes.dynamic import DynamicClient
7+
from ocp_resources.data_science_cluster import DataScienceCluster
78
from ocp_resources.inference_graph import InferenceGraph
89
from ocp_resources.inference_service import InferenceService
910
from ocp_resources.namespace import Namespace
11+
from ocp_resources.resource import ResourceEditor
1012
from ocp_resources.role_binding import RoleBinding
1113
from ocp_resources.secret import Secret
1214
from ocp_resources.service_account import ServiceAccount
@@ -17,13 +19,67 @@
1719
from utilities.infra import create_inference_token, create_inference_graph_view_role
1820

1921

22+
@pytest.fixture(scope="class")
23+
def kserve_raw_headless_service_config(
24+
dsc_resource: DataScienceCluster,
25+
) -> Generator[DataScienceCluster, Any, Any]:
26+
"""
27+
Configure KServe rawDeploymentServiceConfig to Headed for InferenceGraph tests.
28+
29+
This fixture ensures that raw deployment services are configured with headed (non-headless) services,
30+
which is required for InferenceGraph routing to work properly.
31+
After the test completes, the original configuration is restored.
32+
"""
33+
import logging
34+
logger = logging.getLogger(__name__)
35+
36+
# Get current rawDeploymentServiceConfig value (it's directly under kserve, not under kserve.serving)
37+
current_config = None
38+
if hasattr(dsc_resource.instance.spec.components.kserve, 'rawDeploymentServiceConfig'):
39+
current_config = dsc_resource.instance.spec.components.kserve.rawDeploymentServiceConfig
40+
41+
logger.info(f"Current rawDeploymentServiceConfig: {current_config}")
42+
43+
# If already headed (case-insensitive), skip the patch
44+
if current_config and current_config.lower() == "headed":
45+
logger.info("rawDeploymentServiceConfig is already Headed, skipping patch")
46+
yield dsc_resource
47+
else:
48+
logger.info(f"Patching rawDeploymentServiceConfig from '{current_config}' to 'Headed'")
49+
# Patch DSC to set rawDeploymentServiceConfig to Headed
50+
with ResourceEditor(
51+
patches={
52+
dsc_resource: {
53+
"spec": {
54+
"components": {
55+
"kserve": {
56+
"rawDeploymentServiceConfig": "Headed"
57+
}
58+
}
59+
}
60+
}
61+
}
62+
):
63+
logger.info("Waiting for DSC to become ready after patch...")
64+
dsc_resource.wait_for_condition(
65+
condition=dsc_resource.Condition.READY,
66+
status=dsc_resource.Condition.Status.TRUE,
67+
timeout=300,
68+
)
69+
# Verify the patch was applied
70+
new_config = dsc_resource.instance.spec.components.kserve.rawDeploymentServiceConfig
71+
logger.info(f"After patch, rawDeploymentServiceConfig is: {new_config}")
72+
yield dsc_resource
73+
74+
2075
@pytest.fixture
2176
def dog_breed_inference_graph(
2277
request: FixtureRequest,
2378
admin_client: DynamicClient,
2479
unprivileged_model_namespace: Namespace,
2580
dog_cat_inference_service: InferenceService,
2681
dog_breed_inference_service: InferenceService,
82+
kserve_raw_headless_service_config: DataScienceCluster,
2783
) -> Generator[InferenceGraph, Any, Any]:
2884
nodes = {
2985
"root": {
@@ -86,6 +142,7 @@ def dog_cat_inference_service(
86142
unprivileged_model_namespace: Namespace,
87143
ovms_kserve_serving_runtime: ServingRuntime,
88144
models_endpoint_s3_secret: Secret,
145+
kserve_raw_headless_service_config: DataScienceCluster,
89146
) -> Generator[InferenceService, Any, Any]:
90147
with create_isvc(
91148
client=admin_client,
@@ -107,6 +164,7 @@ def dog_breed_inference_service(
107164
unprivileged_model_namespace: Namespace,
108165
ovms_kserve_serving_runtime: ServingRuntime,
109166
models_endpoint_s3_secret: Secret,
167+
kserve_raw_headless_service_config: DataScienceCluster,
110168
) -> Generator[InferenceService, Any, Any]:
111169
with create_isvc(
112170
client=admin_client,

0 commit comments

Comments
 (0)