mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
test(e2e): address greptile review feedback
Remove the duplicate cache/cache_params block in the gateway config so the two can't silently diverge under future edits. Reorder the soft-budget test to assert the call isn't a budget block before require_successful_call, since that helper hard-fails any non-2xx and left the budget-block check unreachable; the misleading "skip" comment is corrected. Add a deferred delete in test_budget_delete_removes_it so a failed delete doesn't leak a budget on the shared proxy. Scope the spend_tracking sys.path insertion in pytest_sessionfinish to just the cleanup import so a broader "pytest tests/" run isn't left with a mutated path.
This commit is contained in:
parent
1033279f25
commit
dcecafa9b5
4 changed files with 10 additions and 11 deletions
|
|
@ -38,6 +38,7 @@ def test_budget_crud_roundtrip(client: BudgetClient, resources: ResourceManager)
|
|||
|
||||
def test_budget_delete_removes_it(client: BudgetClient, resources: ResourceManager) -> None:
|
||||
budget_id = client.create_budget(max_budget=1.0)
|
||||
resources.defer(lambda: client.delete_budget(budget_id))
|
||||
client.delete_budget(budget_id)
|
||||
assert not client.budget_info(budget_id), "budget still present after delete"
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ def test_soft_budget_does_not_block(
|
|||
result = client.chat(
|
||||
key, "claude-haiku-4-5", f"hi {unique_marker()}", max_tokens=16
|
||||
)
|
||||
require_successful_call(result) # skip if provider unavailable
|
||||
assert not is_budget_block(result), (
|
||||
"soft_budget blocked a request; it must alert only, not block "
|
||||
f"(body={result.body[:200]})"
|
||||
)
|
||||
require_successful_call(result) # any other non-2xx (e.g. provider down) is a hard fail
|
||||
|
|
|
|||
|
|
@ -32,14 +32,20 @@ def pytest_configure(config: pytest.Config) -> None:
|
|||
def pytest_sessionfinish(session: pytest.Session, exitstatus: int) -> None:
|
||||
"""Once the whole e2e session is done (all suites), truncate the spend logs so
|
||||
the DB doesn't accumulate test rows. Best-effort: a cleanup failure (no DB
|
||||
reachable) must not fail the run."""
|
||||
sys.path.insert(0, str(Path(__file__).parent / "spend_tracking"))
|
||||
reachable) must not fail the run. The spend_tracking dir goes on sys.path only
|
||||
for this import and is removed after, so a broader `pytest tests/` run is not
|
||||
left with a mutated path."""
|
||||
spend_dir = str(Path(__file__).parent / "spend_tracking")
|
||||
sys.path.insert(0, spend_dir)
|
||||
try:
|
||||
from spend_e2e_client import reset_spend_logs # pyright: ignore
|
||||
|
||||
reset_spend_logs()
|
||||
except Exception as exc: # noqa: BLE001 - cleanup is best-effort
|
||||
print(f"spend-log cleanup skipped: {exc}")
|
||||
finally:
|
||||
if spend_dir in sys.path:
|
||||
sys.path.remove(spend_dir)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
|
|
|
|||
|
|
@ -61,14 +61,6 @@ litellm_settings:
|
|||
# service_callback: ["datadog"]
|
||||
callbacks: ["arize_phoenix", "datadog", "smtp_email", "prometheus", "otel"]
|
||||
require_auth_for_metrics_endpoint: false
|
||||
cache: true
|
||||
cache_params:
|
||||
type: redis
|
||||
host: redis
|
||||
port: 6379
|
||||
password: os.environ/REDIS_PASSWORD
|
||||
namespace: litellm.caching
|
||||
ttl: 16600
|
||||
#type: redis-semantic
|
||||
#similarity_threshold: 0.8 # similarity threshold for semantic cache
|
||||
#redis_semantic_cache_embedding_model: text-embedding-ada-002 # only works with text-embedding-ada-002 for now... https://github.com/BerriAI/litellm/issues/4001
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue