Skip to content

chore(test): add unit test scaffold with testcase harness#6

Open
abhijeet-dhumal wants to merge 2 commits into
kubeflow:mainfrom
abhijeet-dhumal:feat/trainer-mcp-tests
Open

chore(test): add unit test scaffold with testcase harness#6
abhijeet-dhumal wants to merge 2 commits into
kubeflow:mainfrom
abhijeet-dhumal:feat/trainer-mcp-tests

Conversation

@abhijeet-dhumal

@abhijeet-dhumal abhijeet-dhumal commented Apr 26, 2026

Copy link
Copy Markdown
Member

Description

  • Replaces the earlier co-located test layout with a tests/unit scaffold
  • Adds shared harness, fixtures, and example tests for core and trainer modules
  • Establishes patterns for follow-up coverage; for remaining gaps used TODO(test) markers

Checklist

  • Tests pass locally (make test-python)
  • Linting passes (make verify)
  • Documentation updated (if applicable)
  • Commit messages follow conventional format

Related Issues

Fixes. : #9

@google-oss-prow google-oss-prow Bot added the do-not-merge/work-in-progress Work in progress label Apr 26, 2026
@google-oss-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from abhijeet-dhumal. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@abhijeet-dhumal abhijeet-dhumal changed the title Feat/trainer mcp tests test: add unit tests and benchmark suite for trainer MCP tools Apr 26, 2026
@abhijeet-dhumal
abhijeet-dhumal force-pushed the feat/trainer-mcp-tests branch 2 times, most recently from d81b052 to fe3db3c Compare May 12, 2026 12:13
@abhijeet-dhumal abhijeet-dhumal changed the title test: add unit tests and benchmark suite for trainer MCP tools chore: add unit tests and benchmark suite for trainer MCP tools May 12, 2026
@abhijeet-dhumal abhijeet-dhumal changed the title chore: add unit tests and benchmark suite for trainer MCP tools chore: add unit tests suite for trainer MCP tools May 12, 2026
@abhijeet-dhumal
abhijeet-dhumal marked this pull request as ready for review May 12, 2026 15:08
@google-oss-prow google-oss-prow Bot removed the do-not-merge/work-in-progress Work in progress label May 12, 2026
Copilot AI review requested due to automatic review settings July 12, 2026 17:27
@abhijeet-dhumal
abhijeet-dhumal force-pushed the feat/trainer-mcp-tests branch from 11d63da to 21b0fdc Compare July 12, 2026 17:27
@abhijeet-dhumal
abhijeet-dhumal marked this pull request as draft July 12, 2026 17:28
@google-oss-prow google-oss-prow Bot added the do-not-merge/work-in-progress Work in progress label Jul 12, 2026
@abhijeet-dhumal abhijeet-dhumal changed the title chore: add unit tests suite for trainer MCP tools chore(test): add unit test scaffold with testcase harness Jul 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Expands unit-test coverage and supporting infrastructure for core and Trainer MCP components.

Changes:

  • Adds validation, security, resilience, policy, auth, and Trainer tests.
  • Introduces shared mocks, fixtures, and table-driven test helpers.
  • Updates pytest configuration and contributor testing guidance.

Reviewed changes

Copilot reviewed 21 out of 22 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
tests/unit/trainer/test_training.py Tests training validation and helpers.
tests/unit/trainer/test_platform.py Tests runtime validation.
tests/unit/trainer/test_planning.py Adds planning helper tests.
tests/unit/trainer/test_monitoring.py Tests failure-pattern detection.
tests/unit/trainer/test_lifecycle.py Tests lifecycle validation.
tests/unit/trainer/test_discovery.py Tests job discovery behavior.
tests/unit/core/test_tool_integrity.py Adds metadata integrity checks.
tests/unit/core/test_security.py Expands security tests.
tests/unit/core/test_resilience.py Tests resilience primitives.
tests/unit/core/test_policy.py Tests policy filtering and state.
tests/unit/core/test_config.py Tests configuration loading.
tests/unit/core/test_auth.py Tests authentication helpers.
tests/unit/conftest.py Adds SDK and Kubernetes mocks.
tests/unit/common/test_utils.py Adds utility tests.
tests/unit/common/test_types.py Tests response and exception types.
tests/unit/common/test_constants.py Tests error classification.
tests/unit/common/__init__.py Defines the common test package.
tests/conftest.py Adds global test-state fixtures.
tests/common.py Adds shared test utilities.
pyproject.toml Registers pytest markers.
kubeflow_mcp/cli_test.py Stabilizes an auth-provider assertion.
CONTRIBUTING.md Documents test layout and commands.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/unit/trainer/test_training.py
Comment thread tests/common.py Outdated
Comment thread tests/unit/core/test_resilience.py
Comment thread tests/unit/common/test_utils.py
Comment thread tests/unit/core/test_policy.py Outdated
Comment thread CONTRIBUTING.md Outdated
Comment thread tests/unit/core/test_config.py
Comment thread tests/unit/core/test_tool_integrity.py Outdated
@modichika

