Skip to content

Commit 202b97e

Browse files
committed
Don't start multimaster tests until all nodes are connected
1 parent f25aebf commit 202b97e

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

src/server.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4640,8 +4640,17 @@ sds genRedisInfoString(const char *section) {
46404640
listIter li;
46414641
listNode *ln;
46424642
listRewind(g_pserver->masters, &li);
4643+
bool fAllUp = true;
4644+
while ((ln = listNext(&li))) {
4645+
redisMaster *mi = (redisMaster*)listNodeValue(ln);
4646+
fAllUp = fAllUp && mi->repl_state == REPL_STATE_CONNECTED;
4647+
}
4648+
4649+
sdscatprintf(info, "all_master_link_status:%s\r\n",
4650+
fAllUp ? "up" : "down");
46434651

46444652
int cmasters = 0;
4653+
listRewind(g_pserver->masters, &li);
46454654
while ((ln = listNext(&li)))
46464655
{
46474656
long long slave_repl_offset = 1;

tests/integration/replication-multimaster.tcl

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,21 @@ start_server {overrides {hz 500 active-replica yes multi-master yes}} {
3131
$R(3) replicaof $R_host(2) $R_port(2)
3232
}
3333

34-
after 2000
34+
test "$topology all nodes up" {
35+
for {set j 0} {$j < 4} {incr j} {
36+
wait_for_condition 50 100 {
37+
[string match {*all_master_link_status:up*} [$R($j) info replication]]
38+
} else {
39+
fail "Multimaster group didn't connect up in a reasonable period of time"
40+
}
41+
}
42+
}
3543

3644
test "$topology replicates to all nodes" {
3745
$R(0) set testkey foo
3846
after 500
3947
for {set n 0} {$n < 4} {incr n} {
40-
wait_for_condition 50 1000 {
48+
wait_for_condition 50 100 {
4149
[$R($n) get testkey] == "foo"
4250
} else {
4351
fail "Failed to replicate to $n"
@@ -48,12 +56,17 @@ start_server {overrides {hz 500 active-replica yes multi-master yes}} {
4856
test "$topology replicates only once" {
4957
$R(0) set testkey 1
5058
after 500
59+
#wait_for_condition 50 100 {
60+
# [$R(1) get testkey] == 1 && [$R(2) get testkey] == 1
61+
#} else {
62+
# fail "Set failed to replicate"
63+
#}
5164
$R(1) incr testkey
5265
after 500
5366
$R(2) incr testkey
5467
after 500
5568
for {set n 0} {$n < 4} {incr n} {
56-
wait_for_condition 50 1000 {
69+
wait_for_condition 100 100 {
5770
[$R($n) get testkey] == 3
5871
} else {
5972
fail "node $n did not replicate"
@@ -69,7 +82,7 @@ start_server {overrides {hz 500 active-replica yes multi-master yes}} {
6982
$R(0) incr testkey
7083
$R(0) exec
7184
for {set n 0} {$n < 4} {incr n} {
72-
wait_for_condition 50 1000 {
85+
wait_for_condition 50 100 {
7386
[$R($n) get testkey] == 3
7487
} else {
7588
fail "node $n failed to replicate"

0 commit comments

Comments
 (0)