Skip to content

Commit 6367f7a

Browse files
committed
Fixing flaky tests
1 parent 6b848e1 commit 6367f7a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tests/test_asyncio/test_multidb/test_client.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ async def mock_check_health(database):
201201
assert await db1_became_unhealthy.wait(), (
202202
"Timeout waiting for mock_db1 to become unhealthy"
203203
)
204+
204205
await asyncio.sleep(0.01)
205206

206207
assert await client.set("key", "value") == "OK2"
@@ -209,7 +210,14 @@ async def mock_check_health(database):
209210
assert await db2_became_unhealthy.wait(), (
210211
"Timeout waiting for mock_db2 to become unhealthy"
211212
)
212-
await asyncio.sleep(0.01)
213+
214+
# Wait for circuit breaker state to actually reflect the unhealthy status
215+
# (instead of just sleeping)
216+
max_retries = 10
217+
for _ in range(max_retries):
218+
if cb2.state == CBState.OPEN: # Circuit is open (unhealthy)
219+
break
220+
await asyncio.sleep(0.01)
213221

214222
assert await client.set("key", "value") == "OK"
215223

0 commit comments

Comments
 (0)