mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 08:38:27 -05:00
8d011492a0
This commit sets the failover timeout to 30 seconds instead of the 180 seconds default, and allows to reconfigure multiple slaves at the same time. This makes tests less sensible to timing, with the result that there are less false positives due to normal behaviors that require time to succeed or to be retried. However the long term solution is probably some way in order to detect when a test failed because of timing issues (for example split brain during leader election) and retry it.
68 lines
2.2 KiB
Tcl
68 lines
2.2 KiB
Tcl
# Initialization tests -- most units will start including this.
|
|
|
|
test "(init) 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
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
set redis_slaves 4
|
|
test "(init) Create a master-slaves cluster of [expr $redis_slaves+1] instances" {
|
|
create_redis_master_slave_cluster [expr {$redis_slaves+1}]
|
|
}
|
|
set master_id 0
|
|
|
|
test "(init) Sentinels can start monitoring a master" {
|
|
set sentinels [llength $::sentinel_instances]
|
|
set quorum [expr {$sentinels/2+1}]
|
|
foreach_sentinel_id id {
|
|
catch {S $id SENTINEL REMOVE mymaster}
|
|
S $id SENTINEL MONITOR mymaster \
|
|
[get_instance_attrib redis $master_id host] \
|
|
[get_instance_attrib redis $master_id port] $quorum
|
|
}
|
|
foreach_sentinel_id id {
|
|
assert {[S $id sentinel master mymaster] ne {}}
|
|
S $id SENTINEL SET mymaster down-after-milliseconds 2000
|
|
S $id SENTINEL SET mymaster failover-timeout 20000
|
|
S $id SENTINEL SET mymaster parallel-syncs 10
|
|
}
|
|
}
|
|
|
|
test "(init) Sentinels can talk with the master" {
|
|
foreach_sentinel_id id {
|
|
wait_for_condition 100 50 {
|
|
[catch {S $id SENTINEL GET-MASTER-ADDR-BY-NAME mymaster}] == 0
|
|
} else {
|
|
fail "Sentinel $id can't talk with the master."
|
|
}
|
|
}
|
|
}
|
|
|
|
test "(init) Sentinels are able to auto-discover other sentinels" {
|
|
set sentinels [llength $::sentinel_instances]
|
|
foreach_sentinel_id id {
|
|
wait_for_condition 100 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) Sentinels are able to auto-discover slaves" {
|
|
foreach_sentinel_id id {
|
|
wait_for_condition 100 50 {
|
|
[dict get [S $id SENTINEL MASTER mymaster] num-slaves] == $redis_slaves
|
|
} else {
|
|
fail "At least some sentinel can't detect some slave"
|
|
}
|
|
}
|
|
}
|