Skip to content

Commit

Permalink
Improve logs of the grouper cron job (#4656)
Browse files Browse the repository at this point in the history
Always log testcase IDs when grouping two testcases. Also log the reason
why testcases are grouped.
  • Loading branch information
letitz authored Feb 5, 2025
1 parent e77f2d5 commit 3c55bf3
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions src/clusterfuzz/_internal/cron/grouper.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,19 @@ def __init__(self, testcase_id):
self.issue_id = None


def combine_testcases_into_group(testcase_1, testcase_2, testcase_map):
def combine_testcases_into_group(
testcase_1: TestcaseAttributes, testcase_2: TestcaseAttributes,
testcase_map: dict[int, TestcaseAttributes], reason: str) -> None:
"""Combine two testcases into a group."""
logs.info(
'Grouping testcase 1 '
'Grouping testcase %s '
'(crash_type=%s, crash_state=%s, security_flag=%s, group=%s) '
'and testcase 2 '
'(crash_type=%s, crash_state=%s, security_flag=%s, group=%s).' %
(testcase_1.crash_type, testcase_1.crash_state, testcase_1.security_flag,
testcase_1.group_id, testcase_2.crash_type, testcase_2.crash_state,
testcase_2.security_flag, testcase_2.group_id))
'and testcase %s '
'(crash_type=%s, crash_state=%s, security_flag=%s, group=%s). Reason: %s'
% (testcase_1.id, testcase_1.crash_type, testcase_1.crash_state,
testcase_1.security_flag, testcase_1.group_id, testcase_2.id,
testcase_2.crash_type, testcase_2.crash_state,
testcase_2.security_flag, testcase_2.group_id, reason))

# If none of the two testcases have a group id, just assign a new group id to
# both.
Expand All @@ -88,9 +91,14 @@ def combine_testcases_into_group(testcase_1, testcase_2, testcase_map):
# together and reuse one of their group ids.
group_id_to_reuse = testcase_1.group_id
group_id_to_move = testcase_2.group_id
moved_testcase_ids = []
for testcase in testcase_map.values():
if testcase.group_id == group_id_to_move:
testcase.group_id = group_id_to_reuse
moved_testcase_ids.append(testcase.id)

logs.info(f'Merged group {group_id_to_move} into {group_id_to_reuse}: ' +
'moved testcases: ' + ', '.join(moved_testcase_ids))


def _get_new_group_id():
Expand Down Expand Up @@ -227,18 +235,8 @@ def _group_testcases_based_on_variants(testcase_map):
'is a top crash, skipping.')
continue

logs.info(
'VARIANT ANALYSIS: Grouping testcase 1 '
'(id=%s, '
'crash_type=%s, crash_state=%s, security_flag=%s, job=%s, group=%s) '
'and testcase 2 (id=%s, '
'crash_type=%s, crash_state=%s, security_flag=%s, job=%s, group=%s).'
%
(testcase_1.id, testcase_1.crash_type, testcase_1.crash_state,
testcase_1.security_flag, testcase_1.job_type, testcase_1.group_id,
testcase_2.id, testcase_2.crash_type, testcase_2.crash_state,
testcase_2.security_flag, testcase_2.job_type, testcase_2.group_id))
combine_testcases_into_group(testcase_1, testcase_2, testcase_map)
combine_testcases_into_group(testcase_1, testcase_2, testcase_map,
'identical variant')


def _group_testcases_with_same_issues(testcase_map):
Expand Down Expand Up @@ -267,7 +265,8 @@ def _group_testcases_with_same_issues(testcase_map):
if testcase_1.issue_id != testcase_2.issue_id:
continue

combine_testcases_into_group(testcase_1, testcase_2, testcase_map)
combine_testcases_into_group(testcase_1, testcase_2, testcase_map,
'same issue')


def _group_testcases_with_similar_states(testcase_map):
Expand Down Expand Up @@ -316,7 +315,8 @@ def _group_testcases_with_similar_states(testcase_map):
if not crash_comparer.is_similar():
continue

combine_testcases_into_group(testcase_1, testcase_2, testcase_map)
combine_testcases_into_group(testcase_1, testcase_2, testcase_map,
'similar crashes')


def _has_testcase_with_same_params(testcase, testcase_map):
Expand Down

0 comments on commit 3c55bf3

Please sign in to comment.