summaryrefslogtreecommitdiff
path: root/tests/sentinel/tests
diff options
context:
space:
mode:
authorWen Hui <wen.hui.ware@gmail.com>2021-09-05 06:26:29 -0400
committerGitHub <noreply@github.com>2021-09-05 13:26:29 +0300
commit763fd0941683eb64190daca6abab1f29a72a772e (patch)
treedbd710ee5676167bd51f0a580c7dc4e447c9e92d /tests/sentinel/tests
parent8b8f05c86c1f1f002caa1f4e1877020389f167e4 (diff)
downloadredis-763fd0941683eb64190daca6abab1f29a72a772e.tar.gz
Speed up sentinel tests (#9408)
Use sentinel debug to reduce default timeouts and allow tests to execute faster.
Diffstat (limited to 'tests/sentinel/tests')
-rw-r--r--tests/sentinel/tests/00-base.tcl6
-rw-r--r--tests/sentinel/tests/02-slaves-reconf.tcl7
-rw-r--r--tests/sentinel/tests/05-manual.tcl7
-rw-r--r--tests/sentinel/tests/07-down-conditions.tcl11
-rw-r--r--tests/sentinel/tests/09-acl-support.tcl1
-rw-r--r--tests/sentinel/tests/10-replica-priority.tcl7
-rw-r--r--tests/sentinel/tests/11-port-0.tcl2
7 files changed, 35 insertions, 6 deletions
diff --git a/tests/sentinel/tests/00-base.tcl b/tests/sentinel/tests/00-base.tcl
index a1bbb2789..f00efc61e 100644
--- a/tests/sentinel/tests/00-base.tcl
+++ b/tests/sentinel/tests/00-base.tcl
@@ -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 {
diff --git a/tests/sentinel/tests/02-slaves-reconf.tcl b/tests/sentinel/tests/02-slaves-reconf.tcl
index 9edf775ec..8196b60fa 100644
--- a/tests/sentinel/tests/02-slaves-reconf.tcl
+++ b/tests/sentinel/tests/02-slaves-reconf.tcl
@@ -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" {
diff --git a/tests/sentinel/tests/05-manual.tcl b/tests/sentinel/tests/05-manual.tcl
index c97a0e53c..28c5560a6 100644
--- a/tests/sentinel/tests/05-manual.tcl
+++ b/tests/sentinel/tests/05-manual.tcl
@@ -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"
}
}
-
diff --git a/tests/sentinel/tests/07-down-conditions.tcl b/tests/sentinel/tests/07-down-conditions.tcl
index 19cabde49..2c72f8547 100644
--- a/tests/sentinel/tests/07-down-conditions.tcl
+++ b/tests/sentinel/tests/07-down-conditions.tcl
@@ -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
}
diff --git a/tests/sentinel/tests/09-acl-support.tcl b/tests/sentinel/tests/09-acl-support.tcl
index 1366fc4d5..8c967f0bc 100644
--- a/tests/sentinel/tests/09-acl-support.tcl
+++ b/tests/sentinel/tests/09-acl-support.tcl
@@ -47,4 +47,3 @@ test "SENTINEL CONFIG SET handles on-the-fly credentials reconfiguration" {
test "(post-cleanup) Tear down ACL configuration" {
teardown_acl
}
-
diff --git a/tests/sentinel/tests/10-replica-priority.tcl b/tests/sentinel/tests/10-replica-priority.tcl
index 00248a734..d3f868afa 100644
--- a/tests/sentinel/tests/10-replica-priority.tcl
+++ b/tests/sentinel/tests/10-replica-priority.tcl
@@ -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
+
diff --git a/tests/sentinel/tests/11-port-0.tcl b/tests/sentinel/tests/11-port-0.tcl
index e7bfdcc73..a3e8bdba1 100644
--- a/tests/sentinel/tests/11-port-0.tcl
+++ b/tests/sentinel/tests/11-port-0.tcl
@@ -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]