summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/cluster/cluster.tcl7
-rw-r--r--tests/cluster/run.tcl22
-rw-r--r--tests/cluster/tests/00-base.tcl16
-rw-r--r--tests/cluster/tests/includes/init-tests.tcl13
4 files changed, 58 insertions, 0 deletions
diff --git a/tests/cluster/cluster.tcl b/tests/cluster/cluster.tcl
new file mode 100644
index 000000000..685c501da
--- /dev/null
+++ b/tests/cluster/cluster.tcl
@@ -0,0 +1,7 @@
+# Cluster-specific test functions.
+#
+# Copyright (C) 2014 Salvatore Sanfilippo antirez@gmail.com
+# This softare is released under the BSD License. See the COPYING file for
+# more information.
+
+
diff --git a/tests/cluster/run.tcl b/tests/cluster/run.tcl
new file mode 100644
index 000000000..acb6d49cd
--- /dev/null
+++ b/tests/cluster/run.tcl
@@ -0,0 +1,22 @@
+# Cluster test suite. Copyright (C) 2014 Salvatore Sanfilippo antirez@gmail.com
+# This softare is released under the BSD License. See the COPYING file for
+# more information.
+
+cd tests/cluster
+source cluster.tcl
+source ../instances.tcl
+
+proc main {} {
+ parse_options
+ spawn_instance redis $::redis_base_port $::instances_count {
+ "cluster-enabled yes"
+ "appendonly yes"
+ }
+ run_tests
+ cleanup
+}
+
+if {[catch main e]} {
+ puts $::errorInfo
+ cleanup
+}
diff --git a/tests/cluster/tests/00-base.tcl b/tests/cluster/tests/00-base.tcl
new file mode 100644
index 000000000..e3b88e3e8
--- /dev/null
+++ b/tests/cluster/tests/00-base.tcl
@@ -0,0 +1,16 @@
+# Check the basic monitoring and failover capabilities.
+
+source "../tests/includes/init-tests.tcl"
+
+if {$::simulate_error} {
+ test "This test will fail" {
+ fail "Simulated error"
+ }
+}
+
+test "Cluster nodes are reachable." {
+ foreach_redis_id id {
+ # Every node should just know itself.
+ assert {[R $id ping] eq {PONG}}
+ }
+}
diff --git a/tests/cluster/tests/includes/init-tests.tcl b/tests/cluster/tests/includes/init-tests.tcl
new file mode 100644
index 000000000..e3d5471d3
--- /dev/null
+++ b/tests/cluster/tests/includes/init-tests.tcl
@@ -0,0 +1,13 @@
+# Initialization tests -- most units will start including this.
+
+test "(init) Restart killed instances" {
+ foreach type {redis} {
+ foreach_${type}_id id {
+ if {[get_instance_attrib $type $id pid] == -1} {
+ puts -nonewline "$type/$id "
+ flush stdout
+ restart_instance $type $id
+ }
+ }
+ }
+}