added clean-up for tests run under Cygwin

- certain tests (using "debug restart") cause additional processes to be
  spawned and not tracked due to changed process ID (Windows-specific
  behaviour), so we need to clean them up when running tests under Cygwin
This commit is contained in:
tporadowski
2020-11-04 09:26:17 +01:00
parent 623f5e655c
commit 7ced02a356
3 changed files with 66 additions and 11 deletions
+16
View File
@@ -180,6 +180,12 @@ start_server {} {
}
set new_sync_count [status $R($master_id) sync_full]
assert {$sync_count == $new_sync_count}
if {$::uses_cygwin} {
# read Windows PID from "INFO" to be cleaned up at the end
set pid [status $R($slave_id) process_id]
lappend ::winpids $pid
}
}
test "PSYNC2: Replica RDB restart with EVALSHA in backlog issue #4483" {
@@ -227,6 +233,12 @@ start_server {} {
incr retry -1
}
if {$::uses_cygwin} {
# read Windows PID from "INFO" to be cleaned up at the end
set pid [status $R($slave_id) process_id]
lappend ::winpids $pid
}
# The master should be back at 4 slaves eventually
wait_for_condition 50 1000 {
[status $R($master_id) connected_slaves] == 4
@@ -250,3 +262,7 @@ start_server {} {
}
}}}}}
# clean up any additional processes started by "debug restart" under Windows
# when running tests from Cygwin
cygwin_clean_up
+38 -11
View File
@@ -96,30 +96,41 @@ if { $tcl_platform(platform) != "windows" } {
}
}
proc windows_is_alive config {
set pid [dict get $config pid]
set mfilter {PID eq }
append mfilter $pid
if { [string first $pid [exec tasklist.exe -FI ${mfilter}]] != -1 } {
return 1
} else {
return 0
}
}
proc windows_kill_proc config {
set pid [dict get $config pid]
catch {exec taskkill.exe /F /T /PID $pid}
}
proc windows_kill_proc2 pid {
catch {exec taskkill.exe /F /T /PID $pid}
}
if { $tcl_platform(platform) == "windows" } {
proc is_alive config {
set pid [dict get $config pid]
set mfilter {PID eq }
append mfilter $pid
if { [string first $pid [exec tasklist.exe -FI ${mfilter}]] != -1 } {
return 1
} else {
return 0
}
return [windows_is_alive $config]
}
}
if { $tcl_platform(platform) == "windows" } {
proc kill_proc config {
set pid [dict get $config pid]
catch {exec taskkill.exe -F -T -PID $pid}
windows_kill_proc $config
}
}
if { $tcl_platform(platform) == "windows" } {
proc kill_proc2 pid {
catch {exec taskkill.exe -F -T -PID $pid}
windows_kill_proc2 $pid
}
}
@@ -389,3 +400,19 @@ proc start_server {options {code undefined}} {
set _ $srv
}
}
proc cygwin_clean_up {} {
# clean up any new processes started with "debug restart" using Windows-specific tools
foreach newpid $::winpids {
set config [dict create "pid" $newpid]
if {$::verbose} { puts "Checking if WINPID=$newpid is still alive" }
while {[windows_is_alive $config]} {
if {$::verbose} { puts "Trying to stop server with WINPID=$newpid" }
windows_kill_proc $config
after 1000
}
}
set ::winpids {}
}
+12
View File
@@ -454,6 +454,18 @@ proc print_help_screen {} {
} "\n"]
}
# [tporadowski] "debug restart" command in Redis for Windows causes a new process
# with new PID to be started, so we need to properly clean this up when running tests
# from Cygwin
set ::winpids {}
set ::uses_cygwin 0
if {$::tcl_platform(platform) == "unix"} {
set uname [exec uname -s]
if {[string first "CYGWIN" $uname] != -1} {
set ::uses_cygwin 1
}
}
# parse arguments
for {set j 0} {$j < [llength $argv]} {incr j} {
set opt [lindex $argv $j]