Recalculate hardcoded variables from $::instances_count in sentinel tests (#7561)

Co-authored-by: MemuraiUser <githubuser@janeasystems.com>
This commit is contained in:
Mykhailo Pylyp 2020-09-13 18:39:59 +03:00 committed by GitHub
parent 78a6e5eb2b
commit cb2c7c4d34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 13 deletions

View File

@ -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}]
}
}

View File

@ -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
}

View File

@ -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}]
}