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

Side by Side Diff: appengine/findit/waterfall/flake/flake_analysis_service.py

Issue 2411893002: [Findit] Adding metadata for manually vs automatically triggered flake analyses (Closed)
Patch Set: Created 4 years, 2 months 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 logging 5 import logging
6 6
7 from common import constants 7 from common import constants
8 from model.flake.flake_analysis_request import FlakeAnalysisRequest 8 from model.flake.flake_analysis_request import FlakeAnalysisRequest
9 from waterfall.flake import initialize_flake_pipeline 9 from waterfall.flake import initialize_flake_pipeline
10 from waterfall.flake import step_mapper 10 from waterfall.flake import step_mapper
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 return _MergeNewRequestIntoExistingOne(request, previous_request) 169 return _MergeNewRequestIntoExistingOne(request, previous_request)
170 170
171 171
172 def _IsAuthorizedUser(user_email): 172 def _IsAuthorizedUser(user_email):
173 """Returns True if the given user email account is authorized for access.""" 173 """Returns True if the given user email account is authorized for access."""
174 return user_email and ( 174 return user_email and (
175 user_email in constants.WHITELISTED_APP_ACCOUNTS or 175 user_email in constants.WHITELISTED_APP_ACCOUNTS or
176 user_email.endswith('@google.com')) 176 user_email.endswith('@google.com'))
177 177
178 178
179 def ScheduleAnalysisForFlake(request, user_email, is_admin): 179 def ScheduleAnalysisForFlake(request, user_email, is_admin, triggering_source):
180 """Schedules an analysis on the flake in the given request if needed. 180 """Schedules an analysis on the flake in the given request if needed.
181 181
182 Args: 182 Args:
183 request (FlakeAnalysisRequest): The request to analyze a flake. 183 request (FlakeAnalysisRequest): The request to analyze a flake.
184 user_email (str): The email of the requester. 184 user_email (str): The email of the requester.
185 is_admin (bool): Whether the requester is an admin. 185 is_admin (bool): Whether the requester is an admin.
186 triggering_source (int): Where the request is coming from, either Findit
187 itself or Findit API.
stgao 2016/10/13 06:14:38 It could be Findit UI, Findit API, and Findit pipe
lijeffrey 2016/10/14 23:45:21 Done.
186 188
187 Returns: 189 Returns:
188 True if an analysis was scheduled; False if a new analysis is not needed; 190 True if an analysis was scheduled; False if a new analysis is not needed;
189 None if the user has no permission to. 191 None if the user has no permission to.
190 """ 192 """
191 assert len(request.build_steps) > 0, 'At least 1 build step is needed!' 193 assert len(request.build_steps), 'At least 1 build step is needed!'
192 194
193 if not is_admin and not _IsAuthorizedUser(user_email): 195 if not is_admin and not _IsAuthorizedUser(user_email):
194 return None 196 return None
195 request.user_emails = [user_email] 197 request.user_emails = [user_email]
196 198
197 manually_triggered = user_email.endswith('@google.com')
198
199 for build_step in request.build_steps: 199 for build_step in request.build_steps:
200 step_mapper.FindMatchingWaterfallStep(build_step) 200 step_mapper.FindMatchingWaterfallStep(build_step)
201 201
202 version_number, build_step = _CheckForNewAnalysis(request) 202 version_number, build_step = _CheckForNewAnalysis(request)
203 if version_number and build_step: 203 if version_number and build_step:
204 # A new analysis is needed. 204 # A new analysis is needed.
205 logging.info('A new analysis is needed for: %s', build_step) 205 logging.info('A new analysis is needed for: %s', build_step)
206 analysis = initialize_flake_pipeline.ScheduleAnalysisIfNeeded( 206 analysis = initialize_flake_pipeline.ScheduleAnalysisIfNeeded(
207 build_step.wf_master_name, build_step.wf_builder_name, 207 build_step.wf_master_name, build_step.wf_builder_name,
208 build_step.wf_build_number, build_step.wf_step_name, 208 build_step.wf_build_number, build_step.wf_step_name,
209 request.name, allow_new_analysis=True, 209 request.name, allow_new_analysis=True,
210 manually_triggered=manually_triggered, 210 user_email=user_email, triggering_source=triggering_source,
211 queue_name=constants.WATERFALL_ANALYSIS_QUEUE) 211 queue_name=constants.WATERFALL_ANALYSIS_QUEUE)
212 if analysis: 212 if analysis:
213 # TODO: put this in a transaction. 213 # TODO: put this in a transaction.
214 request = FlakeAnalysisRequest.GetVersion( 214 request = FlakeAnalysisRequest.GetVersion(
215 key=request.name, version=version_number) 215 key=request.name, version=version_number)
216 request.analyses.append(analysis.key) 216 request.analyses.append(analysis.key)
217 request.put() 217 request.put()
218 logging.info('A new analysis was triggered successfully: %s', 218 logging.info('A new analysis was triggered successfully: %s',
219 analysis.key) 219 analysis.key)
220 return True 220 return True
221 else: 221 else:
222 logging.info('But no new analysis was not triggered!') 222 logging.error('But new analysis was not triggered!')
223 else: 223 else:
224 logging.info('No new analysis is needed: %s', request) 224 logging.info('No new analysis is needed: %s', request)
225 225
226 return False 226 return False
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698