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
b82d650a
Commit
b82d650a
authored
Sep 15, 2014
by
antirez
Browse files
Cluster test: unit 09, Pub/Sub across the cluster.
parent
3064e9bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/cluster/tests/09-pubsub.tcl
0 → 100644
View file @
b82d650a
# Test PUBLISH propagation across the cluster.
source
"../tests/includes/init-tests.tcl"
test
"Create a 5 nodes cluster"
{
create_cluster 5 5
}
proc test_cluster_publish
{
instance instances
}
{
# Subscribe all the instances but the one we use to send.
for
{
set j 0
}
{
$j
< $instances
}
{
incr j
}
{
if
{
$j
!= $instance
}
{
R $j deferred 1
R $j subscribe testchannel
R $j read
;
# Read the subscribe reply
}
}
set data
[
randomValue
]
R $instance PUBLISH testchannel $data
# Read the message back from all the nodes.
for
{
set j 0
}
{
$j
< $instances
}
{
incr j
}
{
if
{
$j
!= $instance
}
{
set msg
[
R $j read
]
assert
{
$data
eq
[
lindex $msg 2
]}
R $j unsubscribe testchannel
R $j read
;
# Read the unsubscribe reply
R $j deferred 0
}
}
}
test
"Test publishing to master"
{
test_cluster_publish 0 10
}
test
"Test publishing to slave"
{
test_cluster_publish 5 10
}
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