From 3a184880c6488a5027416315ec97ee06a93f1917 Mon Sep 17 00:00:00 2001 From: Antonio Andelic Date: Sun, 5 Mar 2023 17:18:53 +0000 Subject: [PATCH] Add test for clrs --- .../test_keeper_four_word_command/test.py | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/integration/test_keeper_four_word_command/test.py b/tests/integration/test_keeper_four_word_command/test.py index 04f6800b92b..d3fcfcc3014 100644 --- a/tests/integration/test_keeper_four_word_command/test.py +++ b/tests/integration/test_keeper_four_word_command/test.py @@ -679,3 +679,41 @@ def test_cmd_rqld(started_cluster): + " does not become leader after 30s, maybe there is something wrong." ) assert keeper_utils.is_leader(cluster, node) + + +def test_cmd_clrs(started_cluster): + def get_memory_purges(): + return node1.query( + "SELECT value FROM system.events WHERE event = 'MemoryAllocatorPurge' SETTINGS system_events_show_zero_values = 1" + ) + + zk = None + try: + wait_nodes() + + zk = get_fake_zk(node1.name, timeout=30.0) + + paths = [f"/clrs_{i}" for i in range(10000)] + + # we only count the events because we cannot reliably test memory usage of Keeper + # but let's create and delete nodes so the first purge needs to release some memory + create_transaction = zk.transaction() + for path in paths: + create_transaction.create(path) + create_transaction.commit() + + delete_transaction = zk.transaction() + for path in paths: + delete_transaction.delete(path) + delete_transaction.commit() + + # repeat multiple times to make sure MemoryAllocatorPurge isn't increased because of other reasons + for _ in range(5): + prev_purges = int(get_memory_purges()) + keeper_utils.send_4lw_cmd(cluster, node1, cmd="clrs") + current_purges = int(get_memory_purges()) + assert current_purges > prev_purges + prev_purges = current_purges + + finally: + destroy_zk_client(zk)