Skip to content

Commit 653ae26

Browse files
committed
Fixing test_execute_command_against_correct_db_on_background_health_check_determine_active_db_unhealthy
1 parent 72080fa commit 653ae26

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

tests/test_asyncio/test_multidb/test_client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,14 @@ async def mock_check_health(database):
279279
async with MultiDBClient(mock_multi_db_config) as client:
280280
assert await client.set("key", "value") == "OK1"
281281
await error_event.wait()
282+
# Wait for circuit breaker to actually open (not just the event)
283+
max_retries = 10
284+
for _ in range(max_retries):
285+
if mock_db1.circuit.state == CBState.OPEN: # Circuit is open
286+
break
287+
await asyncio.sleep(0.01)
288+
289+
# Now the failover strategy will select mock_db2
282290
assert await client.set("key", "value") == "OK2"
283291
await asyncio.sleep(0.5)
284292
assert await client.set("key", "value") == "OK1"

tests/test_multidb/test_client.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,15 @@ def mock_check_health(database):
268268
client = MultiDBClient(mock_multi_db_config)
269269
assert client.set("key", "value") == "OK1"
270270
error_event.wait(timeout=0.5)
271+
272+
# Wait for circuit breaker to actually open (not just the event)
273+
max_retries = 10
274+
for _ in range(max_retries):
275+
if mock_db1.circuit.state == CBState.OPEN: # Circuit is open
276+
break
277+
sleep(0.01)
278+
279+
# Now the failover strategy will select mock_db2
271280
assert client.set("key", "value") == "OK2"
272281
sleep(0.5)
273282
assert client.set("key", "value") == "OK1"

0 commit comments

Comments
 (0)