Skip to content

Commit

Permalink
Fix build builds and flaky tests
Browse files Browse the repository at this point in the history
Signed-off-by: Ping Xie <[email protected]>
  • Loading branch information
PingXie committed Apr 29, 2024
1 parent 4cef2b4 commit 10944e6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/cluster_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include <sys/stat.h>
#include <math.h>
#include <sys/file.h>
#include <stdbool.h>

/* A global reference to myself is handy to make code more clear.
* Myself always points to server.cluster->myself, that is, the clusterNode
Expand Down Expand Up @@ -2865,7 +2866,7 @@ static clusterNode *getNodeFromLinkAndMsg(clusterLink *link, clusterMsg *hdr) {
return sender;
}

bool clusterValidatePacket(clusterLink *link) {
bool clusterIsValidPacket(clusterLink *link) {
clusterMsg *hdr = (clusterMsg*) link->rcvbuf;
uint32_t totlen = ntohl(hdr->totlen);
uint16_t type = ntohs(hdr->type);
Expand Down Expand Up @@ -2970,7 +2971,7 @@ bool clusterValidatePacket(clusterLink *link) {
int clusterProcessPacket(clusterLink *link) {

/* Validate that the packet is well-formed */
if (!clusterValidatePacket(link)) return 1;
if (!clusterIsValidPacket(link)) return 1;

clusterMsg *hdr = (clusterMsg*) link->rcvbuf;
uint16_t type = ntohs(hdr->type);
Expand Down Expand Up @@ -3177,7 +3178,7 @@ int clusterProcessPacket(clusterLink *link) {

/* Check for role switch: slave -> master or master -> slave. */
if (sender) {
serverLog(LL_VERBOSE,
serverLog(LL_DEBUG,
"node %.40s (%s) announces that it is a %s in shard %.40s",
sender->name,
sender->human_nodename,
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/cluster/hostnames.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,18 @@ test "Verify the nodes configured with prefer hostname only show hostname for ne
# to accept our isolated nodes connections. At this point they will
# start showing up in cluster slots.
wait_for_condition 50 100 {
[llength [R 6 CLUSTER SLOTS]] eq 2
[llength [R 6 CLUSTER SLOTS]] eq 3
} else {
fail "Node did not learn about the 2 shards it can talk to"
}
wait_for_condition 50 100 {
[lindex [get_slot_field [R 6 CLUSTER SLOTS] 0 2 3] 1] eq "shard-1.com"
[lindex [get_slot_field [R 6 CLUSTER SLOTS] 1 2 3] 1] eq "shard-1.com"
} else {
fail "hostname for shard-1 didn't reach node 6"
}

wait_for_condition 50 100 {
[lindex [get_slot_field [R 6 CLUSTER SLOTS] 1 2 3] 1] eq "shard-2.com"
[lindex [get_slot_field [R 6 CLUSTER SLOTS] 2 2 3] 1] eq "shard-2.com"
} else {
fail "hostname for shard-2 didn't reach node 6"
}
Expand Down
1 change: 1 addition & 0 deletions tests/unit/cluster/slot-migration.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ proc wait_for_role {srv_idx role} {
} else {
fail "R $srv_idx didn't assume the cluster $role in time"
}
wait_for_cluster_propagation
}

proc wait_for_slot_state {srv_idx pattern} {
Expand Down

0 comments on commit 10944e6

Please sign in to comment.