← Back to Pull requests

test: add unit tests for the scheduler Registry #3164

Open
magic-peach opened this pull request with 152 lines diff across 2 files
View on GitHub
magic-peach magic-peach commented on Sep 13, 2026 13:33 UTC
Author

Purpose of this PR

internal/scheduler's Registry backs the actual scheduler wiring in cmd/operator/controller/start.go (Register is called there for each of the volcano, yunikorn, and kubescheduler factories) and had no test coverage, including the duplicate-registration error path.

Proposed changes:

  • Add unit tests for Register, covering a normal registration and the duplicate-name error case

  • Add unit tests for GetScheduler, covering a registered name and a not-found error

  • Add unit tests for GetRegisteredSchedulerNames

  • Add a unit test for GetRegistry confirming it returns the same singleton instance across calls
  • Change Category

  • Bugfix (non-breaking change which fixes an issue)

  • Feature (non-breaking change which adds functionality)

  • Breaking change (fix or feature that could affect existing functionality)

  • Documentation update
  • Rationale

    Test-only change, no behavior modified.

    Checklist

  • I have conducted a self-review of my own code.

  • I have updated documentation accordingly.

  • I have added tests that prove my changes are effective or that my feature works.

  • Existing unit tests pass locally with my changes.
  • Additional Notes

    No existing issue tracks this; found while reading the scheduler registry.

    Diff: 152 lines (+152 / -0) across 2 files Reviewer: tariq-hasan Review duration: 30334m
    All Vouch review confidence checks passed
    Residual risk 0.03 = Change Risk (0.35) × (1 − Review Confidence (0.91)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.35 · 152 lines diff across 2 files
    0.35
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.90 · 4 substantive comment(s)
    0.90
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    90%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.301
    Real PR Conversation Timeline
    8 items
    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Sep 13, 2026 13:33 UTC
    Reviewer

    Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

    google-oss-prow[bot] google-oss-prow[bot] commented on Sep 13, 2026 13:33 UTC
    Bot

    [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 assign chenyi015 for approval. For more information see the Kubernetes Code Review Process.

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

    <details open>
    Needs approval from an approver in each of these files:

  • OWNERS
  • Approvers can indicate their approval by writing /approve in a comment
    Approvers can cancel approval by writing /approve cancel in a comment
    </details>
    <!-- META={"approvers":["chenyi015"]} -->

    github-actions[bot] github-actions[bot] commented on Sep 13, 2026 13:33 UTC
    Bot

    🎉 Welcome to the Kubeflow Spark Operator! 🎉

    Thanks for opening your first PR! We're happy to have you as part of our community 🚀

    Here's what happens next:

  • If you haven't already, please check out our Contributing Guide for repo-specific guidelines and the Kubeflow Contributor Guide for general community standards.

  • Our team will review your PR soon!
  • Join the community:

  • Slack: Join our #kubeflow-spark-on-kubernetes Slack channel.
  • Feel free to ask questions in the comments if you need any help or clarification!
    Thanks again for contributing to Kubeflow! 🙏

    tariq-hasan tariq-hasan requested changes on Sep 13, 2026 15:07 UTC
    Changes Requested Reviewer

    Please rewrite the tests using Ginkgo/Gomega as that would be the default going forward.

    magic-peach magic-peach commented on Sep 13, 2026 16:25 UTC
    Author

    Rewrote the tests using Ginkgo/Gomega.

    RobuRishabh RobuRishabh commented on Sep 23, 2026 15:36 UTC
    Contributor

    /ok-to-test

    RobuRishabh RobuRishabh commented on Sep 23, 2026 15:44 UTC
    Reviewer

    Hi @magic-peach thanks for the contribution, Please add a case where the factory returns an error. GetScheduler should return that error to the caller. Right now every fake factory always succeeds, so that path is untested and Optionally you can also pass a non-nil config into GetScheduler and check the factory actually receives it. Today every call uses nil.

    Reviewers
    Assignees
    magic-peach magic-peach
    Labels
    risk: low confidence: 90.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 34.5% (LOW) · Higher = larger blast radius
    34.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 90.8% · Lower = rushed or shallow review
    90.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 3.2% · Safe to merge
    3.2%