Skip to content

Commit 115d996

Browse files
committed
Fixed tests
1 parent f50299e commit 115d996

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

redis/asyncio/multidb/event.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ async def listen(self, event: AsyncActiveDatabaseChanged):
5151
new_pubsub.patterns = old_pubsub.patterns
5252
await new_pubsub.on_connect(None)
5353
event.command_executor.active_pubsub = new_pubsub
54-
await old_pubsub.close()
54+
await old_pubsub.aclose()
5555

5656
class RegisterCommandFailure(AsyncEventListenerInterface):
5757
"""

tests/test_asyncio/test_scenario/conftest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import pytest
66
import pytest_asyncio
77

8-
from redis.asyncio import Redis
8+
from redis.asyncio import Redis, RedisCluster
99
from redis.asyncio.multidb.client import MultiDBClient
1010
from redis.asyncio.multidb.config import DEFAULT_FAILURES_THRESHOLD, DEFAULT_HEALTH_CHECK_INTERVAL, DatabaseConfig, \
1111
MultiDbConfig
@@ -93,6 +93,10 @@ async def r_multi_db(request) -> AsyncGenerator[tuple[MultiDBClient, CheckActive
9393

9494
async def teardown():
9595
await client.aclose()
96+
97+
if isinstance(client.command_executor.active_database.client, Redis):
98+
await client.command_executor.active_database.client.connection_pool.disconnect()
99+
96100
await asyncio.sleep(15)
97101

98102
yield client, listener, endpoint_config

tests/test_asyncio/test_scenario/test_active_active.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,13 @@ async def callback():
186186
)
187187
await asyncio.sleep(0.5)
188188

189-
# Execute commands until database failover
190-
while not listener.is_changed_flag:
191-
await retry.call_with_retry(
192-
lambda: callback(),
193-
lambda _: dummy_fail_async()
194-
)
195-
await asyncio.sleep(0.5)
189+
# Execute commands until database failover
190+
while not listener.is_changed_flag:
191+
await retry.call_with_retry(
192+
lambda: callback(),
193+
lambda _: dummy_fail_async()
194+
)
195+
await asyncio.sleep(0.5)
196196

197197
@pytest.mark.asyncio
198198
@pytest.mark.parametrize(
@@ -235,13 +235,13 @@ async def callback():
235235
)
236236
await asyncio.sleep(0.5)
237237

238-
# Execute pipeline until database failover
239-
while not listener.is_changed_flag:
240-
await retry.call_with_retry(
241-
lambda: callback(),
242-
lambda _: dummy_fail_async()
243-
)
244-
await asyncio.sleep(0.5)
238+
# Execute pipeline until database failover
239+
while not listener.is_changed_flag:
240+
await retry.call_with_retry(
241+
lambda: callback(),
242+
lambda _: dummy_fail_async()
243+
)
244+
await asyncio.sleep(0.5)
245245

246246
@pytest.mark.asyncio
247247
@pytest.mark.parametrize(
@@ -352,5 +352,4 @@ async def handler(message):
352352
# A timeout to ensure that an async handler will handle all previous messages.
353353
await asyncio.sleep(0.1)
354354
task.cancel()
355-
await pubsub.unsubscribe('test-channel') is True
356355
assert messages_count >= 2

0 commit comments

Comments
 (0)