mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-25 22:20:43 +00:00
* test(e2e): run codex in fast mode under the real model name as a team model Each test registers its deployment as a team model named after the real model, on a throwaway team with a team key, so parallel tests never share one pooled deployment. Fast mode sets service_tier to priority the way /fast does and must still answer with a value only reachable through the gateway, on every setup * test(e2e): check codex fast mode really asks the gateway for the fast tier The Fast mode row only checked the answer, so it passed the same if the fast setting quietly stopped doing anything. It now reads whether the gateway's Codex catalog offers the priority tier for the model, and checks the requests the gateway logged for that key carried service_tier priority when it does and never asked for it when it doesn't * test(e2e): fail codex fast mode when the gateway logged too few requests With no spend log rows the tier checks ran over an empty list and passed. The test now requires at least the two requests a command round trip makes before it checks their tiers
69 lines
2.5 KiB
Python
69 lines
2.5 KiB
Python
from __future__ import annotations
|
|
|
|
from collections.abc import Iterator
|
|
from dataclasses import dataclass
|
|
from typing import Final
|
|
|
|
import pytest
|
|
from cli_harness.rate_limiter import get_default_limiter
|
|
from codex.harness import CodexHarness, codex_harness
|
|
from codex.setups import Deployment, ModelSetup
|
|
from e2e_config import PROXY_BASE_URL, unique_marker
|
|
from lifecycle import ResourceManager
|
|
from models import KeyGenerateBody, ModelInfoBody, ModelNewBody, TeamNewBody
|
|
from proxy_client import ProxyClient
|
|
|
|
|
|
@dataclass(frozen=True, slots=True)
|
|
class _Client:
|
|
proxy: ProxyClient
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def client(proxy: ProxyClient) -> _Client:
|
|
return _Client(proxy)
|
|
|
|
|
|
@pytest.fixture
|
|
def setup(deployment: Deployment, proxy: ProxyClient, resources: ResourceManager) -> ModelSetup:
|
|
model: Final = f"e2e-codex-{unique_marker()}"
|
|
model_id: Final = proxy.create_model(model, deployment.litellm_params, provider_live=True)
|
|
resources.defer(lambda: proxy.delete_model(model_id))
|
|
return ModelSetup(
|
|
model=model, rate_bucket=deployment.rate_bucket, api_key=resources.key(models=[model], user_id=None)
|
|
)
|
|
|
|
|
|
@pytest.fixture
|
|
def real_name_setup(deployment: Deployment, proxy: ProxyClient, resources: ResourceManager) -> ModelSetup:
|
|
model: Final = deployment.real_model_name
|
|
team_id: Final = proxy.create_team(TeamNewBody(team_alias=f"e2e-codex-{unique_marker()}", models=[model]))
|
|
resources.defer(lambda: proxy.delete_team(team_id))
|
|
api_key: Final = proxy.generate_key(KeyGenerateBody(team_id=team_id, models=[model]))
|
|
resources.defer(lambda: proxy.delete_key(api_key))
|
|
model_id: Final = proxy.register_model(
|
|
ModelNewBody(
|
|
model_name=model, litellm_params=deployment.litellm_params, model_info=ModelInfoBody(team_id=team_id)
|
|
),
|
|
listed_for=api_key,
|
|
provider_live=True,
|
|
)
|
|
resources.defer(lambda: proxy.delete_model(model_id))
|
|
return ModelSetup(model=model, rate_bucket=deployment.rate_bucket, api_key=api_key)
|
|
|
|
|
|
@pytest.fixture
|
|
def codex(setup: ModelSetup) -> Iterator[CodexHarness]:
|
|
yield from _codex_for(setup)
|
|
|
|
|
|
@pytest.fixture
|
|
def real_name_codex(real_name_setup: ModelSetup) -> Iterator[CodexHarness]:
|
|
yield from _codex_for(real_name_setup)
|
|
|
|
|
|
def _codex_for(setup: ModelSetup) -> Iterator[CodexHarness]:
|
|
with codex_harness(
|
|
gateway=PROXY_BASE_URL, api_key=setup.api_key, rate_bucket=setup.rate_bucket, limiter=get_default_limiter()
|
|
) as harness:
|
|
yield harness
|