From 67135b3b1ea60345a69a906573e93261aeed685e Mon Sep 17 00:00:00 2001 From: webtecnica Date: Tue, 22 Sep 2026 22:58:20 -0300 Subject: [PATCH] test(models): pin live-rebuild budget in model-cache metadata tests The three get_available_models() tests in tests/test_model_cache_metadata.py depend on the rebuild finishing inside _LIVE_REBUILD_BUDGET_SECONDS (4.0s). On a loaded host the rebuild exceeds it and api/config.py::get_available_models serves the over-budget stale payload, failing the rebuilt-metadata assertions. Pin the budget to 0.0 (synchronous rebuild), the same pattern already used by tests/test_issue2513_custom_provider_remote_models.py and tests/test_copilot_provider_model_settings_not_allowlist.py. Closes #7735 --- tests/test_model_cache_metadata.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_model_cache_metadata.py b/tests/test_model_cache_metadata.py index d624ce36..bdb580d6 100644 --- a/tests/test_model_cache_metadata.py +++ b/tests/test_model_cache_metadata.py @@ -112,6 +112,9 @@ def test_load_models_cache_from_disk_rejects_partial_metadata_cache( def test_get_available_models_ignores_invalid_ttl_memory_cache(monkeypatch): + # Pin the budget so a slow/loaded host cannot blow the global 4s limit and + # serve the over-budget stale payload instead of the rebuilt catalog. + monkeypatch.setattr(config, "_LIVE_REBUILD_BUDGET_SECONDS", 0.0, raising=False) _reset_memory_cache() stale_cache = { @@ -152,6 +155,9 @@ def test_get_available_models_does_not_use_disk_cache_after_config_mtime_change( ): cache_path = tmp_path / "models_cache.json" monkeypatch.setattr(config, "_models_cache_path", cache_path) + # Pin the budget so the rebuild cannot exceed the global 4s limit and + # serve the over-budget stale payload instead of the rebuilt catalog. + monkeypatch.setattr(config, "_LIVE_REBUILD_BUDGET_SECONDS", 0.0, raising=False) cache_path.write_text( json.dumps( { @@ -194,6 +200,9 @@ def test_get_available_models_ignores_legacy_disk_cache_and_rebuilds( ): cache_path = tmp_path / "models_cache.json" monkeypatch.setattr(config, "_models_cache_path", cache_path) + # Pin the budget so the rebuild cannot exceed the global 4s limit and + # serve the legacy stale disk groups instead of the rebuilt catalog. + monkeypatch.setattr(config, "_LIVE_REBUILD_BUDGET_SECONDS", 0.0, raising=False) cache_path.write_text( json.dumps( {