mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-17 09:34:48 +00:00
test(spend): wait for the scheduled reset to commit before reading the reset row (#52128)
Co-authored-by: mateo <277851410+mateo-berri@users.noreply.github.com> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
8ba2b23818
commit
2f08fef695
1 changed files with 14 additions and 0 deletions
|
|
@ -121,6 +121,17 @@ def _blocked_reset_updates(table: str) -> int:
|
|||
return int(str(rows[0]["blocked"]))
|
||||
|
||||
|
||||
def _reset_committed(table: str, column: str, identity: str) -> bool:
|
||||
with psycopg.connect(os.environ["DATABASE_URL"]) as observer:
|
||||
row: Final = observer.execute(
|
||||
sql.SQL("SELECT budget_reset_at > now() FROM {} WHERE {} = %s").format(
|
||||
sql.Identifier(table), sql.Identifier(column)
|
||||
),
|
||||
(identity,),
|
||||
).fetchone()
|
||||
return row is not None and row[0] is True
|
||||
|
||||
|
||||
@pytest.mark.parametrize("entity", ("key", "user", "team"))
|
||||
@pytest.mark.parametrize(
|
||||
("workers", "spend", "increment", "rollover", "reset_timezone"),
|
||||
|
|
@ -213,6 +224,9 @@ def test_scheduled_reset_preserves_new_spend_and_never_leaves_roundoff(
|
|||
)
|
||||
gate.commit()
|
||||
eventually(lambda: _blocked_reset_updates(table), lambda count: count == 0, seconds=30)
|
||||
eventually(
|
||||
lambda: _reset_committed(table, column, identity), lambda committed: committed, seconds=30
|
||||
)
|
||||
with psycopg.connect(os.environ["DATABASE_URL"]) as observer:
|
||||
result: Final = observer.execute(
|
||||
sql.SQL(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue