summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-04-24 10:50:51 +0200
committerantirez <antirez@gmail.com>2014-04-28 18:17:02 +0200
commit3bff0291d8d6e3be231e438e1b74521ef2817a4a (patch)
treec2b64aa4fea5bec15f0904b0581931235497ee70
parent08174e730fc9d687f200bca7ff11da95512981a5 (diff)
downloadredis-3bff0291d8d6e3be231e438e1b74521ef2817a4a.tar.gz
Test: spawn_instance now supports additional config.
-rw-r--r--tests/sentinel.tcl14
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/sentinel.tcl b/tests/sentinel.tcl
index bb05103f0..6b1476d96 100644
--- a/tests/sentinel.tcl
+++ b/tests/sentinel.tcl
@@ -29,31 +29,37 @@ if {[catch {cd tests/sentinel-tmp}]} {
}
# Spawn a redis or sentinel instance, depending on 'type'.
-proc spawn_instance {type base_port count} {
+proc spawn_instance {type base_port count {conf {}}} {
for {set j 0} {$j < $count} {incr j} {
set port [find_available_port $base_port]
incr base_port
puts "Starting $type #$j at port $port"
- # Create a directory for this Sentinel.
+ # Create a directory for this instance.
set dirname "${type}_${j}"
lappend ::dirs $dirname
catch {exec rm -rf $dirname}
file mkdir $dirname
- # Write the Sentinel config file.
+ # Write the instance config file.
set cfgfile [file join $dirname $type.conf]
set cfg [open $cfgfile w]
puts $cfg "port $port"
puts $cfg "dir ./$dirname"
puts $cfg "logfile log.txt"
+ # Add additional config files
+ foreach directive $conf {
+ puts $cfg $directive
+ }
close $cfg
# Finally exec it and remember the pid for later cleanup.
if {$type eq "redis"} {
set prgname redis-server
- } else {
+ } elseif {$type eq "sentinel"} {
set prgname redis-sentinel
+ } else {
+ error "Unknown instance type."
}
set pid [exec ../../src/${prgname} $cfgfile &]
lappend ::pids $pid