Skip to content

Commit

Permalink
try to stable the test
Browse files Browse the repository at this point in the history
Signed-off-by: Binbin <[email protected]>
  • Loading branch information
enjoy-binbin committed Oct 27, 2024
1 parent 32043dd commit e7b33fa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
15 changes: 10 additions & 5 deletions tests/support/util.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions tests/unit/cluster/auto-failover-on-shutdown.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit e7b33fa

Please sign in to comment.