Skip to content

Tests for stopping and resuming an ISVC#370

Merged
israel-hdez merged 35 commits intoopendatahub-io:mainfrom
hdefazio:feat/stop_resume_model
Jul 7, 2025
Merged

Tests for stopping and resuming an ISVC#370
israel-hdez merged 35 commits intoopendatahub-io:mainfrom
hdefazio:feat/stop_resume_model

Conversation

@hdefazio
Copy link
Copy Markdown
Contributor

@hdefazio hdefazio commented Jun 20, 2025

Description

Adds tests for the stop and resume feature added in kserve/kserve#4337 and kserve/kserve#4455

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

@hdefazio hdefazio requested a review from a team as a code owner June 20, 2025 14:49
@hdefazio hdefazio marked this pull request as draft June 20, 2025 14:50
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jun 20, 2025

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added tests for stop and resume functionality in serverless ONNX model serving, verifying pod creation and deletion based on annotation state.
    • Introduced utility functions and fixtures to support dynamic annotation patching and consistent pod absence verification.
  • Bug Fixes

    • Improved test reliability by explicitly asserting pod absence in serverless scale-to-zero scenarios.
  • Refactor

    • Updated pod verification utilities to return boolean results and support configurable timeouts.
    • Enhanced annotation management for deployment mode and stop/resume control.
  • Chores

    • Added new constants for annotation keys and API groups to improve maintainability.
## Summary by CodeRabbit

* **New Features**
  * Introduced support for controlling model serving pod rollout using a new "stop" annotation for KServe ONNX deployments.
  * Added end-to-end tests validating stop and resume behavior for both raw and serverless KServe model serving.
  * Provided fixtures to facilitate dynamic patching of the stop annotation during tests.

* **Bug Fixes**
  * None.

* **Refactor**
  * Improved test fixture structure for consistency and maintainability.

* **Chores**
  * Updated constants to centralize KServe annotation keys.

## Walkthrough

This change introduces support for a "stop" annotation in KServe InferenceService deployment and testing utilities. It adds and utilizes new constants for annotation keys, updates the `create_isvc` function to handle the stop annotation, and introduces new end-to-end tests verifying stop/resume behavior for ONNX models in both raw and serverless KServe environments.

## Changes

| Files / Groups                                                                 | Change Summary                                                                                                                    |
|-------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
| tests/model_serving/model_server/conftest.py                                  | Added support for an optional "stop" parameter in KServe-related pytest fixtures, passing it to `create_isvc` as "stop_resume".   |
| tests/model_serving/model_server/stop_resume/conftest.py                      | Added pytest fixtures patching InferenceService resources with stop annotation set to "true" or "false" for raw and serverless.  |
| tests/model_serving/model_server/stop_resume/test_raw_stop_resume_model.py    | New test module: End-to-end tests for raw ONNX model serving with stop/resume annotation behavior.                                |
| tests/model_serving/model_server/stop_resume/test_serverless_stop_resume_model.py | New test module: End-to-end tests for serverless ONNX model serving with stop/resume annotation behavior.                         |
| tests/model_serving/model_server/stop_resume/utils.py                         | Added utility function to verify absence of inference pods within a timeout period for stop/resume tests.                        |
| utilities/constants.py                                                        | Added `KSERVE` API group constant, refactored annotation keys to use it, and introduced `FORCE_STOP_RUNTIME` annotation key.      |
| utilities/inference_utils.py                                                  | Updated `create_isvc` to accept a `stop_resume` parameter, apply the stop annotation, and adjust pod readiness logic accordingly. |

## Suggested labels

`size/m`

## Suggested reviewers

- dbasunag  
- adolfo-ab

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Pylint (3.3.7)
tests/model_serving/model_server/stop_resume/utils.py

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3af8532 and 3344265.

📒 Files selected for processing (1)
  • tests/model_serving/model_server/stop_resume/utils.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/model_serving/model_server/stop_resume/utils.py
✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai 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.

Documentation and Community

  • 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.

@hdefazio hdefazio changed the title [WIP] Rough draft for adding tests for stopping and resuming an ISVC [WIP] Tests for stopping and resuming an ISVC Jun 20, 2025
@github-actions
Copy link
Copy Markdown

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

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

@hdefazio hdefazio force-pushed the feat/stop_resume_model branch from 2e71f46 to 342a5e4 Compare June 20, 2025 14:53
@hdefazio
Copy link
Copy Markdown
Contributor Author

/wip

…rless failing tests.

Signed-off-by: Andres Llausas <allausas@redhat.com>
@hdefazio hdefazio changed the title [WIP] Tests for stopping and resuming an ISVC Tests for stopping and resuming an ISVC Jun 20, 2025
@hdefazio hdefazio marked this pull request as ready for review June 20, 2025 17:25
@hdefazio
Copy link
Copy Markdown
Contributor Author

/wip cancel

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

🧹 Nitpick comments (4)
utilities/inference_utils.py (1)

717-717: Consider more robust string comparison for stop_resume checks.

The current string comparison stop_resume != "True" might be brittle. Consider making it case-insensitive or using a boolean conversion for better robustness.

Consider this approach for more robust comparison:

-        if wait_for_predictor_pods and stop_resume != "True":
+        if wait_for_predictor_pods and stop_resume.lower() != "true":

And similarly for line 731:

-        if wait and stop_resume != "True":
+        if wait and stop_resume.lower() != "true":

Also applies to: 731-731

tests/model_serving/model_server/stop_resume/test_raw_stop_resume_model.py (1)

62-63: Improve docstring formatting consistency.

Some docstrings are not properly formatted. Consider using consistent triple-quote placement.

Apply this formatting for consistency:

-        """Verify pods do not exist"""
+        # Verify pods do not exist

Or use proper multi-line docstring format:

-        """Verify pods do not exist"""
+        """
+        Verify pods do not exist
+        """

Also applies to: 88-89, 103-104

tests/model_serving/model_server/stop_resume/test_serverless_stop_resume_model.py (2)

62-63: Improve docstring formatting consistency.

Same formatting issues as in the raw test file. Consider using consistent docstring formatting.

Apply consistent formatting as suggested in the raw test file review.

Also applies to: 88-89, 103-104


1-111: Consider refactoring to reduce code duplication.

This test file is nearly identical to test_raw_stop_resume_model.py. Consider creating a base test class or shared utilities to reduce duplication and improve maintainability.

You could create a base test class with common test methods and have deployment-specific classes inherit from it, or use shared utility functions for common test patterns.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 04a254e and 2d4dd0d.

📒 Files selected for processing (5)
  • tests/model_serving/model_server/conftest.py (2 hunks)
  • tests/model_serving/model_server/stop_resume/test_raw_stop_resume_model.py (1 hunks)
  • tests/model_serving/model_server/stop_resume/test_serverless_stop_resume_model.py (1 hunks)
  • utilities/constants.py (2 hunks)
  • utilities/inference_utils.py (4 hunks)
🔇 Additional comments (7)
utilities/constants.py (2)

123-123: Good addition of centralized API group constant.

Adding the KSERVE constant centralizes the API group string and improves maintainability across the codebase.


134-135: Excellent refactoring to use centralized constants.

The refactoring of DEPLOYMENT_MODE to use the centralized ApiGroups.KSERVE constant and the addition of FORCE_STOP_RUNTIME improve consistency and maintainability. This follows the DRY principle effectively.

tests/model_serving/model_server/conftest.py (2)

362-363: Good parameter handling for stop functionality.

The addition of stop parameter handling is consistent with the new stop/resume feature requirements.


377-392: Excellent refactoring improves readability and consistency.

The refactoring to build the isvc_kwargs dictionary before calling create_isvc improves readability and maintains consistency with the ovms_kserve_inference_service fixture. The addition of stop parameter handling follows the same pattern.

utilities/inference_utils.py (1)

571-571: Good addition of stop_resume parameter.

The new parameter supports the stop/resume functionality as intended.

tests/model_serving/model_server/stop_resume/test_raw_stop_resume_model.py (1)

1-111: Comprehensive test coverage for raw deployment stop/resume functionality.

The test module provides excellent coverage of the stop/resume functionality for raw deployments. The test scenarios are well-structured and cover all the expected use cases:

  1. Inference works when stop annotation is "False"
  2. Updating stop annotation to "true" deletes pods
  3. No pods exist when stop annotation starts as "True"
  4. Updating stop annotation to "false" creates pods and enables inference

The use of constants and proper pytest parametrization is commendable.

tests/model_serving/model_server/stop_resume/test_serverless_stop_resume_model.py (1)

1-111: Comprehensive test coverage for serverless deployment stop/resume functionality.

The test module mirrors the raw deployment tests effectively, providing comprehensive coverage for serverless deployments. The test scenarios properly validate all aspects of the stop/resume functionality.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@adolfo-ab adolfo-ab left a comment

Choose a reason for hiding this comment

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

lgtm once @dbasunag comments are addressed

@brettmthompson
Copy link
Copy Markdown
Contributor

@hdefazio I created a fixture similar to what you would need here in my last PR. You can create an identical one, but for ovms_kserve_inference_service

https://github.com/opendatahub-io/opendatahub-tests/blob/main/tests/model_serving/model_server/conftest.py#L143

…ching isvcs.

Signed-off-by: Andres Llausas <allausas@redhat.com>
@andresllh
Copy link
Copy Markdown
Member

@hdefazio I created a fixture similar to what you would need here in my last PR. You can create an identical one, but for ovms_kserve_inference_service

https://github.com/opendatahub-io/opendatahub-tests/blob/main/tests/model_serving/model_server/conftest.py#L143

I had not seen this, but this is example I used hahaha.

@github-actions github-actions bot added size/xl and removed size/l labels Jun 25, 2025
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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ba27c5c and 1571e56.

