summaryrefslogtreecommitdiff
path: root/tests/instances.tcl
diff options
context:
space:
mode:
authorOran Agra <oran@redislabs.com>2020-08-09 06:08:00 +0300
committerGitHub <noreply@github.com>2020-08-09 06:08:00 +0300
commite2d64485b8262971776fb1be803c7296c98d1572 (patch)
treea2faa33c7ced1e898bd00668e46fbb0c2b8db691 /tests/instances.tcl
parentca95b71f67f72e41b05dc155ae015f1ad1f16b4c (diff)
downloadredis-e2d64485b8262971776fb1be803c7296c98d1572.tar.gz
Reduce the probability of failure when start redis in runtest-cluster #7554 (#7635)
When runtest-cluster, at first, we need to create a cluster use spawn_instance, a port which is not used is choosen, however sometimes we can't run server on the port. possibley due to a race with another process taking it first. such as redis/redis/runs/896537490. It may be due to the machine problem or In order to reduce the probability of failure when start redis in runtest-cluster, we attemp to use another port when find server do not start up. Co-authored-by: Oran Agra <oran@redislabs.com> Co-authored-by: yanhui13 <yanhui13@meituan.com>
Diffstat (limited to 'tests/instances.tcl')
-rw-r--r--tests/instances.tcl28
1 files changed, 23 insertions, 5 deletions
diff --git a/tests/instances.tcl b/tests/instances.tcl
index 677af6427..e2aa4ab13 100644
--- a/tests/instances.tcl
+++ b/tests/instances.tcl
@@ -59,8 +59,6 @@ proc exec_instance {type cfgfile} {
proc spawn_instance {type base_port count {conf {}}} {
for {set j 0} {$j < $count} {incr j} {
set port [find_available_port $base_port $::redis_port_count]
- incr base_port
- puts "Starting $type #$j at port $port"
# Create a directory for this instance.
set dirname "${type}_${j}"
@@ -93,10 +91,30 @@ proc spawn_instance {type base_port count {conf {}}} {
close $cfg
# Finally exec it and remember the pid for later cleanup.
- set pid [exec_instance $type $cfgfile]
- lappend ::pids $pid
+ set retry 100
+ while {$retry} {
+ set pid [exec_instance $type $cfgfile]
+
+ # Check availability
+ if {[server_is_up 127.0.0.1 $port 100] == 0} {
+ puts "Starting $type #$j at port $port failed, try another"
+ incr retry -1
+ set port [find_available_port $base_port $::redis_port_count]
+ set cfg [open $cfgfile a+]
+ if {$::tls} {
+ puts $cfg "tls-port $port"
+ } else {
+ puts $cfg "port $port"
+ }
+ close $cfg
+ } else {
+ puts "Starting $type #$j at port $port"
+ lappend ::pids $pid
+ break
+ }
+ }
- # Check availability
+ # Check availability finally
if {[server_is_up 127.0.0.1 $port 100] == 0} {
abort_sentinel_test "Problems starting $type #$j: ping timeout"
}