diff --git a/tests/dragonfly/conftest.py b/tests/dragonfly/conftest.py index 2c87daf6294f..2a948f7da1d6 100644 --- a/tests/dragonfly/conftest.py +++ b/tests/dragonfly/conftest.py @@ -250,13 +250,6 @@ def parse_args(args: List[str]) -> Dict[str, Union[str, None]]: return args_dict -@pytest_asyncio.fixture(scope="class") -def event_loop(): - loop = asyncio.new_event_loop() - yield loop - loop.close() - - @pytest_asyncio.fixture(scope="class", params=[{}]) async def df_factory( request, @@ -363,15 +356,22 @@ async def async_pool(df_server: DflyInstance): @pytest_asyncio.fixture(scope="function") -async def async_client(async_pool): +async def async_client(df_server: DflyInstance): """ Return an async client to the default instance with all entries flushed. """ - client = aioredis.Redis(connection_pool=async_pool) + client = aioredis.Redis( + host="localhost", + port=df_server.port, + db=DATABASE_INDEX, + decode_responses=True, + max_connections=32, + ) await client.client_setname("default-async-fixture") await client.flushall() await client.select(DATABASE_INDEX) yield client + await client.aclose() def pytest_addoption(parser): diff --git a/tests/dragonfly/requirements.txt b/tests/dragonfly/requirements.txt index b8f7593cbfdd..06740426d824 100644 --- a/tests/dragonfly/requirements.txt +++ b/tests/dragonfly/requirements.txt @@ -6,11 +6,11 @@ packaging>=23.1 pluggy>=1.0.0 py>=1.11.0 pyparsing>=3.0.9 -pytest>=7.1.2 +pytest>=8.3,<9.0 redis>=5.2.1 tomli>=2.0.1 wrapt>=1.14.1 -pytest-asyncio==0.20.1 +pytest-asyncio>=0.24.0,<0.25.0 pytest-repeat>=0.9.3 pymemcache>=4.0.0 meta_memcache>=2 diff --git a/tests/dragonfly/snapshot_test.py b/tests/dragonfly/snapshot_test.py index 933291a29a61..178c16bec4cf 100644 --- a/tests/dragonfly/snapshot_test.py +++ b/tests/dragonfly/snapshot_test.py @@ -390,7 +390,8 @@ async def test_exit_on_s3_snapshot_load_err(df_factory): reason="AWS S3 snapshots bucket or credentials are not configured", ) @dfly_args({**BASIC_ARGS}) -async def test_s3_snapshot(async_client, tmp_dir): +async def test_s3_snapshot(df_server, tmp_dir): + async_client = df_server.client() seeder = DebugPopulateSeeder(key_target=10_000) await seeder.run(async_client) @@ -460,7 +461,8 @@ async def test_s3_reload_snapshot_after_restart(df_factory, tmp_dir): reason="AWS S3 snapshots bucket or credentials are not configured", ) @dfly_args({**BASIC_ARGS}) -async def test_s3_save_local_dir(async_client, tmp_dir): +async def test_s3_save_local_dir(df_server, tmp_dir): + async_client = df_server.client() seeder = DebugPopulateSeeder(key_target=10_000) await seeder.run(async_client) diff --git a/tests/pytest.ini b/tests/pytest.ini index 6aba5b0d21f2..bfe0620b4151 100644 --- a/tests/pytest.ini +++ b/tests/pytest.ini @@ -5,6 +5,7 @@ log_date_format = %Y-%m-%d %H:%M:%S log_file_level=INFO log_cli = true asyncio_mode=auto +asyncio_default_fixture_loop_scope=session addopts = -ra --emoji --showlocals -m "not large" markers = # Tests that should only run on release builds and take significant amount of time to run.