Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
e22d7573
Commit
e22d7573
authored
Jan 22, 2015
by
antirez
Browse files
Avoid duplicated instance execution code in Cluster test.
parent
ca14440a
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/instances.tcl
View file @
e22d7573
...
@@ -33,6 +33,25 @@ if {[catch {cd tmp}]} {
...
@@ -33,6 +33,25 @@ if {[catch {cd tmp}]} {
exit 1
exit 1
}
}
# Execute the specified instance of the server specified by 'type', using
# the provided configuration file. Returns the PID of the process.
proc exec_instance
{
type cfgfile
}
{
if
{
$type
eq
"redis"
}
{
set prgname redis-server
}
elseif
{
$type
eq
"sentinel"
}
{
set prgname redis-sentinel
}
else
{
error
"Unknown instance type."
}
if
{
$::valgrind
}
{
set pid
[
exec valgrind --track-origins=yes --suppressions=../../../src/valgrind.sup --show-reachable=no --show-possibly-lost=no --leak-check=full ../../../src/$
{
prgname
}
$cfgfile &
]
}
else
{
set pid
[
exec ../../../src/$
{
prgname
}
$cfgfile &
]
}
return $pid
}
# Spawn a redis or sentinel instance, depending on 'type'.
# Spawn a redis or sentinel instance, depending on 'type'.
proc spawn_instance
{
type base_port count
{
conf
{}}}
{
proc spawn_instance
{
type base_port count
{
conf
{}}}
{
for
{
set j 0
}
{
$j
< $count
}
{
incr j
}
{
for
{
set j 0
}
{
$j
< $count
}
{
incr j
}
{
...
@@ -59,20 +78,7 @@ proc spawn_instance {type base_port count {conf {}}} {
...
@@ -59,20 +78,7 @@ proc spawn_instance {type base_port count {conf {}}} {
close $cfg
close $cfg
# Finally exec it and remember the pid for later cleanup.
# Finally exec it and remember the pid for later cleanup.
if
{
$type
eq
"redis"
}
{
set pid
[
exec_instance $type $cfgfile
]
set prgname redis-server
}
elseif
{
$type
eq
"sentinel"
}
{
set prgname redis-sentinel
}
else
{
error
"Unknown instance type."
}
if
{
$::valgrind
}
{
set pid
[
exec valgrind --track-origins=yes --suppressions=../../../src/valgrind.sup --show-reachable=no --show-possibly-lost=no --leak-check=full ../../../src/$
{
prgname
}
$cfgfile &
]
}
else
{
set pid
[
exec ../../../src/$
{
prgname
}
$cfgfile &
]
}
lappend ::pids $pid
lappend ::pids $pid
# Check availability
# Check availability
...
@@ -411,18 +417,7 @@ proc restart_instance {type id} {
...
@@ -411,18 +417,7 @@ proc restart_instance {type id} {
# Execute the instance with its old setup and append the new pid
# Execute the instance with its old setup and append the new pid
# file for cleanup.
# file for cleanup.
if
{
$type
eq
"redis"
}
{
set pid
[
exec_instance $type $cfgfile
]
set prgname redis-server
}
else
{
set prgname redis-sentinel
}
if
{
$::valgrind
}
{
set pid
[
exec valgrind --track-origins=yes --suppressions=../../../src/valgrind.sup --show-reachable=no --show-possibly-lost=no --leak-check=full ../../../src/$
{
prgname
}
$cfgfile &
]
}
else
{
set pid
[
exec ../../../src/$
{
prgname
}
$cfgfile &
]
}
set_instance_attrib $type $id pid $pid
set_instance_attrib $type $id pid $pid
lappend ::pids $pid
lappend ::pids $pid
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment