summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-09-15 18:11:45 +0200
committerantirez <antirez@gmail.com>2014-09-15 18:11:45 +0200
commitb82d650afaff867daf9ac2c69d7e631a0f531641 (patch)
treeecbf8567dea1b6f7f42056589a479759b5986939
parent3064e9bd4b3f3ed1dfaaa10dbef231f2fdbf2975 (diff)
downloadredis-b82d650afaff867daf9ac2c69d7e631a0f531641.tar.gz
Cluster test: unit 09, Pub/Sub across the cluster.
-rw-r--r--tests/cluster/tests/09-pubsub.tcl40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/cluster/tests/09-pubsub.tcl b/tests/cluster/tests/09-pubsub.tcl
new file mode 100644
index 000000000..e62b91c4b
--- /dev/null
+++ b/tests/cluster/tests/09-pubsub.tcl
@@ -0,0 +1,40 @@
+# 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
+}