From e7b33faea3963c058ef8f67c8ab419ea7bb67226 Mon Sep 17 00:00:00 2001 From: Binbin Date: Mon, 28 Oct 2024 00:57:42 +0800 Subject: [PATCH] try to stable the test Signed-off-by: Binbin --- tests/support/util.tcl | 15 ++++++++++----- tests/unit/cluster/auto-failover-on-shutdown.tcl | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/support/util.tcl b/tests/support/util.tcl index 77c22207f2..816fe4cdf6 100644 --- a/tests/support/util.tcl +++ b/tests/support/util.tcl @@ -126,17 +126,22 @@ proc wait_replica_online r { } } -proc get_replica_acked_offset {primary replica_ip replica_port} { +proc check_replica_acked_ofs {primary replica_ip replica_port} { set infostr [$primary info replication] - if {[regexp -lineanchor "^slave\\d:ip=$replica_ip,port=$replica_port,.*,offset=(\\d+).*\r\n" $infostr _ value]} { - return $value + set master_repl_offset [getInfoProperty $infostr master_repl_offset] + if {[regexp -lineanchor "^slave\\d:ip=$replica_ip,port=$replica_port,.*,offset=(\\d+).*\r\n" $infostr _ offset]} { + if {$master_repl_offset == $offset} { + return 1 + } + return 0 } + return 0 } proc wait_replica_acked_ofs {primary replica_ip replica_port} { $primary config set repl-ping-replica-period 3600 - wait_for_condition 500 100 { - [status $primary master_repl_offset] eq [get_replica_acked_offset $primary $replica_ip $replica_port] + wait_for_condition 50 100 { + [check_replica_acked_ofs $primary $replica_ip $replica_port] eq 1 } else { puts "INFO REPLICATION: [$primary info replication]" fail "replica acked offset didn't match in time" diff --git a/tests/unit/cluster/auto-failover-on-shutdown.tcl b/tests/unit/cluster/auto-failover-on-shutdown.tcl index 84050abb3f..aa9dfee20b 100644 --- a/tests/unit/cluster/auto-failover-on-shutdown.tcl +++ b/tests/unit/cluster/auto-failover-on-shutdown.tcl @@ -27,6 +27,7 @@ proc test_main {how} { } # Wait the replica2 catch up with the offset + wait_for_ofs_sync $primary $replica2 wait_replica_acked_ofs $primary $replica2_ip $replica2_port # Shutdown the primary.