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
bbbe68aa
Commit
bbbe68aa
authored
Feb 18, 2014
by
antirez
Browse files
Sentinel test: provide basic commands to access instances.
parent
6e4662e4
Changes
2
Show whitespace changes
Inline
Side-by-side
tests/sentinel-tests/base.tcl
View file @
bbbe68aa
test
"test OK"
{
test
"Sentinels aren't monitoring any master"
{
}
foreach_sentinel_id id
{
assert
{[
S $id sentinel masters
]
eq
{}}
test
"test failed"
{
}
assert
{
"foo"
eq
"bar"
}
}
}
tests/sentinel.tcl
View file @
bbbe68aa
...
@@ -56,10 +56,11 @@ proc spawn_instance {type base_port count} {
...
@@ -56,10 +56,11 @@ proc spawn_instance {type base_port count} {
}
}
# Push the instance into the right list
# Push the instance into the right list
lappend $
{
type
}
_instances
[
list
\
lappend ::$
{
type
}
_instances
[
list
\
pid $sentinel_pid
\
host 127.0.0.1
\
host 127.0.0.1
\
port $port
\
port $port
\
[
redis 127.0.0.1 $port
]
\
link
[
redis 127.0.0.1 $port
]
\
]
]
}
}
}
}
...
@@ -115,6 +116,38 @@ proc run_tests {} {
...
@@ -115,6 +116,38 @@ proc run_tests {} {
}
}
}
}
# The
"S"
command is used to interact with the N-th Sentinel.
# The general form is:
#
# S <sentinel-id> command arg arg arg ...
#
# Example to ping the Sentinel 0
(
first instance
)
: S 0 PING
proc S
{
n args
}
{
set s
[
lindex $::sentinel_instances $n
]
[
dict get $s link
]
{*}
$args
}
# Like R but to chat with Redis instances.
proc R
{
n args
}
{
set r
[
lindex $::redis_instances $n
]
[
dict get $r link
]
{*}
$args
}
# Iterate over IDs of sentinel or redis instances.
proc foreach_sentinel_id
{
idvar code
}
{
upvar 1 $idvar id
for
{
set id 0
}
{
$id
<
[
llength $::sentinel_instances
]}
{
incr id
}
{
uplevel 1 $code
}
}
proc foreach_redis_id
{
idvar code
}
{
upvar 1 $idvar id
for
{
set id 0
}
{
$id
<
[
llength $::redis_instances
]}
{
incr id
}
{
uplevel 1 $code
}
}
if
{[
catch main e
]}
{
if
{[
catch main e
]}
{
puts $::errorInfo
puts $::errorInfo
cleanup
cleanup
...
...
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