diff options
author | antirez <antirez@gmail.com> | 2014-09-15 18:11:45 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2014-09-15 18:11:45 +0200 |
commit | b82d650afaff867daf9ac2c69d7e631a0f531641 (patch) | |
tree | ecbf8567dea1b6f7f42056589a479759b5986939 | |
parent | 3064e9bd4b3f3ed1dfaaa10dbef231f2fdbf2975 (diff) | |
download | redis-b82d650afaff867daf9ac2c69d7e631a0f531641.tar.gz |
Cluster test: unit 09, Pub/Sub across the cluster.
-rw-r--r-- | tests/cluster/tests/09-pubsub.tcl | 40 |
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 +} |