📒 Files selected for processing (3)
  • tests/model_serving/model_server/stop_resume/test_raw_stop_resume_model.py (1 hunks)
  • tests/model_serving/model_server/stop_resume/test_serverless_stop_resume_model.py (1 hunks)
  • tests/model_serving/model_server/stop_resume/utils.py (1 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: israel-hdez
PR: opendatahub-io/opendatahub-tests#346
File: tests/model_serving/model_server/inference_graph/conftest.py:85-92
Timestamp: 2025-06-11T16:40:11.593Z
Learning: The helper `create_isvc` (used in tests/model_serving utilities) already waits until the created InferenceService reports Condition READY=True before returning, so additional readiness waits in fixtures are unnecessary.
tests/model_serving/model_server/stop_resume/utils.py (1)
Learnt from: israel-hdez
PR: opendatahub-io/opendatahub-tests#346
File: tests/model_serving/model_server/inference_graph/conftest.py:85-92
Timestamp: 2025-06-11T16:40:11.593Z
Learning: The helper `create_isvc` (used in tests/model_serving utilities) already waits until the created InferenceService reports Condition READY=True before returning, so additional readiness waits in fixtures are unnecessary.
tests/model_serving/model_server/stop_resume/test_raw_stop_resume_model.py (2)
Learnt from: israel-hdez
PR: opendatahub-io/opendatahub-tests#346
File: tests/model_serving/model_server/inference_graph/conftest.py:85-92
Timestamp: 2025-06-11T16:40:11.593Z
Learning: The helper `create_isvc` (used in tests/model_serving utilities) already waits until the created InferenceService reports Condition READY=True before returning, so additional readiness waits in fixtures are unnecessary.
Learnt from: adolfo-ab
PR: opendatahub-io/opendatahub-tests#334
File: tests/model_explainability/trustyai_service/test_trustyai_service.py:52-65
Timestamp: 2025-06-05T10:05:17.642Z
Learning: For TrustyAI image validation tests: operator image tests require admin_client, related_images_refs, and trustyai_operator_configmap fixtures, while service image tests would require different fixtures like trustyai_service_with_pvc_storage, model_namespace, and current_client_token.
tests/model_serving/model_server/stop_resume/test_serverless_stop_resume_model.py (2)
Learnt from: israel-hdez
PR: opendatahub-io/opendatahub-tests#346
File: tests/model_serving/model_server/inference_graph/conftest.py:85-92
Timestamp: 2025-06-11T16:40:11.593Z
Learning: The helper `create_isvc` (used in tests/model_serving utilities) already waits until the created InferenceService reports Condition READY=True before returning, so additional readiness waits in fixtures are unnecessary.
Learnt from: adolfo-ab
PR: opendatahub-io/opendatahub-tests#334
File: tests/model_explainability/trustyai_service/test_trustyai_service.py:52-65
Timestamp: 2025-06-05T10:05:17.642Z
Learning: For TrustyAI image validation tests: operator image tests require admin_client, related_images_refs, and trustyai_operator_configmap fixtures, while service image tests would require different fixtures like trustyai_service_with_pvc_storage, model_namespace, and current_client_token.
🧬 Code Graph Analysis (1)
tests/model_serving/model_server/stop_resume/utils.py (1)
tests/model_serving/model_server/serverless/utils.py (1)
  • verify_no_inference_pods (20-50)
🪛 Pylint (3.3.7)
tests/model_serving/model_server/stop_resume/test_raw_stop_resume_model.py

[refactor] 54-54: Too many arguments (6/5)

(R0913)


[refactor] 54-54: Too many positional arguments (6/5)

(R0917)


[refactor] 111-111: Too many arguments (6/5)

(R0913)


[refactor] 111-111: Too many positional arguments (6/5)

(R0917)

tests/model_serving/model_server/stop_resume/test_serverless_stop_resume_model.py

[refactor] 55-55: Too many arguments (6/5)

(R0913)


[refactor] 55-55: Too many positional arguments (6/5)

(R0917)


[refactor] 112-112: Too many arguments (6/5)

(R0913)


[refactor] 112-112: Too many positional arguments (6/5)

(R0917)

🔇 Additional comments (4)
tests/model_serving/model_server/stop_resume/test_raw_stop_resume_model.py (1)

64-68: Function usage will be affected by utility fix.

This usage of verify_no_pods_exist_with_timeout will need to be reviewed after the critical logic issue in the utility function is resolved (see comment on utils.py).

tests/model_serving/model_server/stop_resume/test_serverless_stop_resume_model.py (3)

65-69: Function usage will be affected by utility fix.

This usage of verify_no_pods_exist_with_timeout will need to be reviewed after the critical logic issue in the utility function is resolved (see comment on utils.py).


101-105: Function usage will be affected by utility fix.

This usage of verify_no_pods_exist_with_timeout will need to be reviewed after the critical logic issue in the utility function is resolved (see comment on utils.py).


20-36: Good consistent parametrization between test classes.

Both test classes in this file properly include the deployment-mode parameter, maintaining consistency. This is better than the raw deployment tests which have inconsistent parametrization.

Signed-off-by: Andres Llausas <allausas@redhat.com>
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

🧹 Nitpick comments (3)
tests/model_serving/model_server/stop_resume/test_raw_stop_resume_model.py (3)

61-62: Remove redundant docstring.

The method has two separate docstrings that should be combined into one clear description.

-    def test_stop_and_update_to_true_delete_pod_rollout(
-        self,
-        unprivileged_client,
-        unprivileged_model_namespace,
-        ovms_kserve_serving_runtime,
-        ovms_raw_inference_service,
-        patched_raw_inference_service_stop_annotation,
-    ):
-        """Verify pod rollout is deleted when the stop annotation updated to true"""
-        """Verify pods do not exist"""
+    def test_stop_and_update_to_true_delete_pod_rollout(
+        self,
+        unprivileged_client,
+        unprivileged_model_namespace,
+        ovms_kserve_serving_runtime,
+        ovms_raw_inference_service,
+        patched_raw_inference_service_stop_annotation,
+    ):
+        """Verify pod rollout is deleted when the stop annotation is updated to true"""

96-97: Remove redundant docstring.

Similar to the previous method, this has two separate docstrings that should be combined.

-    def test_stop_and_true_no_pod_rollout(
-        self,
-        unprivileged_client,
-        unprivileged_model_namespace,
-        ovms_kserve_serving_runtime,
-        ovms_raw_inference_service,
-    ):
-        """Verify no pod rollout when the stop annotation is true"""
-        """Verify pods do not exist"""
+    def test_stop_and_true_no_pod_rollout(
+        self,
+        unprivileged_client,
+        unprivileged_model_namespace,
+        ovms_kserve_serving_runtime,
+        ovms_raw_inference_service,
+    ):
+        """Verify no pod rollout when the stop annotation is true"""

117-118: Remove redundant docstring.

This method also has two separate docstrings that should be combined for clarity.

-    def test_stop_and_update_to_false_pod_rollout(
-        self,
-        unprivileged_client,
-        unprivileged_model_namespace,
-        ovms_kserve_serving_runtime,
-        ovms_raw_inference_service,
-        patched_raw_inference_service_stop_annotation,
-    ):
-        """Verify pod rollout when the stop annotation is updated to false"""
-        """Verify that kserve Raw ONNX model can be queried using REST"""
+    def test_stop_and_update_to_false_pod_rollout(
+        self,
+        unprivileged_client,
+        unprivileged_model_namespace,
+        ovms_kserve_serving_runtime,
+        ovms_raw_inference_service,
+        patched_raw_inference_service_stop_annotation,
+    ):
+        """Verify pod rollout when the stop annotation is updated to false and model can be queried using REST"""
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1571e56 and 53cb343.

📒 Files selected for processing (1)
  • tests/model_serving/model_server/stop_resume/test_raw_stop_resume_model.py (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: israel-hdez
PR: opendatahub-io/opendatahub-tests#346
File: tests/model_serving/model_server/inference_graph/conftest.py:85-92
Timestamp: 2025-06-11T16:40:11.593Z
Learning: The helper `create_isvc` (used in tests/model_serving utilities) already waits until the created InferenceService reports Condition READY=True before returning, so additional readiness waits in fixtures are unnecessary.
tests/model_serving/model_server/stop_resume/test_raw_stop_resume_model.py (8)
Learnt from: israel-hdez
PR: opendatahub-io/opendatahub-tests#346
File: tests/model_serving/model_server/inference_graph/conftest.py:85-92
Timestamp: 2025-06-11T16:40:11.593Z
Learning: The helper `create_isvc` (used in tests/model_serving utilities) already waits until the created InferenceService reports Condition READY=True before returning, so additional readiness waits in fixtures are unnecessary.
Learnt from: dbasunag
PR: opendatahub-io/opendatahub-tests#338
File: tests/model_registry/rbac/test_mr_rbac.py:24-53
Timestamp: 2025-06-06T12:22:57.057Z
Learning: In the opendatahub-tests repository, prefer keeping test parameterization configurations inline rather than extracting them to separate variables/constants, as it makes triaging easier by avoiding the need to jump between different parts of the file to understand the test setup.
Learnt from: jiripetrlik
PR: opendatahub-io/opendatahub-tests#335
File: tests/rag/test_rag.py:0-0
Timestamp: 2025-06-19T14:32:17.658Z
Learning: The `wait_for_replicas()` method from ocp_resources.deployment.Deployment raises an exception when timeout is reached rather than returning a boolean value, so it doesn't need explicit return value checking in tests.
Learnt from: jiripetrlik
PR: opendatahub-io/opendatahub-tests#335
File: tests/rag/test_rag.py:0-0
Timestamp: 2025-06-19T14:32:17.658Z
Learning: The `wait_for_replicas()` method from ocp_resources.deployment.Deployment raises an exception when timeout is reached rather than returning a boolean value, so it doesn't need explicit return value checking in tests.
Learnt from: adolfo-ab
PR: opendatahub-io/opendatahub-tests#334
File: tests/model_explainability/trustyai_service/test_trustyai_service.py:52-65
Timestamp: 2025-06-05T10:05:17.642Z
Learning: For TrustyAI image validation tests: operator image tests require admin_client, related_images_refs, and trustyai_operator_configmap fixtures, while service image tests would require different fixtures like trustyai_service_with_pvc_storage, model_namespace, and current_client_token.
Learnt from: fege
PR: opendatahub-io/opendatahub-tests#320
File: tests/model_registry/rest_api/conftest.py:200-216
Timestamp: 2025-06-05T14:32:40.247Z
Learning: In the opendatahub-tests repository, the test fixtures should raise exceptions on cleanup failures rather than just logging warnings. The user fege prefers strict cleanup behavior where tests fail if cleanup doesn't work properly, rather than silently continuing.
Learnt from: brettmthompson
PR: opendatahub-io/opendatahub-tests#269
File: tests/model_serving/model_server/serverless/test_scale_to_zero.py:0-0
Timestamp: 2025-04-29T00:49:40.918Z
Learning: In test cases for the opendatahub-tests repository, when verifying specific behaviors resulting from a sequence of operations, hard-coded validation values like "configurationGeneration=3" can be appropriate assertions to validate expected states, especially when they represent an invariant that should remain consistent after specific operations.
Learnt from: dbasunag
PR: opendatahub-io/opendatahub-tests#354
File: tests/model_registry/rbac/conftest.py:166-175
Timestamp: 2025-06-16T11:25:39.599Z
Learning: In tests/model_registry/rbac/conftest.py, predictable names are intentionally used for test resources (like RoleBindings and groups) instead of random names. This design choice prioritizes exposing cleanup failures from previous test runs through name collisions rather than masking such issues with random names. The philosophy is that test failures should be observable and informative to help debug underlying infrastructure or cleanup issues.
🪛 Pylint (3.3.7)
tests/model_serving/model_server/stop_resume/test_raw_stop_resume_model.py

[refactor] 53-53: Too many arguments (6/5)

(R0913)


[refactor] 53-53: Too many positional arguments (6/5)

(R0917)


[refactor] 109-109: Too many arguments (6/5)

(R0913)


[refactor] 109-109: Too many positional arguments (6/5)

(R0917)

🔇 Additional comments (1)
tests/model_serving/model_server/stop_resume/test_raw_stop_resume_model.py (1)

1-126: Well-structured test implementation for stop/resume functionality.

The test file effectively covers the KServe stop/resume functionality with appropriate test cases:

  • TestStopRaw: Tests the workflow from running state (stop=False) to stopped state (stop=True)
  • TestStoppedResumeRaw: Tests the workflow from stopped state (stop=True) to running state (stop=False)

The use of pytest parameterization and fixtures follows the established patterns in the codebase, and the test logic correctly validates both the absence of pods when stopped and successful inference when running.

@opendatahub-io opendatahub-io deleted a comment from coderabbitai bot Jul 2, 2025
andresllh and others added 3 commits July 2, 2025 14:41
…mplers. It gives false positives.

Signed-off-by: Andres Llausas <allausas@redhat.com>
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

🧹 Nitpick comments (1)
tests/model_serving/model_server/serverless/utils.py (1)

34-34: Fix docstring inconsistency.

The docstring states "Raises: TimeoutError: If pods exist after the timeout" but the function now returns False instead of raising an exception in this case.

-    Raises:
-        TimeoutError: If pods exist after the timeout.
+    Note:
+        No exceptions are raised on timeout. Returns False if pods exist after timeout.
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 53cb343 and f9a3091.

📒 Files selected for processing (6)
  • tests/model_serving/model_server/serverless/test_scale_to_zero.py (2 hunks)
  • tests/model_serving/model_server/serverless/test_zero_initial_scale.py (1 hunks)
  • tests/model_serving/model_server/serverless/utils.py (1 hunks)
  • tests/model_serving/model_server/stop_resume/test_raw_stop_resume_model.py (1 hunks)
  • tests/model_serving/model_server/stop_resume/test_serverless_stop_resume_model.py (1 hunks)
  • tests/model_serving/model_server/stop_resume/utils.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • tests/model_serving/model_server/stop_resume/utils.py
  • tests/model_serving/model_server/stop_resume/test_raw_stop_resume_model.py
  • tests/model_serving/model_server/stop_resume/test_serverless_stop_resume_model.py
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: israel-hdez
PR: opendatahub-io/opendatahub-tests#346
File: tests/model_serving/model_server/inference_graph/conftest.py:85-92
Timestamp: 2025-06-11T16:40:11.593Z
Learning: The helper `create_isvc` (used in tests/model_serving utilities) already waits until the created InferenceService reports Condition READY=True before returning, so additional readiness waits in fixtures are unnecessary.
tests/model_serving/model_server/serverless/test_scale_to_zero.py (1)
Learnt from: israel-hdez
PR: opendatahub-io/opendatahub-tests#346
File: tests/model_serving/model_server/inference_graph/conftest.py:85-92
Timestamp: 2025-06-11T16:40:11.593Z
Learning: The helper `create_isvc` (used in tests/model_serving utilities) already waits until the created InferenceService reports Condition READY=True before returning, so additional readiness waits in fixtures are unnecessary.
tests/model_serving/model_server/serverless/test_zero_initial_scale.py (2)
Learnt from: israel-hdez
PR: opendatahub-io/opendatahub-tests#346
File: tests/model_serving/model_server/inference_graph/conftest.py:85-92
Timestamp: 2025-06-11T16:40:11.593Z
Learning: The helper `create_isvc` (used in tests/model_serving utilities) already waits until the created InferenceService reports Condition READY=True before returning, so additional readiness waits in fixtures are unnecessary.
Learnt from: adolfo-ab
PR: opendatahub-io/opendatahub-tests#334
File: tests/model_explainability/trustyai_service/test_trustyai_service.py:52-65
Timestamp: 2025-06-05T10:05:17.642Z
Learning: For TrustyAI image validation tests: operator image tests require admin_client, related_images_refs, and trustyai_operator_configmap fixtures, while service image tests would require different fixtures like trustyai_service_with_pvc_storage, model_namespace, and current_client_token.
tests/model_serving/model_server/serverless/utils.py (4)
Learnt from: israel-hdez
PR: opendatahub-io/opendatahub-tests#346
File: tests/model_serving/model_server/inference_graph/conftest.py:85-92
Timestamp: 2025-06-11T16:40:11.593Z
Learning: The helper `create_isvc` (used in tests/model_serving utilities) already waits until the created InferenceService reports Condition READY=True before returning, so additional readiness waits in fixtures are unnecessary.
Learnt from: fege
PR: opendatahub-io/opendatahub-tests#320
File: tests/model_registry/rest_api/utils.py:40-44
Timestamp: 2025-06-18T06:42:37.705Z
Learning: In tests/model_registry/rest_api/utils.py, the user prefers to keep the default value of verify=False in execute_model_registry_post_command to maintain backward compatibility, rather than changing it to True for security reasons.
Learnt from: jiripetrlik
PR: opendatahub-io/opendatahub-tests#335
File: tests/rag/test_rag.py:0-0
Timestamp: 2025-06-19T14:32:17.658Z
Learning: The `wait_for_replicas()` method from ocp_resources.deployment.Deployment raises an exception when timeout is reached rather than returning a boolean value, so it doesn't need explicit return value checking in tests.
Learnt from: jiripetrlik
PR: opendatahub-io/opendatahub-tests#335
File: tests/rag/test_rag.py:0-0
Timestamp: 2025-06-19T14:32:17.658Z
Learning: The `wait_for_replicas()` method from ocp_resources.deployment.Deployment raises an exception when timeout is reached rather than returning a boolean value, so it doesn't need explicit return value checking in tests.
🧬 Code Graph Analysis (3)
tests/model_serving/model_server/serverless/test_scale_to_zero.py (3)
tests/model_serving/model_server/serverless/utils.py (1)
  • verify_no_inference_pods (20-55)
tests/conftest.py (1)
  • unprivileged_client (288-328)
tests/model_serving/model_server/serverless/conftest.py (1)
  • inference_service_patched_replicas (22-36)
tests/model_serving/model_server/serverless/test_zero_initial_scale.py (3)
tests/model_serving/model_server/serverless/utils.py (1)
  • verify_no_inference_pods (20-55)
tests/conftest.py (1)
  • admin_client (55-56)
tests/model_serving/model_server/conftest.py (1)
  • ovms_kserve_inference_service (325-365)
tests/model_serving/model_server/serverless/utils.py (2)
utilities/constants.py (1)
  • Timeout (209-219)
utilities/infra.py (1)
  • get_pods_by_isvc_label (566-593)
🔇 Additional comments (5)
tests/model_serving/model_server/serverless/test_zero_initial_scale.py (1)

44-44: LGTM! Explicit assertion improves test reliability.

The addition of the assert statement properly validates the boolean return value from the updated verify_no_inference_pods function, making the test outcome explicit rather than relying on implicit behavior.

tests/model_serving/model_server/serverless/test_scale_to_zero.py (2)

64-64: LGTM! Consistent with the updated function signature.

The explicit assertion correctly validates the boolean return value from verify_no_inference_pods, improving test clarity and reliability.


87-87: LGTM! Maintains consistency across test methods.

The assertion pattern is consistent with other test methods and properly handles the boolean return value from the updated utility function.

tests/model_serving/model_server/serverless/utils.py (2)

20-22: LGTM! Improved function signature with configurable timeout.

The addition of the wait_timeout parameter with a sensible default and the boolean return type makes the function more flexible and testable.


49-55: LGTM! Proper boolean return logic.

The return logic is well-implemented:

  • Returns True when no pods are found (success case)
  • Returns True when ResourceNotFoundError occurs (also success - no pods exist)
  • Returns False when timeout expires with pods still present (failure case)
  • Includes appropriate error logging for debugging

@brettmthompson
Copy link
Copy Markdown
Contributor

we dont need .mark.smoke here

Regarding Milind's comment above. Do we want these markers removed? It looks like they are still present

Besides that changes lgtm

@andresllh
Copy link
Copy Markdown
Member

andresllh commented Jul 3, 2025

we dont need .mark.smoke here

Regarding Milind's comment above. Do we want these markers removed? It looks like they are still present

Besides that changes lgtm
@brettmthompson
It was an extra marker on the function. I removed that one, but the one for the class is still needed.

@israel-hdez
Copy link
Copy Markdown
Contributor

@brettmthompson @dbasunag @mwaykole For enabling merge, can you mark your comments as resolved, where applicable?

@israel-hdez israel-hdez merged commit 705fd1f into opendatahub-io:main Jul 7, 2025
8 checks passed
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jul 7, 2025

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

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.

8 participants