Skip to content

Add validation for MR to be ready after it is GA#574

Merged
dbasunag merged 6 commits intoopendatahub-io:mainfrom
fege:mr_default
Sep 15, 2025
Merged

Add validation for MR to be ready after it is GA#574
dbasunag merged 6 commits intoopendatahub-io:mainfrom
fege:mr_default

Conversation

@fege
Copy link
Copy Markdown
Contributor

@fege fege commented Sep 1, 2025

Description

How Has This Been Tested?

Merge criteria:

  • The commits are squashed in a cohesive manner and have meaningful messages.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work

Summary by CodeRabbit

  • Tests
    • Added automated health checks for the Model Registry on the Data Science Cluster. Verifies the component is managed, confirms the registry namespace exists and is active, and asserts the registry reports readiness. These tests improve confidence in cluster health, surface deployment or configuration issues earlier, and reduce release risk by catching regressions in Model Registry availability.

@fege fege requested review from dbasunag and lugi0 as code owners September 1, 2025 16:22
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Sep 1, 2025

📝 Walkthrough

Walkthrough

Adds a new pytest module that verifies the Data Science Cluster's Model Registry managementState is MANAGED, its registries namespace exists and is Active, and the Model Registry readiness condition in the DSC status is True.

Changes

Cohort / File(s) Summary
New MR health tests
tests/model_registry/cluster_health/test_mr_default.py
Adds TestMrDefault with three tests: test_mr_management_state (asserts DscComponents.MODELREGISTRY managementState is MANAGED), test_mr_namespace_exists_and_active (ensures registries namespace exists and is Active, matches py_config["model_registry_namespace"]), and test_mr_condition_in_dsc (asserts the MR readiness condition in DataScienceCluster.status.conditions is "True"). Introduces imports: pytest, DscComponents, DataScienceCluster, Namespace, get_logger, and py_config; defines module-level LOGGER.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 1, 2025

The following are automatically added/executed:

  • PR size label.
  • Run pre-commit
  • Run tox
  • Add PR author as the PR assignee
  • Build image based on the PR

Available user actions:

  • To mark a PR as WIP, add /wip in a comment. To remove it from the PR comment /wip cancel to the PR.
  • To block merging of a PR, add /hold in a comment. To un-block merging of PR comment /hold cancel.
  • To mark a PR as approved, add /lgtm in a comment. To remove, add /lgtm cancel.
    lgtm label removed on each new commit push.
  • To mark PR as verified comment /verified to the PR, to un-verify comment /verified cancel to the PR.
    verified label removed on each new commit push.
  • To Cherry-pick a merged PR /cherry-pick <target_branch_name> to the PR. If <target_branch_name> is valid,
    and the current PR is merged, a cherry-picked PR would be created and linked to the current PR.
  • To build and push image to quay, add /build-push-pr-image in a comment. This would create an image with tag
    pr-<pr_number> to quay repository. This image tag, however would be deleted on PR merge or close action.
Supported labels

{'/verified', '/build-push-pr-image', '/wip', '/lgtm', '/cherry-pick', '/hold'}

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
tests/model_registry/cluster_health/test_mr_default.py (2)

31-37: Defensive check for missing DSC status.conditions

If status or conditions is absent, the loop raises; fail cleanly with a clear reason.

-        for condition in dsc_resource.instance.status.conditions:
+        conditions = getattr(getattr(dsc_resource.instance, "status", None), "conditions", None)
+        if not conditions:
+            pytest.fail("DSC status.conditions missing; MR not ready")
+        for condition in conditions:
             if condition.type == DscComponents.COMPONENT_MAPPING[DscComponents.MODELREGISTRY]:
                 LOGGER.info(f"MR ready in DSC: {condition.status}")
                 assert condition.status == "True"
                 break
         else:
             pytest.fail("MR not ready in DSC")

23-30: Improve debuggability with assertion messages (optional)

Adding short messages helps triage when this fails in CI.

-        assert (
+        assert (
             dsc_resource.instance.spec.components[DscComponents.MODELREGISTRY].managementState
             == DscComponents.ManagementState.MANAGED
-        )
+        ), "Expected MR managementState=Managed in DSC"
@@
-        assert namespace.instance.status.phase == Namespace.Status.ACTIVE
+        assert namespace.instance.status.phase == Namespace.Status.ACTIVE, "MR namespace not Active"
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 97aac18 and 18ffda3.

