summaryrefslogtreecommitdiff
path: root/tests/instances.tcl
diff options
context:
space:
mode:
authorBinbin <binloveplay1314@qq.com>2022-08-01 15:12:27 +0800
committerGitHub <noreply@github.com>2022-08-01 10:12:27 +0300
commite13b6818742f67c515ceb98fe2fb6e587b1e2c70 (patch)
tree6bfe6bac75ac1df94754d8674b19c3a82ba36efb /tests/instances.tcl
parent2029976dc3c331956412bada063ee4df1c288132 (diff)
downloadredis-e13b6818742f67c515ceb98fe2fb6e587b1e2c70.tar.gz
Tests (cluster / sentinel): add --stop and--loop options (#11070)
--stop: Blocks once the first test fails. --loop: Execute the specified set of tests forever. It is useful when we debug some test failures.
Diffstat (limited to 'tests/instances.tcl')
-rw-r--r--tests/instances.tcl19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/instances.tcl b/tests/instances.tcl
index a92c5e553..8faf6fb31 100644
--- a/tests/instances.tcl
+++ b/tests/instances.tcl
@@ -34,6 +34,8 @@ set ::leaked_fds_file [file normalize "tmp/leaked_fds.txt"]
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.
+set ::stop_on_failure 0
+set ::loop 0
if {[catch {cd tmp}]} {
puts "tmp directory not found."
@@ -280,6 +282,10 @@ proc parse_options {} {
set val2 [lindex $::argv [expr $j+2]]
dict set ::global_config $val $val2
incr j 2
+ } elseif {$opt eq {--stop}} {
+ set ::stop_on_failure 1
+ } elseif {$opt eq {--loop}} {
+ set ::loop 1
} elseif {$opt eq "--help"} {
puts "--single <pattern> Only runs tests specified by pattern."
puts "--dont-clean Keep log files on exit."
@@ -289,6 +295,8 @@ proc parse_options {} {
puts "--tls Run tests in TLS mode."
puts "--host <host> Use hostname instead of 127.0.0.1."
puts "--config <k> <v> Extra config argument(s)."
+ puts "--stop Blocks once the first test fails."
+ puts "--loop Execute the specified set of tests forever."
puts "--help Shows this help."
exit 0
} else {
@@ -435,6 +443,8 @@ proc check_leaks instance_types {
# Execute all the units inside the 'tests' directory.
proc run_tests {} {
set tests [lsort [glob ../tests/*]]
+
+while 1 {
foreach test $tests {
# Remove leaked_fds file before starting
if {$::leaked_fds_file != "" && [file exists $::leaked_fds_file]} {
@@ -451,6 +461,12 @@ proc run_tests {} {
puts $::errorInfo
incr ::failed
# letting the tests resume, so we'll eventually reach the cleanup and report crashes
+
+ if {$::stop_on_failure} {
+ puts -nonewline "(Test stopped, press enter to resume the tests)"
+ flush stdout
+ gets stdin
+ }
}
check_leaks {redis sentinel}
@@ -462,6 +478,9 @@ proc run_tests {} {
incr ::failed
}
}
+
+ if {$::loop == 0} { break }
+} ;# while 1
}
# Print a message and exists with 0 / 1 according to zero or more failures.