Skip to content

Commit

Permalink
Adding test case reproducibility metric (#4358)
Browse files Browse the repository at this point in the history
### Motivation

The Chrome team has no easy visibility into how many manually uploaded
test cases flake or successfully reproduce. This PR implements a counter
metric to track that.

There are three possible outcomes, each represented by a string label:
'reproduces', 'one_timer' and 'does_not_reproduce'

Part of #4271
  • Loading branch information
vitorguidi authored Nov 4, 2024
1 parent 13c5b09 commit 74797c2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/clusterfuzz/_internal/bot/tasks/utasks/analyze_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from clusterfuzz._internal.datastore import data_types
from clusterfuzz._internal.fuzzing import leak_blacklist
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.metrics import monitoring_metrics
from clusterfuzz._internal.protos import uworker_msg_pb2
from clusterfuzz._internal.system import environment

Expand Down Expand Up @@ -409,6 +410,14 @@ def utask_main(uworker_input):
analyze_task_output.crash_stacktrace = testcase.crash_stacktrace

if not crashed:
monitoring_metrics.ANALYZE_TASK_REPRODUCIBILITY.increment(
labels={
'fuzzer_name': uworker_input.fuzzer_name,
'job': uworker_input.job_type,
'crashes': False,
'reproducible': False,
'platform': environment.platform(),
})
return uworker_msg_pb2.Output( # pylint: disable=no-member
analyze_task_output=analyze_task_output,
error_type=uworker_msg_pb2.ErrorType.ANALYZE_NO_CRASH, # pylint: disable=no-member
Expand All @@ -425,7 +434,18 @@ def utask_main(uworker_input):

test_for_reproducibility(fuzz_target, testcase, testcase_file_path, state,
test_timeout)
analyze_task_output.one_time_crasher_flag = testcase.one_time_crasher_flag
one_time_flag = testcase.one_time_crasher_flag

analyze_task_output.one_time_crasher_flag = one_time_flag

monitoring_metrics.ANALYZE_TASK_REPRODUCIBILITY.increment(
labels={
'fuzzer_name': uworker_input.fuzzer_name,
'job': uworker_input.job_type,
'crashes': True,
'reproducible': not one_time_flag,
'platform': environment.platform(),
})

fuzz_target_metadata = engine_common.get_fuzz_target_issue_metadata(
fuzz_target)
Expand Down
10 changes: 10 additions & 0 deletions src/clusterfuzz/_internal/metrics/monitoring_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,13 @@
monitor.StringField('fuzzer_name'),
monitor.StringField('status'),
])

ANALYZE_TASK_REPRODUCIBILITY = monitor.CounterMetric(
'task/analyze/reproducibility',
description='Outcome count for analyze task.',
field_spec=[
monitor.StringField('job'),
monitor.StringField('fuzzer_name'),
monitor.BooleanField('reproducible'),
monitor.BooleanField('crashes'),
])

0 comments on commit 74797c2

Please sign in to comment.