@@ -823,7 +823,7 @@ def test_auto_flush_interval(self):
823
823
# Due to CI timing delays there may have been multiple flushes.
824
824
self .assertGreaterEqual (requests_len , 1 )
825
825
826
- def test_auto_flush_interval2 (self ):
826
+ def _do_test_auto_flush_interval2 (self ):
827
827
with HttpServer () as server , self .builder (
828
828
'http' ,
829
829
'localhost' ,
@@ -839,11 +839,25 @@ def test_auto_flush_interval2(self):
839
839
time .sleep (0.02 )
840
840
sender .row ('t' , columns = {'x' : 5 }, at = qi .ServerTimestamp )
841
841
sender .row ('t' , columns = {'x' : 6 }, at = qi .ServerTimestamp )
842
- self .assertEqual (len (server .requests ), 3 )
843
- self .assertEqual (server .requests , [
844
- b't x=1i\n t x=2i\n t x=3i\n ' ,
845
- b't x=4i\n t x=5i\n ' ,
846
- b't x=6i\n ' ])
842
+ return server .requests
843
+
844
+ def test_auto_flush_interval2 (self ):
845
+ # This test is timing-sensitive,
846
+ # so it has a tendency to go wrong in CI.
847
+ # To work around this we'll repeat the test up to 10 times
848
+ # until it passes.
849
+ for _ in range (10 ):
850
+ requests = self ._do_test_auto_flush_interval2 ()
851
+ if len (requests ) == 3 :
852
+ self .assertEqual (requests , [
853
+ b't x=1i\n t x=2i\n t x=3i\n ' ,
854
+ b't x=4i\n t x=5i\n ' ,
855
+ b't x=6i\n ' ])
856
+ break
857
+
858
+ # If this fails, it failed 10 attempts.
859
+ # Due to CI timing delays there may have been multiple flushes.
860
+ self .assertEqual (len (requests ), 3 )
847
861
848
862
def test_http_username_password (self ):
849
863
with HttpServer () as server , self .builder ('http' , 'localhost' , server .port , username = 'user' ,
0 commit comments