From 1c0f22f5fac7da1668971dc639b04ddefa8df8e1 Mon Sep 17 00:00:00 2001 From: adiholden Date: Mon, 6 Jan 2025 08:39:32 +0200 Subject: [PATCH] chore(pytest): add check for rss grow in replicaiton big values (#4406) Signed-off-by: adi_holden --- tests/dragonfly/replication_test.py | 33 +++++++++++++++++++++++------ tests/dragonfly/seeder/__init__.py | 1 + 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/tests/dragonfly/replication_test.py b/tests/dragonfly/replication_test.py index a2695e5b2e81..fef25ebb74f7 100644 --- a/tests/dragonfly/replication_test.py +++ b/tests/dragonfly/replication_test.py @@ -2662,11 +2662,12 @@ async def test_replication_timeout_on_full_sync_heartbeat_expiry( @pytest.mark.parametrize( "element_size, elements_number", - [(16, 20000), (20000, 16)], + [(16, 30000), (30000, 16)], ) +@dfly_args({"proactor_threads": 1}) async def test_big_containers(df_factory, element_size, elements_number): - master = df_factory.create(proactor_threads=4) - replica = df_factory.create(proactor_threads=4) + master = df_factory.create() + replica = df_factory.create() df_factory.start_all([master, replica]) c_master = master.client() @@ -2674,19 +2675,39 @@ async def test_big_containers(df_factory, element_size, elements_number): logging.debug("Fill master with test data") seeder = StaticSeeder( - key_target=10, + key_target=50, data_size=element_size * elements_number, collection_size=elements_number, variance=1, - samples=5, - types=["LIST", "SET", "ZSET", "HASH"], + samples=1, + types=["LIST", "SET", "ZSET", "HASH", "STREAM"], ) await seeder.run(c_master) + async def get_memory(client, field): + info = await client.info("memory") + return info[field] + + await asyncio.sleep(1) # wait for heartbeat to update rss memory + used_memory = await get_memory(c_master, "used_memory_rss") + logging.debug("Start replication and wait for full sync") await c_replica.execute_command(f"REPLICAOF localhost {master.port}") await wait_for_replicas_state(c_replica) + peak_memory = await get_memory(c_master, "used_memory_peak_rss") + + logging.info(f"Used memory {used_memory}, peak memory {peak_memory}") + assert peak_memory < 1.1 * used_memory + + await c_replica.execute_command("memory decommit") + await asyncio.sleep(1) + replica_peak_memory = await get_memory(c_replica, "used_memory_peak_rss") + replica_used_memory = await get_memory(c_replica, "used_memory_rss") + + logging.info(f"Replica Used memory {replica_used_memory}, peak memory {replica_peak_memory}") + assert replica_peak_memory < 1.1 * replica_used_memory + # Check replica data consisten replica_data = await StaticSeeder.capture(c_replica) master_data = await StaticSeeder.capture(c_master) diff --git a/tests/dragonfly/seeder/__init__.py b/tests/dragonfly/seeder/__init__.py index 351fc38a8458..78c51f3839d3 100644 --- a/tests/dragonfly/seeder/__init__.py +++ b/tests/dragonfly/seeder/__init__.py @@ -118,6 +118,7 @@ async def _run_unit(self, client: aioredis.Redis, dtype: str, prefix: str): args = ["DEBUG", "POPULATE", key_target, prefix, math.ceil(dsize)] args += ["RAND", "TYPE", dtype, "ELEMENTS", csize] + logging.debug(args) return await client.execute_command(*args)