1
- # Sentinel test suite. Copyright (C) 2014 Salvatore Sanfilippo antirez@gmail.com
1
+ # Multi-instance test framework.
2
+ # This is used in order to test Sentinel and Redis Cluster, and provides
3
+ # basic capabilities for spawning and handling N parallel Redis / Sentinel
4
+ # instances.
5
+ #
6
+ # Copyright (C) 2014 Salvatore Sanfilippo antirez@gmail.com
2
7
# This softare is released under the BSD License. See the COPYING file for
3
8
# more information.
4
9
5
10
package require Tcl 8.5
6
11
7
12
set tcl_precision 17
8
- source tests /support/redis.tcl
9
- source tests /support/util.tcl
10
- source tests /support/server.tcl
11
- source tests /support/test.tcl
13
+ source .. /support/redis.tcl
14
+ source .. /support/util.tcl
15
+ source .. /support/server.tcl
16
+ source .. /support/test.tcl
12
17
13
18
set ::verbose 0
14
19
set ::pause_on_error 0
@@ -22,8 +27,8 @@ set ::pids {} ; # We kill everything at exit
22
27
set ::dirs {} ; # We remove all the temp dirs at exit
23
28
set ::run_matching {} ; # If non empty, only tests matching pattern are run.
24
29
25
- if {[catch {cd tests/sentinel- tmp}]} {
26
- puts " tests/sentinel- tmp directory not found."
30
+ if {[catch {cd tmp}]} {
31
+ puts " tmp directory not found."
27
32
puts " Please run this test from the Redis source root."
28
33
exit 1
29
34
}
@@ -61,7 +66,7 @@ proc spawn_instance {type base_port count {conf {}}} {
61
66
} else {
62
67
error " Unknown instance type."
63
68
}
64
- set pid [exec ../../src/${prgname} $cfgfile &]
69
+ set pid [exec ../../../ src/${prgname} $cfgfile &]
65
70
lappend ::pids $pid
66
71
67
72
# Check availability
@@ -122,14 +127,6 @@ proc parse_options {} {
122
127
}
123
128
}
124
129
125
- proc main {} {
126
- parse_options
127
- spawn_instance sentinel $::sentinel_base_port $::instances_count
128
- spawn_instance redis $::redis_base_port $::instances_count
129
- run_tests
130
- cleanup
131
- }
132
-
133
130
# If --pause-on-error option was passed at startup this function is called
134
131
# on error in order to give the developer a chance to understand more about
135
132
# the error condition while the instances are still running.
@@ -224,7 +221,7 @@ proc test {descr code} {
224
221
}
225
222
226
223
proc run_tests {} {
227
- set tests [lsort [glob ../sentinel- tests/*]]
224
+ set tests [lsort [glob ../tests/*]]
228
225
foreach test $tests {
229
226
if {$::run_matching ne {} && [string match $::run_matching $test ] == 0} {
230
227
continue
@@ -383,7 +380,7 @@ proc restart_instance {type id} {
383
380
} else {
384
381
set prgname redis-sentinel
385
382
}
386
- set pid [exec ../../src/${prgname} $cfgfile &]
383
+ set pid [exec ../../../ src/${prgname} $cfgfile &]
387
384
set_instance_attrib $type $id pid $pid
388
385
lappend ::pids $pid
389
386
@@ -396,7 +393,3 @@ proc restart_instance {type id} {
396
393
set_instance_attrib $type $id link [redis 127.0.0.1 $port ]
397
394
}
398
395
399
- if {[catch main e]} {
400
- puts $::errorInfo
401
- cleanup
402
- }
0 commit comments