From 5dd825d28d9c1f872e8244e8ed173982a020d3f5 Mon Sep 17 00:00:00 2001 From: Binbin Date: Tue, 16 Jul 2024 17:28:54 +0800 Subject: [PATCH] update comment and indentation Signed-off-by: Binbin --- src/cluster_legacy.c | 2 +- tests/unit/cluster/failover.tcl | 84 ++++++++++++++++----------------- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/cluster_legacy.c b/src/cluster_legacy.c index 7dc16f9bb4..abca3d6144 100644 --- a/src/cluster_legacy.c +++ b/src/cluster_legacy.c @@ -4096,7 +4096,7 @@ void clusterSendFailoverAuthIfNeeded(clusterNode *node, clusterMsg *request) { * multiple replicas may have the same rank, in case they have the same offset. * * If the replication offsets are the same, the one with the lexicographically - * smaller Node id * will have a better ranking to avoid simultaneous elections + * smaller node id will have a lower rank to avoid simultaneous elections * of replicas. * * The replica rank is used to add a delay to start an election in order to diff --git a/tests/unit/cluster/failover.tcl b/tests/unit/cluster/failover.tcl index 3c63ad608c..b7fbfd3da5 100644 --- a/tests/unit/cluster/failover.tcl +++ b/tests/unit/cluster/failover.tcl @@ -73,61 +73,61 @@ test "Instance #0 gets converted into a slave" { start_cluster 3 6 {tags {external:skip cluster}} { -test "Cluster is up" { - wait_for_cluster_state ok -} + test "Cluster is up" { + wait_for_cluster_state ok + } -test "Cluster is writable" { - cluster_write_test [srv 0 port] -} + test "Cluster is writable" { + cluster_write_test [srv 0 port] + } -set current_epoch [CI 1 cluster_current_epoch] + set current_epoch [CI 1 cluster_current_epoch] -set paused_pid [srv 0 pid] -test "Killing the first primary node" { - pause_process $paused_pid -} - -test "Wait for failover" { - wait_for_condition 1000 50 { - [CI 1 cluster_current_epoch] > $current_epoch - } else { - fail "No failover detected" + set paused_pid [srv 0 pid] + test "Killing the first primary node" { + pause_process $paused_pid } -} -test "Cluster should eventually be up again" { - for {set j 0} {$j < [llength $::servers]} {incr j} { - if {[process_is_paused [srv -$j pid]]} continue + test "Wait for failover" { wait_for_condition 1000 50 { - [CI $j cluster_state] eq "ok" + [CI 1 cluster_current_epoch] > $current_epoch } else { - fail "Cluster node $j cluster_state:[CI $j cluster_state]" + fail "No failover detected" } } -} -test "Restarting the previously killed primary node" { - resume_process $paused_pid -} + test "Cluster should eventually be up again" { + for {set j 0} {$j < [llength $::servers]} {incr j} { + if {[process_is_paused [srv -$j pid]]} continue + wait_for_condition 1000 50 { + [CI $j cluster_state] eq "ok" + } else { + fail "Cluster node $j cluster_state:[CI $j cluster_state]" + } + } + } -test "Instance #0 gets converted into a replica" { - wait_for_condition 1000 50 { - [s 0 role] eq {slave} - } else { - fail "Old primary was not converted into replica" + test "Restarting the previously killed primary node" { + resume_process $paused_pid } - wait_for_cluster_propagation -} -test "Make sure the replicas always get the different ranks" { - if {[s -3 role] == "master"} { - verify_log_message -3 "*Start of election*rank #0*" 0 - verify_log_message -6 "*Start of election*rank #1*" 0 - } else { - verify_log_message -3 "*Start of election*rank #1*" 0 - verify_log_message -6 "*Start of election*rank #0*" 0 + test "Instance #0 gets converted into a replica" { + wait_for_condition 1000 50 { + [s 0 role] eq {slave} + } else { + fail "Old primary was not converted into replica" + } + wait_for_cluster_propagation + } + + test "Make sure the replicas always get the different ranks" { + if {[s -3 role] == "master"} { + verify_log_message -3 "*Start of election*rank #0*" 0 + verify_log_message -6 "*Start of election*rank #1*" 0 + } else { + verify_log_message -3 "*Start of election*rank #1*" 0 + verify_log_message -6 "*Start of election*rank #0*" 0 + } } -} } ;# start_cluster