mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-18 09:45:23 +00:00
test(s3_v2): ignore stray non-POST requests in the surface upstream
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
0e456ac599
commit
15665a6918
3 changed files with 11 additions and 4 deletions
|
|
@ -216,6 +216,8 @@ def _responses_stream_frames(identity: str) -> tuple[bytes, ...]:
|
|||
|
||||
def surface_reply(request: Request) -> Reply:
|
||||
"""Scripted upstream that echoes the caller's marker string back as the response id."""
|
||||
if request.method != "POST" or not request.body:
|
||||
return Reply(status=404)
|
||||
body: Final = json.loads(request.body)
|
||||
if request.target.endswith("/chat/completions"):
|
||||
identity: Final = body["messages"][0]["content"]
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ def test_s3_v2_mixed_surface_burst_bounds_puts_one_object_per_response_id(gatewa
|
|||
answered: Final = mixed_burst(candidate, openai_model, anthropic_model, key, marker)
|
||||
payloads: Final = collect_payloads(sink, len(answered))
|
||||
targets: Final = tuple(sink.objects())
|
||||
assert len(provider.drain()) == 48
|
||||
assert sum(1 for r in provider.drain() if r.method == "POST") == 48
|
||||
assert sink.peak <= 16, f"peak concurrent PUTs {sink.peak} exceeded the default bound"
|
||||
assert all(PER_REQUEST_KEY.match(target) for target in targets), list(targets)
|
||||
assert len(targets) == 48
|
||||
|
|
@ -68,7 +68,7 @@ def test_s3_v2_mixed_surface_batch_writes_ndjson_lines_per_response_id(gateway:
|
|||
payloads: Final = collect_payloads(sink, len(answered))
|
||||
targets: Final = tuple(sink.objects())
|
||||
puts: Final = bucket.drain()
|
||||
assert len(provider.drain()) == 48
|
||||
assert sum(1 for r in provider.drain() if r.method == "POST") == 48
|
||||
assert all(BATCH_KEY.match(target) for target in targets), list(targets)
|
||||
assert all(put.headers["content-type"] == "application/x-ndjson" for put in puts), [put.headers for put in puts]
|
||||
assert matched_ids(payloads, answered)
|
||||
|
|
@ -92,6 +92,6 @@ def test_s3_v2_sink_outage_mid_mixed_burst_recovers_every_response_id(gateway: G
|
|||
key: Final = scenario.key(models=[openai_model, anthropic_model])
|
||||
answered: Final = mixed_burst(candidate, openai_model, anthropic_model, key, marker)
|
||||
payloads: Final = collect_payloads(sink, len(answered), seconds=90)
|
||||
assert len(provider.drain()) == 48
|
||||
assert sum(1 for r in provider.drain() if r.method == "POST") == 48
|
||||
assert matched_ids(payloads, answered)
|
||||
assert len(payloads) == 48, "a stored id was overwritten or duplicated"
|
||||
|
|
|
|||
|
|
@ -382,7 +382,12 @@ def test_s3_v2_unknown_model_rejection_keeps_other_requests_logging(gateway: Gat
|
|||
)
|
||||
assert ghost.status_code in (400, 403, 404), ghost.text
|
||||
ids: Final = _burst(candidate, model, key, marker)
|
||||
payloads: Final = collect_payloads(sink, REQUESTS)
|
||||
eventually(
|
||||
lambda: frozenset(payload["id"] for payload in sink.payloads()),
|
||||
lambda landed: ids <= landed,
|
||||
seconds=90,
|
||||
)
|
||||
payloads: Final = sink.payloads()
|
||||
assert sum(1 for r in provider.drain() if r.method == "POST") == REQUESTS
|
||||
assert ids <= frozenset(payload["id"] for payload in payloads)
|
||||
extras: Final = tuple(payload for payload in payloads if payload["id"] not in ids)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue