Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
763fd094
Unverified
Commit
763fd094
authored
Sep 05, 2021
by
Wen Hui
Committed by
GitHub
Sep 05, 2021
Browse files
Speed up sentinel tests (#9408)
Use sentinel debug to reduce default timeouts and allow tests to execute faster.
parent
8b8f05c8
Changes
7
Hide whitespace changes
Inline
Side-by-side
tests/sentinel/tests/00-base.tcl
View file @
763fd094
...
...
@@ -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
{
...
...
tests/sentinel/tests/02-slaves-reconf.tcl
View file @
763fd094
...
...
@@ -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"
{
...
...
tests/sentinel/tests/05-manual.tcl
View file @
763fd094
...
...
@@ -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"
}
}
tests/sentinel/tests/07-down-conditions.tcl
View file @
763fd094
...
...
@@ -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
}
...
...
tests/sentinel/tests/09-acl-support.tcl
View file @
763fd094
...
...
@@ -47,4 +47,3 @@ test "SENTINEL CONFIG SET handles on-the-fly credentials reconfiguration" {
test
"(post-cleanup) Tear down ACL configuration"
{
teardown_acl
}
tests/sentinel/tests/10-replica-priority.tcl
View file @
763fd094
...
...
@@ -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
4
0
5
00
{
wait_for_condition
20
0
1
00
{
[
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
tests/sentinel/tests/11-port-0.tcl
View file @
763fd094
...
...
@@ -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
5
000
after
1
000
# Get new count of total sentinel
set b
[
S 0 SENTINEL master mymaster
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment