Unverified Commit e13b6818 authored by Binbin's avatar Binbin Committed by GitHub
Browse files

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.
parent 2029976d
...@@ -34,6 +34,8 @@ set ::leaked_fds_file [file normalize "tmp/leaked_fds.txt"] ...@@ -34,6 +34,8 @@ set ::leaked_fds_file [file normalize "tmp/leaked_fds.txt"]
set ::pids {} ; # We kill everything at exit set ::pids {} ; # We kill everything at exit
set ::dirs {} ; # We remove all the temp dirs 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 ::run_matching {} ; # If non empty, only tests matching pattern are run.
set ::stop_on_failure 0
set ::loop 0
if {[catch {cd tmp}]} { if {[catch {cd tmp}]} {
puts "tmp directory not found." puts "tmp directory not found."
...@@ -280,6 +282,10 @@ proc parse_options {} { ...@@ -280,6 +282,10 @@ proc parse_options {} {
set val2 [lindex $::argv [expr $j+2]] set val2 [lindex $::argv [expr $j+2]]
dict set ::global_config $val $val2 dict set ::global_config $val $val2
incr j 2 incr j 2
} elseif {$opt eq {--stop}} {
set ::stop_on_failure 1
} elseif {$opt eq {--loop}} {
set ::loop 1
} elseif {$opt eq "--help"} { } elseif {$opt eq "--help"} {
puts "--single <pattern> Only runs tests specified by pattern." puts "--single <pattern> Only runs tests specified by pattern."
puts "--dont-clean Keep log files on exit." puts "--dont-clean Keep log files on exit."
...@@ -289,6 +295,8 @@ proc parse_options {} { ...@@ -289,6 +295,8 @@ proc parse_options {} {
puts "--tls Run tests in TLS mode." puts "--tls Run tests in TLS mode."
puts "--host <host> Use hostname instead of 127.0.0.1." puts "--host <host> Use hostname instead of 127.0.0.1."
puts "--config <k> <v> Extra config argument(s)." 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." puts "--help Shows this help."
exit 0 exit 0
} else { } else {
...@@ -435,6 +443,8 @@ proc check_leaks instance_types { ...@@ -435,6 +443,8 @@ proc check_leaks instance_types {
# Execute all the units inside the 'tests' directory. # Execute all the units inside the 'tests' directory.
proc run_tests {} { proc run_tests {} {
set tests [lsort [glob ../tests/*]] set tests [lsort [glob ../tests/*]]
while 1 {
foreach test $tests { foreach test $tests {
# Remove leaked_fds file before starting # Remove leaked_fds file before starting
if {$::leaked_fds_file != "" && [file exists $::leaked_fds_file]} { if {$::leaked_fds_file != "" && [file exists $::leaked_fds_file]} {
...@@ -451,6 +461,12 @@ proc run_tests {} { ...@@ -451,6 +461,12 @@ proc run_tests {} {
puts $::errorInfo puts $::errorInfo
incr ::failed incr ::failed
# letting the tests resume, so we'll eventually reach the cleanup and report crashes # 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} check_leaks {redis sentinel}
...@@ -462,6 +478,9 @@ proc run_tests {} { ...@@ -462,6 +478,9 @@ proc run_tests {} {
incr ::failed incr ::failed
} }
} }
if {$::loop == 0} { break }
} ;# while 1
} }
# Print a message and exists with 0 / 1 according to zero or more failures. # Print a message and exists with 0 / 1 according to zero or more failures.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment