| 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 from datetime import timedelta |
| 5 import logging | 6 import logging |
| 6 from datetime import timedelta | |
| 7 import random | 7 import random |
| 8 | 8 |
| 9 from common import appengine_util | 9 from common import appengine_util |
| 10 from common import constants | 10 from common import constants |
| 11 from common import time_util | 11 from common import time_util |
| 12 from common.pipeline_wrapper import BasePipeline | 12 from common.pipeline_wrapper import BasePipeline |
| 13 | 13 |
| 14 from model import analysis_status | 14 from model import analysis_status |
| 15 from model import result_status |
| 15 from model.flake.flake_swarming_task import FlakeSwarmingTask | 16 from model.flake.flake_swarming_task import FlakeSwarmingTask |
| 16 from model.flake.master_flake_analysis import MasterFlakeAnalysis | 17 from model.flake.master_flake_analysis import MasterFlakeAnalysis |
| 17 from waterfall import waterfall_config | 18 from waterfall import waterfall_config |
| 18 from waterfall.process_flake_swarming_task_result_pipeline import ( | 19 from waterfall.process_flake_swarming_task_result_pipeline import ( |
| 19 ProcessFlakeSwarmingTaskResultPipeline) | 20 ProcessFlakeSwarmingTaskResultPipeline) |
| 20 from waterfall.trigger_flake_swarming_task_pipeline import ( | 21 from waterfall.trigger_flake_swarming_task_pipeline import ( |
| 21 TriggerFlakeSwarmingTaskPipeline) | 22 TriggerFlakeSwarmingTaskPipeline) |
| 22 | 23 |
| 23 | 24 |
| 24 def _UpdateAnalysisStatusUponCompletion(master_flake_analysis, status, error): | 25 def _UpdateAnalysisStatusUponCompletion(master_flake_analysis, status, error): |
| 25 master_flake_analysis.end_time = time_util.GetUTCNow() | 26 master_flake_analysis.end_time = time_util.GetUTCNow() |
| 26 master_flake_analysis.status = status | 27 master_flake_analysis.status = status |
| 27 | 28 |
| 28 if error: | 29 if error: |
| 29 master_flake_analysis.error = error | 30 master_flake_analysis.error = error |
| 30 | 31 |
| 32 if master_flake_analysis.suspected_flake_build_number is not None: |
| 33 master_flake_analysis.result_status = result_status.FOUND_UNTRIAGED |
| 34 else: |
| 35 master_flake_analysis.result_status = result_status.NOT_FOUND_UNTRIAGED |
| 36 |
| 31 master_flake_analysis.put() | 37 master_flake_analysis.put() |
| 32 | 38 |
| 33 | 39 |
| 34 def _GetETAToStartAnalysis(manually_triggered): | 40 def _GetETAToStartAnalysis(manually_triggered): |
| 35 """Returns an ETA as of a UTC datetime.datetime to start the analysis. | 41 """Returns an ETA as of a UTC datetime.datetime to start the analysis. |
| 36 | 42 |
| 37 If not urgent, Swarming tasks should be run off PST peak hours from 11am to | 43 If not urgent, Swarming tasks should be run off PST peak hours from 11am to |
| 38 6pm on workdays. | 44 6pm on workdays. |
| 39 | 45 |
| 40 Args: | 46 Args: |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 # Unused argument - pylint: disable=W0613 | 234 # Unused argument - pylint: disable=W0613 |
| 229 def run(self, master_name, builder_name, master_build_number, | 235 def run(self, master_name, builder_name, master_build_number, |
| 230 run_build_number, step_name, test_name, version_number, | 236 run_build_number, step_name, test_name, version_number, |
| 231 test_result_future, flakiness_algorithm_results_dict, | 237 test_result_future, flakiness_algorithm_results_dict, |
| 232 manually_triggered=False): | 238 manually_triggered=False): |
| 233 | 239 |
| 234 # Get MasterFlakeAnalysis success list corresponding to parameters. | 240 # Get MasterFlakeAnalysis success list corresponding to parameters. |
| 235 master_flake_analysis = MasterFlakeAnalysis.GetVersion( | 241 master_flake_analysis = MasterFlakeAnalysis.GetVersion( |
| 236 master_name, builder_name, master_build_number, step_name, test_name, | 242 master_name, builder_name, master_build_number, step_name, test_name, |
| 237 version=version_number) | 243 version=version_number) |
| 238 # Don't call another pipeline if we fail. | 244 |
| 239 flake_swarming_task = FlakeSwarmingTask.Get( | 245 flake_swarming_task = FlakeSwarmingTask.Get( |
| 240 master_name, builder_name, run_build_number, step_name, test_name) | 246 master_name, builder_name, run_build_number, step_name, test_name) |
| 241 | 247 |
| 248 # Don't call another pipeline if we fail. |
| 242 if flake_swarming_task.status == analysis_status.ERROR: | 249 if flake_swarming_task.status == analysis_status.ERROR: |
| 243 # TODO(lijeffrey): Implement more detailed error detection and reporting, | 250 # TODO(lijeffrey): Implement more detailed error detection and reporting, |
| 244 # such as timeouts, dead bots, etc. | 251 # such as timeouts, dead bots, etc. |
| 245 error = { | 252 error = { |
| 246 'error': 'Swarming task failed', | 253 'error': 'Swarming task failed', |
| 247 'message': 'Swarming task failed' | 254 'message': 'Swarming task failed' |
| 248 } | 255 } |
| 249 _UpdateAnalysisStatusUponCompletion( | 256 _UpdateAnalysisStatusUponCompletion( |
| 250 master_flake_analysis, analysis_status.ERROR, error) | 257 master_flake_analysis, analysis_status.ERROR, error) |
| 251 return | 258 return |
| (...skipping 19 matching lines...) Expand all Loading... |
| 271 flakiness_algorithm_results_dict=flakiness_algorithm_results_dict, | 278 flakiness_algorithm_results_dict=flakiness_algorithm_results_dict, |
| 272 manually_triggered=manually_triggered) | 279 manually_triggered=manually_triggered) |
| 273 # pylint: disable=W0201 | 280 # pylint: disable=W0201 |
| 274 pipeline_job.target = appengine_util.GetTargetNameForModule( | 281 pipeline_job.target = appengine_util.GetTargetNameForModule( |
| 275 constants.WATERFALL_BACKEND) | 282 constants.WATERFALL_BACKEND) |
| 276 pipeline_job.StartOffPSTPeakHours( | 283 pipeline_job.StartOffPSTPeakHours( |
| 277 queue_name=self.queue_name or constants.DEFAULT_QUEUE) | 284 queue_name=self.queue_name or constants.DEFAULT_QUEUE) |
| 278 else: | 285 else: |
| 279 _UpdateAnalysisStatusUponCompletion( | 286 _UpdateAnalysisStatusUponCompletion( |
| 280 master_flake_analysis, analysis_status.COMPLETED, None) | 287 master_flake_analysis, analysis_status.COMPLETED, None) |
| OLD | NEW |