[Feat] Support fast fail option for tcl test cases (#482)

This PR added a new option for tcl test case which will fail fast once any test cases fail.
This can be useful while running redis CI pipeline, and you want to accelerate the CI pipeline.

usage for example

> ./runtest --single unit/type/hash --fast-fail

---------

Signed-off-by: arthur.lee <arthur-lee@qq.com>
This commit is contained in:
Arthur Lee 2024-05-15 21:55:24 +08:00 committed by GitHub
parent 6e4a61093e
commit 3de5c71f48
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 0 deletions

View File

@ -35,6 +35,7 @@ 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 ::exit_on_failure 0
set ::stop_on_failure 0
set ::loop 0
@ -298,6 +299,8 @@ proc parse_options {} {
set val2 [lindex $::argv [expr $j+2]]
dict set ::global_config $val $val2
incr j 2
} elseif {$opt eq {--fast-fail}} {
set ::exit_on_failure 1
} elseif {$opt eq {--stop}} {
set ::stop_on_failure 1
} elseif {$opt eq {--loop}} {
@ -316,6 +319,7 @@ proc parse_options {} {
puts "--tls-module Run tests in TLS mode with Valkey module."
puts "--host <host> Use hostname instead of 127.0.0.1."
puts "--config <k> <v> Extra config argument(s)."
puts "--fast-fail Exit immediately once the first test fails."
puts "--stop Blocks once the first test fails."
puts "--loop Execute the specified set of tests forever."
puts "--help Shows this help."
@ -483,6 +487,11 @@ while 1 {
incr ::failed
# letting the tests resume, so we'll eventually reach the cleanup and report crashes
if {$::exit_on_failure} {
puts -nonewline "(Fast fail: test will exit now)"
flush stdout
exit 1
}
if {$::stop_on_failure} {
puts -nonewline "(Test stopped, press enter to resume the tests)"
flush stdout

View File

@ -233,6 +233,11 @@ proc test {name code {okpattern undefined} {tags {}}} {
incr ::num_failed
send_data_packet $::test_server_fd err [join $details "\n"]
if {$::exit_on_failure} {
puts "Test error (last server port:[srv port], log:[srv stdout]), test will exit now"
flush stdout
exit 1
}
if {$::stop_on_failure} {
puts "Test error (last server port:[srv port], log:[srv stdout]), press enter to teardown the test."
flush stdout

View File

@ -65,6 +65,7 @@ set ::active_servers {} ; # Pids of active server instances.
set ::dont_clean 0
set ::dont_pre_clean 0
set ::wait_server 0
set ::exit_on_failure 0
set ::stop_on_failure 0
set ::dump_logs 0
set ::loop 0
@ -383,6 +384,11 @@ proc read_from_test_client fd {
puts $err
lappend ::failed_tests $err
set ::active_clients_task($fd) "(ERR) $data"
if {$::exit_on_failure} {
puts -nonewline "(Fast fail: test will exit now)"
flush stdout
exit 1
}
if {$::stop_on_failure} {
puts -nonewline "(Test stopped, press enter to resume the tests)"
flush stdout
@ -564,6 +570,7 @@ proc print_help_screen {} {
"--dont-clean Don't delete valkey log files after the run."
"--dont-pre-clean Don't delete existing valkey log files before the run."
"--no-latency Skip latency measurements and validation by some tests."
"--fastfail Exit immediately once the first test fails."
"--stop Blocks once the first test fails."
"--loop Execute the specified set of tests forever."
"--loops <count> Execute the specified set of tests several times."
@ -688,6 +695,8 @@ for {set j 0} {$j < [llength $argv]} {incr j} {
set ::wait_server 1
} elseif {$opt eq {--dump-logs}} {
set ::dump_logs 1
} elseif {$opt eq {--fastfail}} {
set ::exit_on_failure 1
} elseif {$opt eq {--stop}} {
set ::stop_on_failure 1
} elseif {$opt eq {--loop}} {