File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed
Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -71,18 +71,17 @@ def test_rolling_error_counter_count_is_rolling():
7171 """Check that the error counter is actually rolling by incrementally adding
7272 and sleeping. At some point we should see the counter decrease because
7373 an entry has expired."""
74- rec = RollingErrorCounter (0.03 , 5 )
74+ # Init an error counter that rolls every 0.05 seconds.
75+ # Trying to use a shorter interval, such as 0.01, is flaky in CI.
76+ # We add 2 errors, then sleep 0.1 seconds to ensure the they have expired
77+ # before we add a new one and check the count.
78+ rec = RollingErrorCounter (0.05 , 5 )
7579 rec .add ()
76- assert rec .count () == 1
77- time .sleep (0.01 )
7880 rec .add ()
7981 assert rec .count () == 2
80- time .sleep (0.01 )
81- rec .add ()
82- assert rec .count () == 3
83- time .sleep (0.011 ) # just to be sure the first one expired
82+ time .sleep (0.1 ) # Double duration just to be sure the first two expired
8483 rec .add ()
85- assert rec .count () == 3
84+ assert rec .count () == 1
8685
8786
8887def test_rolling_error_counter_tolerance_exceeded ():
You can’t perform that action at this time.
0 commit comments