Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: appengine/findit/handlers/crash/crash_handler.py

Issue 2432203003: [Predator] Run predator. (Closed)
Patch Set: Rebase. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import base64 5 import base64
6 import json 6 import json
7 import logging 7 import logging
8 8
9 from common import constants 9 from common import constants
10 from common import appengine_util 10 from common import appengine_util
11 from common.base_handler import BaseHandler 11 from common.base_handler import BaseHandler
12 from common.base_handler import Permission 12 from common.base_handler import Permission
13 from common.http_client_appengine import HttpClientAppengine
13 from crash import crash_pipeline 14 from crash import crash_pipeline
14 from crash.crash_pipeline import CrashWrapperPipeline
15 from crash.crash_report import CrashReport 15 from crash.crash_report import CrashReport
16 from lib.gitiles.gitiles_repository import GitilesRepository
16 17
17 18
18 class CrashHandler(BaseHandler): 19 class CrashHandler(BaseHandler):
19 PERMISSION_LEVEL = Permission.ANYONE 20 PERMISSION_LEVEL = Permission.ANYONE
20 21
21 def HandlePost(self): 22 def HandlePost(self):
22 """Handles push delivery from Pub/Sub for crash data. 23 """Handles push delivery from Pub/Sub for crash data.
23 24
24 The crash data should be in the following json format: 25 The crash data should be in the following json format:
25 { 26 {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 there's nothig we can do), then we will skip creating the pipeline 122 there's nothig we can do), then we will skip creating the pipeline
122 at all. 123 at all.
123 124
124 Args: 125 Args:
125 crash_data (JSON): ?? 126 crash_data (JSON): ??
126 127
127 Returns: 128 Returns:
128 True if we started a new pipeline; False otherwise. 129 True if we started a new pipeline; False otherwise.
129 """ 130 """
130 client_id = crash_data['client_id'] 131 client_id = crash_data['client_id']
132 repository = GitilesRepository(http_client=HttpClientAppengine())
131 # N.B., must call FinditForClientID indirectly, for mock testing. 133 # N.B., must call FinditForClientID indirectly, for mock testing.
132 findit_client = crash_pipeline.FinditForClientID(client_id) 134 findit_client = crash_pipeline.FinditForClientID(client_id, repository)
133 135
134 # Check policy and modify the crash_data as needed. 136 # Check policy and modify the crash_data as needed.
135 crash_data = findit_client.CheckPolicy(crash_data) 137 crash_data = findit_client.CheckPolicy(crash_data)
136 if crash_data is None: 138 if crash_data is None:
137 return False 139 return False
138 140
139 # Detect the regression range, and decide if we actually need to 141 # Detect the regression range, and decide if we actually need to
140 # run a new anlaysis or not. 142 # run a new anlaysis or not.
141 if not findit_client._NeedsNewAnalysis(crash_data): 143 if not findit_client._NeedsNewAnalysis(crash_data):
142 return False 144 return False
143 145
144 crash_identifiers = crash_data['crash_identifiers'] 146 crash_identifiers = crash_data['crash_identifiers']
145 # N.B., we cannot pass ``self`` directly to the _pipeline_cls, because 147 # N.B., we cannot pass ``self`` directly to the _pipeline_cls, because
146 # it is not JSON-serializable (and there's no way to make it such, 148 # it is not JSON-serializable (and there's no way to make it such,
147 # since JSON-serializability is defined by JSON-encoders rather than 149 # since JSON-serializability is defined by JSON-encoders rather than
148 # as methods on the objects being encoded). 150 # as methods on the objects being encoded).
149 pipeline = CrashWrapperPipeline(client_id, crash_identifiers) 151 pipeline = crash_pipeline.CrashWrapperPipeline(client_id, crash_identifiers)
150 # Attribute defined outside __init__ - pylint: disable=W0201 152 # Attribute defined outside __init__ - pylint: disable=W0201
151 pipeline.target = appengine_util.GetTargetNameForModule( 153 pipeline.target = appengine_util.GetTargetNameForModule(
152 constants.CRASH_BACKEND[client_id]) 154 constants.CRASH_BACKEND[client_id])
153 queue_name = constants.CRASH_ANALYSIS_QUEUE[client_id] 155 queue_name = constants.CRASH_ANALYSIS_QUEUE[client_id]
154 pipeline.start(queue_name=queue_name) 156 pipeline.start(queue_name=queue_name)
155 logging.info('New %s analysis is scheduled for %s', client_id, 157 logging.info('New %s analysis is scheduled for %s', client_id,
156 repr(crash_identifiers)) 158 repr(crash_identifiers))
157 return True 159 return True
OLDNEW
« no previous file with comments | « appengine/findit/crash/test/crash_testcase.py ('k') | appengine/findit/handlers/crash/test/crash_handler_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698