| 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 from datetime import timedelta |
| 6 import logging | 6 import logging |
| 7 import random | 7 import random |
| 8 import textwrap |
| 8 | 9 |
| 9 from common import appengine_util | 10 from common import appengine_util |
| 10 from common import constants | 11 from common import constants |
| 11 from common import time_util | 12 from common import time_util |
| 12 from common.pipeline_wrapper import BasePipeline | 13 from common.pipeline_wrapper import BasePipeline |
| 13 | 14 |
| 14 from model import analysis_status | 15 from model import analysis_status |
| 15 from model import result_status | 16 from model import result_status |
| 16 from model.flake.flake_swarming_task import FlakeSwarmingTask | 17 from model.flake.flake_swarming_task import FlakeSwarmingTask |
| 17 from model.flake.master_flake_analysis import MasterFlakeAnalysis | 18 from model.flake.master_flake_analysis import MasterFlakeAnalysis |
| 18 from waterfall import waterfall_config | 19 from waterfall import waterfall_config |
| 20 from waterfall.post_comment_to_bug_pipeline import PostCommentToBugPipeline |
| 19 from waterfall.process_flake_swarming_task_result_pipeline import ( | 21 from waterfall.process_flake_swarming_task_result_pipeline import ( |
| 20 ProcessFlakeSwarmingTaskResultPipeline) | 22 ProcessFlakeSwarmingTaskResultPipeline) |
| 21 from waterfall.trigger_flake_swarming_task_pipeline import ( | 23 from waterfall.trigger_flake_swarming_task_pipeline import ( |
| 22 TriggerFlakeSwarmingTaskPipeline) | 24 TriggerFlakeSwarmingTaskPipeline) |
| 23 | 25 |
| 24 | 26 |
| 27 def _UpdateBugWithResult(analysis, queue_name): |
| 28 """Updates attached bug for the flakiness trend.""" |
| 29 if (not analysis.bug_id or |
| 30 not analysis.algorithm_parameters.get('update_monorail_bug')): |
| 31 return False |
| 32 |
| 33 comment = textwrap.dedent(""" |
| 34 Findit has generated the flakiness trend for this flake in the config |
| 35 "%s / %s / %s" by rerunning the test on Swarming with build artifacts from |
| 36 Waterfall. Please visit |
| 37 https://findit-for-me.appspot.com/waterfall/check-flake?key=%s\n |
| 38 Automatically posted by the findit-for-me app (https://goo.gl/YTKnaU). |
| 39 Feedback are welcome using component Tools>Test>FindIt>Flakiness !""") % ( |
| 40 analysis.original_master_name, analysis.original_builder_name, |
| 41 analysis.original_step_name, analysis.key.urlsafe()) |
| 42 labels = ['AnalyzedByFindit'] |
| 43 pipeline = PostCommentToBugPipeline( |
| 44 analysis.bug_id, comment, labels) |
| 45 pipeline.target = appengine_util.GetTargetNameForModule( |
| 46 constants.WATERFALL_BACKEND) |
| 47 pipeline.start(queue_name=queue_name) |
| 48 return True |
| 49 |
| 50 |
| 25 def _UpdateAnalysisStatusUponCompletion(master_flake_analysis, status, error): | 51 def _UpdateAnalysisStatusUponCompletion(master_flake_analysis, status, error): |
| 26 master_flake_analysis.end_time = time_util.GetUTCNow() | 52 master_flake_analysis.end_time = time_util.GetUTCNow() |
| 27 master_flake_analysis.status = status | 53 master_flake_analysis.status = status |
| 28 | 54 |
| 29 if error: | 55 if error: |
| 30 master_flake_analysis.error = error | 56 master_flake_analysis.error = error |
| 31 | 57 |
| 32 if master_flake_analysis.suspected_flake_build_number is not None: | 58 if master_flake_analysis.suspected_flake_build_number is not None: |
| 33 master_flake_analysis.result_status = result_status.FOUND_UNTRIAGED | 59 master_flake_analysis.result_status = result_status.FOUND_UNTRIAGED |
| 34 else: | 60 else: |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 flakiness_algorithm_results_dict=flakiness_algorithm_results_dict, | 304 flakiness_algorithm_results_dict=flakiness_algorithm_results_dict, |
| 279 manually_triggered=manually_triggered) | 305 manually_triggered=manually_triggered) |
| 280 # pylint: disable=W0201 | 306 # pylint: disable=W0201 |
| 281 pipeline_job.target = appengine_util.GetTargetNameForModule( | 307 pipeline_job.target = appengine_util.GetTargetNameForModule( |
| 282 constants.WATERFALL_BACKEND) | 308 constants.WATERFALL_BACKEND) |
| 283 pipeline_job.StartOffPSTPeakHours( | 309 pipeline_job.StartOffPSTPeakHours( |
| 284 queue_name=self.queue_name or constants.DEFAULT_QUEUE) | 310 queue_name=self.queue_name or constants.DEFAULT_QUEUE) |
| 285 else: | 311 else: |
| 286 _UpdateAnalysisStatusUponCompletion( | 312 _UpdateAnalysisStatusUponCompletion( |
| 287 master_flake_analysis, analysis_status.COMPLETED, None) | 313 master_flake_analysis, analysis_status.COMPLETED, None) |
| 314 _UpdateBugWithResult( |
| 315 master_flake_analysis, self.queue_name or constants.DEFAULT_QUEUE) |
| OLD | NEW |