From 24bbf4988ed3378080da711940ec7d8a5cc2e351 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 20 May 2026 18:53:16 +0000 Subject: [PATCH] fix(cicd): drop obsolete async refresh locks auto-prune test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit dfb2524 intentionally reverted _async_refresh_locks from a WeakValueDictionary back to a regular Dict so the per-key asyncio.Lock identity is stable across concurrent callers — preserving single-flight semantics. The test asserting that the dict shrinks back to 0 after refreshes was added when the WeakValueDictionary backing was still in place; it now contradicts the deliberate design and is failing CI. --- .../llms/vertex_ai/test_vertex_llm_base.py | 44 +------------------ 1 file changed, 1 insertion(+), 43 deletions(-) diff --git a/tests/test_litellm/llms/vertex_ai/test_vertex_llm_base.py b/tests/test_litellm/llms/vertex_ai/test_vertex_llm_base.py index 321f4a6784f..4a1cbb67616 100644 --- a/tests/test_litellm/llms/vertex_ai/test_vertex_llm_base.py +++ b/tests/test_litellm/llms/vertex_ai/test_vertex_llm_base.py @@ -1778,51 +1778,9 @@ class TestVertexBase: f"found {len(vertex_base._background_refresh_tasks)}" ) - @pytest.mark.asyncio - async def test_async_refresh_locks_auto_pruned_when_unused(self): - """Locks must be released from _async_refresh_locks once no coroutine - holds them — backed by a WeakValueDictionary so high-cardinality - deployments do not retain a Lock per credential key forever.""" - import gc - - from google.auth.credentials import TokenState - - vertex_base = VertexBase() - - for i in range(10): - mock_creds = MagicMock() - mock_creds.token = f"refreshed-{i}" - mock_creds.token_state = TokenState.FRESH - mock_creds.project_id = f"project-{i}" - mock_creds.quota_project_id = f"project-{i}" - - credentials = {"type": "service_account", "project_id": f"project-{i}"} - - with ( - patch.object( - vertex_base, - "load_auth", - return_value=(mock_creds, f"project-{i}"), - ), - patch.object(vertex_base, "refresh_auth"), - ): - await vertex_base._ensure_access_token_async( - credentials=credentials, - project_id=f"project-{i}", - custom_llm_provider="vertex_ai", - ) - - gc.collect() - - assert len(vertex_base._async_refresh_locks) == 0, ( - f"Expected 0 lingering locks after refreshes completed, " - f"found {len(vertex_base._async_refresh_locks)}" - ) - @pytest.mark.asyncio async def test_async_refresh_lock_shared_while_in_use(self): - """Concurrent callers for the same key must coordinate on the same lock - even with a WeakValueDictionary backing store.""" + """Concurrent callers for the same key must coordinate on the same lock.""" vertex_base = VertexBase() key = ("creds", "project-1")