Skip to content

Commit

Permalink
remove hard reset in base.tcl, update no-failover-option
Browse files Browse the repository at this point in the history
Signed-off-by: Binbin <[email protected]>
  • Loading branch information
enjoy-binbin committed May 8, 2024
1 parent a9374f8 commit f11d682
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 40 deletions.
23 changes: 0 additions & 23 deletions tests/unit/cluster/base.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,6 @@ test "Cluster nodes are reachable" {
}
}

test "Cluster nodes hard reset" {
for {set id 0} {$id < [llength $::servers]} {incr id} {
if {$::valgrind} {
set node_timeout 10000
} else {
set node_timeout 3000
}
catch {R $id flushall} ; # May fail for readonly slaves.
R $id MULTI
R $id cluster reset hard
R $id cluster set-config-epoch [expr {$id+1}]
R $id EXEC
R $id config set cluster-node-timeout $node_timeout
R $id config set cluster-slave-validity-factor 10
R $id config set loading-process-events-interval-bytes 2097152
R $id config set key-load-delay 0
R $id config set repl-diskless-load disabled
R $id config set cluster-announce-hostname ""
R $id DEBUG DROP-CLUSTER-PACKET-FILTER -1
R $id config rewrite
}
}

test "Cluster Join and auto-discovery test" {
# Use multiple attempts since sometimes nodes timeout
# while attempting to connect.
Expand Down
30 changes: 13 additions & 17 deletions tests/unit/cluster/no-failover-option.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,35 @@

source tests/support/cluster.tcl

start_cluster 5 5 {tags {external:skip cluster}} {
start_cluster 3 3 {tags {external:skip cluster}} {

test "Cluster is up" {
wait_for_cluster_state ok
}

test "Instance #5 is a slave" {
assert {[s -5 role] eq {slave}}
test "Instance #3 is a replica" {
assert {[s -3 role] eq {slave}}

# Configure it to never failover the master
R 5 CONFIG SET cluster-slave-no-failover yes
R 3 CONFIG SET cluster-replica-no-failover yes
}

test "Instance #5 synced with the master" {
test "Instance #3 synced with the master" {
wait_for_condition 1000 50 {
[s -5 master_link_status] eq {up}
[s -3 master_link_status] eq {up}
} else {
fail "Instance #5 master link status is not up"
fail "Instance #3 master link status is not up"
}
}

test "The nofailover flag is propagated" {
set slave5_id [dict get [cluster_get_myself 5] id]
set replica3_id [dict get [cluster_get_myself 3] id]

for {set j 0} {$j < [llength $::servers]} {incr j} {
wait_for_condition 1000 50 {
[cluster_has_flag [cluster_get_node_by_id $j $slave5_id] nofailover]
[cluster_has_flag [cluster_get_node_by_id $j $replica3_id] nofailover]
} else {
fail "Instance $id can't see the nofailover flag of slave"
fail "Instance $id can't see the nofailover flag of replica"
}
}
}
Expand All @@ -45,18 +45,14 @@ test "Cluster should be still down after some time" {
[CI 2 cluster_state] eq {fail} &&
[CI 3 cluster_state] eq {fail} &&
[CI 4 cluster_state] eq {fail} &&
[CI 5 cluster_state] eq {fail} &&
[CI 6 cluster_state] eq {fail} &&
[CI 7 cluster_state] eq {fail} &&
[CI 8 cluster_state] eq {fail} &&
[CI 9 cluster_state] eq {fail}
[CI 5 cluster_state] eq {fail}
} else {
fail "Cluster doesn't fail"
}
}

test "Instance #5 is still a slave" {
assert {[s -5 role] eq {slave}}
test "Instance #3 is still a replica" {
assert {[s -3 role] eq {slave}}
}

test "Restarting the previously killed master node" {
Expand Down

0 comments on commit f11d682

Please sign in to comment.