Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions tests/pass_through_tests/test_vertex_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,21 @@ async def test_basic_vertex_ai_pass_through_with_spendlog():

print("response", response)

# Poll for spend update instead of fixed sleep - spend logging is async/batched
max_wait = 120 # total seconds to wait
# Spend logging is async/batched and can lag under CI load, so poll instead of
# sleeping a fixed amount. A transient empty read is skipped, not counted as 0.0
# spend, which would spuriously fail the assertion on an otherwise-billed call.
max_wait = 240 # total seconds to wait
poll_interval = 10 # seconds between checks
elapsed = 0
spend_after = spend_before
while elapsed < max_wait:
await asyncio.sleep(poll_interval)
elapsed += poll_interval
spend_after = await call_spend_logs_endpoint() or 0.0
latest_spend = await call_spend_logs_endpoint()
if latest_spend is None:
print(f"spend logs unavailable (elapsed={elapsed}s), retrying")
continue
spend_after = latest_spend
print(f"spend_after (elapsed={elapsed}s)", spend_after)
if spend_after > spend_before:
break
Expand Down
Loading