litellm/tests/e2e/perf/setup/mocks/server.py
devin-ai-integration[bot] 8fd384b316 test(e2e): perf cases send representative traffic over real model ids, config written out, perf/ split into setup/ and cases/
Model groups and guardrails are written out in the gateway config (helm values in the lane,
gateway/perf_ci_config.yml locally) with real model ids (gpt-6-luna, claude-sonnet-5,
anthropic.claude-sonnet-5 on Bedrock) and each deployment's mock knobs in an x-mock-knobs
extra header, so every name-based branch in the gateway runs; setup checks the deployed config
matches the case instead of registering models and guardrails. Requests carry a RequestShape
(system prompt, history turns, tools, output cap) and the mocks size their reply and usage
from it. tests/e2e/perf is split into setup/ (schema, provision, plan, run, locustfile,
observe, wire, mocks) and cases/ (one PerformanceTestCase per module).

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-13 21:19:21 +00:00

43 lines
1.4 KiB
Python

"""Run one perf mock out of process: `python server.py openai --port 8090`.
Each kind is its own pod (or local process) with its own request log; the gateway talks to it over
HTTP exactly as it would to the real provider, and the test reads `/mock/requests` (providers) or
`/mock/calls` (guardrail) afterwards to join what was received against what each client saw.
"""
from __future__ import annotations
import argparse
from collections.abc import Callable
from typing import Final
import uvicorn
from fastapi import FastAPI
import mock_anthropic
import mock_bedrock
import mock_guardrail
import mock_openai
KINDS: Final[dict[str, Callable[[], FastAPI]]] = {
"openai": mock_openai.build_app,
"anthropic": mock_anthropic.build_app,
"bedrock": mock_bedrock.build_app,
"guardrail": mock_guardrail.build_app,
}
def main() -> None:
parser: Final = argparse.ArgumentParser(description=__doc__)
_ = parser.add_argument("kind", choices=sorted(KINDS))
_ = parser.add_argument("--host", default="0.0.0.0")
_ = parser.add_argument("--port", type=int, default=8090)
args: Final = parser.parse_args()
kind: Final = str(args.kind) # pyright: ignore[reportAny]
port: Final = int(args.port) # pyright: ignore[reportAny]
host: Final = str(args.host) # pyright: ignore[reportAny]
uvicorn.run(KINDS[kind](), host=host, port=port, log_level="warning", access_log=False)
if __name__ == "__main__":
main()