Skip to content

Commit

Permalink
Add for loop for master primary test case
Browse files Browse the repository at this point in the history
  • Loading branch information
hwware committed Jul 10, 2024
1 parent 8ea9947 commit 63ba675
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 36 deletions.
2 changes: 1 addition & 1 deletion sentinel.conf
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ SENTINEL resolve-hostnames no
#
SENTINEL announce-hostnames no

# When primary_reboot_down_after_period is set to 0, Sentinel does not fail over
# When primary-reboot-down-after-period is set to 0, Sentinel does not fail over
# when receiving a -LOADING response from a primary. This was the only supported
# behavior before Redis OSS 7.0.
#
Expand Down
40 changes: 5 additions & 35 deletions tests/sentinel/tests/12-master-reboot.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ test "Primary reboot in very short time" {
R $master_id config rewrite

foreach_sentinel_id id {
S $id SENTINEL SET mymaster primary-reboot-down-after-period 5000
S $id sentinel debug ping-period 500
S $id sentinel debug ask-period 500
foreach role {master primary} {
S $id SENTINEL SET mymaster $role-reboot-down-after-period 5000
S $id sentinel debug ping-period 500
S $id sentinel debug ask-period 500
}
}

kill_instance valkey $master_id
Expand All @@ -76,38 +78,6 @@ test "Primary reboot in very short time" {
break
}
}

# Check the master-reboot-down-after-period still works
foreach_sentinel_id id {
S $id SENTINEL SET mymaster master-reboot-down-after-period 5000
S $id sentinel debug ping-period 500
S $id sentinel debug ask-period 500
}

kill_instance valkey $master_id
reboot_instance valkey $master_id

foreach_sentinel_id id {
wait_for_condition 1000 100 {
[lindex [S $id SENTINEL GET-MASTER-ADDR-BY-NAME mymaster] 1] != $old_port
} else {
fail "At least one Sentinel did not receive failover info"
}
}

set addr [S 0 SENTINEL GET-MASTER-ADDR-BY-NAME mymaster]
set master_id [get_instance_id_by_port valkey [lindex $addr 1]]

# Make sure the instance load all the dataset
while 1 {
catch {[$link ping]} retval
if {[string match {*LOADING*} $retval]} {
after 100
continue
} else {
break
}
}
}

test "New primary [join $addr {:}] role matches" {
Expand Down

0 comments on commit 63ba675

Please sign in to comment.