|
4 | 4 | from kubernetes.dynamic import DynamicClient |
5 | 5 | from ocp_resources.inference_service import InferenceService |
6 | 6 | from ocp_resources.pod import Pod |
| 7 | +from ocp_resources.namespace import Namespace |
| 8 | +from ocp_resources.serving_runtime import ServingRuntime |
| 9 | +from utilities.inference_utils import create_isvc |
| 10 | +from utilities.constants import KServeDeploymentType |
| 11 | + |
7 | 12 |
|
8 | 13 | from tests.model_serving.model_server.inference_service_configuration.constants import ( |
9 | 14 | ISVC_ENV_VARS, |
| 15 | + UPDATED_PULL_SECRET, |
| 16 | + ORIGINAL_PULL_SECRET, |
10 | 17 | ) |
11 | 18 | from tests.model_serving.model_server.inference_service_configuration.utils import ( |
12 | 19 | update_inference_service, |
@@ -65,3 +72,58 @@ def patched_isvc_replicas( |
65 | 72 | wait_for_new_pods=request.param["wait-for-new-pods"], |
66 | 73 | ): |
67 | 74 | yield ovms_kserve_inference_service |
| 75 | + |
| 76 | + |
| 77 | +@pytest.fixture(scope="class") |
| 78 | +def model_car_raw_inference_service_with_pull_secret( |
| 79 | + request: pytest.FixtureRequest, |
| 80 | + unprivileged_client: DynamicClient, |
| 81 | + unprivileged_model_namespace: Namespace, |
| 82 | + serving_runtime_from_template: ServingRuntime, |
| 83 | +) -> Generator[InferenceService, Any, Any]: |
| 84 | + with create_isvc( |
| 85 | + client=unprivileged_client, |
| 86 | + name="model-car-raw", |
| 87 | + namespace=unprivileged_model_namespace.name, |
| 88 | + runtime=serving_runtime_from_template.name, |
| 89 | + storage_uri=request.param["storage-uri"], |
| 90 | + model_format=serving_runtime_from_template.instance.spec.supportedModelFormats[0].name, |
| 91 | + deployment_mode=KServeDeploymentType.RAW_DEPLOYMENT, |
| 92 | + image_pull_secrets=[ORIGINAL_PULL_SECRET], |
| 93 | + wait_for_predictor_pods=False, # Until modelcar initContainer completed, other containers may have Error status |
| 94 | + ) as isvc: |
| 95 | + yield isvc |
| 96 | + |
| 97 | + |
| 98 | +@pytest.fixture(scope="class") |
| 99 | +def updated_isvc_pull_secret( |
| 100 | + request: pytest.FixtureRequest, |
| 101 | + unprivileged_client: DynamicClient, |
| 102 | + model_car_raw_inference_service_with_pull_secret: InferenceService, |
| 103 | +) -> Generator[InferenceService, Any, Any]: |
| 104 | + with update_inference_service( |
| 105 | + client=unprivileged_client, |
| 106 | + isvc=model_car_raw_inference_service_with_pull_secret, |
| 107 | + isvc_updated_dict={"spec": {"predictor": {"imagePullSecrets": [{"name": UPDATED_PULL_SECRET}]}}}, |
| 108 | + ): |
| 109 | + yield model_car_raw_inference_service_with_pull_secret |
| 110 | + |
| 111 | + |
| 112 | +@pytest.fixture(scope="class") |
| 113 | +def updated_isvc_remove_pull_secret( |
| 114 | + request: pytest.FixtureRequest, |
| 115 | + unprivileged_client: DynamicClient, |
| 116 | + model_car_raw_inference_service_with_pull_secret: InferenceService, |
| 117 | +) -> Generator[InferenceService, Any, Any]: |
| 118 | + with update_inference_service( |
| 119 | + client=unprivileged_client, |
| 120 | + isvc=model_car_raw_inference_service_with_pull_secret, |
| 121 | + isvc_updated_dict={ |
| 122 | + "spec": { |
| 123 | + "predictor": { |
| 124 | + "imagePullSecrets": None # Explicitly remove the field |
| 125 | + } |
| 126 | + } |
| 127 | + }, |
| 128 | + ): |
| 129 | + yield model_car_raw_inference_service_with_pull_secret |
0 commit comments