|
35 | 35 | from clusterfuzz._internal.google_cloud_utils import blobs |
36 | 36 | from clusterfuzz._internal.google_cloud_utils import storage |
37 | 37 | from clusterfuzz._internal.issue_management import issue_tracker_utils |
| 38 | +from clusterfuzz._internal.metrics import events |
| 39 | +from clusterfuzz._internal.metrics import monitor |
| 40 | +from clusterfuzz._internal.metrics import monitoring_metrics |
38 | 41 | from clusterfuzz._internal.system import archive |
39 | 42 | from clusterfuzz._internal.system import environment |
40 | 43 | from handlers import base_handler |
@@ -303,6 +306,8 @@ def get_upload(self): |
303 | 306 |
|
304 | 307 | def do_post(self): |
305 | 308 | """Upload a testcase.""" |
| 309 | + # Set artifical task id env to be used by tracing. |
| 310 | + environment.set_task_id_vars(task_name='upload_testcase') |
306 | 311 | email = helpers.get_user_email() |
307 | 312 | testcase_id = request.get('testcaseId') |
308 | 313 | uploaded_file = self.get_upload() |
@@ -393,8 +398,8 @@ def do_post(self): |
393 | 398 | 'trustedAgreement') == TRUSTED_AGREEMENT_TEXT.strip() |
394 | 399 |
|
395 | 400 | # Chrome is the only ClusterFuzz deployment where there are trusted bots |
396 | | - # running utasks. |
397 | | - # This check also fails on oss-fuzz because of the way it abuses platform. |
| 401 | + # running utasks. This check also fails on oss-fuzz because of the way it |
| 402 | + # abuses platform. |
398 | 403 | if (not trusted_agreement_signed and utils.is_chromium() and |
399 | 404 | task_utils.is_remotely_executing_utasks() and |
400 | 405 | ((platform_id and platform_id != 'Linux') or |
@@ -606,8 +611,14 @@ def do_post(self): |
606 | 611 | additional_metadata=testcase_metadata, |
607 | 612 | crash_data=crash_data) |
608 | 613 |
|
| 614 | + testcase = data_handler.get_testcase_by_id(testcase_id) |
| 615 | + events.emit( |
| 616 | + events.TestcaseCreationEvent( |
| 617 | + testcase=testcase, |
| 618 | + creation_origin=events.TestcaseOrigin.MANUAL_UPLOAD, |
| 619 | + uploader=email)) |
| 620 | + |
609 | 621 | if not quiet_flag: |
610 | | - testcase = data_handler.get_testcase_by_id(testcase_id) |
611 | 622 | issue = issue_tracker_utils.get_issue_for_testcase(testcase) |
612 | 623 | if issue: |
613 | 624 | report_url = data_handler.TESTCASE_REPORT_URL.format( |
@@ -668,3 +679,14 @@ def get_upload(self): |
668 | 679 | @handler.oauth |
669 | 680 | def post(self, *args): |
670 | 681 | return self.do_post() |
| 682 | + |
| 683 | + |
| 684 | +class CrashReplicationUploadHandler(base_handler.Handler): |
| 685 | + """Handler that picks up the pubsub notification.""" |
| 686 | + |
| 687 | + @handler.pubsub_push |
| 688 | + def post(self, message): |
| 689 | + helpers.log(message.data.decode(), helpers.VIEW_OPERATION) |
| 690 | + with monitor.wrap_with_monitoring(): |
| 691 | + monitoring_metrics.UPLOAD_TESTCASE_COUNT.increment() |
| 692 | + return 'ok' |
0 commit comments