mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 16:48:27 -05:00
8c254415f7
It is now possible to kill and restart sentinel or redis instances for more real-world testing. The 01 unit tests the capability of Sentinel to update the configuration of Sentinels rejoining the cluster, however the test is pretty trivial and more tests should be added.
33 lines
1.0 KiB
Tcl
33 lines
1.0 KiB
Tcl
# Initialization tests -- most units will start including this.
|
|
|
|
set redis_slaves 4
|
|
test "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 "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
|
|
}
|
|
}
|
|
|
|
test "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."
|
|
}
|
|
}
|
|
}
|