Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions tests/gtid/master_restart.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,15 @@ proc restart_test {master_gtid_enabled slave_gtid_enabled restat_master_gtid_ena
}

wait_for_condition 1000 30 {
[$master dbsize] eq [$slave dbsize]
&& [$slave dbsize] eq 0
[dbsize_loadsafe $master master_dbsize] &&
[dbsize_loadsafe $slave slave_dbsize] &&
$master_dbsize eq $slave_dbsize &&
$slave_dbsize eq 0
} else {
puts [$master dbsize]
puts [$slave dbsize]
puts [dbsize_loadsafe $master master_dbsize]
puts $master_dbsize
puts [dbsize_loadsafe $slave slave_dbsize]
puts $slave_dbsize
fail "slave dbszie != 0"
}

Expand Down
6 changes: 4 additions & 2 deletions tests/gtid/sync.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ start_server {overrides {gtid-enabled yes}} {
$R(1) slaveof $R_host(0) $R_port(0)
wait_for_condition 50 1000 {
[status $R(1) master_link_status] == "up" &&
[$R(1) dbsize] == 1
[dbsize_loadsafe $R(1) replica_dbsize] &&
$replica_dbsize == 1
} else {
fail "Replicas not replicating from master"
}
Expand Down Expand Up @@ -155,7 +156,8 @@ start_server {overrides {gtid-enabled yes}} {
$R(1) slaveof $R_host(0) $R_port(0)
wait_for_condition 50 1000 {
[status $R(1) master_link_status] == "up" &&
[$R(1) dbsize] == 1
[dbsize_loadsafe $R(1) replica_dbsize] &&
$replica_dbsize == 1
} else {
fail "Replicas not replicating from master"
}
Expand Down
14 changes: 13 additions & 1 deletion tests/gtid/xsync.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,18 @@ start_server {tags {"xsync"} overrides {gtid-enabled yes}} {

# after fullresync, S SS is consistent with M
assert_equal [$M hmget hello f1 f2] {v2 v2}

# In swap mode servercron (which triggers forced full resync on
# WRONGTYPE) may be delayed. wait_for_sync only
# checks master_link_status=="up", which can still be true before
# the resync fires. Wait explicitly for S to have the correct type.
if {$::swap} {
wait_for_condition 500 100 {
[catch {$S hmget hello f1 f2} _sr] == 0 && $_sr eq {v2 v2}
} else {
fail "S not fixed by forced full resync in swap mode"
}
}
assert_equal [$S hmget hello f1 f2] {v2 v2}

catch {$SS hmget hello f1 f2} result
Expand Down Expand Up @@ -1638,4 +1650,4 @@ start_server {tags {"xsync"} overrides {gtid-enabled yes}} {
}

}
}
}
5 changes: 4 additions & 1 deletion tests/integration/psync2-pingoff.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ start_server {} {
$R(0) set foo bar
wait_for_condition 50 1000 {
[status $R(1) master_link_status] == "up" &&
[$R(0) dbsize] == 1 && [$R(1) dbsize] == 1
[dbsize_loadsafe $R(0) master_dbsize] &&
[dbsize_loadsafe $R(1) replica_dbsize] &&
$master_dbsize == 1 &&
$replica_dbsize == 1
} else {
fail "Replicas not replicating from master"
}
Expand Down
6 changes: 4 additions & 2 deletions tests/integration/psync2-reg.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ start_server {} {
wait_for_condition 50 1000 {
[status $R(1) master_link_status] == "up" &&
[status $R(2) master_link_status] == "up" &&
[$R(1) dbsize] == 1 &&
[$R(2) dbsize] == 1
[dbsize_loadsafe $R(1) replica1_dbsize] &&
[dbsize_loadsafe $R(2) replica2_dbsize] &&
$replica1_dbsize == 1 &&
$replica2_dbsize == 1
} else {
fail "Replicas not replicating from master"
}
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/replication.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,9 @@ start_server {tags {"repl external:skip tsan:skip"} overrides {save ""}} {
# Make sure that replicas and master have same
# number of keys
wait_for_condition 50 100 {
[$master dbsize] == [$replica dbsize]
[dbsize_loadsafe $master master_dbsize] &&
[dbsize_loadsafe $replica replica_dbsize] &&
$master_dbsize == $replica_dbsize
} else {
fail "Different number of keys between master and replicas after too long time."
}
Expand Down
9 changes: 9 additions & 0 deletions tests/support/util.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ proc status {r property} {
set _ [getInfoProperty [{*}$r info] $property]
}

proc dbsize_loadsafe {r varname} {
upvar 1 $varname dbsize
if {$::swap} {
return [expr {[catch {{*}$r dbsize} dbsize] == 0}]
}
set dbsize [{*}$r dbsize]
return 1
}

proc waitForBgsave r {
while 1 {
if {[status $r rdb_bgsave_in_progress] eq 1} {
Expand Down
5 changes: 3 additions & 2 deletions tests/swap/integration/repro-swapdb-inconsistency.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ start_server {tags {"repl"}} {
}

wait_for_condition 200 100 {
[$master dbsize] == [$slave dbsize]
[dbsize_loadsafe $master master_dbsize] &&
[dbsize_loadsafe $slave slave_dbsize] &&
$master_dbsize == $slave_dbsize
} else {
# dump key lists (scan-based, works for cold keys too)
dump_keylist $master /tmp/replkeys_master.txt
Expand All @@ -120,4 +122,3 @@ start_server {tags {"repl"}} {
}
}


4 changes: 3 additions & 1 deletion tests/swap/ported/integration/block-repl.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ start_server {tags {"repl"}} {
stop_bg_block_op $load_handle1
stop_bg_block_op $load_handle2
wait_for_condition 100 100 {
[$master dbsize] == [$slave dbsize]
[dbsize_loadsafe $master master_dbsize] &&
[dbsize_loadsafe $slave slave_dbsize] &&
$master_dbsize == $slave_dbsize
} else {
set csv1 [csvdump r]
set csv2 [csvdump {r -1}]
Expand Down
13 changes: 9 additions & 4 deletions tests/swap/ported/integration/psync2-reg.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ start_server {} {
wait_for_condition 50 1000 {
[status $R(1) master_link_status] == "up" &&
[status $R(2) master_link_status] == "up" &&
[$R(1) dbsize] == 1 &&
[$R(2) dbsize] == 1
[dbsize_loadsafe $R(1) replica1_dbsize] &&
[dbsize_loadsafe $R(2) replica2_dbsize] &&
$replica1_dbsize == 1 &&
$replica2_dbsize == 1
} else {
fail "Replicas not replicating from master"
}
Expand Down Expand Up @@ -73,8 +75,11 @@ start_server {} {

test "PSYNC2 #3899 regression: verify consistency" {
wait_for_condition 50 1000 {
([$R(0) dbsize] eq [$R(1) dbsize]) &&
([$R(1) dbsize] eq [$R(2) dbsize])
[dbsize_loadsafe $R(0) master_dbsize] &&
[dbsize_loadsafe $R(1) replica1_dbsize] &&
[dbsize_loadsafe $R(2) replica2_dbsize] &&
($master_dbsize eq $replica1_dbsize) &&
($replica1_dbsize eq $replica2_dbsize)
} else {
fail "The three instances have different data sets"
}
Expand Down
9 changes: 6 additions & 3 deletions tests/swap/ported/integration/replication-3.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ start_server {tags {"repl"}} {
r keys * ;# Force DEL syntesizing to slave
after 1000 ;# Wait another second. Now everything should be fine.
wait_for_condition 100 50 {
[r -1 dbsize] == [r dbsize]
[dbsize_loadsafe {r -1} replica_dbsize] &&
[dbsize_loadsafe r master_dbsize] &&
$replica_dbsize == $master_dbsize
} else {
fail "wait sync"
}
Expand All @@ -44,7 +46,9 @@ start_server {tags {"repl"}} {
test {Slave is able to evict keys created in writable slaves} {
# wait createComplexDataset
wait_for_condition 500 100 {
[r dbsize] == [r -1 dbsize]
[dbsize_loadsafe r master_dbsize] &&
[dbsize_loadsafe {r -1} replica_dbsize] &&
$master_dbsize == $replica_dbsize
} else {
fail "Replicas and master offsets were unable to match *exactly*."
}
Expand All @@ -64,4 +68,3 @@ start_server {tags {"repl"}} {
} {0}
}
}

4 changes: 3 additions & 1 deletion tests/swap/ported/integration/replication-psync.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ proc test_psync {descr duration backlog_size backlog_ttl delay cond mdl sdl bgsa
}

wait_for_condition 100 100 {
[$master dbsize] == [$slave dbsize]
[dbsize_loadsafe $master master_dbsize] &&
[dbsize_loadsafe $slave slave_dbsize] &&
$master_dbsize == $slave_dbsize
} else {
set csv1 [csvdump r]
set csv2 [csvdump {r -1}]
Expand Down
11 changes: 8 additions & 3 deletions tests/swap/ported/integration/replication.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,12 @@ start_server {tags {"repl"} overrides {repl-backlog-size 10mb}} {
# Stop the write load
stop_write_load $load_handle0

# number of keys
# number of keys
wait_for_condition 500 100 {
[$master dbsize] eq [$slave dbsize] && [$master dbsize] > 0
[dbsize_loadsafe $master master_dbsize] &&
[dbsize_loadsafe $slave slave_dbsize] &&
$master_dbsize eq $slave_dbsize &&
$master_dbsize > 0
} else {
fail "Different datasets between replica and master"
}
Expand Down Expand Up @@ -450,7 +453,9 @@ start_server {tags {"repl" "nosanitizer"} overrides {swap-repl-rordb-sync no}} {
# Make sure that replicas and master have same
# number of keys
wait_for_condition 50 100 {
[$master dbsize] == [$replica dbsize]
[dbsize_loadsafe $master master_dbsize] &&
[dbsize_loadsafe $replica replica_dbsize] &&
$master_dbsize == $replica_dbsize
} else {
fail "Different number of keys between master and replicas after too long time."
}
Expand Down
4 changes: 2 additions & 2 deletions tests/swap/support/util.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,9 @@ proc swap_data_comp {r1 r2} {
if {$len != $len2} {
data_conflict $t $key '' 'SLEN:$len' 'SLEN:$len2'
}
set skeys [r smembers k1]
set skeys [$r1 smembers $key]
foreach skey $skeys {
if {0 == [$r2 sismember $skey]} {
if {0 == [$r2 sismember $key $skey]} {
data_conflict $t $key $skey "1" "0"
}
}
Expand Down
4 changes: 3 additions & 1 deletion tests/swap/unit/select.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,9 @@ start_server {overrides {save ""} tags {"swap" "select"}} {
$master select $db
$slave select $db
wait_for_condition 500 10 {
[$master dbsize] eq [$slave dbsize]
[dbsize_loadsafe $master master_dbsize] &&
[dbsize_loadsafe $slave slave_dbsize] &&
$master_dbsize eq $slave_dbsize
} else {
fail "db$db dbsize not match"
}
Expand Down
Loading