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:
Ozan Tezcan 2024-09-08 12:54:01 +03:00 committed by GitHub
parent 31227f4faf
commit ac03e3721d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 1 deletions

View File

@ -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

View File

@ -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