Skip to content

Commit 3c55bf3

Browse files
authored
Improve logs of the grouper cron job (#4656)
Always log testcase IDs when grouping two testcases. Also log the reason why testcases are grouped.
1 parent e77f2d5 commit 3c55bf3

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/clusterfuzz/_internal/cron/grouper.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,19 @@ def __init__(self, testcase_id):
5656
self.issue_id = None
5757

5858

59-
def combine_testcases_into_group(testcase_1, testcase_2, testcase_map):
59+
def combine_testcases_into_group(
60+
testcase_1: TestcaseAttributes, testcase_2: TestcaseAttributes,
61+
testcase_map: dict[int, TestcaseAttributes], reason: str) -> None:
6062
"""Combine two testcases into a group."""
6163
logs.info(
62-
'Grouping testcase 1 '
64+
'Grouping testcase %s '
6365
'(crash_type=%s, crash_state=%s, security_flag=%s, group=%s) '
64-
'and testcase 2 '
65-
'(crash_type=%s, crash_state=%s, security_flag=%s, group=%s).' %
66-
(testcase_1.crash_type, testcase_1.crash_state, testcase_1.security_flag,
67-
testcase_1.group_id, testcase_2.crash_type, testcase_2.crash_state,
68-
testcase_2.security_flag, testcase_2.group_id))
66+
'and testcase %s '
67+
'(crash_type=%s, crash_state=%s, security_flag=%s, group=%s). Reason: %s'
68+
% (testcase_1.id, testcase_1.crash_type, testcase_1.crash_state,
69+
testcase_1.security_flag, testcase_1.group_id, testcase_2.id,
70+
testcase_2.crash_type, testcase_2.crash_state,
71+
testcase_2.security_flag, testcase_2.group_id, reason))
6972

7073
# If none of the two testcases have a group id, just assign a new group id to
7174
# both.
@@ -88,9 +91,14 @@ def combine_testcases_into_group(testcase_1, testcase_2, testcase_map):
8891
# together and reuse one of their group ids.
8992
group_id_to_reuse = testcase_1.group_id
9093
group_id_to_move = testcase_2.group_id
94+
moved_testcase_ids = []
9195
for testcase in testcase_map.values():
9296
if testcase.group_id == group_id_to_move:
9397
testcase.group_id = group_id_to_reuse
98+
moved_testcase_ids.append(testcase.id)
99+
100+
logs.info(f'Merged group {group_id_to_move} into {group_id_to_reuse}: ' +
101+
'moved testcases: ' + ', '.join(moved_testcase_ids))
94102

95103

96104
def _get_new_group_id():
@@ -227,18 +235,8 @@ def _group_testcases_based_on_variants(testcase_map):
227235
'is a top crash, skipping.')
228236
continue
229237

230-
logs.info(
231-
'VARIANT ANALYSIS: Grouping testcase 1 '
232-
'(id=%s, '
233-
'crash_type=%s, crash_state=%s, security_flag=%s, job=%s, group=%s) '
234-
'and testcase 2 (id=%s, '
235-
'crash_type=%s, crash_state=%s, security_flag=%s, job=%s, group=%s).'
236-
%
237-
(testcase_1.id, testcase_1.crash_type, testcase_1.crash_state,
238-
testcase_1.security_flag, testcase_1.job_type, testcase_1.group_id,
239-
testcase_2.id, testcase_2.crash_type, testcase_2.crash_state,
240-
testcase_2.security_flag, testcase_2.job_type, testcase_2.group_id))
241-
combine_testcases_into_group(testcase_1, testcase_2, testcase_map)
238+
combine_testcases_into_group(testcase_1, testcase_2, testcase_map,
239+
'identical variant')
242240

243241

244242
def _group_testcases_with_same_issues(testcase_map):
@@ -267,7 +265,8 @@ def _group_testcases_with_same_issues(testcase_map):
267265
if testcase_1.issue_id != testcase_2.issue_id:
268266
continue
269267

270-
combine_testcases_into_group(testcase_1, testcase_2, testcase_map)
268+
combine_testcases_into_group(testcase_1, testcase_2, testcase_map,
269+
'same issue')
271270

272271

273272
def _group_testcases_with_similar_states(testcase_map):
@@ -316,7 +315,8 @@ def _group_testcases_with_similar_states(testcase_map):
316315
if not crash_comparer.is_similar():
317316
continue
318317

319-
combine_testcases_into_group(testcase_1, testcase_2, testcase_map)
318+
combine_testcases_into_group(testcase_1, testcase_2, testcase_map,
319+
'similar crashes')
320320

321321

322322
def _has_testcase_with_same_params(testcase, testcase_map):

0 commit comments

Comments
 (0)