Skip to content

Commit c3f85c0

Browse files
committed
Redis Cluster test framework skeleton.
1 parent 7d9b45b commit c3f85c0

File tree

5 files changed

+72
-0
lines changed

5 files changed

+72
-0
lines changed

runtest-cluster

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
TCL_VERSIONS="8.5 8.6"
3+
TCLSH=""
4+
5+
for VERSION in $TCL_VERSIONS; do
6+
TCL=`which tclsh$VERSION 2>/dev/null` && TCLSH=$TCL
7+
done
8+
9+
if [ -z $TCLSH ]
10+
then
11+
echo "You need tcl 8.5 or newer in order to run the Redis Sentinel test"
12+
exit 1
13+
fi
14+
$TCLSH tests/cluster/run.tcl $*

tests/cluster/cluster.tcl

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Cluster-specific test functions.
2+
#
3+
# Copyright (C) 2014 Salvatore Sanfilippo [email protected]
4+
# This softare is released under the BSD License. See the COPYING file for
5+
# more information.
6+
7+

tests/cluster/run.tcl

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Cluster test suite. Copyright (C) 2014 Salvatore Sanfilippo [email protected]
2+
# This softare is released under the BSD License. See the COPYING file for
3+
# more information.
4+
5+
cd tests/cluster
6+
source cluster.tcl
7+
source ../instances.tcl
8+
9+
proc main {} {
10+
parse_options
11+
spawn_instance redis $::redis_base_port $::instances_count {
12+
"cluster-enabled yes"
13+
"appendonly yes"
14+
}
15+
run_tests
16+
cleanup
17+
}
18+
19+
if {[catch main e]} {
20+
puts $::errorInfo
21+
cleanup
22+
}

tests/cluster/tests/00-base.tcl

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Check the basic monitoring and failover capabilities.
2+
3+
source "../tests/includes/init-tests.tcl"
4+
5+
if {$::simulate_error} {
6+
test "This test will fail" {
7+
fail "Simulated error"
8+
}
9+
}
10+
11+
test "Cluster nodes are reachable." {
12+
foreach_redis_id id {
13+
# Every node should just know itself.
14+
assert {[R $id ping] eq {PONG}}
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Initialization tests -- most units will start including this.
2+
3+
test "(init) Restart killed instances" {
4+
foreach type {redis} {
5+
foreach_${type}_id id {
6+
if {[get_instance_attrib $type $id pid] == -1} {
7+
puts -nonewline "$type/$id "
8+
flush stdout
9+
restart_instance $type $id
10+
}
11+
}
12+
}
13+
}

0 commit comments

Comments
 (0)