mirror of https://mirror.osredm.com/root/redis.git
Fix flaky replication tests (#13518)
#13495 introduced a change to reply -LOADING while flushing existing db on a replica. Some of our tests are sensitive to this change and do no expect -LOADING reply. Fixing a couple of tests that fail time to time.
This commit is contained in:
parent
31227f4faf
commit
ac03e3721d
|
@ -32,6 +32,13 @@ proc get_one_of_my_replica {id} {
|
|||
}
|
||||
set replica_port [lindex [lindex [lindex [R $id role] 2] 0] 1]
|
||||
set replica_id_num [get_instance_id_by_port redis $replica_port]
|
||||
|
||||
# To avoid -LOADING reply, wait until replica syncs with master.
|
||||
wait_for_condition 1000 50 {
|
||||
[RI $replica_id_num master_link_status] eq {up}
|
||||
} else {
|
||||
fail "Replica did not sync in time."
|
||||
}
|
||||
return $replica_id_num
|
||||
}
|
||||
|
||||
|
@ -105,8 +112,15 @@ proc test_slave_load_expired_keys {aof} {
|
|||
# start the replica again (loading an RDB or AOF file)
|
||||
restart_instance redis $replica_id
|
||||
|
||||
# Replica may start a full sync after restart, trying in a loop to avoid
|
||||
# -LOADING reply in that case.
|
||||
wait_for_condition 1000 50 {
|
||||
[catch {set replica_dbsize_3 [R $replica_id dbsize]} e] == 0
|
||||
} else {
|
||||
fail "Replica is not up."
|
||||
}
|
||||
|
||||
# make sure the keys are still there
|
||||
set replica_dbsize_3 [R $replica_id dbsize]
|
||||
assert {$replica_dbsize_3 > $replica_dbsize_0}
|
||||
|
||||
# restore settings
|
||||
|
|
|
@ -2069,6 +2069,14 @@ start_server {tags {"scripting"}} {
|
|||
} 1 x
|
||||
|
||||
r replicaof [srv -1 host] [srv -1 port]
|
||||
|
||||
# To avoid -LOADING reply, wait until replica syncs with master.
|
||||
wait_for_condition 50 100 {
|
||||
[s master_link_status] eq {up}
|
||||
} else {
|
||||
fail "Replica did not sync in time."
|
||||
}
|
||||
|
||||
assert_error {EXECABORT Transaction discarded because of: READONLY *} {$rr exec}
|
||||
assert_error {READONLY You can't write against a read only replica. script: *} {$rr2 exec}
|
||||
$rr close
|
||||
|
|
Loading…
Reference in New Issue