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

Side by Side Diff: appengine/findit/waterfall/analyze_build_failure_pipeline.py

Issue 2158533002: [Findit] Use unittest.mock for testing and create a shared method to mock pipeline. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 4 years, 5 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 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 datetime 5 from datetime import datetime
6 6
7 from common import appengine_util 7 from common import appengine_util
8 from common.pipeline_wrapper import BasePipeline 8 from common.pipeline_wrapper import BasePipeline
9 from common.pipeline_wrapper import pipeline 9 from common.pipeline_wrapper import pipeline
10 from model import analysis_status 10 from model import analysis_status
(...skipping 19 matching lines...) Expand all
30 self.master_name = master_name 30 self.master_name = master_name
31 self.builder_name = builder_name 31 self.builder_name = builder_name
32 self.build_number = build_number 32 self.build_number = build_number
33 33
34 def _LogUnexpectedAborting(self, was_aborted): 34 def _LogUnexpectedAborting(self, was_aborted):
35 """Marks the WfAnalysis status as error, indicating that it was aborted. 35 """Marks the WfAnalysis status as error, indicating that it was aborted.
36 36
37 Args: 37 Args:
38 was_aborted (bool): True if the pipeline was aborted, otherwise False. 38 was_aborted (bool): True if the pipeline was aborted, otherwise False.
39 """ 39 """
40 if was_aborted: 40 if not was_aborted:
41 analysis = WfAnalysis.Get( 41 return
42 self.master_name, self.builder_name, self.build_number) 42
43 # Heuristic analysis could have already completed, while triggering the 43 analysis = WfAnalysis.Get(
44 # try job kept failing and lead to the abortion. 44 self.master_name, self.builder_name, self.build_number)
45 if analysis and not analysis.completed: 45 # Heuristic analysis could have already completed, while triggering the
46 analysis.status = analysis_status.ERROR 46 # try job kept failing and lead to the abortion.
47 analysis.result_status = None 47 if not analysis.completed:
48 analysis.put() 48 analysis.status = analysis_status.ERROR
49 analysis.result_status = None
50 analysis.put()
49 51
50 def finalized(self): 52 def finalized(self):
51 self._LogUnexpectedAborting(self.was_aborted) 53 self._LogUnexpectedAborting(self.was_aborted)
52 54
53 def _ResetAnalysis(self, master_name, builder_name, build_number): 55 def _ResetAnalysis(self, master_name, builder_name, build_number):
54 analysis = WfAnalysis.Get(master_name, builder_name, build_number) 56 analysis = WfAnalysis.Get(master_name, builder_name, build_number)
55 analysis.pipeline_status_path = self.pipeline_status_path() 57 analysis.pipeline_status_path = self.pipeline_status_path()
56 analysis.status = analysis_status.RUNNING 58 analysis.status = analysis_status.RUNNING
57 analysis.result_status = None 59 analysis.result_status = None
58 analysis.start_time = datetime.utcnow() 60 analysis.start_time = datetime.utcnow()
(...skipping 18 matching lines...) Expand all
77 failure_info, change_logs, deps_info, signals, build_completed) 79 failure_info, change_logs, deps_info, signals, build_completed)
78 80
79 with pipeline.InOrder(): 81 with pipeline.InOrder():
80 # Triggers swarming tasks when test failure happens. 82 # Triggers swarming tasks when test failure happens.
81 yield TriggerSwarmingTasksPipeline( 83 yield TriggerSwarmingTasksPipeline(
82 master_name, builder_name, build_number, failure_info) 84 master_name, builder_name, build_number, failure_info)
83 # Checks if need a try job and starts one if yes. 85 # Checks if need a try job and starts one if yes.
84 yield StartTryJobOnDemandPipeline( 86 yield StartTryJobOnDemandPipeline(
85 failure_info, signals, build_completed, force_rerun_try_job, 87 failure_info, signals, build_completed, force_rerun_try_job,
86 heuristic_result) 88 heuristic_result)
OLDNEW
« no previous file with comments | « appengine/findit/common/findit_testcase.py ('k') | appengine/findit/waterfall/build_failure_analysis_pipelines.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698