mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-11 03:38:38 +00:00
test(integration): slow half the kill-worker burst so the kill lands mid-flight
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
495418966a
commit
8e70e83f77
2 changed files with 11 additions and 3 deletions
|
|
@ -5,6 +5,7 @@ import ipaddress
|
|||
import json
|
||||
import ssl
|
||||
import threading
|
||||
import time
|
||||
from collections.abc import Generator
|
||||
from contextlib import contextmanager
|
||||
from dataclasses import dataclass
|
||||
|
|
@ -140,6 +141,8 @@ class _CipherPeerHandler(BaseHTTPRequestHandler):
|
|||
user_value: Final = body.get("user")
|
||||
user: Final = user_value if isinstance(user_value, str) else None
|
||||
peer.record(TlsPeerRequest(path=self.path, user=user, cipher=_negotiated_cipher(self)))
|
||||
if user is not None and "slow" in user:
|
||||
time.sleep(5)
|
||||
identifier: Final = f"chatcmpl-{user or ''}"
|
||||
model_value: Final = body.get("model")
|
||||
model: Final = model_value if isinstance(model_value, str) else "gpt-4o-mini"
|
||||
|
|
|
|||
|
|
@ -308,7 +308,7 @@ class _BurstOutcome:
|
|||
|
||||
def _chaos_request(proxy: Gateway, kind: str, index: int, marker: str) -> _BurstOutcome:
|
||||
user: Final = f"chaos-{kind}-{index}-{marker}"
|
||||
if kind == "chat":
|
||||
if kind in ("chat", "slow"):
|
||||
try:
|
||||
chat_response: Final = proxy.request(
|
||||
"POST",
|
||||
|
|
@ -429,7 +429,10 @@ def test_proxy_burst_survives_losing_one_worker(cipher_owned_proxy: OwnedProxy,
|
|||
marker: Final = uuid.uuid4().hex[:8]
|
||||
executor: Final = ThreadPoolExecutor(max_workers=12)
|
||||
with executor:
|
||||
futures: Final = tuple(executor.submit(_chaos_request, proxy, "chat", index, marker) for index in range(12))
|
||||
futures: Final = tuple(
|
||||
executor.submit(_chaos_request, proxy, "slow" if index % 2 else "chat", index, marker)
|
||||
for index in range(12)
|
||||
)
|
||||
eventually(
|
||||
lambda: sum(1 for future in futures if future.done() and future.result().status == 200),
|
||||
lambda successes: successes >= 2,
|
||||
|
|
@ -441,7 +444,9 @@ def test_proxy_burst_survives_losing_one_worker(cipher_owned_proxy: OwnedProxy,
|
|||
children[0].kill()
|
||||
finished: Final = tuple(future.result(timeout=120) for future in futures)
|
||||
assert len(finished) == 12, finished
|
||||
assert any(outcome.status == 200 and outcome.finished_at > killed_at for outcome in finished), finished
|
||||
assert any(outcome.finished_at > killed_at for outcome in finished), finished
|
||||
post_kill_id: Final = _sync_completion(proxy, "tls-peer", f"post-kill-{marker}")
|
||||
assert post_kill_id == f"chatcmpl-post-kill-{marker}"
|
||||
|
||||
def _ready() -> bool:
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue