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

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

Issue 2159023002: [Findit] Catch ValueError when get swarming result. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: . Created 4 years, 5 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
« no previous file with comments | « appengine/findit/model/wf_analysis.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 urllib 9 import urllib
9 import zlib 10 import zlib
10 11
11 from google.appengine.ext import ndb 12 from google.appengine.ext import ndb
12 13
13 from common import auth_util 14 from common import auth_util
14 from model.wf_step import WfStep 15 from model.wf_step import WfStep
15 from waterfall import waterfall_config 16 from waterfall import waterfall_config
16 from waterfall.swarming_task_request import SwarmingTaskRequest 17 from waterfall.swarming_task_request import SwarmingTaskRequest
17 18
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 else the log would be in content so use it directly. 246 else the log would be in content so use it directly.
246 """ 247 """
247 json_content = json.loads(output_json_content) 248 json_content = json.loads(output_json_content)
248 output_json_url = json_content.get('url') 249 output_json_url = json_content.get('url')
249 if output_json_url: 250 if output_json_url:
250 get_content = _SendRequestToServer(output_json_url, http_client) 251 get_content = _SendRequestToServer(output_json_url, http_client)
251 elif json_content.get('content'): 252 elif json_content.get('content'):
252 get_content = base64.b64decode(json_content['content']) 253 get_content = base64.b64decode(json_content['content'])
253 else: # pragma: no cover 254 else: # pragma: no cover
254 get_content = None # Just for precausion. 255 get_content = None # Just for precausion.
255 return json.loads(zlib.decompress(get_content)) if get_content else None 256 try:
256 257 return json.loads(zlib.decompress(get_content)) if get_content else None
258 except ValueError: # pragma: no cover
259 logging.info(
260 'swarming result is invalid: %s' % zlib.decompress(get_content))
261 return None
257 262
258 def _DownloadTestResults(isolated_data, http_client): 263 def _DownloadTestResults(isolated_data, http_client):
259 """Downloads the output.json file and returns the json object.""" 264 """Downloads the output.json file and returns the json object."""
260 # First POST request to get hash for the output.json file. 265 # First POST request to get hash for the output.json file.
261 content = _FetchOutputJsonInfoFromIsolatedServer( 266 content = _FetchOutputJsonInfoFromIsolatedServer(
262 isolated_data, http_client) 267 isolated_data, http_client)
263 if not content: 268 if not content:
264 return None 269 return None
265 output_json_hash = _GetOutputJsonHash(content) 270 output_json_hash = _GetOutputJsonHash(content)
266 if not output_json_hash: 271 if not output_json_hash:
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 shard_results = [] 348 shard_results = []
344 for isolated_data in list_isolated_data: 349 for isolated_data in list_isolated_data:
345 output_json = _DownloadTestResults(isolated_data, http_client) 350 output_json = _DownloadTestResults(isolated_data, http_client)
346 if not output_json: 351 if not output_json:
347 return None 352 return None
348 shard_results.append(output_json) 353 shard_results.append(output_json)
349 354
350 if len(list_isolated_data) == 1: 355 if len(list_isolated_data) == 1:
351 return shard_results[0] 356 return shard_results[0]
352 return _MergeSwarmingTestShards(shard_results) 357 return _MergeSwarmingTestShards(shard_results)
OLDNEW
« no previous file with comments | « appengine/findit/model/wf_analysis.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698