mirror of
http://github.com/valkey-io/valkey
synced 2024-11-22 00:52:38 +00:00
test infra - write test name to logfile
This commit is contained in:
parent
58e5feb3f4
commit
9d527d076b
@ -301,6 +301,13 @@ proc start_server {options {code undefined}} {
|
||||
set stdout [format "%s/%s" [dict get $config "dir"] "stdout"]
|
||||
set stderr [format "%s/%s" [dict get $config "dir"] "stderr"]
|
||||
|
||||
# if we're inside a test, write the test name to the server log file
|
||||
if {[info exists ::cur_test]} {
|
||||
set fd [open $stdout "a+"]
|
||||
puts $fd "### Starting server for test $::cur_test"
|
||||
close $fd
|
||||
}
|
||||
|
||||
# We need a loop here to retry with different ports.
|
||||
set server_started 0
|
||||
while {$server_started == 0} {
|
||||
@ -443,6 +450,13 @@ proc restart_server {level wait_ready} {
|
||||
set stderr [dict get $srv "stderr"]
|
||||
set config_file [dict get $srv "config_file"]
|
||||
|
||||
# if we're inside a test, write the test name to the server log file
|
||||
if {[info exists ::cur_test]} {
|
||||
set fd [open $stdout "a+"]
|
||||
puts $fd "### Restarting server for test $::cur_test"
|
||||
close $fd
|
||||
}
|
||||
|
||||
set prev_ready_count [exec grep -i "Ready to accept" | wc -l < $stdout]
|
||||
|
||||
set pid [spawn_server $config_file $stdout $stderr]
|
||||
|
@ -143,6 +143,18 @@ proc test {name code {okpattern undefined}} {
|
||||
set details {}
|
||||
lappend details "$name in $::curfile"
|
||||
|
||||
# set a cur_test global to be logged into new servers that are spown
|
||||
# and log the test name in all existing servers
|
||||
set ::cur_test "$name in $::curfile"
|
||||
if {!$::external} {
|
||||
foreach srv $::servers {
|
||||
set stdout [dict get $srv stdout]
|
||||
set fd [open $stdout "a+"]
|
||||
puts $fd "### Starting test $::cur_test"
|
||||
close $fd
|
||||
}
|
||||
}
|
||||
|
||||
send_data_packet $::test_server_fd testing $name
|
||||
|
||||
if {[catch {set retval [uplevel 1 $code]} error]} {
|
||||
@ -183,4 +195,5 @@ proc test {name code {okpattern undefined}} {
|
||||
send_data_packet $::test_server_fd err "Detected a memory leak in test '$name': $output"
|
||||
}
|
||||
}
|
||||
unset ::cur_test
|
||||
}
|
||||
|
@ -138,6 +138,14 @@ proc wait_for_log_messages {srv_idx patterns from_line maxtries delay} {
|
||||
}
|
||||
}
|
||||
|
||||
# write line to server log file
|
||||
proc write_log_line {srv_idx msg} {
|
||||
set logfile [srv $srv_idx stdout]
|
||||
set fd [open $logfile "a+"]
|
||||
puts $fd "### $msg"
|
||||
close $fd
|
||||
}
|
||||
|
||||
# Random integer between 0 and max (excluded).
|
||||
proc randomInt {max} {
|
||||
expr {int(rand()*$max)}
|
||||
|
Loading…
Reference in New Issue
Block a user