@@ -1422,7 +1422,7 @@ class TestCase:
14221422 self .suite = suite
14231423 self .case : str = case # case file name
14241424 self .args : Namespace = args
1425- self .tags : Set [str ] = suite .all_tags [case ] if case in suite . all_tags else set ()
1425+ self .tags : Set [str ] = suite .all_tags [case ]
14261426 self .random_settings_limits = (
14271427 suite .all_random_settings_limits [case ]
14281428 if case in suite .all_random_settings_limits
@@ -1550,7 +1550,7 @@ class TestCase:
15501550
15511551 if tags and ("no-fasttest" in tags ) and args .fast_tests_only :
15521552 return FailureReason .FAST_ONLY
1553-
1553+
15541554 if tags and ("fasttest-only" in tags ) and not args .fast_tests_only :
15551555 return FailureReason .NOT_FAST_ONLY
15561556
@@ -1877,6 +1877,8 @@ class TestCase:
18771877 print ("Cannot insert coverage data: " , str (e ))
18781878
18791879 # Check for dumped coverage files
1880+
1881+ # FIXME: This is a race condition
18801882 file_pattern = "coverage.*"
18811883 matching_files = glob .glob (file_pattern )
18821884 for file_path in matching_files :
@@ -1892,8 +1894,13 @@ class TestCase:
18921894 )
18931895 except Exception as e :
18941896 print ("Cannot insert coverage data: " , str (e ))
1897+
18951898 # Remove the file even in case of exception to avoid accumulation and quadratic complexity.
1896- os .remove (file_path )
1899+ try :
1900+ os .remove (file_path )
1901+ except Exception as e :
1902+ print ("FIXME: Race! Cannot remove coverage file: " , str (e ))
1903+ # FIXME: This is a race condition. END
18971904
18981905 _ = clickhouse_execute (args , "SYSTEM FLUSH ASYNC INSERT QUEUE" )
18991906
@@ -2443,8 +2450,7 @@ class TestSuite:
24432450 ) = load_tags_and_random_settings_limits_from_file (
24442451 os .path .join (suite_dir , test_name )
24452452 ) # noqa: ignore E203
2446- if tags :
2447- all_tags [test_name ] = tags
2453+ all_tags [test_name ] = tags or set ()
24482454 if random_settings_limits :
24492455 all_random_settings_limits [test_name ] = random_settings_limits
24502456 elapsed = (datetime .now () - start_time ).total_seconds ()
@@ -2499,13 +2505,20 @@ class TestSuite:
24992505 self .all_tests = self .apply_test_runs (all_tests )
25002506 self .all_tests .sort (key = self .tests_in_suite_key_func )
25012507
2502- for test_name in self .all_tests :
2503- if self .is_sequential_test (test_name ):
2508+ post_run_check_tests = []
2509+
2510+ for test_name , tags in self .all_tags .items ():
2511+ if "post-run-check" in tags :
2512+ # post_run_check_tests are tests that supposed to run after all normal tests finished
2513+ post_run_check_tests .append (test_name )
2514+ continue
2515+ if self .is_sequential_test (test_name , tags ):
25042516 if not args .no_sequential :
25052517 self .sequential_tests .append (test_name )
25062518 else :
25072519 if not args .no_parallel :
25082520 self .parallel_tests .append (test_name )
2521+ self .sequential_tests .extend (post_run_check_tests )
25092522
25102523 def apply_test_runs (self , all_tests ):
25112524 test_runs = self .args .test_runs
@@ -2526,7 +2539,13 @@ class TestSuite:
25262539 return False
25272540 return "long" in self .all_tags [test_name ]
25282541
2529- def is_sequential_test (self , test_name ):
2542+ def is_sequential_test (self , test_name , tags = None ):
2543+ if tags is not None :
2544+ return (
2545+ ("no-parallel" in tags )
2546+ or ("sequential" in tags )
2547+ or ("stateful" in tags )
2548+ )
25302549 if args .sequential :
25312550 if any (s in test_name for s in args .sequential ):
25322551 return True
@@ -2996,7 +3015,13 @@ def run_tests_process(*args_, **kwargs):
29963015
29973016
29983017def do_run_tests (
2999- jobs , test_suite : TestSuite , args , exit_code , restarted_tests , server_died
3018+ jobs ,
3019+ test_suite : TestSuite ,
3020+ args ,
3021+ exit_code ,
3022+ restarted_tests ,
3023+ server_died ,
3024+ runner_process_killed ,
30003025):
30013026 print (
30023027 "Found" ,
@@ -3077,7 +3102,14 @@ def do_run_tests(
30773102
30783103 for p in processes [:]:
30793104 if not p .is_alive ():
3105+ # Check if process was killed with exception
3106+ if p .exitcode is not None and p .exitcode != 0 :
3107+ print (
3108+ f"ERROR: Process { p .name } was killed with exit code { p .exitcode } "
3109+ )
3110+ runner_process_killed .set ()
30803111 processes .remove (p )
3112+
30813113 if test_suite .sequential_tests :
30823114 run_tests_array (
30833115 (
@@ -3336,6 +3368,7 @@ def try_get_skip_list(base_dir, name, remove_comment=True):
33363368def main (args ):
33373369 exit_code = multiprocessing .Value ("i" , 0 )
33383370 server_died = multiprocessing .Event ()
3371+ runner_process_killed = multiprocessing .Event ()
33393372 multiprocessing_manager = multiprocessing .Manager ()
33403373 restarted_tests = multiprocessing_manager .list ()
33413374
@@ -3468,12 +3501,21 @@ def main(args):
34683501 test_suite .private_skip_list = private_skip_list
34693502 test_suite .blacklist_check = blacklist_check
34703503 total_tests_run += do_run_tests (
3471- args .jobs , test_suite , args , exit_code , restarted_tests , server_died
3504+ args .jobs ,
3505+ test_suite ,
3506+ args ,
3507+ exit_code ,
3508+ restarted_tests ,
3509+ server_died ,
3510+ runner_process_killed ,
34723511 )
34733512
34743513 if server_died .is_set ():
34753514 exit_code .value = 1
34763515
3516+ if runner_process_killed .is_set ():
3517+ exit_code .value = 1
3518+
34773519 if args .hung_check :
34783520 # Some queries may execute in background for some time after test was finished. This is normal.
34793521 print ("Checking the hung queries: " , end = "" )
0 commit comments