|
| 1 | +import pytest |
| 2 | + |
| 3 | +from tests.model_serving.model_server.utils import verify_inference_response |
| 4 | +from utilities.constants import ModelFormat, ModelVersion, Protocols, ModelInferenceRuntime |
| 5 | +from utilities.inference_utils import Inference |
| 6 | +from utilities.infra import get_model_mesh_route |
| 7 | +from utilities.manifests.onnx import ONNX_INFERENCE_CONFIG |
| 8 | + |
| 9 | +pytestmark = [pytest.mark.rawdeployment, pytest.mark.usefixtures("valid_aws_config")] |
| 10 | + |
| 11 | + |
| 12 | +@pytest.mark.rawdeployment |
| 13 | +@pytest.mark.parametrize( |
| 14 | + "model_namespace, openvino_kserve_serving_runtime, ovms_raw_inference_service", |
| 15 | + [ |
| 16 | + pytest.param( |
| 17 | + {"name": "raw-deployment-onnx"}, |
| 18 | + { |
| 19 | + "runtime-name": ModelInferenceRuntime.ONNX_RUNTIME, |
| 20 | + "model-format": {ModelFormat.ONNX: ModelVersion.OPSET13}, |
| 21 | + }, |
| 22 | + {"name": ModelFormat.ONNX, "model-version": ModelVersion.OPSET13, "model-dir": "test-dir"}, |
| 23 | + ) |
| 24 | + ], |
| 25 | + indirect=True, |
| 26 | +) |
| 27 | +class TestONNXRaw: |
| 28 | + """Test suite for Validating reconciliation """ |
| 29 | + |
| 30 | + @pytest.mark.smoke |
| 31 | + @pytest.mark.jira("RHOAIENG-9045") |
| 32 | + def test_raw_onnx_rout_reconciliation(self, admin_client, ovms_raw_inference_service): |
| 33 | + """ |
| 34 | + Verify that the KServe Raw ONNX model can be queried using REST |
| 35 | + and ensure that the model rout reconciliation works correctly . |
| 36 | + """ |
| 37 | + # Initial inference validation |
| 38 | + verify_inference_response( |
| 39 | + inference_service=ovms_raw_inference_service, |
| 40 | + inference_config=ONNX_INFERENCE_CONFIG, |
| 41 | + inference_type=Inference.INFER, |
| 42 | + protocol=Protocols.HTTPS, |
| 43 | + use_default_query=True, |
| 44 | + ) |
| 45 | + |
| 46 | + # Validate ingress status before and after route deletion |
| 47 | + self.assert_ingress_status_changed(admin_client, ovms_raw_inference_service) |
| 48 | + |
| 49 | + # Final inference validation after route update |
| 50 | + verify_inference_response( |
| 51 | + inference_service=ovms_raw_inference_service, |
| 52 | + inference_config=ONNX_INFERENCE_CONFIG, |
| 53 | + inference_type=Inference.INFER, |
| 54 | + protocol=Protocols.HTTPS, |
| 55 | + use_default_query=True, |
| 56 | + ) |
| 57 | + |
| 58 | + @staticmethod |
| 59 | + def assert_ingress_status_changed(admin_client, inference_service): |
| 60 | + """ |
| 61 | + Validates that the ingress status changes correctly after route deletion. |
| 62 | + """ |
| 63 | + route = get_model_mesh_route(admin_client, inference_service) |
| 64 | + |
| 65 | + initial_status = route.instance.status["ingress"][0]["conditions"][0] |
| 66 | + initial_host = route.host |
| 67 | + initial_transition_time = initial_status["lastTransitionTime"] |
| 68 | + initial_status_value = initial_status["status"] |
| 69 | + |
| 70 | + route.delete() |
| 71 | + |
| 72 | + updated_status = route.instance.status["ingress"][0]["conditions"][0] |
| 73 | + updated_host = route.host |
| 74 | + updated_transition_time = updated_status["lastTransitionTime"] |
| 75 | + updated_status_value = updated_status["status"] |
| 76 | + |
| 77 | + assert updated_host == initial_host, "Host should remain the same after route update" |
| 78 | + assert updated_transition_time != initial_transition_time, "Transition time should change" |
| 79 | + assert updated_status_value == "True", "Updated ingress status should be True" |
| 80 | + assert initial_status_value == "True", "Initial ingress status should be True" |
0 commit comments