← Back to Pull requests

test(scheduler): add unit tests for the batch scheduler registry #3232

Closed
unknown closed this pull request without merging on Oct 23, 2026 18:05 UTC
View on GitHub
unknown unknown commented on Oct 13, 2026 02:25 UTC
Author

Purpose of this PR

internal/scheduler had no test files — 0% statement coverage. The registry is the indirection every batch scheduler goes through (volcano, yunikorn, kube-scheduler), but its error paths were only exercised incidentally via the concrete implementations in the subpackages.

Adds internal/scheduler/registry_test.go. Coverage goes from 0% to 100%. No production code changes.

Part of #3202.

Proposed changes:

  • Add unit tests for GetRegistry, Register, GetScheduler and GetRegisteredSchedulerNames, including duplicate registration, unknown scheduler lookup, factory error propagation and Config pass-through.
  • Change Category

    <!-- Test-only change; none of the categories below apply. -->

  • 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

    Tests use isolated Registry instances rather than the package-level singleton, so they cannot interact through ordering. The one test that exercises the singleton restores it via t.Cleanup.

    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

    go test ./internal/scheduler/ -cover
    ok  github.com/kubeflow/spark-operator/v2/internal/scheduler  0.583s  coverage: 100.0% of statements
    

    ---

    Asks for reviewers @nabuskey @vjanelle @tariq-hasan

    1. Data race, not fixed here. GetRegisteredSchedulerNames (registry.go:69) iterates r.factories without taking r.mu, while Register and GetScheduler both lock it. I did not add a test for it — it would fail under -race and the fix belongs in its own PR. Should I open a separate issue?

    2. Scope check on #3202. This is one of the low-coverage packages listed there. Happy to keep going package by package in small PRs like this one, or to hold until the sub-issues are agreed — let me know which you'd prefer.

    Diff: 275 lines (+206 / -69) across 3 files Reviewer: vjanelle Review duration: 15340m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.40) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 275 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    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.336
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3232"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.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: 39.6% (MEDIUM) · Higher = larger blast radius
    39.6%
    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: 56.8% · Lower = rushed or shallow review
    56.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: 17.1% · Safe to merge
    17.1%