Test: fixed osx msg passing issue in testing framework.
The Redis test uses a server-clients model in order to parallelize the execution of different tests. However in recent versions of osx not setting the channel to a binary encoding caused issues even if AFAIK no binary data is really sent via this channel. However now the channels are deliberately set to a binary encoding and this solves the issue. The exact issue was the test not terminating and giving the impression of running forever, since test clients or servers were unable to exchange the messages to continue.
This commit is contained in:
parent
e40d3e28e8
commit
331de6930a
@ -204,6 +204,7 @@ proc test_server_main {} {
|
|||||||
# Setup global state for the test server
|
# Setup global state for the test server
|
||||||
set ::idle_clients {}
|
set ::idle_clients {}
|
||||||
set ::active_clients {}
|
set ::active_clients {}
|
||||||
|
array set ::active_clients_task {}
|
||||||
array set ::clients_start_time {}
|
array set ::clients_start_time {}
|
||||||
set ::clients_time_history {}
|
set ::clients_time_history {}
|
||||||
set ::failed_tests {}
|
set ::failed_tests {}
|
||||||
@ -217,9 +218,12 @@ proc test_server_main {} {
|
|||||||
# may be used in the future in order to detect test clients taking too much
|
# may be used in the future in order to detect test clients taking too much
|
||||||
# time to execute the task.
|
# time to execute the task.
|
||||||
proc test_server_cron {} {
|
proc test_server_cron {} {
|
||||||
|
# Do some work here.
|
||||||
|
after 100 test_server_cron
|
||||||
}
|
}
|
||||||
|
|
||||||
proc accept_test_clients {fd addr port} {
|
proc accept_test_clients {fd addr port} {
|
||||||
|
fconfigure $fd -encoding binary
|
||||||
fileevent $fd readable [list read_from_test_client $fd]
|
fileevent $fd readable [list read_from_test_client $fd]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,14 +257,17 @@ proc read_from_test_client fd {
|
|||||||
puts "\[$completed_tests_count/$all_tests_count [colorstr yellow $status]\]: $data ($elapsed seconds)"
|
puts "\[$completed_tests_count/$all_tests_count [colorstr yellow $status]\]: $data ($elapsed seconds)"
|
||||||
lappend ::clients_time_history $elapsed $data
|
lappend ::clients_time_history $elapsed $data
|
||||||
signal_idle_client $fd
|
signal_idle_client $fd
|
||||||
|
set ::active_clients_task($fd) DONE
|
||||||
} elseif {$status eq {ok}} {
|
} elseif {$status eq {ok}} {
|
||||||
if {!$::quiet} {
|
if {!$::quiet} {
|
||||||
puts "\[[colorstr green $status]\]: $data"
|
puts "\[[colorstr green $status]\]: $data"
|
||||||
}
|
}
|
||||||
|
set ::active_clients_task($fd) "(OK) $data"
|
||||||
} elseif {$status eq {err}} {
|
} elseif {$status eq {err}} {
|
||||||
set err "\[[colorstr red $status]\]: $data"
|
set err "\[[colorstr red $status]\]: $data"
|
||||||
puts $err
|
puts $err
|
||||||
lappend ::failed_tests $err
|
lappend ::failed_tests $err
|
||||||
|
set ::active_clients_task($fd) "(ERR) $data"
|
||||||
} elseif {$status eq {exception}} {
|
} elseif {$status eq {exception}} {
|
||||||
puts "\[[colorstr red $status]\]: $data"
|
puts "\[[colorstr red $status]\]: $data"
|
||||||
foreach p $::clients_pids {
|
foreach p $::clients_pids {
|
||||||
@ -268,7 +275,7 @@ proc read_from_test_client fd {
|
|||||||
}
|
}
|
||||||
exit 1
|
exit 1
|
||||||
} elseif {$status eq {testing}} {
|
} elseif {$status eq {testing}} {
|
||||||
# No op
|
set ::active_clients_task($fd) "(IN PROGRESS) $data"
|
||||||
} else {
|
} else {
|
||||||
if {!$::quiet} {
|
if {!$::quiet} {
|
||||||
puts "\[$status\]: $data"
|
puts "\[$status\]: $data"
|
||||||
@ -282,10 +289,24 @@ proc signal_idle_client fd {
|
|||||||
# Remove this fd from the list of active clients.
|
# Remove this fd from the list of active clients.
|
||||||
set ::active_clients \
|
set ::active_clients \
|
||||||
[lsearch -all -inline -not -exact $::active_clients $fd]
|
[lsearch -all -inline -not -exact $::active_clients $fd]
|
||||||
|
|
||||||
|
if 0 {
|
||||||
|
# The following loop is only useful for debugging tests that may
|
||||||
|
# enter an infinite loop. Commented out normally.
|
||||||
|
foreach x $::active_clients {
|
||||||
|
if {[info exist ::active_clients_task($x)]} {
|
||||||
|
puts "$x => $::active_clients_task($x)"
|
||||||
|
} else {
|
||||||
|
puts "$x => ???"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# New unit to process?
|
# New unit to process?
|
||||||
if {$::next_test != [llength $::all_tests]} {
|
if {$::next_test != [llength $::all_tests]} {
|
||||||
if {!$::quiet} {
|
if {!$::quiet} {
|
||||||
puts [colorstr bold-white "Testing [lindex $::all_tests $::next_test]"]
|
puts [colorstr bold-white "Testing [lindex $::all_tests $::next_test]"]
|
||||||
|
set ::active_clients_task($fd) "ASSIGNED: $fd ([lindex $::all_tests $::next_test])"
|
||||||
}
|
}
|
||||||
set ::clients_start_time($fd) [clock seconds]
|
set ::clients_start_time($fd) [clock seconds]
|
||||||
send_data_packet $fd run [lindex $::all_tests $::next_test]
|
send_data_packet $fd run [lindex $::all_tests $::next_test]
|
||||||
@ -326,6 +347,7 @@ proc the_end {} {
|
|||||||
# to read the command, execute, reply... all this in a loop.
|
# to read the command, execute, reply... all this in a loop.
|
||||||
proc test_client_main server_port {
|
proc test_client_main server_port {
|
||||||
set ::test_server_fd [socket localhost $server_port]
|
set ::test_server_fd [socket localhost $server_port]
|
||||||
|
fconfigure $::test_server_fd -encoding binary
|
||||||
send_data_packet $::test_server_fd ready [pid]
|
send_data_packet $::test_server_fd ready [pid]
|
||||||
while 1 {
|
while 1 {
|
||||||
set bytes [gets $::test_server_fd]
|
set bytes [gets $::test_server_fd]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user