Fix races in test for tot-net-in, tot-net-out, tot-cmds (#559)
The races are between the '$rd' client and the 'r' client in the test case. Test case "client input output and command process statistics" in unit/introspection. --------- Signed-off-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
This commit is contained in:
parent
045d475a94
commit
4e44f5aae9
@ -41,6 +41,14 @@ start_server {tags {"introspection"}} {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
proc get_client_tot_in_out_cmds {id} {
|
||||||
|
set info_list [r client list]
|
||||||
|
set in [get_field_in_client_list $id $info_list "tot-net-in"]
|
||||||
|
set out [get_field_in_client_list $id $info_list "tot-net-out"]
|
||||||
|
set cmds [get_field_in_client_list $id $info_list "tot-cmds"]
|
||||||
|
return [list $in $out $cmds]
|
||||||
|
}
|
||||||
|
|
||||||
test {client input output and command process statistics} {
|
test {client input output and command process statistics} {
|
||||||
set info1 [r client info]
|
set info1 [r client info]
|
||||||
set input1 [get_field_in_client_info $info1 "tot-net-in"]
|
set input1 [get_field_in_client_info $info1 "tot-net-in"]
|
||||||
@ -63,21 +71,29 @@ start_server {tags {"introspection"}} {
|
|||||||
set output3 [get_field_in_client_list $rd_id $info_list "tot-net-out"]
|
set output3 [get_field_in_client_list $rd_id $info_list "tot-net-out"]
|
||||||
set cmd3 [get_field_in_client_list $rd_id $info_list "tot-cmds"]
|
set cmd3 [get_field_in_client_list $rd_id $info_list "tot-cmds"]
|
||||||
$rd blpop mylist 0
|
$rd blpop mylist 0
|
||||||
set info_list [r client list]
|
set input4 [expr $input3 + 34]
|
||||||
set input4 [get_field_in_client_list $rd_id $info_list "tot-net-in"]
|
set output4 $output3
|
||||||
set output4 [get_field_in_client_list $rd_id $info_list "tot-net-out"]
|
set cmd4 $cmd3
|
||||||
set cmd4 [get_field_in_client_list $rd_id $info_list "tot-cmds"]
|
wait_for_condition 5 100 {
|
||||||
assert_equal [expr $input3+34] $input4
|
[list $input4 $output4 $cmd4] eq [get_client_tot_in_out_cmds $rd_id]
|
||||||
assert_equal $output3 $output4
|
} else {
|
||||||
assert_equal $cmd3 $cmd4
|
puts "--------- tot-net-in tot-net-out tot-cmds (4)"
|
||||||
|
puts "Expected: [list $input4 $output4 $cmd4]"
|
||||||
|
puts "Actual: [get_client_tot_in_out_cmds $rd_id]"
|
||||||
|
fail "Blocked BLPOP didn't increment expected client fields"
|
||||||
|
}
|
||||||
r lpush mylist a
|
r lpush mylist a
|
||||||
set info_list [r client list]
|
set input5 $input4
|
||||||
set input5 [get_field_in_client_list $rd_id $info_list "tot-net-in"]
|
set output5 [expr $output4 + 23]
|
||||||
set output5 [get_field_in_client_list $rd_id $info_list "tot-net-out"]
|
set cmd5 [expr $cmd4 + 1]
|
||||||
set cmd5 [get_field_in_client_list $rd_id $info_list "tot-cmds"]
|
wait_for_condition 5 100 {
|
||||||
assert_equal $input4 $input5
|
[list $input5 $output5 $cmd5] eq [get_client_tot_in_out_cmds $rd_id]
|
||||||
assert_equal [expr $output4+23] $output5
|
} else {
|
||||||
assert_equal [expr $cmd4+1] $cmd5
|
puts "--------- tot-net-in tot-net-out tot-cmds (5)"
|
||||||
|
puts "Expected: [list $input5 $output5 $cmd5]"
|
||||||
|
puts "Actual: [get_client_tot_in_out_cmds $rd_id]"
|
||||||
|
fail "Unblocked BLPOP didn't increment expected client fields"
|
||||||
|
}
|
||||||
$rd close
|
$rd close
|
||||||
# test recursive command
|
# test recursive command
|
||||||
set info [r client info]
|
set info [r client info]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user