📒 Files selected for processing (1)
  • tests/model_registry/cluster_health/test_mr_default.py (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: dbasunag
PR: opendatahub-io/opendatahub-tests#354
File: tests/model_registry/rbac/test_mr_rbac.py:64-77
Timestamp: 2025-06-16T11:26:53.789Z
Learning: In Model Registry RBAC tests, client instantiation tests are designed to verify the ability to create and use the MR python client, with actual API functionality testing covered by separate existing tests.
📚 Learning: 2025-06-16T11:26:53.789Z
Learnt from: dbasunag
PR: opendatahub-io/opendatahub-tests#354
File: tests/model_registry/rbac/test_mr_rbac.py:64-77
Timestamp: 2025-06-16T11:26:53.789Z
Learning: In Model Registry RBAC tests, client instantiation tests are designed to verify the ability to create and use the MR python client, with actual API functionality testing covered by separate existing tests.

Applied to files:

  • tests/model_registry/cluster_health/test_mr_default.py
🧬 Code graph analysis (1)
tests/model_registry/cluster_health/test_mr_default.py (3)
utilities/infra.py (1)
  • get_data_science_cluster (868-869)
utilities/constants.py (2)
  • DscComponents (156-177)
  • ManagementState (162-164)
tests/conftest.py (2)
  • admin_client (66-67)
  • dsc_resource (415-416)
🔇 Additional comments (1)
tests/model_registry/cluster_health/test_mr_default.py (1)

15-21: LGTM: Scope and checks align with MR GA readiness validation

The three checks (managementState, namespace phase, readiness condition) are appropriate for post-GA validation.

Comment thread tests/model_registry/cluster_health/test_mr_default.py Outdated
Comment thread tests/model_registry/cluster_health/test_mr_default.py Outdated
Comment thread tests/model_registry/cluster_health/test_mr_default.py Outdated
@fege fege requested a review from lugi0 September 2, 2025 10:04
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
tests/model_registry/cluster_health/test_mr_default.py (1)

22-26: Use the configured DSC name (or the dsc_resource fixture) to avoid targeting the wrong cluster

Calling get_data_science_cluster without dsc_name defaults to "default-dsc", which may not match the environment’s DSC.

-        dsc_resource = get_data_science_cluster(client=admin_client)
+        dsc_resource = get_data_science_cluster(
+            client=admin_client, dsc_name=py_config["dsc_name"]
+        )

(Optional) Alternatively, inject the existing dsc_resource fixture and drop this call.

🧹 Nitpick comments (1)
tests/model_registry/cluster_health/test_mr_default.py (1)

34-40: Optional: Clearer failure when DSC conditions are missing

Guarding against absent/empty conditions yields a more actionable failure than a TypeError from iterating None.

-        for condition in dsc_resource.instance.status.conditions:
+        conditions = getattr(dsc_resource.instance.status, "conditions", None)
+        assert conditions, "DSC status.conditions is empty"
+        for condition in conditions:
             if condition.type == DscComponents.COMPONENT_MAPPING[DscComponents.MODELREGISTRY]:
                 LOGGER.info(f"MR ready in DSC: {condition.status}")
                 assert condition.status == "True"
                 break
         else:
             pytest.fail("MR not ready in DSC")
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 8488ef1 and 64b9ad2.

📒 Files selected for processing (1)
  • tests/model_registry/cluster_health/test_mr_default.py (1 hunks)
🧰 Additional context used
🧠 Learnings (6)
📚 Learning: 2025-09-02T07:29:44.457Z
Learnt from: fege
PR: opendatahub-io/opendatahub-tests#574
File: tests/model_registry/cluster_health/test_mr_default.py:28-29
Timestamp: 2025-09-02T07:29:44.457Z
Learning: In tests/model_registry/cluster_health/test_mr_default.py, passing admin_client to Namespace constructor is not necessary according to fege, indicating the current approach without explicit client parameter is acceptable for this test.

Applied to files:

  • tests/model_registry/cluster_health/test_mr_default.py
📚 Learning: 2025-08-11T12:14:34.102Z
Learnt from: dbasunag
PR: opendatahub-io/opendatahub-tests#504
File: tests/model_registry/upgrade/conftest.py:20-30
Timestamp: 2025-08-11T12:14:34.102Z
Learning: In tests/model_registry/upgrade/conftest.py, when using ResourceEditor to patch DataScienceCluster resources with a partial components dictionary like `{DscComponents.MODELREGISTRY: {"managementState": ...}}`, the patch is applied correctly without overwriting other components in spec.components. ResourceEditor performs the appropriate merge operation for this resource type.

Applied to files:

  • tests/model_registry/cluster_health/test_mr_default.py
📚 Learning: 2025-08-21T19:08:14.982Z
Learnt from: dbasunag
PR: opendatahub-io/opendatahub-tests#527
File: tests/model_registry/rbac/conftest.py:358-359
Timestamp: 2025-08-21T19:08:14.982Z
Learning: In tests/model_registry/rbac/conftest.py, the model catalog configmap only exists in one specific namespace (py_config["model_registry_namespace"]) regardless of where model registry instances are deployed, making it a shared resource that serves all model registry instances across namespaces.

Applied to files:

  • tests/model_registry/cluster_health/test_mr_default.py
📚 Learning: 2025-07-17T15:43:04.876Z
Learnt from: lugi0
PR: opendatahub-io/opendatahub-tests#446
File: tests/model_registry/conftest.py:579-591
Timestamp: 2025-07-17T15:43:04.876Z
Learning: In tests/model_registry/conftest.py, Service resources can be created without explicitly passing the admin_client parameter when using the context manager approach with "with Service()". The client parameter is optional for Service resource creation.

Applied to files:

  • tests/model_registry/cluster_health/test_mr_default.py
📚 Learning: 2025-07-17T15:43:04.876Z
Learnt from: lugi0
PR: opendatahub-io/opendatahub-tests#446
File: tests/model_registry/conftest.py:579-591
Timestamp: 2025-07-17T15:43:04.876Z
Learning: In tests/model_registry/conftest.py, the db_service_1 and db_service_2 fixtures do not require the admin_client parameter for Service resource creation, despite the existing model_registry_db_service fixture using client=admin_client. This inconsistency was confirmed as intentional by user lugi0.

Applied to files:

  • tests/model_registry/cluster_health/test_mr_default.py
📚 Learning: 2025-06-16T11:26:53.789Z
Learnt from: dbasunag
PR: opendatahub-io/opendatahub-tests#354
File: tests/model_registry/rbac/test_mr_rbac.py:64-77
Timestamp: 2025-06-16T11:26:53.789Z
Learning: In Model Registry RBAC tests, client instantiation tests are designed to verify the ability to create and use the MR python client, with actual API functionality testing covered by separate existing tests.

Applied to files:

  • tests/model_registry/cluster_health/test_mr_default.py
🧬 Code graph analysis (1)
tests/model_registry/cluster_health/test_mr_default.py (3)
utilities/infra.py (1)
  • get_data_science_cluster (868-869)
utilities/constants.py (2)
  • DscComponents (156-177)
  • ManagementState (162-164)
tests/conftest.py (2)
  • admin_client (66-67)
  • dsc_resource (415-416)
🔇 Additional comments (1)
tests/model_registry/cluster_health/test_mr_default.py (1)

31-33: LGTM: Validates registries namespace matches configured expectation

Asserting the resolved registries namespace equals py_config["model_registry_namespace"] addresses earlier feedback and prevents drift.

Comment thread tests/model_registry/cluster_health/test_mr_default.py
Comment thread tests/model_registry/cluster_health/test_mr_default.py
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
tests/model_registry/cluster_health/test_mr_default.py (1)

25-31: Don’t mutate cluster state in a health check; also guard for missing Namespace

Remove ensure_exists=True so the test doesn’t create the namespace, and assert instance is present before reading status. (Acknowledging prior feedback; not adding client=admin_client per learning that it’s unnecessary here.)

-        namespace = Namespace(
-            name=dsc_resource.instance.spec.components[DscComponents.MODELREGISTRY].registriesNamespace,
-            ensure_exists=True,
-        )
-        assert namespace.instance.status.phase == Namespace.Status.ACTIVE
+        namespace = Namespace(
+            name=dsc_resource.instance.spec.components[DscComponents.MODELREGISTRY].registriesNamespace
+        )
+        assert namespace.instance is not None, "MR registriesNamespace not found; health check must not create it"
+        assert namespace.instance.status.phase == Namespace.Status.ACTIVE
         assert namespace.instance.metadata.name == py_config["model_registry_namespace"]
🧹 Nitpick comments (1)
tests/model_registry/cluster_health/test_mr_default.py (1)

32-39: Make readiness-condition lookup robust and clearer

Handle absent status/conditions and avoid the for-else by selecting the condition directly.

-        for condition in dsc_resource.instance.status.conditions:
-            if condition.type == DscComponents.COMPONENT_MAPPING[DscComponents.MODELREGISTRY]:
-                assert condition.status == "True"
-                break
-        else:
-            pytest.fail("MR ready condition not found in DSC")
+        expected_type = DscComponents.COMPONENT_MAPPING[DscComponents.MODELREGISTRY]
+        conditions = (getattr(dsc_resource.instance, "status", None) and dsc_resource.instance.status.conditions) or []
+        cond = next((c for c in conditions if c.type == expected_type), None)
+        assert cond is not None, f"{expected_type} condition not found in DSC status"
+        assert cond.status == "True"
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 64b9ad2 and 21f37cc.

📒 Files selected for processing (1)
  • tests/model_registry/cluster_health/test_mr_default.py (1 hunks)
🧰 Additional context used
🧠 Learnings (5)
📚 Learning: 2025-09-02T07:29:44.473Z
Learnt from: fege
PR: opendatahub-io/opendatahub-tests#574
File: tests/model_registry/cluster_health/test_mr_default.py:28-29
Timestamp: 2025-09-02T07:29:44.473Z
Learning: In tests/model_registry/cluster_health/test_mr_default.py, passing admin_client to Namespace constructor is not necessary according to fege, indicating the current approach without explicit client parameter is acceptable for this test.

Applied to files:

  • tests/model_registry/cluster_health/test_mr_default.py
📚 Learning: 2025-08-11T12:14:34.102Z
Learnt from: dbasunag
PR: opendatahub-io/opendatahub-tests#504
File: tests/model_registry/upgrade/conftest.py:20-30
Timestamp: 2025-08-11T12:14:34.102Z
Learning: In tests/model_registry/upgrade/conftest.py, when using ResourceEditor to patch DataScienceCluster resources with a partial components dictionary like `{DscComponents.MODELREGISTRY: {"managementState": ...}}`, the patch is applied correctly without overwriting other components in spec.components. ResourceEditor performs the appropriate merge operation for this resource type.

Applied to files:

  • tests/model_registry/cluster_health/test_mr_default.py
📚 Learning: 2025-08-21T19:08:14.982Z
Learnt from: dbasunag
PR: opendatahub-io/opendatahub-tests#527
File: tests/model_registry/rbac/conftest.py:358-359
Timestamp: 2025-08-21T19:08:14.982Z
Learning: In tests/model_registry/rbac/conftest.py, the model catalog configmap only exists in one specific namespace (py_config["model_registry_namespace"]) regardless of where model registry instances are deployed, making it a shared resource that serves all model registry instances across namespaces.

Applied to files:

  • tests/model_registry/cluster_health/test_mr_default.py
📚 Learning: 2025-07-17T15:43:04.876Z
Learnt from: lugi0
PR: opendatahub-io/opendatahub-tests#446
File: tests/model_registry/conftest.py:579-591
Timestamp: 2025-07-17T15:43:04.876Z
Learning: In tests/model_registry/conftest.py, Service resources can be created without explicitly passing the admin_client parameter when using the context manager approach with "with Service()". The client parameter is optional for Service resource creation.

Applied to files:

  • tests/model_registry/cluster_health/test_mr_default.py
📚 Learning: 2025-07-17T15:43:04.876Z
Learnt from: lugi0
PR: opendatahub-io/opendatahub-tests#446
File: tests/model_registry/conftest.py:579-591
Timestamp: 2025-07-17T15:43:04.876Z
Learning: In tests/model_registry/conftest.py, the db_service_1 and db_service_2 fixtures do not require the admin_client parameter for Service resource creation, despite the existing model_registry_db_service fixture using client=admin_client. This inconsistency was confirmed as intentional by user lugi0.

Applied to files:

  • tests/model_registry/cluster_health/test_mr_default.py
🧬 Code graph analysis (1)
tests/model_registry/cluster_health/test_mr_default.py (2)
utilities/constants.py (2)
  • DscComponents (156-177)
  • ManagementState (162-164)
tests/conftest.py (1)
  • dsc_resource (415-416)
🔇 Additional comments (1)
tests/model_registry/cluster_health/test_mr_default.py (1)

16-21: LGTM: managementState check is correct and targeted

Compares against the canonical constant and uses the injected DSC fixture.

@dbasunag dbasunag merged commit c5ca79f into opendatahub-io:main Sep 15, 2025
11 checks passed
@github-actions
Copy link
Copy Markdown

Status of building tag latest: success.
Status of pushing tag latest to image registry: success.

@fege fege deleted the mr_default branch September 23, 2025 13:14
mwaykole pushed a commit to mwaykole/opendatahub-tests that referenced this pull request Jan 23, 2026
* change: add validation for MR to be ready after it is GA

* change: use registerd namespace

* change: assert ns name based on distribution

* change: split test and use fixture for the dsc_resource

---------

Co-authored-by: Debarati Basu-Nag <dbasunag@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants