Skip to content

Refactor test to verify TrustyAIService works with multiple namespaces#408

Merged
adolfo-ab merged 3 commits intoopendatahub-io:mainfrom
kpunwatk:multi_ns
Jul 24, 2025
Merged

Refactor test to verify TrustyAIService works with multiple namespaces#408
adolfo-ab merged 3 commits intoopendatahub-io:mainfrom
kpunwatk:multi_ns

Conversation

@kpunwatk
Copy link
Copy Markdown
Contributor

@kpunwatk kpunwatk commented Jul 8, 2025

Addresses: https://issues.redhat.com/browse/RHOAIENG-28243

Description
This PR removes duplication across fixtures such as model_namespace_2, gaussian_credit_model_2, etc. A new directory has been created to host test classes specifically targeting multi-namespace scenarios. Additionally, a dedicated conftest.py file was introduced to define reusable fixtures capable of iterating over multiple namespaces. The existing test class for PVC-based drift service scenarios has been refactored to leverage this new structure.

@kpunwatk kpunwatk requested a review from a team as a code owner July 8, 2025 11:44
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 8, 2025

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added support for testing TrustyAIService functionality across multiple namespaces, including new fixtures and test cases for multi-namespace scenarios.
  • Tests

    • Introduced comprehensive multi-namespace test coverage for inference, data upload, metric scheduling, and metric deletion.
    • Removed old multi-namespace tests and related fixtures from single-namespace test files to streamline test organization.
  • Refactor

    • Improved resource management in test utilities by explicitly marking resource-creation helpers as context managers for safer setup and cleanup.

Summary by CodeRabbit

  • New Features
    • Introduced comprehensive test coverage for TrustyAI service operations across multiple namespaces, including inference, data upload, drift metric scheduling, and metric deletion.
  • Tests
    • Added new fixtures and test modules to support multi-namespace scenarios.
    • Removed legacy multi-namespace test logic and related fixtures, consolidating multi-namespace testing into a dedicated suite.
  • Refactor
    • Updated utility functions to improve resource management using context managers for cleaner test setup and teardown.

Walkthrough

This change removes all multi-namespace TrustyAIService test fixtures and related logic from the main test configuration, relocating them to a new dedicated module. It introduces a new test suite and fixture set for multi-namespace scenarios and marks resource-creation functions as context managers. The main single-namespace test module is simplified accordingly.

Changes

Files/Paths Change Summary
tests/model_explainability/trustyai_service/service/conftest.py Removed all fixtures and imports for secondary model namespace and associated resources.
tests/model_explainability/trustyai_service/service/multi_ns/conftest.py Added new fixture module for multi-namespace TrustyAIService and resource setup.
tests/model_explainability/trustyai_service/service/multi_ns/test_trustyai_service_multi_ns.py Introduced new test class and tests for TrustyAIService multi-namespace operations.
tests/model_explainability/trustyai_service/service/test_trustyai_service.py Removed the multi-namespace TrustyAIService test class and related imports.
tests/model_explainability/trustyai_service/utils.py Added @contextmanager decorators to resource-creation functions.

Estimated code review effort

2 (~20 minutes)

Possibly related PRs

Suggested labels

size/l, lgtm-by-israel-hdez

Suggested reviewers

  • dbasunag
  • adolfo-ab

📜 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 0140ca2 and e3af2d8.

📒 Files selected for processing (5)
  • tests/model_explainability/trustyai_service/service/conftest.py (0 hunks)
  • tests/model_explainability/trustyai_service/service/multi_ns/conftest.py (1 hunks)
  • tests/model_explainability/trustyai_service/service/multi_ns/test_trustyai_service_multi_ns.py (1 hunks)
  • tests/model_explainability/trustyai_service/service/test_trustyai_service.py (0 hunks)
  • tests/model_explainability/trustyai_service/utils.py (6 hunks)
🧠 Learnings (1)
📓 Common learnings
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.
💤 Files with no reviewable changes (2)
  • tests/model_explainability/trustyai_service/service/conftest.py
  • tests/model_explainability/trustyai_service/service/test_trustyai_service.py
✅ Files skipped from review due to trivial changes (1)
  • tests/model_explainability/trustyai_service/utils.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/model_explainability/trustyai_service/service/multi_ns/test_trustyai_service_multi_ns.py
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
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.
🔇 Additional comments (10)
tests/model_explainability/trustyai_service/service/multi_ns/conftest.py (10)

1-41: LGTM! Well-organized imports for multi-namespace testing.

The import structure is comprehensive and well-organized, properly importing all necessary OCP resources, utilities, and constants. The use of ExitStack for context management is a good practice for handling multiple resources.


43-49: LGTM! Proper context management for multiple namespaces.

The fixture correctly uses ExitStack to manage multiple namespace contexts and follows the parameterized testing pattern. This ensures proper cleanup of all namespaces regardless of test outcome.


52-68: LGTM! Proper multi-namespace MinIO data connection management.

The fixture correctly creates data connection secrets for each namespace using the established context management pattern. The use of zip to pair namespaces with their parameters is appropriate and clean.


71-91: LGTM! Proper TrustyAI service deployment across namespaces.

The fixture correctly creates TrustyAI services with PVC storage for each namespace. Using configuration constants and setting teardown=False with wait_for_replicas=True is appropriate since the ExitStack handles cleanup while ensuring services are ready for testing.


94-113: LGTM! Proper MLServer runtime deployment pattern.

The fixture correctly creates MLServer serving runtimes for each namespace using established configuration constants. The context management pattern is properly implemented.


116-152: LGTM! Comprehensive inference service deployment with proper coordination.

The fixture correctly orchestrates the creation of inference services across multiple namespaces, properly coordinating multiple dependencies. The wait for ISVC registration with TrustyAI service ensures proper initialization before testing.


155-162: LGTM! Proper service account creation pattern.

The fixture correctly creates service accounts for each namespace using the established utility function and context management pattern.


165-172: LGTM! Proper role creation with namespace-specific naming.

The fixture correctly creates roles with unique names per namespace using the pattern f"isvc-getter-{ns.name}", which prevents naming conflicts across namespaces.


175-195: LGTM! Proper role binding coordination across related resources.

The fixture correctly creates role bindings that link roles and service accounts using zip to coordinate the three related fixtures, ensuring proper RBAC relationships across namespaces.


198-225: LGTM! Proper token management with appropriate separation of concerns.

Both fixtures correctly handle authentication token creation. The isvc_getter_token_secret_multi_ns properly manages token secret resources with context cleanup, while isvc_getter_token_multi_ns generates the actual tokens from service accounts. The separation between resource management and token generation is well-designed.

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

@kpunwatk
Copy link
Copy Markdown
Contributor Author

kpunwatk commented Jul 8, 2025

/wip

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jul 8, 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

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

@kpunwatk kpunwatk changed the title [WIP] Refactor to verify TrustyAIService works with multiple ns [WIP] Refactor test to verify TrustyAIService works with multiple ns Jul 8, 2025
Comment thread tests/model_explainability/trustyai_service/service/multi_ns/conftest.py Outdated
Comment thread tests/model_explainability/trustyai_service/service/multi_ns/conftest.py Outdated
Comment thread tests/model_explainability/trustyai_service/service/multi_ns/conftest.py Outdated
Comment thread tests/model_explainability/trustyai_service/service/multi_ns/conftest.py Outdated
Comment thread tests/model_explainability/trustyai_service/service/multi_ns/conftest.py Outdated
Comment thread tests/model_explainability/trustyai_service/service/multi_ns/conftest.py Outdated
Comment thread tests/model_explainability/trustyai_service/service/multi_ns/conftest.py Outdated
Comment thread tests/model_explainability/trustyai_service/service/multi_ns/conftest.py Outdated
Comment thread tests/model_explainability/trustyai_service/service/multi_ns/conftest.py Outdated
@kpunwatk kpunwatk force-pushed the multi_ns branch 3 times, most recently from aa095d3 to 9098f49 Compare July 14, 2025 11:00
@kpunwatk kpunwatk changed the title [WIP] Refactor test to verify TrustyAIService works with multiple ns Refactor test to verify TrustyAIService works with multiple namespaces Jul 14, 2025
@kpunwatk
Copy link
Copy Markdown
Contributor Author

/wip cancel

@kpunwatk
Copy link
Copy Markdown
Contributor Author

/verified

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_explainability/trustyai_service/service/multi_ns/test_trustyai_service_multi_ns.py (1)

58-58: Address the missing tests mentioned in the previous review.

A past review comment indicated that additional tests are missing. Please ensure all necessary test scenarios are covered or create a follow-up issue to track the missing tests.

🧹 Nitpick comments (1)
tests/model_explainability/trustyai_service/service/multi_ns/conftest.py (1)

51-51: Use deploy() instead of create() for namespace creation.

Based on previous review feedback, use ns.deploy() instead of ns.create() as it's more graceful and follows the recommended pattern in the openshift-python-wrapper.

Apply this change:

-        ns.create()
+        ns.deploy()
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e8db035 and 4238bf1.

📒 Files selected for processing (5)
  • tests/model_explainability/trustyai_service/service/conftest.py (0 hunks)
  • tests/model_explainability/trustyai_service/service/multi_ns/conftest.py (1 hunks)
  • tests/model_explainability/trustyai_service/service/multi_ns/test_trustyai_service_multi_ns.py (1 hunks)
  • tests/model_explainability/trustyai_service/service/test_trustyai_service.py (0 hunks)
  • tests/model_explainability/trustyai_service/utils.py (6 hunks)
💤 Files with no reviewable changes (2)
  • tests/model_explainability/trustyai_service/service/test_trustyai_service.py
  • tests/model_explainability/trustyai_service/service/conftest.py
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
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: 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: 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#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.
tests/model_explainability/trustyai_service/service/multi_ns/test_trustyai_service_multi_ns.py (1)
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_explainability/trustyai_service/service/multi_ns/conftest.py (10)
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: 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.
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#401
File: tests/model_registry/rest_api/mariadb/conftest.py:89-110
Timestamp: 2025-07-04T00:17:47.799Z
Learning: In tests/model_registry/rest_api/mariadb/conftest.py, the model_registry_with_mariadb fixture should always use OAUTH_PROXY_CONFIG_DICT for the oauth_proxy parameter regardless of the is_model_registry_oauth parameter value, based on expected product behavior for MariaDB-backed ModelRegistry instances.
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: fege
PR: opendatahub-io/opendatahub-tests#320
File: tests/model_registry/rest_api/conftest.py:257-264
Timestamp: 2025-06-18T08:27:21.114Z
Learning: In tests/model_registry/rest_api/conftest.py, the user fege prefers using next() without a default value to raise StopIteration when the mysql container is not found, rather than gracefully handling it with None checks. This is a deliberate "fail fast" design choice.
Learnt from: dbasunag
PR: opendatahub-io/opendatahub-tests#296
File: tests/model_registry/conftest.py:438-444
Timestamp: 2025-05-06T23:35:36.174Z
Learning: In the ocp-resources library, when creating Kubernetes resources like Role and RoleBinding, it's preferred to use the `ensure_exists=True` constructor parameter instead of calling `.wait()` after resource creation.
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: dbasunag
PR: opendatahub-io/opendatahub-tests#354
File: utilities/user_utils.py:71-76
Timestamp: 2025-06-17T00:29:48.834Z
Learning: In utilities/user_utils.py, the wait_for_user_creation function's retry decorator is intentionally configured to only catch ExceptionUserLogin, not ClusterLoginError. The function catches the result of login_with_user_password and raises ExceptionUserLogin based on the boolean return value, which is the intended retry pattern.
🔇 Additional comments (4)
tests/model_explainability/trustyai_service/utils.py (1)

1-1: Good use of explicit context manager decorators.

Adding the @contextmanager decorator to these generator functions is a good practice. It makes the intent clear and ensures these utilities can be properly used with Python's with statement for resource management.

Also applies to: 119-119, 160-160, 178-178, 205-205, 233-233

tests/model_explainability/trustyai_service/service/multi_ns/test_trustyai_service_multi_ns.py (1)

14-117: Well-structured multi-namespace test implementation.

The test class properly uses parameterization with ns_index to validate TrustyAI service operations across multiple namespaces. The test coverage includes key operations: inference data sending, data upload, metric scheduling, and metric deletion.

tests/model_explainability/trustyai_service/service/multi_ns/conftest.py (2)

94-94: Verify the intention behind teardown=False.

The trustyai_service_with_pvc_storage_multi_ns and mlserver_runtime_multi_ns fixtures use teardown=False, which means these resources won't be automatically cleaned up. This could lead to resource leaks if not handled properly.

Please confirm if this is intentional. If these resources are meant to be cleaned up by the fixture's cleanup logic (via ExitStack), consider setting teardown=True to ensure proper cleanup even if the test fails unexpectedly.

Also applies to: 115-115


1-237: Excellent fixture design for multi-namespace testing.

