Unverified Commit 6075f506 authored by Binbin's avatar Binbin Committed by GitHub
Browse files

Move restart_killed_instances and verify_sentinel_auto_discovery to utils (#10497)

Create a utils.tcl in sentinel/tests/includes, and move two procs to it.
Allow sentinel test 08-hostname-conf run on its own.
parent 4e55d557
source "../tests/includes/utils.tcl"
proc set_redis_announce_ip {addr} { proc set_redis_announce_ip {addr} {
foreach_redis_id id { foreach_redis_id id {
R $id config set replica-announce-ip $addr R $id config set replica-announce-ip $addr
......
# Initialization tests -- most units will start including this. # Initialization tests -- most units will start including this.
source "../tests/includes/utils.tcl"
proc restart_killed_instances {} {
foreach type {redis sentinel} {
foreach_${type}_id id {
if {[get_instance_attrib $type $id pid] == -1} {
puts -nonewline "$type/$id "
flush stdout
restart_instance $type $id
}
}
}
}
proc verify_sentinel_auto_discovery {} {
set sentinels [llength $::sentinel_instances]
foreach_sentinel_id id {
wait_for_condition 1000 50 {
[dict get [S $id SENTINEL MASTER mymaster] num-other-sentinels] == ($sentinels-1)
} else {
fail "At least some sentinel can't detect some other sentinel"
}
}
}
test "(init) Restart killed instances" { test "(init) Restart killed instances" {
restart_killed_instances restart_killed_instances
......
proc restart_killed_instances {} {
foreach type {redis sentinel} {
foreach_${type}_id id {
if {[get_instance_attrib $type $id pid] == -1} {
puts -nonewline "$type/$id "
flush stdout
restart_instance $type $id
}
}
}
}
proc verify_sentinel_auto_discovery {} {
set sentinels [llength $::sentinel_instances]
foreach_sentinel_id id {
wait_for_condition 1000 50 {
[dict get [S $id SENTINEL MASTER mymaster] num-other-sentinels] == ($sentinels-1)
} else {
fail "At least some sentinel can't detect some other sentinel"
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment