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
2b4bc4f9
Commit
2b4bc4f9
authored
Feb 20, 2014
by
antirez
Browse files
Sentinel test: ability to run just a subset of test files.
parent
21a7f9e7
Changes
2
Hide whitespace changes
Inline
Side-by-side
tests/sentinel-tests/00-base.tcl
View file @
2b4bc4f9
...
@@ -16,6 +16,7 @@ test "Sentinels can start monitoring a master" {
...
@@ -16,6 +16,7 @@ test "Sentinels can start monitoring a master" {
set sentinels
[
llength $::sentinel_instances
]
set sentinels
[
llength $::sentinel_instances
]
set quorum
[
expr
{
$sentinels
/2+1
}]
set quorum
[
expr
{
$sentinels
/2+1
}]
foreach_sentinel_id id
{
foreach_sentinel_id id
{
catch
{
S $id SENTINEL REMOVE mymaster
}
S $id SENTINEL MONITOR mymaster
\
S $id SENTINEL MONITOR mymaster
\
[
get_instance_attrib redis $master_id host
]
\
[
get_instance_attrib redis $master_id host
]
\
[
get_instance_attrib redis $master_id port
]
$quorum
[
get_instance_attrib redis $master_id port
]
$quorum
...
...
tests/sentinel.tcl
View file @
2b4bc4f9
...
@@ -18,6 +18,7 @@ set ::redis_base_port 30000
...
@@ -18,6 +18,7 @@ set ::redis_base_port 30000
set ::instances_count 5
;
# How many Sentinels / Instances we use at max
set ::instances_count 5
;
# How many Sentinels / Instances we use at max
set ::pids
{}
;
# We kill everything at exit
set ::pids
{}
;
# We kill everything at exit
set ::dirs
{}
;
# We remove all the temp dirs at exit
set ::dirs
{}
;
# We remove all the temp dirs at exit
set ::run_matching
{}
;
# If non empty, only tests matching pattern are run.
if
{[
catch
{
cd tests/sentinel-tmp
}]}
{
if
{[
catch
{
cd tests/sentinel-tmp
}]}
{
puts
"tests/sentinel-tmp directory not found."
puts
"tests/sentinel-tmp directory not found."
...
@@ -87,7 +88,28 @@ proc abort_sentinel_test msg {
...
@@ -87,7 +88,28 @@ proc abort_sentinel_test msg {
exit 1
exit 1
}
}
proc parse_options
{}
{
for
{
set j 0
}
{
$j
<
[
llength $::argv
]}
{
incr j
}
{
set opt
[
lindex $::argv $j
]
set val
[
lindex $::argv
[
expr $j+1
]]
if
{
$opt
eq
"--single"
}
{
incr j
set ::run_matching
"*
${val}
*"
}
elseif
{
$opt
eq
"--help"
}
{
puts
"Hello, I'm sentinel.tcl and I run Sentinel unit tests."
puts
"
\n
Options:"
puts
"--single <pattern> Only runs tests specified by pattern."
puts
"--help Shows this help."
exit 0
}
else
{
puts
"Unknown option
$opt
"
exit 1
}
}
}
proc main
{}
{
proc main
{}
{
parse_options
spawn_instance sentinel $::sentinel_base_port $::instances_count
spawn_instance sentinel $::sentinel_base_port $::instances_count
spawn_instance redis $::redis_base_port $::instances_count
spawn_instance redis $::redis_base_port $::instances_count
run_tests
run_tests
...
@@ -116,6 +138,9 @@ proc test {descr code} {
...
@@ -116,6 +138,9 @@ proc test {descr code} {
proc run_tests
{}
{
proc run_tests
{}
{
set tests
[
lsort
[
glob ../sentinel-tests/*
]]
set tests
[
lsort
[
glob ../sentinel-tests/*
]]
foreach test $tests
{
foreach test $tests
{
if
{
$::run
_matching ne
{}
&&
[
string match $::run_matching $test
]
== 0
}
{
continue
}
puts
[
colorstr yellow
"Testing unit:
[
lindex
[
file split $test
]
end
]
"
]
puts
[
colorstr yellow
"Testing unit:
[
lindex
[
file split $test
]
end
]
"
]
source $test
source $test
}
}
...
...
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