|
5 | 5 | import yaml |
6 | 6 | from kubernetes.dynamic import DynamicClient |
7 | 7 | from ocp_resources.config_map import ConfigMap |
| 8 | +from ocp_resources.gateway import Gateway |
8 | 9 | from ocp_resources.inference_service import InferenceService |
| 10 | +from ocp_resources.llm_inference_service import LLMInferenceService |
9 | 11 | from ocp_resources.namespace import Namespace |
10 | 12 | from ocp_resources.role import Role |
11 | 13 | from ocp_resources.role_binding import RoleBinding |
|
23 | 25 | ModelVersion, |
24 | 26 | Protocols, |
25 | 27 | RuntimeTemplates, |
| 28 | + Timeout, |
26 | 29 | ) |
27 | 30 | from utilities.inference_utils import create_isvc |
28 | 31 | from utilities.infra import ( |
|
32 | 35 | s3_endpoint_secret, |
33 | 36 | update_configmap_data, |
34 | 37 | ) |
| 38 | +from utilities.llmd_constants import KServeGateway, LLMDGateway |
| 39 | +from utilities.llmd_utils import create_llmd_gateway |
35 | 40 | from utilities.logger import RedactedString |
36 | 41 | from utilities.serving_runtime import ServingRuntimeFromTemplate |
37 | 42 |
|
|
42 | 47 | MODEL_CAR_UPGRADE_NAMESPACE = "upgrade-model-car" |
43 | 48 | METRICS_UPGRADE_NAMESPACE = "upgrade-metrics" |
44 | 49 | PRIVATE_ENDPOINT_UPGRADE_NAMESPACE = "upgrade-private-endpoint" |
| 50 | +LLMD_UPGRADE_NAMESPACE = "upgrade-llmd" |
45 | 51 | S3_CONNECTION = "upgrade-connection" |
46 | 52 |
|
47 | 53 |
|
@@ -765,3 +771,88 @@ def private_endpoint_inference_service_fixture( |
765 | 771 | **isvc_kwargs, |
766 | 772 | ) as isvc: |
767 | 773 | yield isvc |
| 774 | + |
| 775 | + |
| 776 | +# LLMD Upgrade Fixtures |
| 777 | +@pytest.fixture(scope="session") |
| 778 | +def llmd_namespace_fixture( |
| 779 | + pytestconfig: pytest.Config, |
| 780 | + admin_client: DynamicClient, |
| 781 | + teardown_resources: bool, |
| 782 | +) -> Generator[Namespace, Any, Any]: |
| 783 | + """Namespace for LLMD upgrade tests.""" |
| 784 | + ns = Namespace(client=admin_client, name=LLMD_UPGRADE_NAMESPACE) |
| 785 | + |
| 786 | + if pytestconfig.option.post_upgrade: |
| 787 | + yield ns |
| 788 | + ns.clean_up() |
| 789 | + else: |
| 790 | + with create_ns( |
| 791 | + admin_client=admin_client, |
| 792 | + name=LLMD_UPGRADE_NAMESPACE, |
| 793 | + model_mesh_enabled=False, |
| 794 | + add_dashboard_label=True, |
| 795 | + teardown=teardown_resources, |
| 796 | + ) as ns: |
| 797 | + yield ns |
| 798 | + |
| 799 | + |
| 800 | +@pytest.fixture(scope="session") |
| 801 | +def llmd_gateway_fixture( |
| 802 | + pytestconfig: pytest.Config, |
| 803 | + admin_client: DynamicClient, |
| 804 | + teardown_resources: bool, |
| 805 | +) -> Generator[Gateway, Any, Any]: |
| 806 | + """Shared LLMD Gateway for upgrade tests.""" |
| 807 | + gateway = Gateway( |
| 808 | + client=admin_client, |
| 809 | + name=LLMDGateway.DEFAULT_NAME, |
| 810 | + namespace=LLMDGateway.DEFAULT_NAMESPACE, |
| 811 | + api_group=KServeGateway.API_GROUP, |
| 812 | + ) |
| 813 | + |
| 814 | + if pytestconfig.option.post_upgrade: |
| 815 | + yield gateway |
| 816 | + gateway.clean_up() |
| 817 | + else: |
| 818 | + with create_llmd_gateway( |
| 819 | + client=admin_client, |
| 820 | + namespace=LLMDGateway.DEFAULT_NAMESPACE, |
| 821 | + gateway_class_name=LLMDGateway.DEFAULT_CLASS, |
| 822 | + wait_for_condition=True, |
| 823 | + timeout=Timeout.TIMEOUT_1MIN, |
| 824 | + teardown=teardown_resources, |
| 825 | + ) as gateway: |
| 826 | + yield gateway |
| 827 | + |
| 828 | + |
| 829 | +@pytest.fixture(scope="session") |
| 830 | +def llmd_inference_service_fixture( |
| 831 | + pytestconfig: pytest.Config, |
| 832 | + admin_client: DynamicClient, |
| 833 | + llmd_namespace_fixture: Namespace, |
| 834 | + llmd_gateway_fixture: Gateway, |
| 835 | + teardown_resources: bool, |
| 836 | +) -> Generator[LLMInferenceService, Any, Any]: |
| 837 | + """LLMInferenceService using TinyLlama OCI for upgrade tests.""" |
| 838 | + from tests.model_serving.model_server.llmd.conftest import _create_llmisvc_from_config |
| 839 | + from tests.model_serving.model_server.llmd.llmd_configs import TinyLlamaOciConfig |
| 840 | + |
| 841 | + config_cls = TinyLlamaOciConfig |
| 842 | + llmisvc = LLMInferenceService( |
| 843 | + client=admin_client, |
| 844 | + name=config_cls.name, |
| 845 | + namespace=llmd_namespace_fixture.name, |
| 846 | + ) |
| 847 | + |
| 848 | + if pytestconfig.option.post_upgrade: |
| 849 | + yield llmisvc |
| 850 | + llmisvc.clean_up() |
| 851 | + else: |
| 852 | + with _create_llmisvc_from_config( |
| 853 | + config_cls=config_cls, |
| 854 | + namespace=llmd_namespace_fixture.name, |
| 855 | + client=admin_client, |
| 856 | + teardown=teardown_resources, |
| 857 | + ) as llmisvc: |
| 858 | + yield llmisvc |
0 commit comments