Unverified Commit 763fd094 authored by Wen Hui's avatar Wen Hui Committed by GitHub
Browse files

Speed up sentinel tests (#9408)

Use sentinel debug to reduce default timeouts and allow tests to execute faster.
parent 8b8f05c8
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
source "../tests/includes/start-init-tests.tcl" source "../tests/includes/start-init-tests.tcl"
source "../tests/includes/init-tests.tcl" source "../tests/includes/init-tests.tcl"
foreach_sentinel_id id {
S $id sentinel debug default-down-after 1000
}
if {$::simulate_error} { if {$::simulate_error} {
test "This test will fail" { test "This test will fail" {
fail "Simulated error" fail "Simulated error"
...@@ -14,6 +18,8 @@ test "Basic failover works if the master is down" { ...@@ -14,6 +18,8 @@ test "Basic failover works if the master is down" {
assert {[lindex $addr 1] == $old_port} assert {[lindex $addr 1] == $old_port}
kill_instance redis $master_id kill_instance redis $master_id
foreach_sentinel_id id { foreach_sentinel_id id {
S $id sentinel debug ping-period 100
S $id sentinel debug ask-period 100
wait_for_condition 1000 50 { wait_for_condition 1000 50 {
[lindex [S $id SENTINEL GET-MASTER-ADDR-BY-NAME mymaster] 1] != $old_port [lindex [S $id SENTINEL GET-MASTER-ADDR-BY-NAME mymaster] 1] != $old_port
} else { } else {
......
...@@ -48,6 +48,13 @@ proc 02_crash_and_failover {} { ...@@ -48,6 +48,13 @@ proc 02_crash_and_failover {} {
02_test_slaves_replication 02_test_slaves_replication
02_crash_and_failover 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 02_test_slaves_replication
test "Kill a slave instance" { test "Kill a slave instance" {
......
...@@ -2,6 +2,12 @@ ...@@ -2,6 +2,12 @@
source "../tests/includes/init-tests.tcl" 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" { test "Manual failover works" {
set old_port [RPort $master_id] set old_port [RPort $master_id]
set addr [S 0 SENTINEL GET-MASTER-ADDR-BY-NAME mymaster] 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" { ...@@ -42,4 +48,3 @@ test "The old master eventually gets reconfigured as a slave" {
fail "Old master not reconfigured as slave of new master" fail "Old master not reconfigured as slave of new master"
} }
} }
...@@ -5,6 +5,10 @@ source "../../../tests/support/cli.tcl" ...@@ -5,6 +5,10 @@ source "../../../tests/support/cli.tcl"
set ::alive_sentinel [expr {$::instances_count/2+2}] set ::alive_sentinel [expr {$::instances_count/2+2}]
proc ensure_master_up {} { 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 { wait_for_condition 1000 50 {
[dict get [S $::alive_sentinel sentinel master mymaster] flags] eq "master" [dict get [S $::alive_sentinel sentinel master mymaster] flags] eq "master"
} else { } else {
...@@ -12,7 +16,12 @@ proc ensure_master_up {} { ...@@ -12,7 +16,12 @@ proc ensure_master_up {} {
} }
} }
proc ensure_master_down {} { 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 { wait_for_condition 1000 50 {
[string match *down* \ [string match *down* \
[dict get [S $::alive_sentinel sentinel master mymaster] flags]] [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" { ...@@ -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" { test "SDOWN is triggered by non-responding but not crashed instance" {
lassign [S $::alive_sentinel SENTINEL GET-MASTER-ADDR-BY-NAME mymaster] host port lassign [S $::alive_sentinel SENTINEL GET-MASTER-ADDR-BY-NAME mymaster] host port
ensure_master_up 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_down
ensure_master_up ensure_master_up
} }
......
...@@ -47,4 +47,3 @@ test "SENTINEL CONFIG SET handles on-the-fly credentials reconfiguration" { ...@@ -47,4 +47,3 @@ test "SENTINEL CONFIG SET handles on-the-fly credentials reconfiguration" {
test "(post-cleanup) Tear down ACL configuration" { test "(post-cleanup) Tear down ACL configuration" {
teardown_acl teardown_acl
} }
...@@ -33,9 +33,11 @@ proc 10_test_number_of_replicas {n_replicas_expected} { ...@@ -33,9 +33,11 @@ proc 10_test_number_of_replicas {n_replicas_expected} {
test "Check sentinel replies with $n_replicas_expected replicas" { test "Check sentinel replies with $n_replicas_expected replicas" {
# ensure sentinels replies with the right number of replicas # ensure sentinels replies with the right number of replicas
foreach_sentinel_id id { 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]] 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 [llength [S $id SENTINEL REPLICAS mymaster]] == $n_replicas_expected
} else { } else {
fail "Sentinel replies with a wrong number of replicas with replica-announced=yes (expected $n_replicas_expected but got $len) on sentinel $id" 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} { ...@@ -71,3 +73,4 @@ proc 10_set_replica_announced {master_id announced n_replicas} {
10_set_replica_announced $master_id "yes" "all" 10_set_replica_announced $master_id "yes" "all"
# ensure all replicas are not announced by sentinels # ensure all replicas are not announced by sentinels
10_test_number_of_replicas 4 10_test_number_of_replicas 4
...@@ -20,7 +20,7 @@ test "Start/Stop sentinel on same port with a different runID should not change ...@@ -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] set pid [exec_instance "sentinel" $dirname $orgfilename]
lappend ::pids $pid lappend ::pids $pid
after 5000 after 1000
# Get new count of total sentinel # Get new count of total sentinel
set b [S 0 SENTINEL master mymaster] set b [S 0 SENTINEL master mymaster]
......
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