Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Monitoring] Extend TESTCASE_UPLOAD_TRIAGE_DURATION to account for fuzzer generated test cases #4481

Merged
merged 8 commits into from
Dec 16, 2024

Conversation

vitorguidi
Copy link
Collaborator

@vitorguidi vitorguidi commented Dec 10, 2024

Motivation

#4364 implemented the tracking for the time it takes clusterfuzz to complete several steps of the manually uploaded testcase lifecycle.

As per Chrome's request, the metric will now contain an 'origin' label, which indicates if the testcase was 'manually_uploaded' or generated by a 'fuzzer'.

The code was also simplified, by reusing the get_age_in_seconds method from the TestCase entity.

Also, it adds the 'stuck_in_triage' boolean field to the testcase entity, to facilitate figuring out what testcases are in a stuck state, so follow up actions can be taken.

Part of #4271

@vitorguidi vitorguidi changed the title Extend TESTCASE_UPLOAD_TRIAGE_DURATION to account for fuzzer generated test cases [Monitoring] Extend TESTCASE_UPLOAD_TRIAGE_DURATION to account for fuzzer generated test cases Dec 10, 2024
@letitz letitz removed their request for review December 10, 2024 11:17
@letitz
Copy link
Collaborator

letitz commented Dec 10, 2024

I'll let @alhijazi review this first. Let me know if you'd still like my review afterwards.

@vitorguidi vitorguidi merged commit 8da25b5 into master Dec 16, 2024
7 checks passed
@vitorguidi vitorguidi deleted the feature/triage-lifecycle-for-fuzzers branch December 16, 2024 13:59
vitorguidi added a commit that referenced this pull request Dec 16, 2024
…zzer generated test cases (#4481)

[#4364](#4364) implemented the
tracking for the time it takes clusterfuzz to complete several steps of
the manually uploaded testcase lifecycle.

As per Chrome's request, the metric will now contain an 'origin' label,
which indicates if the testcase was 'manually_uploaded' or generated by
a 'fuzzer'.

The code was also simplified, by reusing the get_age_in_seconds method
from the TestCase entity.

Also, it adds the 'stuck_in_triage' boolean field to the testcase
entity, to facilitate figuring out what testcases are in a stuck state,
so follow up actions can be taken.

Part of #4271
vitorguidi added a commit that referenced this pull request Dec 16, 2024
Running CI checks with a PR prior to deployment
@@ -31,6 +31,8 @@


def emit_testcase_triage_duration_metric(testcase_id: int, step: str):
'''Finds out if a testcase is fuzzer generated or manually uploaded,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong style docstring.

@@ -61,15 +60,30 @@ def emit_testcase_triage_duration_metric(testcase_id: int, step: str):
' failed to emit TESTCASE_UPLOAD_TRIAGE_DURATION metric.')
return

from_fuzzer = not get_testcase_upload_metadata(testcase_id)

assert step in [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we can throw an assertion failure if our metrics collection isn't working? I don't think this is a good idea.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to removing this.

' failed to emit TESTCASE_UPLOAD_TRIAGE_DURATION metric.')
return

testcase_age_in_hours = testcase.get_age_in_seconds() / 3600
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: / (60 * 60)

bucketer=monitor.GeometricBucketer(),
field_spec=[
monitor.StringField('step'),
monitor.StringField('job'),
monitor.StringField('origin'),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, this can be a boolean field.

@@ -686,6 +689,8 @@ def get_created_time(self) -> ndb.DateTimeProperty:

def get_age_in_seconds(self):
current_time = datetime.datetime.utcnow()
if not self.get_created_time():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this check is needed since get_created_time seems to never return None

logs.info('Emiting TESTCASE_UPLOAD_TRIAGE_DURATION metric for testcase '
f'{testcase_id} (age = {elapsed_time_since_upload}) '
f'{testcase_id} (age = {testcase_age_in_hours} hours.) '
'in step {step}.')

monitoring_metrics.TESTCASE_UPLOAD_TRIAGE_DURATION.add(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming of this metric is now inaccurate since it now covers both fuzzed and uploaded testcases, it needs to be changed.
Does BUG_FILING_FROM_TESTCASE_ELAPSED_TIME cover both also?

vitorguidi added a commit that referenced this pull request Dec 23, 2024
vitorguidi added a commit that referenced this pull request Dec 23, 2024
…stuck in analyze (#4547)

### Motivation

We currently have no way to tell if analyze task was successfully
executed. The TESTCASE_UPLOAD_TRIAGE_DURATION metric from #4364 would
only track duration for tasks that did finish.

An analyze_pending field is added to the Testcase entity in datastore,
which is set to False by default, to True for manually uploaded
testcases, and to False once analyze task postprocess runs.

It also increments the UNTRIAGED_TESTCASE_AGE metric from #4381 with a
status label, so we can know at what step the testcase is stuck, thus
allowing us to alert if analyze is taking longer to finish than
expected.

The alert itself could be, for instance, P50 age of untriaged testcase
(status=analyze_pending) > 3h.

Also, this retroactively addresses comments from #4481:

* Fixes docstring for emit_testcase_triage_duration_metric
* Removes assertions
* Renames TESTCASE_UPLOAD_TRIAGE_DURATION to TESTCASE_TRIAGE_DURATION,
since it now accounts for fuzzer generated testcases
* Use a boolean "from_fuzzer" field, instead of "origin" string, in
TESTCASE_TRIAGE_DURATION
vitorguidi added a commit that referenced this pull request Dec 26, 2024
…stuck in analyze (#4547)

### Motivation

We currently have no way to tell if analyze task was successfully
executed. The TESTCASE_UPLOAD_TRIAGE_DURATION metric from #4364 would
only track duration for tasks that did finish.

An analyze_pending field is added to the Testcase entity in datastore,
which is set to False by default, to True for manually uploaded
testcases, and to False once analyze task postprocess runs.

It also increments the UNTRIAGED_TESTCASE_AGE metric from #4381 with a
status label, so we can know at what step the testcase is stuck, thus
allowing us to alert if analyze is taking longer to finish than
expected.

The alert itself could be, for instance, P50 age of untriaged testcase
(status=analyze_pending) > 3h.

Also, this retroactively addresses comments from #4481:

* Fixes docstring for emit_testcase_triage_duration_metric
* Removes assertions
* Renames TESTCASE_UPLOAD_TRIAGE_DURATION to TESTCASE_TRIAGE_DURATION,
since it now accounts for fuzzer generated testcases
* Use a boolean "from_fuzzer" field, instead of "origin" string, in
TESTCASE_TRIAGE_DURATION
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants