From e13b6818742f67c515ceb98fe2fb6e587b1e2c70 Mon Sep 17 00:00:00 2001 From: Binbin Date: Mon, 1 Aug 2022 15:12:27 +0800 Subject: 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. --- tests/instances.tcl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests/instances.tcl') 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 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 Use hostname instead of 127.0.0.1." puts "--config 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. -- cgit v1.2.1