@@ -251,23 +251,16 @@ def kill_query(
251251 if is_initial_query is not None
252252 else ""
253253 )
254+ old_time = time .monotonic ()
254255 node .query (
255256 f"KILL QUERY WHERE (query_kind='{ query_kind } ') AND (query LIKE '%{ id } %'){ filter_for_is_initial_query } SYNC"
256257 )
257- node .query ("SYSTEM FLUSH LOGS" )
258- duration = (
259- int (
260- node .query (
261- f"SELECT query_duration_ms FROM system.query_log WHERE query_kind='KillQuery' AND query LIKE '%{ id } %' AND type='QueryFinish'"
262- )
263- )
264- / 1000
265- )
258+ waited = time .monotonic () - old_time
266259 print (
267- f"{ get_node_name (node )} : Cancelled { operation_name } { id } after { duration } seconds"
260+ f"{ get_node_name (node )} : Cancelled { operation_name } { id } after { waited } seconds"
268261 )
269262 if timeout is not None :
270- assert duration < timeout
263+ assert waited < timeout
271264
272265
273266# Stops all ZooKeeper servers.
@@ -305,7 +298,7 @@ def sleep(seconds):
305298class NoTrashChecker :
306299 def __init__ (self ):
307300 self .expect_backups = []
308- self .expect_unfinished_backups = []
301+ self .allow_unfinished_backups = []
309302 self .expect_errors = []
310303 self .allow_errors = []
311304 self .check_zookeeper = True
@@ -373,7 +366,7 @@ def __exit__(self, type, value, traceback):
373366 if unfinished_backups :
374367 print (f"Found unfinished backups: { unfinished_backups } " )
375368 assert new_backups == set (self .expect_backups )
376- assert unfinished_backups == set (self . expect_unfinished_backups )
369+ assert unfinished_backups . difference ( self . allow_unfinished_backups ) == set ()
377370
378371 all_errors = set ()
379372 start_time = time .strftime (
@@ -641,7 +634,7 @@ def test_long_disconnection_stops_backup():
641634 assert get_status (initiator , backup_id = backup_id ) == "CREATING_BACKUP"
642635 assert get_num_system_processes (initiator , backup_id = backup_id ) >= 1
643636
644- no_trash_checker .expect_unfinished_backups = [backup_id ]
637+ no_trash_checker .allow_unfinished_backups = [backup_id ]
645638 no_trash_checker .allow_errors = [
646639 "FAILED_TO_SYNC_BACKUP_OR_RESTORE" ,
647640 "KEEPER_EXCEPTION" ,
@@ -674,7 +667,7 @@ def test_long_disconnection_stops_backup():
674667 # A backup is expected to fail, but it isn't expected to fail too soon.
675668 print (f"Backup failed after { time_to_fail } seconds disconnection" )
676669 assert time_to_fail > 3
677- assert time_to_fail < 30
670+ assert time_to_fail < 35
678671
679672
680673# A backup must NOT be stopped if Zookeeper is disconnected shorter than `failure_after_host_disconnected_for_seconds`.
@@ -695,21 +688,21 @@ def test_short_disconnection_doesnt_stop_backup():
695688 backup_id = random_id ()
696689 initiator .query (
697690 f"BACKUP TABLE tbl ON CLUSTER 'cluster' TO { get_backup_name (backup_id )} SETTINGS id='{ backup_id } ' ASYNC" ,
698- settings = {"backup_restore_failure_after_host_disconnected_for_seconds" : 6 },
691+ settings = {"backup_restore_failure_after_host_disconnected_for_seconds" : 10 },
699692 )
700693
701694 assert get_status (initiator , backup_id = backup_id ) == "CREATING_BACKUP"
702695 assert get_num_system_processes (initiator , backup_id = backup_id ) >= 1
703696
704697 # Dropping connection for less than `failure_after_host_disconnected_for_seconds`
705698 with PartitionManager () as pm :
706- random_sleep (3 )
699+ random_sleep (4 )
707700 node_to_drop_zk_connection = random_node ()
708701 print (
709702 f"Dropping connection between { get_node_name (node_to_drop_zk_connection )} and ZooKeeper"
710703 )
711704 pm .drop_instance_zk_connections (node_to_drop_zk_connection )
712- random_sleep (3 )
705+ random_sleep (4 )
713706 print (
714707 f"Restoring connection between { get_node_name (node_to_drop_zk_connection )} and ZooKeeper"
715708 )
0 commit comments