@@ -823,7 +823,7 @@ def test_auto_flush_interval(self):
823823 # Due to CI timing delays there may have been multiple flushes.
824824 self .assertGreaterEqual (requests_len , 1 )
825825
826- def test_auto_flush_interval2 (self ):
826+ def _do_test_auto_flush_interval2 (self ):
827827 with HttpServer () as server , self .builder (
828828 'http' ,
829829 'localhost' ,
@@ -839,11 +839,25 @@ def test_auto_flush_interval2(self):
839839 time .sleep (0.02 )
840840 sender .row ('t' , columns = {'x' : 5 }, at = qi .ServerTimestamp )
841841 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 )
847861
848862 def test_http_username_password (self ):
849863 with HttpServer () as server , self .builder ('http' , 'localhost' , server .port , username = 'user' ,
0 commit comments