Skip to content

Commit a99f1dd

Browse files
authored
test: fix flaky test_takeover_bug_wrong_replica_checked_in_logs (#6075)
* test: fix flaky test_takeover_bug_wrong_replica_checked_in_logs * fix: review comments
1 parent 16e69bc commit a99f1dd

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

tests/dragonfly/replication_test.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3592,20 +3592,18 @@ async def test_takeover_bug_wrong_replica_checked_in_logs(df_factory):
35923592

35933593
# Reconnect replica[1] and immediately takeover from replica[0]
35943594
await clients[1].execute_command(f"REPLICAOF localhost {master.port}")
3595-
try:
3596-
await clients[0].execute_command("REPLTAKEOVER 1")
3597-
except Exception:
3598-
pass
3595+
3596+
await check_all_replicas_finished(clients, c_master)
3597+
3598+
await clients[0].execute_command("REPLTAKEOVER 10")
35993599

36003600
# Check master logs
36013601
master.stop(kill=False)
3602-
timeout_logs = master.find_in_logs("Couldn't synchronize with replica")
36033602

3604-
if timeout_logs:
3605-
for log in timeout_logs:
3606-
assert (
3607-
str(replicas[0].port) not in log
3608-
), f"BUG: Checked initiating replica {replicas[0].port} instead of others"
3603+
timeout_logs = master.find_in_logs(
3604+
f"Couldn't synchronize with replica for takeover in time: 127.0.0.1:{replicas[0].port}"
3605+
)
3606+
assert not timeout_logs
36093607

36103608

36113609
@pytest.mark.slow

0 commit comments

Comments
 (0)