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

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

Issue 2491473002: [Findit] Implementing swarming task error detection (Closed)
Patch Set: Created 4 years, 1 month 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 import logging 6 import logging
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.http_client_appengine import HttpClientAppengine as HttpClient 11 from common.http_client_appengine import HttpClientAppengine as HttpClient
12 from common.pipeline_wrapper import BasePipeline 12 from common.pipeline_wrapper import BasePipeline
13 from lib import time_util 13 from lib import time_util
14 from model import analysis_status 14 from model import analysis_status
15 from model.wf_swarming_task import WfSwarmingTask 15 from model.wf_swarming_task import WfSwarmingTask
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 # TODO(lijeffrey): Refactor and merge this file with
20 # trigger_base_swarming_task_pipeline.
21
19 22
20 def _GetSwarmingTaskName(ref_task_id): # pragma: no cover. 23 def _GetSwarmingTaskName(ref_task_id): # pragma: no cover.
21 """Returns a unique task name. 24 """Returns a unique task name.
22 25
23 Have this separate function in order to mock for testing purpose. 26 Have this separate function in order to mock for testing purpose.
24 """ 27 """
25 return 'findit/deflake/ref_task_id/%s/%s' % ( 28 return 'findit/deflake/ref_task_id/%s/%s' % (
26 ref_task_id, time_util.GetUTCNow().strftime('%Y-%m-%d %H:%M:%S %f')) 29 ref_task_id, time_util.GetUTCNow().strftime('%Y-%m-%d %H:%M:%S %f'))
27 30
28 31
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 ref_task_id, http_client) 147 ref_task_id, http_client)
145 148
146 # 2. Update/Overwrite parameters for the re-run. 149 # 2. Update/Overwrite parameters for the re-run.
147 iterations_to_rerun = waterfall_config.GetSwarmingSettings().get( 150 iterations_to_rerun = waterfall_config.GetSwarmingSettings().get(
148 'iterations_to_rerun') 151 'iterations_to_rerun')
149 new_request = _CreateNewSwarmingTaskRequest( 152 new_request = _CreateNewSwarmingTaskRequest(
150 ref_task_id, ref_request, master_name, builder_name, build_number, 153 ref_task_id, ref_request, master_name, builder_name, build_number,
151 step_name, tests, iterations_to_rerun) 154 step_name, tests, iterations_to_rerun)
152 155
153 # 3. Trigger a new Swarming task to re-run the failed tests. 156 # 3. Trigger a new Swarming task to re-run the failed tests.
154 task_id = swarming_util.TriggerSwarmingTask(new_request, http_client) 157 task_id, error = swarming_util.TriggerSwarmingTask(new_request, http_client)
155 158
156 # Save the task id. 159 # Save the task id.
157 swarming_task = WfSwarmingTask.Get( 160 swarming_task = WfSwarmingTask.Get(
158 master_name, builder_name, build_number, step_name) 161 master_name, builder_name, build_number, step_name)
159 swarming_task.task_id = task_id 162 swarming_task.task_id = task_id
163 if error:
164 swarming_task.error = error
chanli 2016/11/11 00:05:13 Comments of trigger_base_swarming_task_pipeline.py
lijeffrey 2016/11/11 20:55:41 Done. This file will be refactored in an upcoming
160 swarming_task.parameters['tests'] = tests 165 swarming_task.parameters['tests'] = tests
161 swarming_task.parameters['iterations_to_rerun'] = iterations_to_rerun 166 swarming_task.parameters['iterations_to_rerun'] = iterations_to_rerun
162 swarming_task.parameters['ref_name'] = swarming_util.GetTagValue( 167 swarming_task.parameters['ref_name'] = swarming_util.GetTagValue(
163 new_request.tags, 'ref_name') 168 new_request.tags, 'ref_name')
164 swarming_task.put() 169 swarming_task.put()
165 170
166 logging.info('A Swarming task was triggered:%s', task_id) 171 logging.info('A Swarming task was triggered:%s', task_id)
167 return task_id 172 return task_id
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698