The fixture structure is well-designed:

  • Proper use of ExitStack for managing multiple context managers
  • Consistent pattern across all fixtures
  • Good separation of concerns with each fixture handling specific resources
  • Proper dependency management between fixtures

@kpunwatk kpunwatk force-pushed the multi_ns branch 5 times, most recently from 05a6f92 to f74a172 Compare July 14, 2025 13:04
@kpunwatk kpunwatk requested a review from adolfo-ab July 14, 2025 15:12
@kpunwatk kpunwatk force-pushed the multi_ns branch 5 times, most recently from b7c2551 to a190a03 Compare July 15, 2025 08:16
@kpunwatk kpunwatk force-pushed the multi_ns branch 3 times, most recently from ae5ad37 to fcdf529 Compare July 16, 2025 10:03
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 (1)
tests/model_explainability/trustyai_service/service/multi_ns/test_trustyai_service_multi_ns.py (1)

103-118: Consider removing unused parameter.

The method correctly implements metric deletion testing. However, the minio_data_connection_multi_ns parameter is not used in the method body.

If this parameter is not required for fixture dependency ordering, consider removing it:

 def test_drift_metric_delete_multiple_ns(
         self,
         ns_index,
         admin_client,
         current_client_token,
-        minio_data_connection_multi_ns,
         trustyai_service_with_pvc_storage_multi_ns
 ):
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9820ecb and 11cbf60.

📒 Files selected for processing (5)
  • tests/model_explainability/trustyai_service/service/conftest.py (0 hunks)
  • tests/model_explainability/trustyai_service/service/multi_ns/conftest.py (1 hunks)
  • tests/model_explainability/trustyai_service/service/multi_ns/test_trustyai_service_multi_ns.py (1 hunks)
  • tests/model_explainability/trustyai_service/service/test_trustyai_service.py (1 hunks)
  • tests/model_explainability/trustyai_service/utils.py (6 hunks)
🧠 Learnings (2)
📓 Common learnings
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: 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: lugi0
PR: opendatahub-io/opendatahub-tests#446
File: tests/model_registry/conftest.py:595-612
Timestamp: 2025-07-17T15:42:04.167Z
Learning: In tests/model_registry/conftest.py, the db_deployment_1 fixture (and similar duplicated resource fixtures) do not require the admin_client parameter or explicit dependencies on related fixtures like db_secret_1, db_pvc_1, and db_service_1, even though the original model_registry_db_deployment fixture includes these parameters.
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.
Learnt from: lugi0
PR: opendatahub-io/opendatahub-tests#446
File: tests/model_registry/conftest.py:733-770
Timestamp: 2025-07-17T15:42:23.880Z
Learning: In tests/model_registry/conftest.py, the model_registry_instance_1 and model_registry_instance_2 fixtures do not need explicit database dependency fixtures (like db_deployment_1, db_secret_1, etc.) in their function signatures. Pytest's dependency injection automatically handles the fixture dependencies when they reference db_name_1 and db_name_2 parameters. This is the correct pattern for these Model Registry instance fixtures.
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: 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.
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.
tests/model_explainability/trustyai_service/service/multi_ns/test_trustyai_service_multi_ns.py (2)

Learnt from: adolfo-ab
PR: #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: Snomaan6846
PR: #444
File: tests/model_serving/model_runtime/mlserver/basic_model_deployment/test_mlserver_basic_model_deployment.py:48-714
Timestamp: 2025-07-16T12:20:29.672Z
Learning: In tests/model_serving/model_runtime/mlserver/basic_model_deployment/test_mlserver_basic_model_deployment.py, the same get_deployment_config_dict() function is called twice in each pytest.param because different fixtures (mlserver_inference_service and mlserver_serving_runtime) need the same deployment configuration data. This duplication is intentional to provide identical configuration to multiple fixtures.

🧬 Code Graph Analysis (1)
tests/model_explainability/trustyai_service/service/multi_ns/test_trustyai_service_multi_ns.py (4)
tests/model_explainability/trustyai_service/trustyai_service_utils.py (6)
  • send_inferences_and_verify_trustyai_service_registered (272-336)
  • verify_upload_data_to_trustyai_service (519-551)
  • TrustyAIServiceMetrics (32-41)
  • verify_trustyai_service_metric_scheduling_request (465-516)
  • verify_trustyai_service_metric_delete_request (554-595)
  • Drift (37-41)
