33from tests .model_registry .constants import MODEL_NAME , MODEL_DICT
44from model_registry .types import RegisteredModel
55from model_registry import ModelRegistry as ModelRegistryClient
6+ from ocp_resources .model_registry_modelregistry_opendatahub_io import ModelRegistry
67from simple_logger .logger import get_logger
8+ from tests .model_registry .rest_api .utils import ModelRegistryV1Alpha1
79
810LOGGER = get_logger (name = __name__ )
911
@@ -42,7 +44,7 @@ def test_registering_model_pre_upgrade(
4244 pytest .fail ("errors found in model registry response validation:\n {}" .format ("\n " .join (errors )))
4345
4446 # TODO: if we are in <=2.21, we can create a servicemesh MR here instead of oauth (v1alpha1), and then in
45- # post-upgrade check that it automatically gets converted to oauth (v1beta1)
47+ # post-upgrade check that it automatically gets converted to oauth (v1beta1) - to be done in 2.21 branch directly.
4648
4749
4850@pytest .mark .usefixtures ("post_upgrade_dsc_patch" )
@@ -51,6 +53,7 @@ class TestPostUpgradeModelRegistry:
5153 def test_retrieving_model_post_upgrade (
5254 self : Self ,
5355 model_registry_client : ModelRegistryClient ,
56+ model_registry_instance : ModelRegistry ,
5457 ):
5558 model = model_registry_client .get_registered_model (name = MODEL_NAME )
5659 expected_attrs = {
@@ -65,8 +68,20 @@ def test_retrieving_model_post_upgrade(
6568 LOGGER .error (f"received model: { model } " )
6669 pytest .fail ("errors found in model registry response validation:\n {}" .format ("\n " .join (errors )))
6770
68- # TODO: if we are in >= 2.22, we can check that this is using oauth instead of servicemesh
69- # TODO: if we are in >= 2.22, we can check that the conversion webhook is working as expected, i.e.
70- # the MR instance has api version v1beta1, and that when querying for older api version (e.g.
71- # `oc get modelregistries.v1alpha1.modelregistry.opendatahub.io -o wide -n rhoai-model-registries`)
72- # it also returns the status stanza (used by dashboard)
71+ # the following is valid for 2.22+
72+ api_version = model_registry_instance .instance .apiVersion
73+ expected_version = f"{ ModelRegistry .ApiGroup .MODELREGISTRY_OPENDATAHUB_IO } /{ ModelRegistry .ApiVersion .V1BETA1 } "
74+ assert api_version == expected_version
75+
76+ model_registry_instance_spec = model_registry_instance .instance .spec
77+ assert not model_registry_instance_spec .istio
78+ assert model_registry_instance_spec .oauthProxy .serviceRoute == "enabled"
79+
80+ # After v1alpha1 is removed (2.24?) this has to be removed
81+ mr_instance = ModelRegistryV1Alpha1 (
82+ name = model_registry_instance .name , namespace = model_registry_instance .namespace , ensure_exists = True
83+ ).instance
84+ status = mr_instance .status .to_dict ()
85+ LOGGER .info (f"Validating MR status { status } " )
86+ if not status :
87+ pytest .fail (f"Empty status found for { mr_instance } " )
0 commit comments