← Back to Pull requests

test: fix flaky KubernetesTaskRunnerTest start tests #20316

Closed
unknown closed this pull request without merging on Sep 16, 2026 02:31 UTC
View on GitHub
unknown unknown commented on Sep 10, 2026 15:28 UTC
Author

Related to #20312 (item 1).

Description

KubernetesTaskRunnerTest.test_start_whenDeserializationExceptionThrown_isIgnored fails intermittently on master with:

Unexpected method calls:
  EasyMock for field KubernetesTaskRunnerTest.peonClient -> KubernetesPeonClient.deleteCompletedPeonJobsOlderThan(172800000 (long), MILLISECONDS)

Example: https://github.com/apache/druid/actions/runs/34431507380/job/102727804299 (failed all 4 surefire attempts).

KubernetesTaskRunner.start() schedules deleteCompletedPeonJobsOlderThan on a real ScheduledExecutorService with an initial delay of 1 ms. Whether the first cleanup runs before the test's verifyAll() depends on thread scheduling, so the strict mock sometimes sees a call it was not told to expect.

Changes

In the three tests that call runner.start() on a locally created runner, expect deleteCompletedPeonJobsOlderThan(anyLong(), MILLISECONDS) any number of times via a small helper. Only this one call is relaxed; the rest of peonClient stays strictly verified.
Stop each locally created runner in a finally block so the cleanup executor does not outlive the test.

Verified locally with mvn -pl extensions-core/kubernetes-overlord-extensions test -Dtest=KubernetesTaskRunnerTest.

<hr>

##### Key changed/added classes in this PR
* KubernetesTaskRunnerTest

<hr>

This PR has:

  • been self-reviewed.

  • added or updated unit tests.
  • Additional CI evidence

    This same scheduled-cleanup race reappeared as a recovered flaky failure in PR #20330, unit-test job:

    Unexpected method calls:
      KubernetesPeonClient.deleteCompletedPeonJobsOlderThan(172800000 (long), MILLISECONDS)
    

    The corresponding PR #20329 unit run did not reach this assertion: its embedded tests failed earlier with NoClassDefFoundError: org/apache/curator/test/TestingServer after the curator-test dependency was removed.

    Diff: 261 lines (+195 / -66) across 3 files Reviewer: GWphua Review duration: 7862m
    All Vouch review confidence checks passed
    Residual risk 0.25 = Change Risk (0.62) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.62 · 261 lines diff across 3 files
    0.62
    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%
    60%
    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.333
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.062
    Real PR Conversation Timeline
    1 comments
    "Review active on #20316"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 62.4% (MEDIUM) · Higher = larger blast radius
    62.4%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 24.6% · Safe to merge
    24.6%
    Repository