1# Test PUBLISH propagation across the cluster. 2 3source "../tests/includes/init-tests.tcl" 4 5test "Create a 5 nodes cluster" { 6 create_cluster 5 5 7} 8 9proc test_cluster_publish {instance instances} { 10 # Subscribe all the instances but the one we use to send. 11 for {set j 0} {$j < $instances} {incr j} { 12 if {$j != $instance} { 13 R $j deferred 1 14 R $j subscribe testchannel 15 R $j read; # Read the subscribe reply 16 } 17 } 18 19 set data [randomValue] 20 R $instance PUBLISH testchannel $data 21 22 # Read the message back from all the nodes. 23 for {set j 0} {$j < $instances} {incr j} { 24 if {$j != $instance} { 25 set msg [R $j read] 26 assert {$data eq [lindex $msg 2]} 27 R $j unsubscribe testchannel 28 R $j read; # Read the unsubscribe reply 29 R $j deferred 0 30 } 31 } 32} 33 34test "Test publishing to master" { 35 test_cluster_publish 0 10 36} 37 38test "Test publishing to slave" { 39 test_cluster_publish 5 10 40} 41