-
Notifications
You must be signed in to change notification settings - Fork 734
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sergey Kolosov <[email protected]>
- Loading branch information
1 parent
591ae9a
commit c8a713b
Showing
4 changed files
with
130 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
proc find_slots_for_node {node_idx node_id_to_find} { | ||
set shards_cfg [R $node_idx CLUSTER SHARDS] | ||
foreach shard_cfg $shards_cfg { | ||
set nodes [dict get $shard_cfg nodes] | ||
foreach node $nodes { | ||
if {[dict get $node id] eq $node_id_to_find} { | ||
return [dict get $shard_cfg slots] | ||
} | ||
} | ||
} | ||
return [list] | ||
} | ||
|
||
start_cluster 3 3 {tags {external:skip cluster}} { | ||
test "Cluster should start ok" { | ||
wait_for_cluster_state ok | ||
} | ||
|
||
test "CLUSTER REPLICATE NO ONE should turn node into empty primary" { | ||
set replica_node 3 | ||
set replica_node_id [R $replica_node CLUSTER MYID] | ||
# make sure node is replica | ||
wait_for_condition 100 100 { | ||
[string first "slave" [R $replica_node ROLE]] >= 0 | ||
} else { | ||
puts "R $replica_node ROLE: [R $replica_node ROLE]" | ||
fail "R $replica_node didn't assume replica role in time" | ||
} | ||
|
||
assert_equal "OK" [R $replica_node CLUSTER REPLICATE NO ONE] | ||
|
||
# make sure node is turned into primary | ||
wait_for_condition 100 100 { | ||
[string first "master" [R $replica_node ROLE]] >= 0 | ||
} else { | ||
puts "R $replica_node ROLE: [R $replica_node ROLE]" | ||
fail "R $replica_node didn't assume primary role in time" | ||
} | ||
|
||
# checking that new primary has no slots across all nodes | ||
foreach node_idx {0 1 2 3 4 5} { | ||
wait_for_condition 100 100 { | ||
[llength [find_slots_for_node $node_idx $replica_node_id]] == 0 | ||
} else { | ||
puts "R $node_idx still returns node $replica_node_id owning slots: [find_slots_for_node $node_idx $replica_node_id]" | ||
fail "R $node_idx didn't refresh topology after detaching replica $replica_node/$replica_node_id" | ||
} | ||
} | ||
} | ||
} |