Skip to content

Commit d00c15b

Browse files
committed
feat: add 2.22/oauth checks in post-upgrade
Signed-off-by: lugi0 <lgiorgi@redhat.com>
1 parent 9787668 commit d00c15b

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

tests/model_registry/rest_api/utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from tests.model_registry.rest_api.constants import MODEL_REGISTRY_BASE_URI
1313
from pyhelper_utils.shell import run_command
1414
from utilities.exceptions import ResourceValueMismatch
15+
from ocp_resources.model_registry_modelregistry_opendatahub_io import ModelRegistry
1516

1617
LOGGER = get_logger(name=__name__)
1718

@@ -262,3 +263,7 @@ def sign_db_server_cert_with_ca_with_openssl(
262263
],
263264
check=True,
264265
)
266+
267+
268+
class ModelRegistryV1Alpha1(ModelRegistry):
269+
api_version = f"{ModelRegistry.ApiGroup.MODELREGISTRY_OPENDATAHUB_IO}/{ModelRegistry.ApiVersion.V1ALPHA1}"

tests/model_registry/upgrade/test_model_registry_upgrade.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
from tests.model_registry.constants import MODEL_NAME, MODEL_DICT
44
from model_registry.types import RegisteredModel
55
from model_registry import ModelRegistry as ModelRegistryClient
6+
from ocp_resources.model_registry_modelregistry_opendatahub_io import ModelRegistry
67
from simple_logger.logger import get_logger
8+
from tests.model_registry.rest_api.utils import ModelRegistryV1Alpha1
79

810
LOGGER = 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

Comments
 (0)