File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed
Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -996,6 +996,7 @@ def poll_query_until(self,
996996 max_attempts: how many times should we try? 0 == infinite
997997 sleep_time: how much should we sleep after a failure?
998998 expected: what should be returned to break the cycle?
999+ commit: should (possible) changes be committed?
9991000 raise_programming_error: mute ProgrammingError?
10001001 raise_internal_error: mute InternalError?
10011002 """
@@ -1024,7 +1025,7 @@ def poll_query_until(self,
10241025 if len (res [0 ]) == 0 :
10251026 raise QueryException ('Query returned 0 columns' )
10261027
1027- if res [0 ][0 ]:
1028+ if res [0 ][0 ] == expected :
10281029 return # done
10291030
10301031 except pglib .ProgrammingError as e :
Original file line number Diff line number Diff line change @@ -376,6 +376,7 @@ def test_poll_query_until(self):
376376 with self .assertRaises (QueryException ):
377377 node .poll_query_until (
378378 dbname = 'postgres' , query = 'select from pg_class limit 1' )
379+
379380 # check None, fail
380381 with self .assertRaises (QueryException ):
381382 node .poll_query_until (
@@ -386,17 +387,26 @@ def test_poll_query_until(self):
386387 dbname = 'postgres' , query = 'create table def()' ,
387388 expected = None ) # returns nothing
388389
389- # check arbitrary expected value
390+ # check arbitrary expected value, fail
391+ with self .assertRaises (TimeoutException ):
392+ node .poll_query_until (
393+ dbname = 'postgres' ,
394+ query = 'select 3' ,
395+ expected = 1 ,
396+ max_attempts = 3 ,
397+ sleep_time = 0.01 )
398+
399+ # check arbitrary expected value, ok
390400 node .poll_query_until (
391- dbname = 'postgres' , query = 'select 1 ' , expected = 1 )
401+ dbname = 'postgres' , query = 'select 2 ' , expected = 2 )
392402
393403 # check timeout
394404 with self .assertRaises (TimeoutException ):
395405 node .poll_query_until (
396406 dbname = 'postgres' ,
397407 query = 'select 1 > 2' ,
398- max_attempts = 5 ,
399- sleep_time = 0.2 )
408+ max_attempts = 3 ,
409+ sleep_time = 0.01 )
400410
401411 def test_logging (self ):
402412 logfile = tempfile .NamedTemporaryFile ('w' , delete = True )
You can’t perform that action at this time.
0 commit comments