From d56a7d9b0510017ca5096074f7772ce2bc5db6b0 Mon Sep 17 00:00:00 2001 From: Binbin Date: Wed, 5 Jul 2023 14:32:30 +0800 Subject: [PATCH] Fix and increase tollerance of event loop test, add verbose logs (#12385) The test fails on freebsd CI: ``` *** [err]: stats: eventloop metrics in tests/unit/info.tcl Expected '31777' to be less than '16183' (context: type eval line 17 cmd {assert_lessthan $el_sum2 [expr $el_sum1+10000] } proc ::test) ``` The test added in #11963, fails on freebsd CI which is slow, increase tollerance and also add some verbose logs, now we can see these logs in verbose mode (for better views): ``` eventloop metrics cycle1: 12, cycle2: 15 eventloop metrics el_sum1: 315, el_sum2: 411 eventloop metrics cmd_sum1: 126, cmd_sum2: 137 [ok]: stats: eventloop metrics (111 ms) instantaneous metrics instantaneous_eventloop_cycles_per_sec: 8 instantaneous metrics instantaneous_eventloop_duration_usec: 55 [ok]: stats: instantaneous metrics (1603 ms) [ok]: stats: debug metrics (112 ms) ``` --- tests/unit/info.tcl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/unit/info.tcl b/tests/unit/info.tcl index 84251d034..812704340 100644 --- a/tests/unit/info.tcl +++ b/tests/unit/info.tcl @@ -287,21 +287,26 @@ start_server {tags {"info" "external:skip"}} { set cycle2 [getInfoProperty $info2 eventloop_cycles] set el_sum2 [getInfoProperty $info2 eventloop_duration_sum] set cmd_sum2 [getInfoProperty $info2 eventloop_duration_cmd_sum] + if {$::verbose} { puts "eventloop metrics cycle1: $cycle1, cycle2: $cycle2" } assert_morethan $cycle2 $cycle1 assert_lessthan $cycle2 [expr $cycle1+10] ;# we expect 2 or 3 cycles here, but allow some tolerance + if {$::verbose} { puts "eventloop metrics el_sum1: $el_sum1, el_sum2: $el_sum2" } assert_morethan $el_sum2 $el_sum1 - assert_lessthan $el_sum2 [expr $el_sum1+10000] ;# we expect roughly 100ms here, but allow some tolerance + assert_lessthan $el_sum2 [expr $el_sum1+30000] ;# we expect roughly 100ms here, but allow some tolerance + if {$::verbose} { puts "eventloop metrics cmd_sum1: $cmd_sum1, cmd_sum2: $cmd_sum2" } assert_morethan $cmd_sum2 $cmd_sum1 - assert_lessthan $cmd_sum2 [expr $cmd_sum1+5000] ;# we expect about tens of ms here, but allow some tolerance + assert_lessthan $cmd_sum2 [expr $cmd_sum1+15000] ;# we expect about tens of ms here, but allow some tolerance } - + test {stats: instantaneous metrics} { r config resetstat after 1600 ;# hz is 10, wait for 16 cron tick so that sample array is fulfilled set value [s instantaneous_eventloop_cycles_per_sec] + if {$::verbose} { puts "instantaneous metrics instantaneous_eventloop_cycles_per_sec: $value" } assert_morethan $value 0 assert_lessthan $value 15 ;# default hz is 10 set value [s instantaneous_eventloop_duration_usec] + if {$::verbose} { puts "instantaneous metrics instantaneous_eventloop_duration_usec: $value" } assert_morethan $value 0 assert_lessthan $value 22000 ;# default hz is 10, so duration < 1000 / 10, allow some tolerance }