diff --git a/src/cluster_legacy.c b/src/cluster_legacy.c index 8f801f4751..cea1c03fe7 100644 --- a/src/cluster_legacy.c +++ b/src/cluster_legacy.c @@ -3096,7 +3096,7 @@ int clusterProcessPacket(clusterLink *link) { link->node ? link->node->name : "NULL"); if (sender && (sender->flags & CLUSTER_NODE_MEET)) { - // Once we get a response for MEET from the sender, we can stop sending more MEET + /* Once we get a response for MEET from the sender, we can stop sending more MEET. */ sender->flags &= ~CLUSTER_NODE_MEET; } diff --git a/tests/cluster/tests/includes/init-tests.tcl b/tests/cluster/tests/includes/init-tests.tcl index d01258f6ce..41fc49aa6d 100644 --- a/tests/cluster/tests/includes/init-tests.tcl +++ b/tests/cluster/tests/includes/init-tests.tcl @@ -74,19 +74,17 @@ proc join_nodes_in_cluster {} { return 1 } -if {![info exists do_not_join_cluster_nodes] || !$do_not_join_cluster_nodes} { - test "Cluster Join and auto-discovery test" { - # Use multiple attempts since sometimes nodes timeout - # while attempting to connect. - for {set attempts 3} {$attempts > 0} {incr attempts -1} { - if {[join_nodes_in_cluster] == 1} { - break - } - } - if {$attempts == 0} { - fail "Cluster failed to form full mesh" +test "Cluster Join and auto-discovery test" { + # Use multiple attempts since sometimes nodes timeout + # while attempting to connect. + for {set attempts 3} {$attempts > 0} {incr attempts -1} { + if {[join_nodes_in_cluster] == 1} { + break } } + if {$attempts == 0} { + fail "Cluster failed to form full mesh" + } } test "Before slots allocation, all nodes report cluster failure" { diff --git a/tests/cluster/tests/30-reliable-meet.tcl b/tests/unit/cluster/cluster-reliable-meet.tcl similarity index 51% rename from tests/cluster/tests/30-reliable-meet.tcl rename to tests/unit/cluster/cluster-reliable-meet.tcl index 84fde8b4e6..b8e7d5b2a3 100644 --- a/tests/cluster/tests/30-reliable-meet.tcl +++ b/tests/unit/cluster/cluster-reliable-meet.tcl @@ -1,37 +1,55 @@ -set do_not_join_cluster_nodes 1 +# make sure the test infra won't use SELECT +set old_singledb $::singledb +set ::singledb 1 -source "../tests/includes/init-tests.tcl" +tags {tls:skip external:skip cluster} { -# Create a cluster composed of the specified number of primaries. -proc create_primaries_only_cluster {primaries} { - cluster_allocate_slots $primaries - set ::cluster_master_nodes $primaries +set base_conf [list cluster-enabled yes] +start_multiple_servers 2 [list overrides $base_conf] { + +test "Cluster nodes are reachable" { + for {set id 0} {$id < [llength $::servers]} {incr id} { + # Every node should be reachable. + wait_for_condition 1000 50 { + ([catch {R $id ping} ping_reply] == 0) && + ($ping_reply eq {PONG}) + } else { + catch {R $id ping} err + fail "Node #$id keeps replying '$err' to PING." + } + } +} + +test "Before slots allocation, all nodes report cluster failure" { + wait_for_cluster_state fail } set CLUSTER_PACKET_TYPE_MEET 2 set CLUSTER_PACKET_TYPE_NONE -1 -set a 0 -set b 1 +set b 0 +set a 1 test "Cluster nodes haven't met each other" { assert {[llength [get_cluster_nodes $a]] == 1} assert {[llength [get_cluster_nodes $b]] == 1} } -test "Create a 2 nodes cluster with 2 shards" { - create_primaries_only_cluster 2 +test "Allocate slots" { + cluster_allocate_slots 2 0 } test "MEET is reliabile when target drops the initial MEETs" { - set b_port [get_instance_attrib valkey $b port] - # Make b drop the initial MEET messages due to link failure R $b DEBUG DROP-CLUSTER-PACKET-FILTER $CLUSTER_PACKET_TYPE_MEET R $b DEBUG CLOSE-CLUSTER-LINK-ON-PACKET-DROP 1 + set b_port [srv 0 port] + R $a CLUSTER MEET 127.0.0.1 $b_port + # Wait for at least a few MEETs to be sent so that we are sure that b is + # dropping them. wait_for_condition 1000 50 { [CI $b cluster_stats_messages_meet_received] >= 3 } else { @@ -46,9 +64,16 @@ test "MEET is reliabile when target drops the initial MEETs" { # If the MEET is reliable, both a and b will turn to cluster state ok wait_for_condition 1000 50 { - [CI $a cluster_state] eq {ok} && [CI $b cluster_state] eq {ok} + [CI $a cluster_state] eq {ok} && [CI $b cluster_state] eq {ok} && + [CI $b cluster_stats_messages_meet_received] >= 4 && + [CI $a cluster_stats_messages_meet_sent] == [CI $b cluster_stats_messages_meet_received] } else { fail "$a cluster_state:[CI $a cluster_state], $b cluster_state: [CI $b cluster_state]" } } +} ;# stop servers + +} ;# tags + +set ::singledb $old_singledb