Skip to content

fix(tests): run the worker-replacement chaos test under strict supervision - #51296

Closed
mateo-berri wants to merge 1 commit into
mainfrom
litellm_chaos_replacement_strict_healthcheck
Closed

mateo-berri wants to merge 1 commit into
mainfrom
litellm_chaos_replacement_strict_healthcheck

Conversation

@mateo-berri

@mateo-berri mateo-berri commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Handwritten 1-3 sentence description

The fine-tuning chaos test that kills each proxy worker could time out in CI because its proxy ran with the long healthcheck meant for the worker-pause test, so uvicorn took minutes to notice each dead worker. This gives the kill test its own proxy with normal supervision and lets the module use the calibrated per-test timeout, so the scheduled extensions run stops failing on it

Details

TLDR

Problem this solves:

  • test_a_replaced_worker_still_sends_the_provider_file_ids hit pytest-timeout (>480s) in scheduled run 42680944695
  • Its shared fixture used WorkerHealthcheck.LENIENT, which is 12 x import_seconds, 262s on that box
  • uvicorn 0.51.0 only reaps a worker killed during an unanswered ping after the healthcheck expires, so two sequential kills can burn over 480s
  • The module's fixed timeout(480) also bypassed the calibrated budget (920s on that box)

How it solves it:

  • Split the module fixture into rig (STRICT, 5s healthcheck) and suspension_rig (LENIENT)
  • Only test_each_worker_alone_sends_the_provider_file_ids suspends workers, so only it uses LENIENT
  • Dropped the fixed 480s override so the module follows _support/budget.py calibration like other owned-proxy tests
  • Both kills, replacement readiness waits and every assertion are unchanged

Triage verdict is a test/harness bug, not a product or infra fault. The CI proxy log for gw11 shows both killed workers were reaped and replaced (Child process [102829] died, then Started server process [269067] ready about 280s after test start). The harness and lockfile have no diff between the last passing sha d10de278c1 and the failing 457365f, the combination came in with #46552

Screenshots / Proof of Fix

Shared setup is local PostgreSQL and Redis per tests/integration/README.md, two-worker owned proxies built by the same _rig the test uses. The script suspends each worker for 0.8s so the supervisor has a ping in flight, SIGKILLs it, then measures kill to reap and kill to replacement readiness. LENIENT was scaled to this box's calibration (36s), STRICT stays 5s

real_proxy_healthcheck_proof.py
import time, threading
from pathlib import Path
from integration._support.process import WorkerHealthcheck, WorkerKill, healthcheck_seconds
from integration.compatibility.test_fine_tuning_managed_files_chaos import _rig

root = Path("real-proxy-proof"); root.mkdir(exist_ok=True)
for healthcheck in (WorkerHealthcheck.LENIENT, WorkerHealthcheck.STRICT):
    with _rig(root / healthcheck.value, healthcheck) as rig:
        before = sorted(rig.owned.worker_pids())
        for pid in before:
            victim, before_kill = rig.owned._victim(pid)
            victim.suspend(); time.sleep(0.8)
            started = time.monotonic(); reaped = []
            def observe_reap():
                while victim.is_running(): time.sleep(0.01)
                reaped.append(time.monotonic() - started)
            t = threading.Thread(target=observe_reap, daemon=True); t.start()
            WorkerKill(victim, threading.Event())()
            replacement = rig.owned._replacement_of(victim, before_kill)
            t.join(timeout=1)
            print(f"{healthcheck.value}: healthcheck={healthcheck_seconds(healthcheck)}s killed={pid} "
                  f"replacement={replacement} kill_to_reap={reaped[0]:.3f}s "
                  f"kill_to_replacement_ready={time.monotonic() - started:.3f}s")

Before (072290e, fixture used LENIENT for the kill test)

lenient: healthcheck=36s killed=14213 replacement=14539 kill_to_reap=35.327s kill_to_replacement_ready=46.494s
lenient: healthcheck=36s killed=14214 replacement=14756 kill_to_reap=35.464s kill_to_replacement_ready=50.644s

Each kill waits out the full lenient healthcheck. At CI's 262s that is two waits over 480s, which is the reported timeout inside _wait_until_reaped

After (41e0d91, kill test uses STRICT)

strict: healthcheck=5s killed=15080 replacement=15287 kill_to_reap=4.517s kill_to_replacement_ready=17.320s
strict: healthcheck=5s killed=15081 replacement=15424 kill_to_reap=4.338s kill_to_replacement_ready=15.431s

Full module at the tip via uv run python tests/integration/run.py extensions filtered to this file, two pytest workers

23.34s call     tests/integration/compatibility/test_fine_tuning_managed_files_chaos.py::test_a_replaced_worker_still_sends_the_provider_file_ids
======================== 5 passed in 155.46s (0:02:35) =========================
execution complete=True passed=5 skipped=0

Gates were ruff check, ruff format --check and scripts/test_quality_gate.py --base origin/main, all clean

Type

✅ Test

Caveats (if any)

Low

  • The suspension test now boots its own two-worker proxy, adding one proxy boot to the module
  • The original 480s CI timeout was not reproduced end to end locally, only the per-kill delay

Link to Devin session: https://app.devin.ai/sessions/4818bd0c68974edaa320f8d39ba32257
Open in Devin Desktop: https://app.devin.ai/desktop/session/4818bd0c68974edaa320f8d39ba32257?variant=devin
Requested by: @mateo-berri

Bugbot summary

[!NOTE]
Low Risk
Test-harness only: fixture split and timeout behavior in one integration module; no product or runtime code changes.

Overview
Fixes CI timeouts in the fine-tuning managed-files chaos module by separating proxy setup by healthcheck policy instead of one shared fixture.

A shared _rig context manager now takes WorkerHealthcheck, while rig uses STRICT (fast reap after worker kills) and suspension_rig uses LENIENT for the test that pauses workers. The worker-replacement test keeps using strict supervision; only the suspension test uses the lenient rig.

The module’s fixed pytest.mark.timeout(480) override is removed so timing follows the integration test budget calibration like other owned-proxy tests.

Reviewed by Cursor Bugbot for commit 41e0d91. Bugbot is set up for automated code reviews on this repo. Configure here.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration

Copy link
Copy Markdown
Contributor

@greptileai

@veria-ai

veria-ai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

No security issues were found in this pull request.

Reviews

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@greptile-apps

greptile-apps Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] This test-only change appears safe to merge.

Summary

The worker-replacement test now uses strict supervision. The worker-pause test keeps lenient supervision through a separate fixture. Removing the fixed timeout lets the runner apply its calibrated budget.

  • Worker-kill tests now use the short healthcheck.

Reviews (1) · Last reviewed commit: "Use strict supervision for worker replac..." · Reviewed by Greptile

@codecov

codecov Bot commented Nov 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 41e0d91. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants