summaryrefslogtreecommitdiff
path: root/tests/sentinel
diff options
context:
space:
mode:
authorBinbin <binloveplay1314@qq.com>2022-03-31 01:42:51 +0800
committerGitHub <noreply@github.com>2022-03-30 20:42:51 +0300
commit6075f5066334055dde1bd299d5f4954ad3de86ea (patch)
treea8126dfcbf8cf7bbb0fa0dac658ce719447798fd /tests/sentinel
parent4e55d557ebb35bfd741491caafd5a246b4043062 (diff)
downloadredis-6075f5066334055dde1bd299d5f4954ad3de86ea.tar.gz
Move restart_killed_instances and verify_sentinel_auto_discovery to utils (#10497)
Create a utils.tcl in sentinel/tests/includes, and move two procs to it. Allow sentinel test 08-hostname-conf run on its own.
Diffstat (limited to 'tests/sentinel')
-rw-r--r--tests/sentinel/tests/08-hostname-conf.tcl2
-rw-r--r--tests/sentinel/tests/includes/init-tests.tcl24
-rw-r--r--tests/sentinel/tests/includes/utils.tcl22
3 files changed, 25 insertions, 23 deletions
diff --git a/tests/sentinel/tests/08-hostname-conf.tcl b/tests/sentinel/tests/08-hostname-conf.tcl
index be6e42cb0..263b06fca 100644
--- a/tests/sentinel/tests/08-hostname-conf.tcl
+++ b/tests/sentinel/tests/08-hostname-conf.tcl
@@ -1,3 +1,5 @@
+source "../tests/includes/utils.tcl"
+
proc set_redis_announce_ip {addr} {
foreach_redis_id id {
R $id config set replica-announce-ip $addr
diff --git a/tests/sentinel/tests/includes/init-tests.tcl b/tests/sentinel/tests/includes/init-tests.tcl
index 7adc235ea..fe9a61815 100644
--- a/tests/sentinel/tests/includes/init-tests.tcl
+++ b/tests/sentinel/tests/includes/init-tests.tcl
@@ -1,27 +1,5 @@
# Initialization tests -- most units will start including this.
-
-proc restart_killed_instances {} {
- foreach type {redis sentinel} {
- foreach_${type}_id id {
- if {[get_instance_attrib $type $id pid] == -1} {
- puts -nonewline "$type/$id "
- flush stdout
- restart_instance $type $id
- }
- }
- }
-}
-
-proc verify_sentinel_auto_discovery {} {
- set sentinels [llength $::sentinel_instances]
- foreach_sentinel_id id {
- wait_for_condition 1000 50 {
- [dict get [S $id SENTINEL MASTER mymaster] num-other-sentinels] == ($sentinels-1)
- } else {
- fail "At least some sentinel can't detect some other sentinel"
- }
- }
-}
+source "../tests/includes/utils.tcl"
test "(init) Restart killed instances" {
restart_killed_instances
diff --git a/tests/sentinel/tests/includes/utils.tcl b/tests/sentinel/tests/includes/utils.tcl
new file mode 100644
index 000000000..adfd91c09
--- /dev/null
+++ b/tests/sentinel/tests/includes/utils.tcl
@@ -0,0 +1,22 @@
+proc restart_killed_instances {} {
+ foreach type {redis sentinel} {
+ foreach_${type}_id id {
+ if {[get_instance_attrib $type $id pid] == -1} {
+ puts -nonewline "$type/$id "
+ flush stdout
+ restart_instance $type $id
+ }
+ }
+ }
+}
+
+proc verify_sentinel_auto_discovery {} {
+ set sentinels [llength $::sentinel_instances]
+ foreach_sentinel_id id {
+ wait_for_condition 1000 50 {
+ [dict get [S $id SENTINEL MASTER mymaster] num-other-sentinels] == ($sentinels-1)
+ } else {
+ fail "At least some sentinel can't detect some other sentinel"
+ }
+ }
+}