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
cb2c7c4d
Unverified
Commit
cb2c7c4d
authored
Sep 13, 2020
by
Mykhailo Pylyp
Committed by
GitHub
Sep 13, 2020
Browse files
Recalculate hardcoded variables from $::instances_count in sentinel tests (#7561)
Co-authored-by:
MemuraiUser
<
githubuser@janeasystems.com
>
parent
78a6e5eb
Changes
3
Hide whitespace changes
Inline
Side-by-side
tests/sentinel/tests/06-ckquorum.tcl
View file @
cb2c7c4d
...
...
@@ -20,15 +20,16 @@ test "CKQUORUM detects quorum cannot be reached" {
test
"CKQUORUM detects failover authorization cannot be reached"
{
set orig_quorum
[
expr
{
$num
_sentinels/2+1
}]
S 0 SENTINEL SET mymaster quorum 1
kill_instance sentinel 1
kill_instance sentinel 2
kill_instance sentinel 3
for
{
set i 0
}
{
$i
< $orig_quorum
}
{
incr i
}
{
kill_instance sentinel
[
expr
{
$i
+ 1
}]
}
after 5000
catch
{[
S 0 SENTINEL CKQUORUM mymaster
]}
err
assert_match
"*NOQUORUM*"
$err
S 0 SENTINEL SET mymaster quorum $orig_quorum
restart_instance sentinel 1
restart_instance sentinel
2
restart_instance sentinel 3
for
{
set i 0
}
{
$i
< $orig_quorum
}
{
incr i
}
{
restart_instance sentinel
[
expr
{
$i
+ 1
}]
}
}
tests/sentinel/tests/07-down-conditions.tcl
View file @
cb2c7c4d
...
...
@@ -3,9 +3,10 @@
source
"../tests/includes/init-tests.tcl"
source
"../../../tests/support/cli.tcl"
set ::alive_sentinel
[
expr
{
$::instances
_count/2+2
}]
proc ensure_master_up
{}
{
wait_for_condition 1000 50
{
[
dict get
[
S
4
sentinel master mymaster
]
flags
]
eq
"master"
[
dict get
[
S
$::alive_sentinel
sentinel master mymaster
]
flags
]
eq
"master"
}
else
{
fail
"Master flags are not just 'master'"
}
...
...
@@ -14,7 +15,7 @@ proc ensure_master_up {} {
proc ensure_master_down
{}
{
wait_for_condition 1000 50
{
[
string match *down*
\
[
dict get
[
S
4
sentinel master mymaster
]
flags
]]
[
dict get
[
S
$::alive_sentinel
sentinel master mymaster
]
flags
]]
}
else
{
fail
"Master is not flagged SDOWN"
}
...
...
@@ -27,7 +28,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
4
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
exec ../../../src/redis-cli -h $host -p $port
{*}
[
rediscli_tls_config
"../../../tests"
]
debug sleep 10 > /dev/null &
ensure_master_down
...
...
@@ -35,7 +36,7 @@ test "SDOWN is triggered by non-responding but not crashed instance" {
}
test
"SDOWN is triggered by crashed instance"
{
lassign
[
S
4
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
kill_instance redis 0
ensure_master_down
...
...
@@ -72,8 +73,8 @@ test "SDOWN is triggered by misconfigured instance repling with errors" {
# effect of the master going down if we send PONG instead of PING
test
"SDOWN is triggered if we rename PING to PONG"
{
ensure_master_up
S
4
SENTINEL SET mymaster rename-command PING PONG
S
$::alive_sentinel
SENTINEL SET mymaster rename-command PING PONG
ensure_master_down
S
4
SENTINEL SET mymaster rename-command PING PING
S
$::alive_sentinel
SENTINEL SET mymaster rename-command PING PING
ensure_master_up
}
tests/sentinel/tests/includes/init-tests.tcl
View file @
cb2c7c4d
...
...
@@ -18,7 +18,7 @@ test "(init) Remove old master entry from sentinels" {
}
}
set redis_slaves
4
set redis_slaves
[
expr $::instances_count - 1
]
test
"(init) Create a master-slaves cluster of
[
expr $redis_slaves+1
]
instances"
{
create_redis_master_slave_cluster
[
expr
{
$redis
_slaves+1
}]
}
...
...
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