diff options
author | Yossi Gottlieb <yossigo@gmail.com> | 2021-02-08 17:02:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-08 17:02:46 +0200 |
commit | dbcc0a85d070f94f5c524a4bbdd3e492c32e845b (patch) | |
tree | 66ad3940dda787969cdaf1f877073fcc07d3a816 /tests/instances.tcl | |
parent | b2351ea0dc9f60e7987dc6db4c1ef09d70003a9e (diff) | |
download | redis-dbcc0a85d070f94f5c524a4bbdd3e492c32e845b.tar.gz |
Fix and cleanup Sentinel leaked fds test. (#8469)
* For consistency, use tclsh for the script as well
* Ignore leaked fds that originate from grandparent process, since we
only care about fds redis-sentinel itself is responsible for
* Check every test iteration to catch problems early
* Some cleanups, e.g. parameterization of file name, etc.
Diffstat (limited to 'tests/instances.tcl')
-rw-r--r-- | tests/instances.tcl | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/tests/instances.tcl b/tests/instances.tcl index 8cb616ae8..793bce80d 100644 --- a/tests/instances.tcl +++ b/tests/instances.tcl @@ -29,6 +29,7 @@ set ::sentinel_base_port 20000 set ::redis_base_port 30000 set ::redis_port_count 1024 set ::host "127.0.0.1" +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. @@ -410,13 +411,13 @@ proc check_leaks instance_types { # Execute all the units inside the 'tests' directory. proc run_tests {} { - set sentinel_fd_leaks_file "sentinel_fd_leaks" - if { [file exists $sentinel_fd_leaks_file] } { - file delete $sentinel_fd_leaks_file - } - set tests [lsort [glob ../tests/*]] foreach test $tests { + # Remove leaked_fds file before starting + if {$::leaked_fds_file != "" && [file exists $::leaked_fds_file]} { + file delete $::leaked_fds_file + } + if {$::run_matching ne {} && [string match $::run_matching $test] == 0} { continue } @@ -424,19 +425,19 @@ proc run_tests {} { puts [colorstr yellow "Testing unit: [lindex [file split $test] end]"] source $test check_leaks {redis sentinel} + + # Check if a leaked fds file was created and abort the test. + if {$::leaked_fds_file != "" && [file exists $::leaked_fds_file]} { + puts [colorstr red "ERROR: Sentinel has leaked fds to scripts:"] + puts [exec cat $::leaked_fds_file] + puts "----" + incr ::failed + } } } # Print a message and exists with 0 / 1 according to zero or more failures. proc end_tests {} { - set sentinel_fd_leaks_file "sentinel_fd_leaks" - if { [file exists $sentinel_fd_leaks_file] } { - # temporarily disabling this error from failing the tests until leaks are fixed. - #puts [colorstr red "WARNING: sentinel test(s) failed, there are leaked fds in sentinel:"] - #puts [exec cat $sentinel_fd_leaks_file] - #exit 1 - } - if {$::failed == 0 } { puts "GOOD! No errors." exit 0 |