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

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

Issue 2187763004: [Findit] Refactor Findit pipeline. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: rebase Created 4 years, 4 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 import json 6 import json
7 import time 7 import time
8 8
9 from google.appengine.ext import ndb 9 from google.appengine.ext import ndb
10 10
11 from common.pipeline_wrapper import BasePipeline 11 from common.pipeline_wrapper import BasePipeline
12 from common.pipeline_wrapper import pipeline 12 from common.pipeline_wrapper import pipeline
13 from common.waterfall import buildbucket_client 13 from common.waterfall import buildbucket_client
14 from common.waterfall import failure_type
14 from common.waterfall import try_job_error 15 from common.waterfall import try_job_error
15 from common.waterfall.buildbucket_client import BuildbucketBuild 16 from common.waterfall.buildbucket_client import BuildbucketBuild
16 from model import analysis_status 17 from model import analysis_status
17 from model.wf_try_job import WfTryJob 18 from model.wf_try_job import WfTryJob
18 from model.wf_try_job_data import WfTryJobData 19 from model.wf_try_job_data import WfTryJobData
19 from waterfall import waterfall_config 20 from waterfall import waterfall_config
20 from waterfall.try_job_type import TryJobType
21 21
22 22
23 def _MicrosecondsToDatetime(microseconds): 23 def _MicrosecondsToDatetime(microseconds):
24 """Returns a datetime given the number of microseconds, or None.""" 24 """Returns a datetime given the number of microseconds, or None."""
25 if microseconds: 25 if microseconds:
26 return datetime.utcfromtimestamp(float(microseconds) / 1000000) 26 return datetime.utcfromtimestamp(float(microseconds) / 1000000)
27 return None 27 return None
28 28
29 29
30 def _GetError(buildbucket_response, buildbucket_error, timed_out): 30 def _GetError(buildbucket_response, buildbucket_error, timed_out):
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 self, status, master_name, builder_name, build_number, try_job_type, 158 self, status, master_name, builder_name, build_number, try_job_type,
159 try_job_id, try_job_url, result_content=None): 159 try_job_id, try_job_url, result_content=None):
160 """Updates try job result based on response try job status and result.""" 160 """Updates try job result based on response try job status and result."""
161 result = { 161 result = {
162 'report': result_content, 162 'report': result_content,
163 'url': try_job_url, 163 'url': try_job_url,
164 'try_job_id': try_job_id, 164 'try_job_id': try_job_id,
165 } 165 }
166 166
167 try_job_result = WfTryJob.Get(master_name, builder_name, build_number) 167 try_job_result = WfTryJob.Get(master_name, builder_name, build_number)
168 if try_job_type == TryJobType.COMPILE: 168 if try_job_type == failure_type.COMPILE:
169 result_to_update = try_job_result.compile_results 169 result_to_update = try_job_result.compile_results
170 else: 170 else:
171 result_to_update = try_job_result.test_results 171 result_to_update = try_job_result.test_results
172 if (result_to_update and 172 if (result_to_update and
173 result_to_update[-1]['try_job_id'] == try_job_id): 173 result_to_update[-1]['try_job_id'] == try_job_id):
174 result_to_update[-1].update(result) 174 result_to_update[-1].update(result)
175 else: # pragma: no cover 175 else: # pragma: no cover
176 # Normally result for current try job should've been saved in 176 # Normally result for current try job should've been saved in
177 # schedule_try_job_pipeline, so this branch shouldn't be reached. 177 # schedule_try_job_pipeline, so this branch shouldn't be reached.
178 result_to_update.append(result) 178 result_to_update.append(result)
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 already_set_started = True 246 already_set_started = True
247 247
248 if time.time() > deadline: # pragma: no cover 248 if time.time() > deadline: # pragma: no cover
249 _UpdateTryJobMetadata(try_job_data, start_time, build, error, True) 249 _UpdateTryJobMetadata(try_job_data, start_time, build, error, True)
250 # Explicitly abort the whole pipeline. 250 # Explicitly abort the whole pipeline.
251 raise pipeline.Abort( 251 raise pipeline.Abort(
252 'Try job %s timed out after %d hours.' % ( 252 'Try job %s timed out after %d hours.' % (
253 try_job_id, timeout_hours)) 253 try_job_id, timeout_hours))
254 254
255 time.sleep(pipeline_wait_seconds) # pragma: no cover 255 time.sleep(pipeline_wait_seconds) # pragma: no cover
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698