From f7e9b41e7203ca6547073c22e990dc98ff166158 Mon Sep 17 00:00:00 2001 From: Ping Xie Date: Mon, 8 Jul 2024 14:55:26 -0700 Subject: [PATCH] Add a missing test helper function Signed-off-by: Ping Xie --- tests/support/cluster_util.tcl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/support/cluster_util.tcl b/tests/support/cluster_util.tcl index 5160466474..64d4bf52e4 100644 --- a/tests/support/cluster_util.tcl +++ b/tests/support/cluster_util.tcl @@ -66,6 +66,21 @@ proc continuous_slot_allocation {masters} { } } +# Assuming nodes are reset, this function performs slots allocation. +# # Only the first 'masters' nodes are used. +proc cluster_allocate_slots {masters replicas} { + set slot 16383 + while {$slot >= 0} { + # Allocate successive slots to random nodes. + set node [randomInt $masters] + lappend slots_$node $slot + incr slot -1 + } + for {set j 0} {$j < $masters} {incr j} { + R $j cluster addslots {*}[set slots_${j}] + } +} + # Setup method to be executed to configure the cluster before the # tests run. proc cluster_setup {masters node_count slot_allocator code} {