← Back to Pull requests

test(kubernetes): use testing/synctest in the autoscaler controllers and device plugin tests #61404

Open
unknown opened this pull request with 354 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 25, 2026 17:23 UTC
Author

What does this PR do?

Runs the timing-sensitive unit tests below in testing/synctest bubbles: Eventually/EventuallyWithT polling, time.Sleep and time.After guards are replaced by the bubble's fake clock and synctest.Wait() followed by a direct assertion.

Code owners of every file touched: container-integrations + container-platform + kubernetes-experiences (per CODEOWNERS).

  • pkg/util/kubernetes/apiserver/controllers/hpa_controller_test.go

  • pkg/util/kubernetes/apiserver/controllers/store_test.go

  • pkg/util/kubernetes/apiserver/controllers/wpa_controller_test.go

  • pkg/util/kubernetes/kubelet/deviceplugin_test.go
  • This PR is one of a series (one PR per set of co-maintainers) that replaces the single, larger draft #61285.

    Motivation

    Faster, deterministic and less flaky tests: no more real-time waiting or polling in these tests.

    Describe how you validated your changes

    dda inv test on the touched packages, from this branch only (rebased on main).

    Execution time of the modified tests, before (main) and after (this branch). Measured with
    dda inv test --targets=<pkgs> --bazel-args="--nocache_test_results --runs_per_test=3 --local_test_jobs=1":
    tests really run (no (cached) result), 3 runs per target, tests executed one at a time, median of the 3 runs read from each target's test.xml
    (only files written after the start of the measurement were considered). Resolution is 10 ms.

    | Test | Package | Before (s) | After (s) | Note |
    |---|---|---:|---:|---|
    | TestAutoscalerController | pkg/util/kubernetes/apiserver/controllers | 0.62 | 0.02 | |
    | TestAutoscalerControllerLegacyHPAVersions | pkg/util/kubernetes/apiserver/controllers | 0.04 | 0.03 | |
    | TestWPAController | pkg/util/kubernetes/apiserver/controllers | 0.62 | 0.02 | |
    | TestCachedDevicePluginClient | pkg/util/kubernetes/kubelet | 1.00 | < 0.01 | (first of 3 build flavors: kubelet_test_cel_docker_kubelet) |
    | Sum of the tests above | | 2.28 | 0.07 | |

    Reading the numbers: TestAutoscalerController and TestWPAController used EventuallyWithT with a 500 ms poll interval; TestCachedDevicePluginClient slept for the real 1 s cache timeout. Not in the table: store_test.go only changes the assertNotified/assertNotNotified helpers (non-blocking select since the store notifies synchronously, instead of a 50 ms sleep and a 1 s timeout), used by tests that were already below 10 ms in aggregate. The tests that need real I/O (resourcetypes_test.go, the HTTPS retry in kubelet_test.go, the unix-socket/gRPC device plugin tests) are deliberately not migrated.

    Additional Notes

    Test-only change (plus the production change described above, if any); no functional impact on the Agent.

    🤖 Generated with Claude Code

    Diff: 354 lines (+265 / -89) across 4 files Reviewer: L3n41c Review duration: 5004m
    All Vouch review confidence checks passed
    Residual risk 0.35 = Change Risk (0.66) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.66 · 354 lines diff across 4 files
    0.66
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    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.351
    Shallow Review Depth shallow_review_depth
    0.344
    Sensitive Paths sensitive_paths
    0.066
    Real PR Conversation Timeline
    1 comments
    "Review active on #61404"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 46.7% reviewed sensitive_module
    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: 65.7% (HIGH) · Higher = larger blast radius
    65.7%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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: 35% · Moderate risk
    35%