| OLD | NEW |
| 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 |
| 11 from waterfall.test_info import TestInfo |
| 11 | 12 |
| 12 | 13 |
| 13 def _CheckFlakeSwarmedAndSupported(request): | 14 def _CheckFlakeSwarmedAndSupported(request): |
| 14 """Checks if the flake is Swarmed and supported in any build step. | 15 """Checks if the flake is Swarmed and supported in any build step. |
| 15 | 16 |
| 16 Args: | 17 Args: |
| 17 request (FlakeAnalysisRequest): The request to analyze a flake. | 18 request (FlakeAnalysisRequest): The request to analyze a flake. |
| 18 | 19 |
| 19 Returns: | 20 Returns: |
| 20 (swarmed, supported, build_step) | 21 (swarmed, supported, build_step) |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 | 197 |
| 197 manually_triggered = user_email.endswith('@google.com') | 198 manually_triggered = user_email.endswith('@google.com') |
| 198 | 199 |
| 199 for build_step in request.build_steps: | 200 for build_step in request.build_steps: |
| 200 step_mapper.FindMatchingWaterfallStep(build_step) | 201 step_mapper.FindMatchingWaterfallStep(build_step) |
| 201 | 202 |
| 202 version_number, build_step = _CheckForNewAnalysis(request) | 203 version_number, build_step = _CheckForNewAnalysis(request) |
| 203 if version_number and build_step: | 204 if version_number and build_step: |
| 204 # A new analysis is needed. | 205 # A new analysis is needed. |
| 205 logging.info('A new analysis is needed for: %s', build_step) | 206 logging.info('A new analysis is needed for: %s', build_step) |
| 206 analysis = initialize_flake_pipeline.ScheduleAnalysisIfNeeded( | 207 normalized_test = TestInfo( |
| 207 build_step.wf_master_name, build_step.wf_builder_name, | 208 build_step.wf_master_name, build_step.wf_builder_name, |
| 208 build_step.wf_build_number, build_step.wf_step_name, | 209 build_step.wf_build_number, build_step.wf_step_name, |
| 209 request.name, allow_new_analysis=True, | 210 request.name) |
| 210 manually_triggered=manually_triggered, | 211 original_test = TestInfo( |
| 212 build_step.master_name, build_step.builder_name, |
| 213 build_step.build_number, build_step.step_name, |
| 214 request.name) |
| 215 analysis = initialize_flake_pipeline.ScheduleAnalysisIfNeeded( |
| 216 normalized_test, original_test, bug_id=request.bug_id, |
| 217 allow_new_analysis=True, manually_triggered=manually_triggered, |
| 211 queue_name=constants.WATERFALL_ANALYSIS_QUEUE) | 218 queue_name=constants.WATERFALL_ANALYSIS_QUEUE) |
| 212 if analysis: | 219 if analysis: |
| 213 # TODO: put this in a transaction. | 220 # TODO: put this in a transaction. |
| 214 request = FlakeAnalysisRequest.GetVersion( | 221 request = FlakeAnalysisRequest.GetVersion( |
| 215 key=request.name, version=version_number) | 222 key=request.name, version=version_number) |
| 216 request.analyses.append(analysis.key) | 223 request.analyses.append(analysis.key) |
| 217 request.put() | 224 request.put() |
| 218 logging.info('A new analysis was triggered successfully: %s', | 225 logging.info('A new analysis was triggered successfully: %s', |
| 219 analysis.key) | 226 analysis.key) |
| 220 return True | 227 return True |
| 221 else: | 228 else: |
| 222 logging.info('But no new analysis was not triggered!') | 229 logging.info('But no new analysis was not triggered!') |
| 223 else: | 230 else: |
| 224 logging.info('No new analysis is needed: %s', request) | 231 logging.info('No new analysis is needed: %s', request) |
| 225 | 232 |
| 226 return False | 233 return False |
| OLD | NEW |