Skip to content

Commit c0a7d70

Browse files
committed
test: make TTL assertions in RedisEventStore flake-resistant
1 parent 07bf1ca commit c0a7d70

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

tests/server/contrib/test_redis_event_store.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,25 +267,26 @@ async def test_event_key_has_ttl_when_configured(store_with_ttl, redis_client):
267267
event_id = await store_with_ttl.store_event("stream-A", SAMPLE_MSG)
268268

269269
ttl = await redis_client.ttl(f"test:event:{event_id}")
270-
# TTL should be set and very close to 60 seconds
271-
# (allow 2s tolerance for test execution time)
272-
assert 58 <= ttl <= 60
270+
# TTL should be set and positive (allow execution delay on slow runners)
271+
assert 0 < ttl <= 60
273272

274273

275274
@pytest.mark.anyio
276275
async def test_stream_key_has_ttl_when_configured(store_with_ttl, redis_client):
277276
await store_with_ttl.store_event("stream-A", SAMPLE_MSG)
278277

279278
ttl = await redis_client.ttl("test:stream:stream-A")
280-
assert 58 <= ttl <= 60
279+
# TTL should be set and positive (allow execution delay on slow runners)
280+
assert 0 < ttl <= 60
281281

282282

283283
@pytest.mark.anyio
284284
async def test_counter_key_has_ttl_when_configured(store_with_ttl, redis_client):
285285
await store_with_ttl.store_event("stream-A", SAMPLE_MSG)
286286

287287
ttl = await redis_client.ttl("test:counter")
288-
assert 58 <= ttl <= 60
288+
# TTL should be set and positive (allow execution delay on slow runners)
289+
assert 0 < ttl <= 60
289290

290291

291292
@pytest.mark.anyio

0 commit comments

Comments
 (0)