Skip to content

Commit 6900c18

Browse files
committed
add debug logging to stateless crossouts
1 parent 016243c commit 6900c18

File tree

3 files changed

+55
-45
lines changed

3 files changed

+55
-45
lines changed

ci/jobs/functional_tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,10 @@ def collect_logs():
449449
)
450450
force_ok_exit = True
451451

452+
broken_tests_handler_log = os.path.join(temp_dir, "broken_tests_handler.log")
453+
if os.path.exists(broken_tests_handler_log):
454+
debug_files.append(broken_tests_handler_log)
455+
452456
Result.create_from(
453457
results=results,
454458
stopwatch=stop_watch,

ci/jobs/scripts/functional_tests_results.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import dataclasses
2-
import json
3-
import os
42
import traceback
53
from typing import List
6-
import re
7-
8-
import yaml
94

105
from praktika.result import Result
116

tests/clickhouse-test

Lines changed: 51 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -131,53 +131,64 @@ def get_broken_tests_rules(broken_tests_file_path: str) -> dict:
131131
def test_is_known_fail(test_name, test_logs, build_flags, broken_tests_file_path):
132132
matching_rules = []
133133

134-
known_broken_tests = get_broken_tests_rules(broken_tests_file_path)
135-
136-
# print(f"Checking known broken tests for failed test: {test_name}")
137-
# print("Potential matching rules:")
138-
exact_rule = known_broken_tests["exact"].get(test_name)
139-
if exact_rule:
140-
# print(f"{test_name} - {exact_rule}")
141-
matching_rules.append(exact_rule)
142-
143-
for name_re, data in known_broken_tests["pattern"].items():
144-
if name_re.fullmatch(test_name):
145-
# print(f"{name_re} - {data}")
146-
matching_rules.append(data)
147-
148-
if not matching_rules:
149-
return False
150-
151134
def matches_substring(substring, log, is_regex):
152135
if log is None:
153136
return False
154137
if is_regex:
155138
return bool(substring.search(log))
156139
return substring in log
157140

158-
for rule_data in matching_rules:
159-
if rule_data.get("check_types") and not any(
160-
ct in build_flags for ct in rule_data["check_types"]
161-
):
162-
# print(
163-
# f"Check types didn't match: '{rule_data['check_types']}' not in '{build_flags}'"
164-
# )
165-
continue # check_types didn't match → skip rule
166-
167-
is_regex = rule_data.get("regex", False)
168-
not_message = rule_data.get("not_message")
169-
if not_message and matches_substring(not_message, test_logs, is_regex):
170-
# print(f"Skip rule: Not message matched: '{rule_data['not_message']}'")
171-
continue # not_message matched → skip rule
172-
message = rule_data.get("message")
173-
if message and not matches_substring(message, test_logs, is_regex):
174-
# print(f"Skip rule: Message didn't match: '{rule_data['message']}'")
175-
continue
141+
broken_tests_log = "ci/tmp/broken_tests_handler.log"
142+
143+
with open(broken_tests_log, "a") as log_file:
144+
try:
145+
known_broken_tests = get_broken_tests_rules(broken_tests_file_path)
146+
except Exception as e:
147+
log_file.write(f"Error getting broken tests rules: {e}\n")
148+
return False
176149

177-
# print(f"Test {test_name} matched rule: {rule_data}")
178-
return rule_data["reason"]
150+
log_file.write(f"Checking known broken tests for failed test: {test_name}\n")
151+
log_file.write("Potential matching rules:\n")
152+
exact_rule = known_broken_tests["exact"].get(test_name)
153+
if exact_rule:
154+
log_file.write(f"{test_name} - {exact_rule}\n")
155+
matching_rules.append(exact_rule)
179156

180-
return False
157+
for name_re, data in known_broken_tests["pattern"].items():
158+
if name_re.fullmatch(test_name):
159+
log_file.write(f"{name_re} - {data}\n")
160+
matching_rules.append(data)
161+
162+
if not matching_rules:
163+
return False
164+
165+
for rule_data in matching_rules:
166+
if rule_data.get("check_types") and not any(
167+
ct in build_flags for ct in rule_data["check_types"]
168+
):
169+
log_file.write(
170+
f"Check types didn't match: '{rule_data['check_types']}' not in '{build_flags}'\n"
171+
)
172+
continue # check_types didn't match → skip rule
173+
174+
is_regex = rule_data.get("regex", False)
175+
not_message = rule_data.get("not_message")
176+
if not_message and matches_substring(not_message, test_logs, is_regex):
177+
log_file.write(
178+
f"Skip rule: Not message matched: '{rule_data['not_message']}'\n"
179+
)
180+
continue # not_message matched → skip rule
181+
message = rule_data.get("message")
182+
if message and not matches_substring(message, test_logs, is_regex):
183+
log_file.write(
184+
f"Skip rule: Message didn't match: '{rule_data['message']}'\n"
185+
)
186+
continue
187+
188+
log_file.write(f"Test {test_name} matched rule: {rule_data}\n")
189+
return rule_data["reason"]
190+
191+
return False
181192

182193

183194
class SharedEngineReplacer:
@@ -2332,8 +2343,8 @@ class TestCase:
23322343
result.status = TestStatus.BROKEN
23332344

23342345
# Place the message on the second line
2335-
result.description.replace(
2336-
"\n", f"\nMarked as broken: {known_fail_reason}\n", count=1
2346+
result.description = result.description.replace(
2347+
"\n", f"\nMarked as broken: {known_fail_reason}\n", 1
23372348
)
23382349

23392350
if self.name in suite.blacklist_check:

0 commit comments

Comments
 (0)