提交 bbbe68aa 编写于 作者: A antirez

Sentinel test: provide basic commands to access instances.

上级 6e4662e4
test "test OK" {
}
test "test failed" {
assert {"foo" eq "bar"}
test "Sentinels aren't monitoring any master" {
foreach_sentinel_id id {
assert {[S $id sentinel masters] eq {}}
}
}
......@@ -56,10 +56,11 @@ proc spawn_instance {type base_port count} {
}
# Push the instance into the right list
lappend ${type}_instances [list \
lappend ::${type}_instances [list \
pid $sentinel_pid \
host 127.0.0.1 \
port $port \
[redis 127.0.0.1 $port] \
link [redis 127.0.0.1 $port] \
]
}
}
......@@ -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]} {
puts $::errorInfo
cleanup
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册