-
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 95c0b42
Showing
4 changed files
with
133 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,53 @@ | ||
# Replication test. | ||
# | ||
# Check CLUSTER REPLICATE commands. | ||
|
||
source "../tests/includes/init-tests.tcl" | ||
|
||
# Create a cluster with 3 master and 6 slaves, to make sure there are no | ||
# empty masters and make rebalancing simpler to handle during the test. | ||
test "Create a 3 shards cluster" { | ||
cluster_create_with_continuous_slots 3 6 | ||
} | ||
|
||
test "Cluster is up" { | ||
assert_cluster_state ok | ||
} | ||
|
||
set replica_node 3 | ||
|
||
test "CLUSTER REPLICATE NO ONE should turn node into empty primary" { | ||
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 | ||
set shards_cfg [R $replica_node CLUSTER SHARDS] | ||
foreach shard_cfg $shards_cfg { | ||
set slots [dict get $shard_cfg slots] | ||
if {[llength $slots] > 0} { | ||
set nodes [dict get $shard_cfg nodes] | ||
foreach node $nodes { | ||
if {[dict get $node id] eq $replica_node_id} { | ||
puts "R $replica_node/$replica_node_id owns some slots: $slots" | ||
fail "R $replica_node/$replica_node_id should not own any slots" | ||
} | ||
} | ||
} | ||
} | ||
} |