From bafd8b3b8b8d48e38dcfe57ea36d73e7d4c22034 Mon Sep 17 00:00:00 2001 From: Shahar Mike Date: Sun, 8 Dec 2024 13:34:59 +0200 Subject: [PATCH] chore: Fix `test_rss_used_mem_gap` for all types (#4254) * chore: Fix `test_rss_used_mem_gap` for all types The test fails when it checks the gap between `used_memory` and `object_used_memory`, by assuming that all used memory is consumed by the `type` it `DEBUG POPULATE`s with. This assumption is wrong, because there are other overheads, for example the dash table and string keys. The test failed for types `STRING` and `LIST` because they used a larger number of keys as part of the test parameters, which added a larger overhead. I fixed the parameters such that all types use the same number of keys, and also the same number of elements, modifying only the element sizes (except for `STRING` which doesn't have sub-elements) so that the overall `min_rss` requirement of 3.5gb still passes. Fixes #3723 * threshold * list * comments test assert * previous numbers * ??? --- tests/dragonfly/memory_test.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/dragonfly/memory_test.py b/tests/dragonfly/memory_test.py index 438f5296f..41b450847 100644 --- a/tests/dragonfly/memory_test.py +++ b/tests/dragonfly/memory_test.py @@ -63,7 +63,7 @@ async def test_rss_used_mem_gap(df_server: DflyInstance, type, keys, val_size, e client = df_server.client() await asyncio.sleep(1) # Wait for another RSS heartbeat update in Dragonfly - cmd = f"DEBUG POPULATE {keys} {type} {val_size} RAND TYPE {type} ELEMENTS {elements}" + cmd = f"DEBUG POPULATE {keys} k {val_size} RAND TYPE {type} ELEMENTS {elements}" print(f"Running {cmd}") await client.execute_command(cmd) @@ -76,11 +76,12 @@ async def test_rss_used_mem_gap(df_server: DflyInstance, type, keys, val_size, e # It could be the case that the machine is configured to use swap if this assertion fails assert delta > 0 assert delta < max_unaccounted - delta = info["used_memory_rss"] - info["object_used_memory"] - # TODO investigate why it fails on string - if type == "JSON" or type == "STREAM": - assert delta > 0 - assert delta < max_unaccounted + + if type != "STRING" and type != "JSON": + # STRINGs keep some of the data inline, so not all of it is accounted in object_used_memory + # We have a very small over-accounting bug in JSON + assert info["object_used_memory"] > keys * elements * val_size + assert info["used_memory"] > info["object_used_memory"] @pytest.mark.asyncio