Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix(tests): prevent flaky TTL expiration tests from second-boundary race (#2465)

LearningCircuit1865ecbc7302
diff --git a/tests/utilities/test_search_cache_stampede.py b/tests/utilities/test_search_cache_stampede.py
index 105a09cc7c..57ef216481 100644
--- a/tests/utilities/test_search_cache_stampede.py
+++ b/tests/utilities/test_search_cache_stampede.py
@@ -456,14 +456,16 @@ class TestTTLExpiration:
def test_expired_entry_not_returned(self, short_ttl_cache):
"""Expired entry returns None."""
- short_ttl_cache.put("expiring", [{"title": "Temp"}], "engine1", ttl=1)
+ # Use ttl=2 to avoid flaky failures when put/get straddle a second
+ # boundary (int(time.time()) can jump between the two calls).
+ short_ttl_cache.put("expiring", [{"title": "Temp"}], "engine1", ttl=2)
# Immediately should work
result = short_ttl_cache.get("expiring", "engine1")
assert result is not None
# Wait for expiration
- time.sleep(1.5)
+ time.sleep(2.5)
result = short_ttl_cache.get("expiring", "engine1")
assert result is None
@@ -471,13 +473,13 @@ class TestTTLExpiration:
def test_expired_entry_removed_from_memory(self, short_ttl_cache):
"""Expired entry removed on access."""
short_ttl_cache.put(
- "memory_expire", [{"title": "Temp"}], "engine1", ttl=1
+ "memory_expire", [{"title": "Temp"}], "engine1", ttl=2
)
query_hash = short_ttl_cache._get_query_hash("memory_expire", "engine1")
assert query_hash in short_ttl_cache._memory_cache
- time.sleep(1.5)
+ time.sleep(2.5)
# Access triggers removal
short_ttl_cache.get("memory_expire", "engine1")
@@ -486,9 +488,9 @@ class TestTTLExpiration:
def test_cleanup_removes_expired_from_database(self, short_ttl_cache):
"""_cleanup_expired removes DB entries."""
- short_ttl_cache.put("db_expire", [{"title": "DB"}], "engine1", ttl=1)
+ short_ttl_cache.put("db_expire", [{"title": "DB"}], "engine1", ttl=2)
- time.sleep(1.5)
+ time.sleep(2.5)
# Run cleanup
short_ttl_cache._cleanup_expired()