Speed up sentinel tests (#9408)
Use sentinel debug to reduce default timeouts and allow tests to execute faster.
This commit is contained in:
parent
8b8f05c86c
commit
763fd09416
@ -2,6 +2,10 @@
|
||||
source "../tests/includes/start-init-tests.tcl"
|
||||
source "../tests/includes/init-tests.tcl"
|
||||
|
||||
foreach_sentinel_id id {
|
||||
S $id sentinel debug default-down-after 1000
|
||||
}
|
||||
|
||||
if {$::simulate_error} {
|
||||
test "This test will fail" {
|
||||
fail "Simulated error"
|
||||
@ -14,6 +18,8 @@ test "Basic failover works if the master is down" {
|
||||
assert {[lindex $addr 1] == $old_port}
|
||||
kill_instance redis $master_id
|
||||
foreach_sentinel_id id {
|
||||
S $id sentinel debug ping-period 100
|
||||
S $id sentinel debug ask-period 100
|
||||
wait_for_condition 1000 50 {
|
||||
[lindex [S $id SENTINEL GET-MASTER-ADDR-BY-NAME mymaster] 1] != $old_port
|
||||
} else {
|
||||
|
@ -48,6 +48,13 @@ proc 02_crash_and_failover {} {
|
||||
|
||||
02_test_slaves_replication
|
||||
02_crash_and_failover
|
||||
|
||||
foreach_sentinel_id id {
|
||||
S $id sentinel debug info-period 100
|
||||
S $id sentinel debug default-down-after 1000
|
||||
S $id sentinel debug publish-period 100
|
||||
}
|
||||
|
||||
02_test_slaves_replication
|
||||
|
||||
test "Kill a slave instance" {
|
||||
|
@ -2,6 +2,12 @@
|
||||
|
||||
source "../tests/includes/init-tests.tcl"
|
||||
|
||||
foreach_sentinel_id id {
|
||||
S $id sentinel debug info-period 1000
|
||||
S $id sentinel debug default-down-after 3000
|
||||
S $id sentinel debug publish-period 500
|
||||
}
|
||||
|
||||
test "Manual failover works" {
|
||||
set old_port [RPort $master_id]
|
||||
set addr [S 0 SENTINEL GET-MASTER-ADDR-BY-NAME mymaster]
|
||||
@ -42,4 +48,3 @@ test "The old master eventually gets reconfigured as a slave" {
|
||||
fail "Old master not reconfigured as slave of new master"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,10 @@ source "../../../tests/support/cli.tcl"
|
||||
|
||||
set ::alive_sentinel [expr {$::instances_count/2+2}]
|
||||
proc ensure_master_up {} {
|
||||
S $::alive_sentinel sentinel debug info-period 1000
|
||||
S $::alive_sentinel sentinel debug ping-period 100
|
||||
S $::alive_sentinel sentinel debug ask-period 100
|
||||
S $::alive_sentinel sentinel debug publish-period 100
|
||||
wait_for_condition 1000 50 {
|
||||
[dict get [S $::alive_sentinel sentinel master mymaster] flags] eq "master"
|
||||
} else {
|
||||
@ -12,7 +16,12 @@ proc ensure_master_up {} {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
proc ensure_master_down {} {
|
||||
S $::alive_sentinel sentinel debug info-period 1000
|
||||
S $::alive_sentinel sentinel debug ping-period 100
|
||||
S $::alive_sentinel sentinel debug ask-period 100
|
||||
S $::alive_sentinel sentinel debug publish-period 100
|
||||
wait_for_condition 1000 50 {
|
||||
[string match *down* \
|
||||
[dict get [S $::alive_sentinel sentinel master mymaster] flags]]
|
||||
@ -30,7 +39,7 @@ test "Crash the majority of Sentinels to prevent failovers for this unit" {
|
||||
test "SDOWN is triggered by non-responding but not crashed instance" {
|
||||
lassign [S $::alive_sentinel SENTINEL GET-MASTER-ADDR-BY-NAME mymaster] host port
|
||||
ensure_master_up
|
||||
exec ../../../src/redis-cli -h $host -p $port {*}[rediscli_tls_config "../../../tests"] debug sleep 10 > /dev/null &
|
||||
exec ../../../src/redis-cli -h $host -p $port {*}[rediscli_tls_config "../../../tests"] debug sleep 3 > /dev/null &
|
||||
ensure_master_down
|
||||
ensure_master_up
|
||||
}
|
||||
|
@ -47,4 +47,3 @@ test "SENTINEL CONFIG SET handles on-the-fly credentials reconfiguration" {
|
||||
test "(post-cleanup) Tear down ACL configuration" {
|
||||
teardown_acl
|
||||
}
|
||||
|
||||
|
@ -33,9 +33,11 @@ proc 10_test_number_of_replicas {n_replicas_expected} {
|
||||
test "Check sentinel replies with $n_replicas_expected replicas" {
|
||||
# ensure sentinels replies with the right number of replicas
|
||||
foreach_sentinel_id id {
|
||||
# retries 40 x 500ms = 20s as SENTINEL_INFO_PERIOD = 10s
|
||||
S $id sentinel debug info-period 100
|
||||
S $id sentinel debug default-down-after 1000
|
||||
S $id sentinel debug publish-period 100
|
||||
set len [llength [S $id SENTINEL REPLICAS mymaster]]
|
||||
wait_for_condition 40 500 {
|
||||
wait_for_condition 200 100 {
|
||||
[llength [S $id SENTINEL REPLICAS mymaster]] == $n_replicas_expected
|
||||
} else {
|
||||
fail "Sentinel replies with a wrong number of replicas with replica-announced=yes (expected $n_replicas_expected but got $len) on sentinel $id"
|
||||
@ -71,3 +73,4 @@ proc 10_set_replica_announced {master_id announced n_replicas} {
|
||||
10_set_replica_announced $master_id "yes" "all"
|
||||
# ensure all replicas are not announced by sentinels
|
||||
10_test_number_of_replicas 4
|
||||
|
||||
|
@ -20,7 +20,7 @@ test "Start/Stop sentinel on same port with a different runID should not change
|
||||
set pid [exec_instance "sentinel" $dirname $orgfilename]
|
||||
lappend ::pids $pid
|
||||
|
||||
after 5000
|
||||
after 1000
|
||||
|
||||
# Get new count of total sentinel
|
||||
set b [S 0 SENTINEL master mymaster]
|
||||
|
Loading…
x
Reference in New Issue
Block a user