Skip to content

test(budgets): age the monthly window past any calendar month so the reset test passes on the 31st - #49372

Merged
ryan-crabbe-berri merged 1 commit into
mainfrom
litellm_fix_month_end_budget_window_test
Oct 31, 2026
Merged

ryan-crabbe-berri merged 1 commit into
mainfrom
litellm_fix_month_end_budget_window_test

Conversation

@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor

The monthly budget reset test failed on the 31st of every month because it aged the window by a fixed 30 days while the limiter measures a calendar month. The test now ages the window past the longest calendar month and computes the expected reset time the way the limiter does

Details

TLDR

Problem this solves:

  • test_user_model_budget_window_resets_when_the_period_elapses fails on every 31st
  • Expected budget_reset_at assumed 30-day months too

How it solves it:

  • Age the window start by 31 days plus a minute
  • Expected reset time uses budget_window_seconds, the limiter's own calendar math

Pre-Submission checklist

  • I have added meaningful tests
  • The handful of test files covering my change pass locally
  • My PR passes all required CI/CD checks
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • Every automated review on my PR's latest commit has finished, and I have addressed or replied to each of its findings before requesting a maintainer review

Screenshots / Proof of Fix

E2E exception at 79283ab. Test-only change, no product code touched, so a live proxy run proves nothing extra. The clock was faked with faketime to hit month ends

# base 837f36e872
faketime "2026-10-31 12:00:00" pytest ...::test_user_model_budget_window_resets_when_the_period_elapses  -> 1 failed
faketime "2027-03-31 12:00:00" pytest ...::test_user_model_budget_window_resets_when_the_period_elapses  -> 1 failed

# fix 79283ab20f
faketime "2026-10-31 12:00:00" -> 1 passed
faketime "2027-01-31 12:00:00" -> 1 passed
faketime "2027-03-31 12:00:00" -> 1 passed
faketime "2026-11-15 12:00:00" -> 1 passed

# whole file at the fix
faketime "2026-10-31 12:00:00" pytest tests/unit/proxy/hooks/test_unit_test_max_model_budget_limiter.py -> 83 passed
faketime "2027-01-31 12:00:00" pytest tests/unit/proxy/hooks/test_unit_test_max_model_budget_limiter.py -> 83 passed
real clock -> 83 passed

Type

✅ Test

Caveats (if any)

Low

Link to Devin session: https://app.devin.ai/sessions/7df8c116a866458db64eb92ff28900fe
Open in Devin Desktop: https://app.devin.ai/desktop/session/7df8c116a866458db64eb92ff28900fe?variant=devin
Requested by: @ryan-crabbe-berri

…reset test passes on the 31st

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@mateo-berri mateo-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@ryan-crabbe-berri
ryan-crabbe-berri enabled auto-merge (squash) October 31, 2026 01:45
@ryan-crabbe-berri
ryan-crabbe-berri merged commit 5029d02 into main Oct 31, 2026
85 of 86 checks passed
@ryan-crabbe-berri
ryan-crabbe-berri deleted the litellm_fix_month_end_budget_window_test branch October 31, 2026 01:57
@codecov

codecov Bot commented Oct 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

DeoLeung pushed a commit to aiyou178/litellm that referenced this pull request Nov 5, 2026
…reset test passes on the 31st (BerriAI#49372)

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
(cherry picked from commit 5029d02)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants