← Back to Pull requests

test(celery): make test_amqp_task fail fast and drop rpc result backend #22180

Closed
unknown closed this pull request without merging on Nov 30, 2026 14:51 UTC
View on GitHub
unknown unknown commented on Nov 30, 2026 10:57 UTC
Author

Description

test_amqp_task (tests/contrib/celery/test_tagging.py) is the flaky test behind frequent celery CI session failures. It is the only test combining a RabbitMQ broker with the rpc:// result backend, and it fails slowly by construction:

  • On celery 5.7 / kombu 5.7 (bumped in #21820), the rpc:// backend declares its reply queue with retry=True and a 20-retry policy, and its result consumer reconnects on errors. A flaky broker connection stacks tens of seconds of internal retries inside add.delay() and t.get().

  • Those stack on the test's own waits: t.get(timeout=30), the trace-poll loop (10s), and the worker-thread join(shutdown_timeout=30) when the thread is wedged.

  • The runner has no per-test timeout, and testrunner jobs retry stuck_or_timeout_failure up to 2 more times, so one bad run costs minutes and can push a session into the 20m job timeout across retries.
  • Changes:

  • Switch the app's result backend from rpc:// to the Redis backend already used by the sibling tests. Every tag the test asserts (celery.routing_key, out.host, network.destination.port == 5672, worker hostname) is derived from the broker side, so coverage is unchanged while the AMQP result-consumer retry/reconnect surface disappears.

  • t.get(timeout=30) -> 10: start_worker yields only after the consumer is ready and the solo pool executes in-process; test_redis_task uses 2s.

  • shutdown_timeout=30 -> 15: the join in celery's start_worker blocks for the full shutdown_timeout when the worker thread is wedged, so keep it low to fail fast instead of burning CI time on a stuck run.
  • Testing

  • scripts/lint fmt and scripts/lint checks pass on the edited file.

  • Local run via scripts/run-tests --venv d16ffca3679d (Python 3.10, celery 5.7.0): full tests/contrib/celery suite — 58 passed, 1 skipped in 240s, including test_amqp_task (passing run: ~10s, dominated by RabbitMQ worker startup).

  • The exact CI failure signature could not be re-confirmed via Test Optimization at the time of the change, so the fix is based on code analysis of celery 5.7 sources.
  • Risks

    Low. The change is test-only. The one behavioral narrowing: the pure-AMQP result path (rpc://) is no longer exercised in this test — nothing asserted depends on it, and no other test in the suite uses rpc://.

    Additional Notes

    Release note: not needed — test-only change (changelog/no-changelog label).

    Diff: 305 lines (+228 / -77) across 3 files Reviewer: gnufede Review duration: 233m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 305 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%
    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.342
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #22180"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 40.2% (MEDIUM) · Higher = larger blast radius
    40.2%
    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: 15.9% · Safe to merge
    15.9%