|
1 | 1 | from typing import Self, Any |
2 | 2 | import pytest |
3 | 3 | from pytest_testconfig import config as py_config |
4 | | - |
| 4 | +from ocp_resources.model_registry_modelregistry_opendatahub_io import ModelRegistry |
5 | 5 | from tests.model_registry.rest_api.constants import MODEL_REGISTER, MODEL_ARTIFACT, MODEL_VERSION, MODEL_REGISTER_DATA |
6 | | -from tests.model_registry.rest_api.utils import validate_resource_attributes |
| 6 | +from tests.model_registry.rest_api.utils import validate_resource_attributes, ModelRegistryV1Alpha1 |
7 | 7 | from utilities.constants import DscComponents |
8 | 8 | from simple_logger.logger import get_logger |
9 | 9 |
|
|
25 | 25 |
|
26 | 26 |
|
27 | 27 | @pytest.mark.parametrize( |
28 | | - "updated_dsc_component_state_scope_class, registered_model_rest_api", |
| 28 | + "updated_dsc_component_state_scope_class, is_model_registry_oauth, registered_model_rest_api", |
29 | 29 | [ |
30 | 30 | pytest.param( |
31 | 31 | { |
|
36 | 36 | }, |
37 | 37 | }, |
38 | 38 | }, |
| 39 | + {"use_oauth_proxy": False}, |
| 40 | + MODEL_REGISTER_DATA, |
| 41 | + ), |
| 42 | + pytest.param( |
| 43 | + { |
| 44 | + "component_patch": { |
| 45 | + DscComponents.MODELREGISTRY: { |
| 46 | + "managementState": DscComponents.ManagementState.MANAGED, |
| 47 | + "registriesNamespace": py_config["model_registry_namespace"], |
| 48 | + }, |
| 49 | + }, |
| 50 | + }, |
| 51 | + {}, |
39 | 52 | MODEL_REGISTER_DATA, |
40 | 53 | ), |
41 | 54 | ], |
42 | 55 | indirect=True, |
43 | 56 | ) |
44 | | -@pytest.mark.usefixtures("updated_dsc_component_state_scope_class", "registered_model_rest_api") |
| 57 | +@pytest.mark.usefixtures( |
| 58 | + "updated_dsc_component_state_scope_class", "is_model_registry_oauth", "registered_model_rest_api" |
| 59 | +) |
45 | 60 | class TestModelRegistryCreationRest: |
46 | 61 | """ |
47 | 62 | Tests the creation of a model registry. If the component is set to 'Removed' it will be switched to 'Managed' |
@@ -80,6 +95,27 @@ def test_validate_model_registry_resource( |
80 | 95 | resource_name=data_key, |
81 | 96 | ) |
82 | 97 |
|
| 98 | + def test_model_registry_validate_api_version(self: Self, model_registry_instance): |
| 99 | + api_version = model_registry_instance.instance.apiVersion |
| 100 | + LOGGER.info(f"Validating apiversion {api_version} for model registry") |
| 101 | + expected_version = f"{ModelRegistry.ApiGroup.MODELREGISTRY_OPENDATAHUB_IO}/{ModelRegistry.ApiVersion.V1BETA1}" |
| 102 | + assert api_version == expected_version |
| 103 | + |
| 104 | + def test_model_registry_validate_oauthproxy_enabled(self: Self, model_registry_instance): |
| 105 | + model_registry_instance_spec = model_registry_instance.instance.spec |
| 106 | + LOGGER.info(f"Validating that MR is using oauth proxy {model_registry_instance_spec}") |
| 107 | + assert not model_registry_instance_spec.istio |
| 108 | + assert model_registry_instance_spec.oauthProxy.serviceRoute == "enabled" |
| 109 | + |
| 110 | + def test_model_registry_validate_mr_status_v1alpha1(self: Self, model_registry_instance): |
| 111 | + mr_instance = ModelRegistryV1Alpha1( |
| 112 | + name=model_registry_instance.name, namespace=model_registry_instance.namespace, ensure_exists=True |
| 113 | + ).instance |
| 114 | + status = mr_instance.status.to_dict() |
| 115 | + LOGGER.info(f"Validating MR status {status}") |
| 116 | + if not status: |
| 117 | + pytest.fail(f"Empty status found for {mr_instance}") |
| 118 | + |
83 | 119 | @pytest.mark.parametrize( |
84 | 120 | "updated_model_registry_resource, expected_param", |
85 | 121 | [ |
|
0 commit comments