Skip to content

Commit 62f1766

Browse files
authored
Merge pull request ClickHouse#82602 from ClickHouse/ci_post_run_test_cases_in_ft
CI: Run 00002_log_and_exception_messages_formatting in the end
2 parents c17fd86 + 7ea8e8c commit 62f1766

4 files changed

Lines changed: 63 additions & 15 deletions

File tree

‎ci/jobs/functional_tests.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ def start():
381381
results.append(
382382
Result.create_from(
383383
name="Check errors",
384-
results=CH.check_fatal_messeges_in_logs(),
384+
results=CH.check_fatal_messages_in_logs(),
385385
status=Result.Status.SUCCESS,
386386
stopwatch=sw_,
387387
)

‎ci/jobs/scripts/clickhouse_proc.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,10 +770,16 @@ def _get_logs_archives_server(self):
770770
).exists(), f"Log directory {self.log_dir} does not exist"
771771
return [f for f in glob.glob(f"{self.log_dir}/*.log")]
772772

773-
def check_fatal_messeges_in_logs(self):
773+
def check_fatal_messages_in_logs(self):
774774
results = []
775775

776776
# if command exit code is 1 - it's failed test case, script output will be stored into test case info
777+
results.append(
778+
Result.from_commands_run(
779+
name="Exception in test runner",
780+
command=f"! grep -A10 'Traceback (most recent call last)' {temp_dir}/job.log | head -n 100 | tee /dev/stderr | grep -q .",
781+
)
782+
)
777783
results.append(
778784
Result.from_commands_run(
779785
name="Sanitizer assert (in stderr.log)",

‎tests/clickhouse-test‎

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

29983017
def 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):
33363368
def 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="")

‎tests/queries/0_stateless/00002_log_and_exception_messages_formatting.sql‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
-- Tags: no-parallel, no-fasttest, no-ubsan, no-batch, no-flaky-check
2-
-- no-parallel because we want to run this test when most of the other tests already passed
1+
-- Tags: no-fasttest, no-ubsan, no-batch, no-flaky-check, post-run-check
32

3+
-- post-run-check - to run it after all other tests:
44
-- This is not a regular test. It is intended to run once after other tests to validate certain statistics about the whole test runs.
5-
-- TODO: I advise to put in inside clickhouse-test instead.
5+
66

77
-- If this test fails, see the "Top patterns of log messages" diagnostics in the end of run.log
88

0 commit comments

Comments
 (0)