utilities/constants.py (3)
  • MinIo (251-304)
  • PodConfig (267-300)
  • Buckets (263-265)
tests/conftest.py (2)
  • admin_client (65-66)
  • current_client_token (81-82)
tests/model_explainability/trustyai_service/service/multi_ns/conftest.py (5)
  • trustyai_service_with_pvc_storage_multi_ns (73-90)
  • gaussian_credit_model_multi_ns (114-149)
  • isvc_getter_token_multi_ns (215-222)
  • model_namespaces (43-54)
  • minio_data_connection_multi_ns (57-70)
🪛 Flake8 (7.2.0)
tests/model_explainability/trustyai_service/service/multi_ns/test_trustyai_service_multi_ns.py

[error] 72-72: over-indented

(E117)


[error] 89-89: over-indented

(E117)

💤 Files with no reviewable changes (1)
  • tests/model_explainability/trustyai_service/service/conftest.py
✅ Files skipped from review due to trivial changes (1)
  • tests/model_explainability/trustyai_service/utils.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/model_explainability/trustyai_service/service/test_trustyai_service.py
  • tests/model_explainability/trustyai_service/service/multi_ns/conftest.py
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
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: 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: lugi0
PR: opendatahub-io/opendatahub-tests#446
File: tests/model_registry/conftest.py:595-612
Timestamp: 2025-07-17T15:42:04.167Z
Learning: In tests/model_registry/conftest.py, the db_deployment_1 fixture (and similar duplicated resource fixtures) do not require the admin_client parameter or explicit dependencies on related fixtures like db_secret_1, db_pvc_1, and db_service_1, even though the original model_registry_db_deployment fixture includes these parameters.
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.
Learnt from: lugi0
PR: opendatahub-io/opendatahub-tests#446
File: tests/model_registry/conftest.py:733-770
Timestamp: 2025-07-17T15:42:23.880Z
Learning: In tests/model_registry/conftest.py, the model_registry_instance_1 and model_registry_instance_2 fixtures do not need explicit database dependency fixtures (like db_deployment_1, db_secret_1, etc.) in their function signatures. Pytest's dependency injection automatically handles the fixture dependencies when they reference db_name_1 and db_name_2 parameters. This is the correct pattern for these Model Registry instance fixtures.
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: 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.
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.
tests/model_explainability/trustyai_service/service/multi_ns/test_trustyai_service_multi_ns.py (2)

Learnt from: adolfo-ab
PR: #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: Snomaan6846
PR: #444
File: tests/model_serving/model_runtime/mlserver/basic_model_deployment/test_mlserver_basic_model_deployment.py:48-714
Timestamp: 2025-07-16T12:20:29.672Z
Learning: In tests/model_serving/model_runtime/mlserver/basic_model_deployment/test_mlserver_basic_model_deployment.py, the same get_deployment_config_dict() function is called twice in each pytest.param because different fixtures (mlserver_inference_service and mlserver_serving_runtime) need the same deployment configuration data. This duplication is intentional to provide identical configuration to multiple fixtures.

🧬 Code Graph Analysis (1)
tests/model_explainability/trustyai_service/service/multi_ns/test_trustyai_service_multi_ns.py (4)
tests/model_explainability/trustyai_service/trustyai_service_utils.py (6)
  • send_inferences_and_verify_trustyai_service_registered (272-336)
  • verify_upload_data_to_trustyai_service (519-551)
  • TrustyAIServiceMetrics (32-41)
  • verify_trustyai_service_metric_scheduling_request (465-516)
  • verify_trustyai_service_metric_delete_request (554-595)
  • Drift (37-41)
utilities/constants.py (3)
  • MinIo (251-304)
  • PodConfig (267-300)
  • Buckets (263-265)
tests/conftest.py (2)
  • admin_client (65-66)
  • current_client_token (81-82)
tests/model_explainability/trustyai_service/service/multi_ns/conftest.py (5)
  • trustyai_service_with_pvc_storage_multi_ns (73-90)
  • gaussian_credit_model_multi_ns (114-149)
  • isvc_getter_token_multi_ns (215-222)
  • model_namespaces (43-54)
  • minio_data_connection_multi_ns (57-70)
🪛 Flake8 (7.2.0)
tests/model_explainability/trustyai_service/service/multi_ns/test_trustyai_service_multi_ns.py

[error] 72-72: over-indented

(E117)


[error] 89-89: over-indented

(E117)

🔇 Additional comments (4)
tests/model_explainability/trustyai_service/service/multi_ns/test_trustyai_service_multi_ns.py (4)

1-13: LGTM!

The imports are well-organized and all imported modules and constants are appropriately used in the test methods.


15-34: LGTM!

The class definition and parametrization structure correctly sets up multi-namespace testing scenarios. The use of predictable namespace names and proper fixture parametrization follows established patterns.


36-59: LGTM!

The test method correctly implements multi-namespace testing by using the ns_index parameter to select appropriate resources from fixture lists. All required parameters are properly passed to the verification utility function.


33-33: All multi-namespace tests have been migrated successfully.

Verified that the new test_trustyai_service_multi_ns.py includes all four key test methods (inference sending, data upload, drift metric scheduling, and drift metric deletion) and no additional multi-namespace tests or TODO/FIXME markers remain. Everything appears covered.

	new file:   tests/model_explainability/trustyai_service/service/multi_ns/conftest.py
	new file:   tests/model_explainability/trustyai_service/service/multi_ns/test_trustyai_service_multi_ns.py

	new file:   tests/model_explainability/trustyai_service/service/multi_ns/conftest.py

	new file:   tests/model_explainability/trustyai_service/service/multi_ns/conftest.py

	modified:   tests/model_explainability/trustyai_service/service/conftest.py
	new file:   tests/model_explainability/trustyai_service/service/multi_ns/conftest.py
	new file:   tests/model_explainability/trustyai_service/service/multi_ns/test_trustyai_service_multi_ns.py
	modified:   tests/model_explainability/trustyai_service/service/test_trustyai_service.py
	modified:   tests/model_explainability/trustyai_service/utils.py

	new file:   tests/model_explainability/trustyai_service/service/multi_ns/conftest.py

	new file:   tests/model_explainability/trustyai_service/service/multi_ns/conftest.py

	new file:   tests/model_explainability/trustyai_service/service/multi_ns/conftest.pyi

	new file:   tests/model_explainability/trustyai_service/service/multi_ns/conftest.py

	new file:   tests/model_explainability/trustyai_service/service/multi_ns/conftest.py

	new file:   tests/model_explainability/trustyai_service/service/multi_ns/conftest.py

	new file:   tests/model_explainability/trustyai_service/service/multi_ns/conftest.py

	new file:   tests/model_explainability/trustyai_service/service/multi_ns/conftest.py

	new file:   tests/model_explainability/trustyai_service/service/multi_ns/conftest.py

	new file:   tests/model_explainability/trustyai_service/service/multi_ns/conftest.py

	new file:   tests/model_explainability/trustyai_service/service/multi_ns/test_trustyai_service_multi_ns.py

	modified:   tests/model_explainability/trustyai_service/service/conftest.py
	new file:   tests/model_explainability/trustyai_service/service/multi_ns/conftest.py
	new file:   tests/model_explainability/trustyai_service/service/multi_ns/test_trustyai_service_multi_ns.py
	modified:   tests/model_explainability/trustyai_service/service/test_trustyai_service.py
	modified:   tests/model_explainability/trustyai_service/utils.py

	new file:   tests/model_explainability/trustyai_service/service/multi_ns/conftest.py

	new file:   tests/model_explainability/trustyai_service/service/multi_ns/conftest.py

	modified:   tests/model_explainability/trustyai_service/service/conftest.py
	new file:   tests/model_explainability/trustyai_service/service/multi_ns/conftest.py
	new file:   tests/model_explainability/trustyai_service/service/multi_ns/test_trustyai_service_multi_ns.py
	modified:   tests/model_explainability/trustyai_service/service/test_trustyai_service.py
	modified:   tests/model_explainability/trustyai_service/utils.py

	new file:   tests/model_explainability/trustyai_service/service/multi_ns/test_trustyai_service_multi_ns.py
@adolfo-ab
Copy link
Copy Markdown
Contributor

/lgtm

Copy link
Copy Markdown
Contributor

@sheltoncyril sheltoncyril left a comment

Choose a reason for hiding this comment

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

/lgtm

@adolfo-ab adolfo-ab dismissed their stale review July 24, 2025 08:27

outdated

@adolfo-ab adolfo-ab merged commit 3a0e702 into opendatahub-io:main Jul 24, 2025
10 checks passed
@github-actions
Copy link
Copy Markdown

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.

4 participants