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

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

Issue 2312413002: [Findit] Record error if swarming task completes with exit_code as 2. (Closed)
Patch Set: . Created 4 years, 3 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 import base64 5 import base64
6 from collections import defaultdict 6 from collections import defaultdict
7 import json 7 import json
8 import logging 8 import logging
9 import urllib 9 import urllib
10 import zlib 10 import zlib
11 11
12 from google.appengine.ext import ndb 12 from google.appengine.ext import ndb
13 13
14 from common import auth_util 14 from common import auth_util
15 from model.wf_step import WfStep 15 from model.wf_step import WfStep
16 from waterfall import waterfall_config 16 from waterfall import waterfall_config
17 from waterfall.swarming_task_request import SwarmingTaskRequest 17 from waterfall.swarming_task_request import SwarmingTaskRequest
18 18
19 19
20 STATES_RUNNING = ('RUNNING', 'PENDING') 20 STATES_RUNNING = ('RUNNING', 'PENDING')
21 STATE_COMPLETED = 'COMPLETED' 21 STATE_COMPLETED = 'COMPLETED'
22 STATES_NOT_RUNNING = ( 22 STATES_NOT_RUNNING = (
23 'EXPIRED', 'TIMED_OUT', 'BOT_DIED', 'CANCELED', 'COMPLETED') 23 'EXPIRED', 'TIMED_OUT', 'BOT_DIED', 'CANCELED', 'COMPLETED')
24 24
25 ALL_TESTS_PASSED = 0
26 SOME_TESTS_FAILED = 1
27 TASK_FAILED = 2
28
29 EXIT_CODE_DESCRIPTIONS = {
30 ALL_TESTS_PASSED: 'all tests passed',
31 SOME_TESTS_FAILED: 'some tests failed',
32 TASK_FAILED: 'swarming task failed'
33 }
34
25 35
26 def _SendRequestToServer(url, http_client, post_data=None): 36 def _SendRequestToServer(url, http_client, post_data=None):
27 """Sends GET/POST request to arbitrary url and returns response content.""" 37 """Sends GET/POST request to arbitrary url and returns response content."""
28 headers = {'Authorization': 'Bearer ' + auth_util.GetAuthToken()} 38 headers = {'Authorization': 'Bearer ' + auth_util.GetAuthToken()}
29 if post_data: 39 if post_data:
30 post_data = json.dumps(post_data, sort_keys=True, separators=(',', ':')) 40 post_data = json.dumps(post_data, sort_keys=True, separators=(',', ':'))
31 headers['Content-Type'] = 'application/json; charset=UTF-8' 41 headers['Content-Type'] = 'application/json; charset=UTF-8'
32 headers['Content-Length'] = len(post_data) 42 headers['Content-Length'] = len(post_data)
33 status_code, content = http_client.Post(url, post_data, headers=headers) 43 status_code, content = http_client.Post(url, post_data, headers=headers)
34 else: 44 else:
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 return step_isolated_data 216 return step_isolated_data
207 217
208 218
209 def _FetchOutputJsonInfoFromIsolatedServer(isolated_data, http_client): 219 def _FetchOutputJsonInfoFromIsolatedServer(isolated_data, http_client):
210 """Sends POST request to isolated server and returns response content. 220 """Sends POST request to isolated server and returns response content.
211 221
212 This function is used for fetching 222 This function is used for fetching
213 1. hash code for the output.json file, 223 1. hash code for the output.json file,
214 2. the redirect url. 224 2. the redirect url.
215 """ 225 """
226 if not isolated_data:
227 return None
228
216 post_data = { 229 post_data = {
217 'digest': isolated_data['digest'], 230 'digest': isolated_data['digest'],
218 'namespace': { 231 'namespace': {
219 'namespace': isolated_data['namespace'] 232 'namespace': isolated_data['namespace']
220 } 233 }
221 } 234 }
222 url = '%s/_ah/api/isolateservice/v1/retrieve' % ( 235 url = '%s/_ah/api/isolateservice/v1/retrieve' % (
223 isolated_data['isolatedserver']) 236 isolated_data['isolatedserver'])
224 content = _SendRequestToServer(url, http_client, post_data) 237 content = _SendRequestToServer(url, http_client, post_data)
225 return content 238 return content
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 shard_results = [] 363 shard_results = []
351 for isolated_data in list_isolated_data: 364 for isolated_data in list_isolated_data:
352 output_json = _DownloadTestResults(isolated_data, http_client) 365 output_json = _DownloadTestResults(isolated_data, http_client)
353 if not output_json: 366 if not output_json:
354 return None 367 return None
355 shard_results.append(output_json) 368 shard_results.append(output_json)
356 369
357 if len(list_isolated_data) == 1: 370 if len(list_isolated_data) == 1:
358 return shard_results[0] 371 return shard_results[0]
359 return _MergeSwarmingTestShards(shard_results) 372 return _MergeSwarmingTestShards(shard_results)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698