summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-04-24 11:08:22 +0200
committerantirez <antirez@gmail.com>2014-04-24 11:08:22 +0200
commit897adc1c8c6bbe5bc23bb85b97f5114fbb59cd99 (patch)
treee6339647772b41e549f555acc6f148c0bb1d67d6
parente6b681365614a7e49110b0547456288a8f02d5e6 (diff)
downloadredis-897adc1c8c6bbe5bc23bb85b97f5114fbb59cd99.tar.gz
Sentinel test files / directories layout improved.
The test now runs in a self-contained directory. The general abstractions to run the tests in an environment where mutliple instances are executed at the same time was extrapolated into instances.tcl, that will be reused to test Redis Cluster.
-rwxr-xr-xruntest-sentinel2
-rw-r--r--tests/instances.tcl (renamed from tests/sentinel.tcl)37
-rw-r--r--tests/sentinel/run.tcl19
-rw-r--r--tests/sentinel/tests/00-base.tcl (renamed from tests/sentinel-tests/00-base.tcl)2
-rw-r--r--tests/sentinel/tests/01-conf-update.tcl (renamed from tests/sentinel-tests/01-conf-update.tcl)2
-rw-r--r--tests/sentinel/tests/02-slaves-reconf.tcl (renamed from tests/sentinel-tests/02-slaves-reconf.tcl)2
-rw-r--r--tests/sentinel/tests/03-runtime-reconf.tcl (renamed from tests/sentinel-tests/03-runtime-reconf.tcl)0
-rw-r--r--tests/sentinel/tests/04-slave-selection.tcl (renamed from tests/sentinel-tests/04-slave-selection.tcl)0
-rw-r--r--tests/sentinel/tests/includes/init-tests.tcl (renamed from tests/sentinel-tests/includes/init-tests.tcl)0
-rw-r--r--tests/sentinel/tmp/.gitignore (renamed from tests/sentinel-tmp/.gitignore)0
10 files changed, 38 insertions, 26 deletions
diff --git a/runtest-sentinel b/runtest-sentinel
index 1650eea73..3fb1ef615 100755
--- a/runtest-sentinel
+++ b/runtest-sentinel
@@ -11,4 +11,4 @@ then
echo "You need tcl 8.5 or newer in order to run the Redis Sentinel test"
exit 1
fi
-$TCLSH tests/sentinel.tcl $*
+$TCLSH tests/sentinel/run.tcl $*
diff --git a/tests/sentinel.tcl b/tests/instances.tcl
index 6b1476d96..7cc798dcd 100644
--- a/tests/sentinel.tcl
+++ b/tests/instances.tcl
@@ -1,14 +1,19 @@
-# Sentinel test suite. Copyright (C) 2014 Salvatore Sanfilippo antirez@gmail.com
+# Multi-instance test framework.
+# This is used in order to test Sentinel and Redis Cluster, and provides
+# basic capabilities for spawning and handling N parallel Redis / Sentinel
+# instances.
+#
+# Copyright (C) 2014 Salvatore Sanfilippo antirez@gmail.com
# This softare is released under the BSD License. See the COPYING file for
# more information.
package require Tcl 8.5
set tcl_precision 17
-source tests/support/redis.tcl
-source tests/support/util.tcl
-source tests/support/server.tcl
-source tests/support/test.tcl
+source ../support/redis.tcl
+source ../support/util.tcl
+source ../support/server.tcl
+source ../support/test.tcl
set ::verbose 0
set ::pause_on_error 0
@@ -22,8 +27,8 @@ set ::pids {} ; # We kill everything at exit
set ::dirs {} ; # We remove all the temp dirs at exit
set ::run_matching {} ; # If non empty, only tests matching pattern are run.
-if {[catch {cd tests/sentinel-tmp}]} {
- puts "tests/sentinel-tmp directory not found."
+if {[catch {cd tmp}]} {
+ puts "tmp directory not found."
puts "Please run this test from the Redis source root."
exit 1
}
@@ -61,7 +66,7 @@ proc spawn_instance {type base_port count {conf {}}} {
} else {
error "Unknown instance type."
}
- set pid [exec ../../src/${prgname} $cfgfile &]
+ set pid [exec ../../../src/${prgname} $cfgfile &]
lappend ::pids $pid
# Check availability
@@ -122,14 +127,6 @@ proc parse_options {} {
}
}
-proc main {} {
- parse_options
- spawn_instance sentinel $::sentinel_base_port $::instances_count
- spawn_instance redis $::redis_base_port $::instances_count
- run_tests
- cleanup
-}
-
# If --pause-on-error option was passed at startup this function is called
# on error in order to give the developer a chance to understand more about
# the error condition while the instances are still running.
@@ -224,7 +221,7 @@ proc test {descr code} {
}
proc run_tests {} {
- set tests [lsort [glob ../sentinel-tests/*]]
+ set tests [lsort [glob ../tests/*]]
foreach test $tests {
if {$::run_matching ne {} && [string match $::run_matching $test] == 0} {
continue
@@ -383,7 +380,7 @@ proc restart_instance {type id} {
} else {
set prgname redis-sentinel
}
- set pid [exec ../../src/${prgname} $cfgfile &]
+ set pid [exec ../../../src/${prgname} $cfgfile &]
set_instance_attrib $type $id pid $pid
lappend ::pids $pid
@@ -396,7 +393,3 @@ proc restart_instance {type id} {
set_instance_attrib $type $id link [redis 127.0.0.1 $port]
}
-if {[catch main e]} {
- puts $::errorInfo
- cleanup
-}
diff --git a/tests/sentinel/run.tcl b/tests/sentinel/run.tcl
new file mode 100644
index 000000000..78d2f61bc
--- /dev/null
+++ b/tests/sentinel/run.tcl
@@ -0,0 +1,19 @@
+# Sentinel 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/sentinel
+source ../instances.tcl
+
+proc main {} {
+ parse_options
+ spawn_instance sentinel $::sentinel_base_port $::instances_count
+ spawn_instance redis $::redis_base_port $::instances_count
+ run_tests
+ cleanup
+}
+
+if {[catch main e]} {
+ puts $::errorInfo
+ cleanup
+}
diff --git a/tests/sentinel-tests/00-base.tcl b/tests/sentinel/tests/00-base.tcl
index 26758de09..a79d0c371 100644
--- a/tests/sentinel-tests/00-base.tcl
+++ b/tests/sentinel/tests/00-base.tcl
@@ -1,6 +1,6 @@
# Check the basic monitoring and failover capabilities.
-source "../sentinel-tests/includes/init-tests.tcl"
+source "../tests/includes/init-tests.tcl"
if {$::simulate_error} {
test "This test will fail" {
diff --git a/tests/sentinel-tests/01-conf-update.tcl b/tests/sentinel/tests/01-conf-update.tcl
index 4625ebd4c..4998104d2 100644
--- a/tests/sentinel-tests/01-conf-update.tcl
+++ b/tests/sentinel/tests/01-conf-update.tcl
@@ -1,6 +1,6 @@
# Test Sentinel configuration consistency after partitions heal.
-source "../sentinel-tests/includes/init-tests.tcl"
+source "../tests/includes/init-tests.tcl"
test "We can failover with Sentinel 1 crashed" {
set old_port [RI $master_id tcp_port]
diff --git a/tests/sentinel-tests/02-slaves-reconf.tcl b/tests/sentinel/tests/02-slaves-reconf.tcl
index 843c62dcc..868bae5ec 100644
--- a/tests/sentinel-tests/02-slaves-reconf.tcl
+++ b/tests/sentinel/tests/02-slaves-reconf.tcl
@@ -5,7 +5,7 @@
# 2) That partitioned slaves point to new master when they are partitioned
# away during failover and return at a latter time.
-source "../sentinel-tests/includes/init-tests.tcl"
+source "../tests/includes/init-tests.tcl"
proc 03_test_slaves_replication {} {
uplevel 1 {
diff --git a/tests/sentinel-tests/03-runtime-reconf.tcl b/tests/sentinel/tests/03-runtime-reconf.tcl
index 426596c37..426596c37 100644
--- a/tests/sentinel-tests/03-runtime-reconf.tcl
+++ b/tests/sentinel/tests/03-runtime-reconf.tcl
diff --git a/tests/sentinel-tests/04-slave-selection.tcl b/tests/sentinel/tests/04-slave-selection.tcl
index 3d2ca6484..3d2ca6484 100644
--- a/tests/sentinel-tests/04-slave-selection.tcl
+++ b/tests/sentinel/tests/04-slave-selection.tcl
diff --git a/tests/sentinel-tests/includes/init-tests.tcl b/tests/sentinel/tests/includes/init-tests.tcl
index cb359ea1b..cb359ea1b 100644
--- a/tests/sentinel-tests/includes/init-tests.tcl
+++ b/tests/sentinel/tests/includes/init-tests.tcl
diff --git a/tests/sentinel-tmp/.gitignore b/tests/sentinel/tmp/.gitignore
index f581f73e2..f581f73e2 100644
--- a/tests/sentinel-tmp/.gitignore
+++ b/tests/sentinel/tmp/.gitignore