futriix/tests/unit/cluster/pubsub.tcl
Binbin fdd023ff82
Migrate cluster mode tests to normal framework (#442)
We currently has two disjoint TCL frameworks:
1. Normal testing framework, which trigger by runtest, which individually
launches nodes for testing.
2. Cluster framework, which trigger by runtest-cluster, which pre-allocates
N nodes and uses them for testing large configurations.

The normal TCL testing framework is much more readily tested and is also
automatically run as part of the CI for new PRs. The runtest-cluster since
it runs very slowly (cannot be parallelized), it currently only runs in daily
CI, this results in some changes to the cluster not being exposed in PR CI
in time.

This PR migrate the Cluster mode tests to normal framework. Some cluster
tests are kept in runtest-cluster because of timing issues or not yet
supported, we can process them later.

Signed-off-by: Binbin <binloveplay1314@qq.com>
2024-05-09 10:14:47 +08:00

39 lines
991 B
Tcl

# Test PUBLISH propagation across the cluster.
start_cluster 5 5 {tags {external:skip cluster}} {
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
}
} ;# start_cluster