@@ -8905,27 +8905,37 @@ var _ = Describe("Commands", func() {
89058905 const key = "latency-monitor-threshold"
89068906
89078907 old := client .ConfigGet (ctx , key ).Val ()
8908- client .ConfigSet (ctx , key , "1" )
8908+ // Use a higher threshold (100ms) to avoid capturing normal operations
8909+ // that could cause flakiness due to timing variations
8910+ client .ConfigSet (ctx , key , "100" )
89098911 defer client .ConfigSet (ctx , key , old [key ])
89108912
89118913 result , err := client .Latency (ctx ).Result ()
89128914 Expect (err ).NotTo (HaveOccurred ())
89138915 Expect (len (result )).Should (Equal (0 ))
89148916
8915- err = client .Do (ctx , "DEBUG" , "SLEEP" , 0.01 ).Err ()
8917+ // Use a longer sleep (150ms) to ensure it exceeds the 100ms threshold
8918+ err = client .Do (ctx , "DEBUG" , "SLEEP" , 0.15 ).Err ()
89168919 Expect (err ).NotTo (HaveOccurred ())
89178920
89188921 result , err = client .Latency (ctx ).Result ()
89198922 Expect (err ).NotTo (HaveOccurred ())
8920- Expect (len (result )).Should (Equal ( 1 ))
8923+ Expect (len (result )).Should (BeNumerically ( ">=" , 1 ))
89218924
89228925 // reset latency by event name
8923- err = client .LatencyReset (ctx , result [0 ].Name ).Err ()
8926+ eventName := result [0 ].Name
8927+ err = client .LatencyReset (ctx , eventName ).Err ()
89248928 Expect (err ).NotTo (HaveOccurred ())
89258929
8930+ // Verify the specific event was reset (not that all events are gone)
8931+ // This avoids flakiness from other operations triggering latency events
89268932 result , err = client .Latency (ctx ).Result ()
89278933 Expect (err ).NotTo (HaveOccurred ())
8928- Expect (len (result )).Should (Equal (0 ))
8934+ for _ , event := range result {
8935+ if event .Name == eventName {
8936+ Fail ("Event " + eventName + " should have been reset" )
8937+ }
8938+ }
89298939 })
89308940 })
89318941})
0 commit comments