Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

test(integration): reconcile concurrent cost tracking changes

kerry7d9a95462e17
diff --cc tests/integration/cost_calculation/conftest.py
index 4f1f723c2f7,fb20f5a9cc2..3536c020515
--- a/tests/integration/cost_calculation/conftest.py
+++ b/tests/integration/cost_calculation/conftest.py
@@@ -185,17 -178,21 +185,18 @@@ def poll_rollups
daily_user=DailySpend.model_validate(daily_user_rows[0]),
daily_team=DailySpend.model_validate(daily_team_rows[0]),
)
- if rollups.daily_user.api_requests < requests or rollups.daily_team.api_requests < requests:
- return None
- if not all(
- approx_equal(actual, spend)
- for actual in (
- rollups.key_spend,
- rollups.team_spend,
- rollups.user_spend,
- rollups.end_user_spend,
- )
- ):
- return None
+ return rollups
- result: Final = eventually(read, lambda value: value is not None, seconds=60)
+ result: Final = eventually(
+ read,
+ lambda value: (
+ value is not None
+ and value.daily_user.api_requests >= requests
+ and value.daily_team.api_requests >= requests
+ and approx_equal(value.key_spend, target_spend)
+ ),
+ seconds=60,
+ )
assert result is not None
return result