chore: fix test_snapshot (#4607)

This commit is contained in:
Kostas Kyrimis 2025-02-13 17:29:41 +02:00 committed by GitHub
parent 7930b585ee
commit 59cd931113
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -154,7 +154,7 @@ async def test_dbfilenames(
{
**BASIC_ARGS,
"proactor_threads": 4,
"dbfilename": "test-redis-load-rdb",
"dbfilename": "test-redis-load-rdb",
}
)
async def test_redis_load_snapshot(
@ -402,13 +402,13 @@ class TestDflySnapshotOnShutdown:
assert memory_counters == {"object_used_memory": 0}
@pytest.mark.asyncio
@pytest.mark.slow
async def test_snapshot(self, df_server, async_client):
"""Checks that:
1. After reloading the snapshot file the data is the same
2. Memory counters after loading from snapshot is similar to before creating a snapshot
2. Memory counters after loading should be non zero
3. Memory counters after deleting all keys loaded by snapshot - this validates the memory
counting when loading from snapshot."""
seeder = StaticSeeder(**self.SEEDER_ARGS)
await seeder.run(async_client)
start_capture = await StaticSeeder.capture(async_client)
@ -426,10 +426,8 @@ class TestDflySnapshotOnShutdown:
memory_after = await self._get_info_memory_fields(async_client)
for counter, value in memory_before.items():
# Unfortunately memory usage sometimes depends on order of insertion / deletion, so
# it's usually not exactly the same. For the test to be stable we check that it's
# at least 50% that of the original value.
assert memory_after[counter] >= 0.5 * value
# Counters should be non zero.
assert memory_after[counter] > 0
await self._delete_all_keys(async_client)
memory_empty = await self._get_info_memory_fields(async_client)