mirror of
https://github.com/fluencelabs/redis
synced 2025-03-17 16:10:50 +00:00
Sentinel test: provide basic commands to access instances.
This commit is contained in:
parent
7cec9e48ce
commit
141bac4c79
@ -1,6 +1,5 @@
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user