Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tests/support/cluster_util.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -458,3 +458,13 @@ proc wait_for_slot_state {srv_idx pattern} {
fail "incorrect slot state on R $srv_idx: expected $pattern; got [get_open_slots $srv_idx]"
}
}

# Returns the test index of a node given its node ID
proc get_node_index_by_id {node_id} {
for {set i 0} {$i < [llength $::servers]} {incr i} {
if {[R $i CLUSTER MYID] eq $node_id} {
return $i
}
}
return -1 ;# not found
}
9 changes: 9 additions & 0 deletions tests/unit/cluster/cli.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,15 @@ test {Migrate the last slot away from a node using valkey-cli} {
set owner_r [valkey $owner_host $owner_port 0 $::tls]
set owner_id [$owner_r CLUSTER MYID]

# get the index of the owner node
set owner_index [get_node_index_by_id $owner_id]

wait_for_condition 1000 50 {
[cluster_get_node_by_id $owner_index $newnode_id] ne {}
} else {
fail "Owner node never learned the new node"
}

# Move slot to new node using plain commands
assert_equal OK [$newnode_r CLUSTER SETSLOT $slot IMPORTING $owner_id]
assert_equal OK [$owner_r CLUSTER SETSLOT $slot MIGRATING $newnode_id]
Expand Down
Loading