| 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 manually_triggered = user_email.endswith('@google.com') | 200 manually_triggered = user_email.endswith('@google.com') |
| 200 | 201 |
| 201 for build_step in request.build_steps: | 202 for build_step in request.build_steps: |
| 202 step_mapper.FindMatchingWaterfallStep(build_step) | 203 step_mapper.FindMatchingWaterfallStep(build_step) |
| 203 | 204 |
| 204 version_number, build_step = _CheckForNewAnalysis(request) | 205 version_number, build_step = _CheckForNewAnalysis(request) |
| 205 if version_number and build_step: | 206 if version_number and build_step: |
| 206 # A new analysis is needed. | 207 # A new analysis is needed. |
| 207 # TODO(lijeffrey): Add support for the force flag to trigger a rerun. | 208 # TODO(lijeffrey): Add support for the force flag to trigger a rerun. |
| 208 logging.info('A new analysis is needed for: %s', build_step) | 209 logging.info('A new analysis is needed for: %s', build_step) |
| 209 analysis = initialize_flake_pipeline.ScheduleAnalysisIfNeeded( | 210 normalized_test = TestInfo( |
| 210 build_step.wf_master_name, build_step.wf_builder_name, | 211 build_step.wf_master_name, build_step.wf_builder_name, |
| 211 build_step.wf_build_number, build_step.wf_step_name, | 212 build_step.wf_build_number, build_step.wf_step_name, |
| 212 request.name, allow_new_analysis=True, | 213 request.name) |
| 213 manually_triggered=manually_triggered, user_email=user_email, | 214 original_test = TestInfo( |
| 214 triggering_source=triggering_source, | 215 build_step.master_name, build_step.builder_name, |
| 216 build_step.build_number, build_step.step_name, |
| 217 request.name) |
| 218 analysis = initialize_flake_pipeline.ScheduleAnalysisIfNeeded( |
| 219 normalized_test, original_test, bug_id=request.bug_id, |
| 220 allow_new_analysis=True, manually_triggered=manually_triggered, |
| 221 user_email=user_email, triggering_source=triggering_source, |
| 215 queue_name=constants.WATERFALL_ANALYSIS_QUEUE) | 222 queue_name=constants.WATERFALL_ANALYSIS_QUEUE) |
| 216 if analysis: | 223 if analysis: |
| 217 # TODO: put this in a transaction. | 224 # TODO: put this in a transaction. |
| 218 request = FlakeAnalysisRequest.GetVersion( | 225 request = FlakeAnalysisRequest.GetVersion( |
| 219 key=request.name, version=version_number) | 226 key=request.name, version=version_number) |
| 220 request.analyses.append(analysis.key) | 227 request.analyses.append(analysis.key) |
| 221 request.put() | 228 request.put() |
| 222 logging.info('A new analysis was triggered successfully: %s', | 229 logging.info('A new analysis was triggered successfully: %s', |
| 223 analysis.key) | 230 analysis.key) |
| 224 return True | 231 return True |
| 225 else: | 232 else: |
| 226 logging.error('But new analysis was not triggered!') | 233 logging.error('But new analysis was not triggered!') |
| 227 else: | 234 else: |
| 228 logging.info('No new analysis is needed: %s', request) | 235 logging.info('No new analysis is needed: %s', request) |
| 229 | 236 |
| 230 return False | 237 return False |
| OLD | NEW |