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

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

Issue 1866883002: [Findit] A huge refactoring and some bug fixing. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Fix nit. Created 4 years, 8 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 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 copy 5 import copy
6 from datetime import datetime 6 from datetime import datetime
7 import logging 7 import logging
8 import time 8 import time
9 9
10 from google.appengine.ext import ndb 10 from google.appengine.ext import ndb
11 11
12 from common.http_client_appengine import HttpClientAppengine as HttpClient 12 from common.http_client_appengine import HttpClientAppengine as HttpClient
13 from model import wf_analysis_status 13 from model import analysis_status
14 from model.wf_swarming_task import WfSwarmingTask 14 from model.wf_swarming_task import WfSwarmingTask
15 from pipeline_wrapper import BasePipeline 15 from pipeline_wrapper import BasePipeline
16 from waterfall import swarming_util 16 from waterfall import swarming_util
17 from waterfall import waterfall_config 17 from waterfall import waterfall_config
18 18
19 19
20 def _GetSwarmingTaskName(ref_task_id): # pragma: no cover. 20 def _GetSwarmingTaskName(ref_task_id): # pragma: no cover.
21 """Returns a unique task name. 21 """Returns a unique task name.
22 22
23 Have this separate function in order to mock for testing purpose. 23 Have this separate function in order to mock for testing purpose.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 69
70 @ndb.transactional 70 @ndb.transactional
71 def _NeedANewSwarmingTask(master_name, builder_name, build_number, step_name): 71 def _NeedANewSwarmingTask(master_name, builder_name, build_number, step_name):
72 swarming_task = WfSwarmingTask.Get( 72 swarming_task = WfSwarmingTask.Get(
73 master_name, builder_name, build_number, step_name) 73 master_name, builder_name, build_number, step_name)
74 74
75 if not swarming_task: 75 if not swarming_task:
76 swarming_task = WfSwarmingTask.Create( 76 swarming_task = WfSwarmingTask.Create(
77 master_name, builder_name, build_number, step_name) 77 master_name, builder_name, build_number, step_name)
78 swarming_task.status = wf_analysis_status.PENDING 78 swarming_task.status = analysis_status.PENDING
79 swarming_task.put() 79 swarming_task.put()
80 return True 80 return True
81 else: 81 else:
82 # TODO(http://crbug.com/585676): Rerun the Swarming task if it runs into 82 # TODO(http://crbug.com/585676): Rerun the Swarming task if it runs into
83 # unexpected infra errors. 83 # unexpected infra errors.
84 return False 84 return False
85 85
86 86
87 def _GetSwarmingTaskId(master_name, builder_name, build_number, step_name): 87 def _GetSwarmingTaskId(master_name, builder_name, build_number, step_name):
88 deadline = time.time() + 5 * 60 # Wait for 5 minutes. 88 deadline = time.time() + 5 * 60 # Wait for 5 minutes.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 master_name, builder_name, build_number, step_name) 157 master_name, builder_name, build_number, step_name)
158 swarming_task.task_id = task_id 158 swarming_task.task_id = task_id
159 swarming_task.parameters['tests'] = tests 159 swarming_task.parameters['tests'] = tests
160 swarming_task.parameters['iterations_to_rerun'] = iterations_to_rerun 160 swarming_task.parameters['iterations_to_rerun'] = iterations_to_rerun
161 swarming_task.parameters['ref_name'] = swarming_util.GetTagValue( 161 swarming_task.parameters['ref_name'] = swarming_util.GetTagValue(
162 new_request.tags, 'ref_name') 162 new_request.tags, 'ref_name')
163 swarming_task.put() 163 swarming_task.put()
164 164
165 logging.info('A Swarming task was triggered:%s', task_id) 165 logging.info('A Swarming task was triggered:%s', task_id)
166 return task_id 166 return task_id
OLDNEW
« no previous file with comments | « appengine/findit/waterfall/test/wf_testcase.py ('k') | appengine/findit/waterfall/try_job_pipeline.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698