Skip to content

Commit b9e65aa

Browse files
committed
Add --failures-json flag to control test failure output
Only write failures JSON when explicitly requested via --failures-json. CI passes the flag to write to test-failures/; local runs stay clean. Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
1 parent a0d2969 commit b9e65aa

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

.github/workflows/daily.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ jobs:
119119
- name: test
120120
if: true && !contains(github.event.inputs.skiptests, 'valkey')
121121
# run: ./runtest ${{ github.event_name != 'pull_request' && '--accurate' || '' }} --verbose --dump-logs ${{github.event.inputs.test_args}}
122-
run: ./runtest --single unit/dummy-flaky --verbose --dump-logs ${{github.event.inputs.test_args}}
122+
run: ./runtest --single unit/dummy-flaky --failures-json test-failures/valkey.json --verbose --dump-logs ${{github.event.inputs.test_args}}
123123
- name: module api test
124124
if: true && !contains(github.event.inputs.skiptests, 'modules')
125-
run: CFLAGS='-Werror' ./runtest-moduleapi --verbose --dump-logs ${{github.event.inputs.test_args}}
125+
run: CFLAGS='-Werror' ./runtest-moduleapi --failures-json test-failures/moduleapi.json --verbose --dump-logs ${{github.event.inputs.test_args}}
126126
- name: sentinel tests
127127
if: true && !contains(github.event.inputs.skiptests, 'sentinel')
128128
run: ./runtest-sentinel ${{github.event.inputs.cluster_test_args}}
@@ -1919,10 +1919,10 @@ jobs:
19191919
- name: test
19201920
if: true && !contains(github.event.inputs.skiptests, 'valkey')
19211921
# run: ./runtest --log-req-res --no-latency --dont-clean --force-resp3 --tags -slow --verbose --dump-logs ${{github.event.inputs.test_args}}
1922-
run: ./runtest --single unit/dummy-flaky --log-req-res --no-latency --dont-clean --force-resp3 --tags -slow --verbose --dump-logs ${{github.event.inputs.test_args}}
1922+
run: ./runtest --single unit/dummy-flaky --failures-json test-failures/valkey.json --log-req-res --no-latency --dont-clean --force-resp3 --tags -slow --verbose --dump-logs ${{github.event.inputs.test_args}}
19231923
- name: module api test
19241924
if: true && !contains(github.event.inputs.skiptests, 'modules')
1925-
run: CFLAGS='-Werror' ./runtest-moduleapi --log-req-res --no-latency --dont-clean --force-resp3 --dont-pre-clean --verbose --dump-logs ${{github.event.inputs.test_args}}
1925+
run: CFLAGS='-Werror' ./runtest-moduleapi --failures-json test-failures/moduleapi.json --log-req-res --no-latency --dont-clean --force-resp3 --dont-pre-clean --verbose --dump-logs ${{github.event.inputs.test_args}}
19261926
- name: sentinel tests
19271927
if: true && !contains(github.event.inputs.skiptests, 'sentinel')
19281928
run: ./runtest-sentinel --log-req-res --dont-clean --force-resp3 ${{github.event.inputs.cluster_test_args}}

tests/test_helper.tcl

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ set ::file ""; # If set, runs only the tests in this comma separated list
7373
set ::curfile ""; # Hold the filename of the current suite
7474
set ::accurate 0; # If true runs fuzz tests with more iterations
7575
set ::force_failure 0
76+
set ::failures_json_file ""; # If set, write failures JSON to this path
7677
set ::timeout 1200; # 20 minutes without progresses will quit the test.
7778
set ::last_progress [clock seconds]
7879
set ::active_servers {} ; # Pids of active server instances.
@@ -638,13 +639,15 @@ proc write_test_failures {} {
638639
lappend failures "\{\"test_name\":\"$test_name\",\"test_file\":\"$test_file\",\"status\":\"$status\",\"error\":\"$error_msg\"\}"
639640
}
640641

641-
file mkdir "test-failures"
642-
if {[info exists ::module_api_mode] && $::module_api_mode} {
643-
set suite_name "moduleapi"
644-
} else {
645-
set suite_name "valkey"
642+
if {$::failures_json_file eq ""} {
643+
return
646644
}
647-
set fp [open "test-failures/${suite_name}.json" w]
645+
646+
set outdir [file dirname $::failures_json_file]
647+
if {$outdir ne "."} {
648+
file mkdir $outdir
649+
}
650+
set fp [open $::failures_json_file w]
648651
puts $fp "\[[join $failures ","]\]"
649652
close $fp
650653
}
@@ -729,6 +732,8 @@ proc print_help_screen {} {
729732
"--clients <num> Number of test clients (default 16)."
730733
"--timeout <sec> Test timeout in seconds (default 20 min)."
731734
"--force-failure Force the execution of a test that always fails."
735+
"--failures-json <path>"
736+
" Write test failures to the specified JSON file."
732737
"--config <k> <v> Extra config file argument."
733738
"--skipfile <file> Name of a file containing test names or regexp patterns (if"
734739
" <test> starts with '/') that should be skipped (one per"
@@ -853,6 +858,9 @@ for {set j 0} {$j < [llength $argv]} {incr j} {
853858
set ::accurate 1
854859
} elseif {$opt eq {--force-failure}} {
855860
set ::force_failure 1
861+
} elseif {$opt eq {--failures-json}} {
862+
set ::failures_json_file $arg
863+
incr j
856864
} elseif {$opt eq {--single}} {
857865
foreach unit [expand_unit_spec $arg] {
858866
lappend ::single_tests $unit

0 commit comments

Comments
 (0)