mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 00:28:26 -05:00
Cluster test: move basic read/write test into a procedure.
This commit is contained in:
parent
a700bc74a8
commit
aa5dfb3c2c
@ -106,3 +106,25 @@ proc create_cluster {masters slaves} {
|
|||||||
}
|
}
|
||||||
assert_cluster_state ok
|
assert_cluster_state ok
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Set the cluster node-timeout to all the reachalbe nodes.
|
||||||
|
proc set_cluster_node_timeout {to} {
|
||||||
|
foreach_redis_id id {
|
||||||
|
catch {R $id CONFIG SET cluster-node-timeout $to}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if the cluster is writable and readable. Use node "id"
|
||||||
|
# as a starting point to talk with the cluster.
|
||||||
|
proc cluster_write_test {id} {
|
||||||
|
set prefix [randstring 20 20 alpha]
|
||||||
|
set port [get_instance_attrib redis $id port]
|
||||||
|
set cluster [redis_cluster 127.0.0.1:$port]
|
||||||
|
for {set j 0} {$j < 100} {incr j} {
|
||||||
|
$cluster set key.$j $prefix.$j
|
||||||
|
}
|
||||||
|
for {set j 0} {$j < 100} {incr j} {
|
||||||
|
assert {[$cluster get key.$j] eq "$prefix.$j"}
|
||||||
|
}
|
||||||
|
$cluster close
|
||||||
|
}
|
||||||
|
@ -55,13 +55,5 @@ test "Nodes should report cluster_state is ok now" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "It is possible to write and read from the cluster" {
|
test "It is possible to write and read from the cluster" {
|
||||||
set port [get_instance_attrib redis 0 port]
|
cluster_write_test 0
|
||||||
set cluster [redis_cluster 127.0.0.1:$port]
|
|
||||||
for {set j 0} {$j < 100} {incr j} {
|
|
||||||
$cluster set key.$j $j
|
|
||||||
}
|
|
||||||
for {set j 0} {$j < 100} {incr j} {
|
|
||||||
assert {[$cluster get key.$j] eq $j}
|
|
||||||
}
|
|
||||||
$cluster close
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user