Copy link
Copy Markdown

Hey @abhijeet-dhumal I'll help review this PR.
Thanks!

@abhijeet-dhumal

Copy link
Copy Markdown
Member Author

@andreyvelich @thesuperzapper @szaher @astefanutti @modichika
This PR is a candidate for the first release (0.1.0) tracking #9 / #56.
Can you take a look at what’s still needed so we can unblock the test gate for rc1?

@modichika

Copy link
Copy Markdown

Hey @abhijeet-dhumal I have reviewed every files in tests/ folder that you have changed and it's amazing to see the work.
Here are my observations:

  • Infrastructure: conftest.py setup is highly robust, centralizing complex Kubernetes mocking and side-effect management.
  • Maintainability: use of custom verification helpers (verify_tool_success/error) and standardized mock data generators makes the test suite highly readable and easy to maintain as the project grows.
  • Scalability: established a clean, repeatable pattern for adding new test cases that reduces technical debt in future feature development.
  • The pattern listed in the PR like TODO markers are consistent across all files that helps anyone understand how to write new tests.

I have included comments in two files, lmk your thoughts!

Signed-off-by: abhijeet-dhumal <abhijeetdhumal652@gmail.com>
Signed-off-by: abhijeet-dhumal <abhijeetdhumal652@gmail.com>
@abhijeet-dhumal
abhijeet-dhumal force-pushed the feat/trainer-mcp-tests branch from 636d5a8 to e453c35 Compare July 18, 2026 14:45
@abhijeet-dhumal

Copy link
Copy Markdown
Member Author

Hey @abhijeet-dhumal I have reviewed every files in tests/ folder that you have changed and it's amazing to see the work. Here are my observations:

  • Infrastructure: conftest.py setup is highly robust, centralizing complex Kubernetes mocking and side-effect management.
  • Maintainability: use of custom verification helpers (verify_tool_success/error) and standardized mock data generators makes the test suite highly readable and easy to maintain as the project grows.
  • Scalability: established a clean, repeatable pattern for adding new test cases that reduces technical debt in future feature development.
  • The pattern listed in the PR like TODO markers are consistent across all files that helps anyone understand how to write new tests.

I have included comments in two files, lmk your thoughts!

@modichika Glad you liked the LLD used for scaffold 😊

I don’t see the two file comments you added on the PR yet (might still be in an unsubmitted review draft). Mind pasting them here or re-submitting the review so I can address them? 👀

Also just rebased onto main after #46 landed .. ✅

Comment thread CONTRIBUTING.md

### Unit Testing
To run unit tests locally, use the following `make` command:
```bash

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

image

Hey @abhijeet-dhumal great work with the CONTRIBUTIING.md file it sets clear tests/ structure for new contributors.
Is it ok to add a prerequisite note thatuvneeds to be installed(acc. to thier local env like macos/linux or windows) in the environment for these make commands to work?
Because when I first tried it, it gave an error as you can see in the image.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks @modichika for reviewing the PR 🙌
Agreed! I will mention in docs accordingly ..

def test_returns_false_for_module_not_found(self):
assert is_k8s_not_found(ModuleNotFoundError("not found")) is False

# TODO(test): test chained exception (__cause__) with ApiException 404

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

These chained exception tests look important for debugging do you have a rough idea of when you'd like to get those covered? Because cause and context must be known of 404 Not Found API Error.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed they’re useful for 404 debugging left as TODO(test) so this PR can land the scaffold without growing further.
Aiming at a follow-up under #9 right after this merges (ApiException cause/context on the discovery/monitoring mocks). If you’d rather track it as its own issue, I can open one 👍

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Yeah I can take up on that and solve it?

@modichika

modichika commented Jul 18, 2026

Copy link
Copy Markdown

Now it will be showing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants