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

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

Issue 2536723005: [Findit] Fix bugs when pulling gtest result. (Closed)
Patch Set: . Created 4 years 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
« no previous file with comments | « no previous file | appengine/findit/waterfall/process_swarming_task_result_pipeline.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 from collections import defaultdict 5 from collections import defaultdict
6 import datetime 6 import datetime
7 import logging 7 import logging
8 import time 8 import time
9 9
10 from common.http_client_appengine import HttpClientAppengine as HttpClient 10 from common.http_client_appengine import HttpClientAppengine as HttpClient
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 def _MonitorSwarmingTask(self, task_id, *call_args): 72 def _MonitorSwarmingTask(self, task_id, *call_args):
73 """Monitors the swarming task and waits for it to complete.""" 73 """Monitors the swarming task and waits for it to complete."""
74 assert task_id 74 assert task_id
75 timeout_hours = waterfall_config.GetSwarmingSettings().get( 75 timeout_hours = waterfall_config.GetSwarmingSettings().get(
76 'task_timeout_hours') 76 'task_timeout_hours')
77 deadline = time.time() + timeout_hours * 60 * 60 77 deadline = time.time() + timeout_hours * 60 * 60
78 server_query_interval_seconds = waterfall_config.GetSwarmingSettings().get( 78 server_query_interval_seconds = waterfall_config.GetSwarmingSettings().get(
79 'server_query_interval_seconds') 79 'server_query_interval_seconds')
80 task_started = False 80 task_started = False
81 task_completed = False 81 task_completed = False
82 tests_statuses = {}
83 step_name_no_platform = None 82 step_name_no_platform = None
84 task = self._GetSwarmingTask(*call_args) 83 task = self._GetSwarmingTask(*call_args)
85 84
86 while not task_completed: 85 while not task_completed:
87 data, error = swarming_util.GetSwarmingTaskResultById( 86 data, error = swarming_util.GetSwarmingTaskResultById(
88 task_id, self.HTTP_CLIENT) 87 task_id, self.HTTP_CLIENT)
89 88
90 if error: 89 if error:
91 # An error occurred when trying to contact the swarming server. 90 # An error occurred when trying to contact the swarming server.
92 task.status = analysis_status.ERROR 91 task.status = analysis_status.ERROR
93 task.error = error 92 task.error = error
94 task.put() 93 task.put()
95 break 94 break
96 95
97 task_state = data['state'] 96 task_state = data['state']
98 exit_code = (data.get('exit_code') if 97 exit_code = (data.get('exit_code') if
99 task_state == swarming_util.STATE_COMPLETED else None) 98 task_state == swarming_util.STATE_COMPLETED else None)
100 step_name_no_platform = ( 99 step_name_no_platform = (
101 step_name_no_platform or swarming_util.GetTagValue( 100 step_name_no_platform or swarming_util.GetTagValue(
102 data.get('tags', {}), 'ref_name')) 101 data.get('tags', {}), 'ref_name'))
103 102
104 if task_state not in swarming_util.STATES_RUNNING: 103 if task_state not in swarming_util.STATES_RUNNING:
105 task_completed = True 104 task_completed = True
106 105
107 if (task_state == swarming_util.STATE_COMPLETED and 106 if (task_state == swarming_util.STATE_COMPLETED and
108 int(exit_code) != swarming_util.TASK_FAILED): 107 int(exit_code) != swarming_util.TASK_FAILED):
109 outputs_ref = data.get('outputs_ref') 108 outputs_ref = data.get('outputs_ref')
109
110 # If swarming task aborted because of errors in request arguments,
stgao 2016/11/30 06:05:31 Double check: do such cases have a specific exit c
chanli 2016/11/30 07:13:29 I have checked the state is STATE_COMPLETED and ex
111 # it's possible that there is no outputs_ref.
112 if not outputs_ref:
113 task.status = analysis_status.ERROR
114 task.error = {
115 'code': swarming_util.NO_TASK_OUTPUTS,
116 'message': 'outputs_ref is None'
117 }
118 task.put()
119 break
120
110 output_json, error = swarming_util.GetSwarmingTaskFailureLog( 121 output_json, error = swarming_util.GetSwarmingTaskFailureLog(
111 outputs_ref, self.HTTP_CLIENT) 122 outputs_ref, self.HTTP_CLIENT)
112 123
113 if error: 124 if error:
114 task.status = analysis_status.ERROR 125 task.status = analysis_status.ERROR
115 task.error = error 126 task.error = error
116 else: 127 else:
117 task.status = analysis_status.COMPLETED 128 task.status = analysis_status.COMPLETED
118 129
119 tests_statuses = self._CheckTestsRunStatuses(output_json, *call_args) 130 tests_statuses = self._CheckTestsRunStatuses(output_json, *call_args)
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 task_id (str): The task id to query the swarming server on the progresss 203 task_id (str): The task id to query the swarming server on the progresss
193 of a swarming task. 204 of a swarming task.
194 205
195 Returns: 206 Returns:
196 A dict of lists for reliable/flaky tests. 207 A dict of lists for reliable/flaky tests.
197 """ 208 """
198 call_args = self._GetArgs(master_name, builder_name, build_number, 209 call_args = self._GetArgs(master_name, builder_name, build_number,
199 step_name, *args) 210 step_name, *args)
200 step_name_no_platform = self._MonitorSwarmingTask(task_id, *call_args) 211 step_name_no_platform = self._MonitorSwarmingTask(task_id, *call_args)
201 return step_name, step_name_no_platform 212 return step_name, step_name_no_platform
OLDNEW
« no previous file with comments | « no previous file | appengine/findit/waterfall/process_swarming_task_result_pipeline.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698