File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
test_asyncio/test_multidb Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff 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"
Original file line number Diff line number Diff 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"
You can’t perform that action at this time.
0 commit comments