Skip to content

test(auth): freeze prefetch cache clock on staging so Postgres Tests stop flaking - #41130

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/ci-autofix-automation-15b7
Draft

cursor[bot] wants to merge 1 commit into
mainfrom
cursor/ci-autofix-automation-15b7

Conversation

@cursor

@cursor cursor Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

How it solves it:

  • Cherry-pick the frozen-clock fix onto the staging branch
  • Injects InMemoryCache(clock=lambda: 1_000_000.0) in the three prefetch tests
  • Cache TTL cannot expire mid-test, so the getters serve from the cache and never touch the mock DB

Relevant issues

Staging-only re-application of PR #40996

Linear ticket

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
  • I have received a Greptile Confidence Score of at least 4/5

Type

Test

Caveats (if any)

Low

  • Test-only change, straight cherry-pick of an upstream fix already merged to main
Open in Web View Automation 

The org cache entries written by prefetch_auth_objects carry the 5s
DEFAULT_IN_MEMORY_TTL. The first @log_db_metrics getter lazily imports
litellm.proxy.proxy_server, which on a cold CI runner can take longer
than 5s, so the org entry expired before get_org_object read it and the
getter fell through to the MagicMock database. Inject a frozen clock
into InMemoryCache so the test asserts the join, not import latency.

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

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@devin-ai-integration
devin-ai-integration Bot changed the base branch from litellm_internal_staging to main September 23, 2026 14:34

This branch has not been deployed

No deployments
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.

1 participant