Skip to content

Commit e6b6813

Browse files
committed
Test: spawn_instance now supports additional config.
1 parent 32c9179 commit e6b6813

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

tests/sentinel.tcl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,37 @@ if {[catch {cd tests/sentinel-tmp}]} {
2929
}
3030

3131
# Spawn a redis or sentinel instance, depending on 'type'.
32-
proc spawn_instance {type base_port count} {
32+
proc spawn_instance {type base_port count {conf {}}} {
3333
for {set j 0} {$j < $count} {incr j} {
3434
set port [find_available_port $base_port]
3535
incr base_port
3636
puts "Starting $type #$j at port $port"
3737

38-
# Create a directory for this Sentinel.
38+
# Create a directory for this instance.
3939
set dirname "${type}_${j}"
4040
lappend ::dirs $dirname
4141
catch {exec rm -rf $dirname}
4242
file mkdir $dirname
4343

44-
# Write the Sentinel config file.
44+
# Write the instance config file.
4545
set cfgfile [file join $dirname $type.conf]
4646
set cfg [open $cfgfile w]
4747
puts $cfg "port $port"
4848
puts $cfg "dir ./$dirname"
4949
puts $cfg "logfile log.txt"
50+
# Add additional config files
51+
foreach directive $conf {
52+
puts $cfg $directive
53+
}
5054
close $cfg
5155

5256
# Finally exec it and remember the pid for later cleanup.
5357
if {$type eq "redis"} {
5458
set prgname redis-server
55-
} else {
59+
} elseif {$type eq "sentinel"} {
5660
set prgname redis-sentinel
61+
} else {
62+
error "Unknown instance type."
5763
}
5864
set pid [exec ../../src/${prgname} $cfgfile &]
5965
lappend ::pids $pid

0 commit comments

Comments
 (0)