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

Side by Side Diff: scripts/slave/recipe_modules/swarming/resources/collect_gtest_task.py

Issue 2372783002: Size limit gtest collect (Closed)
Patch Set: Created 4 years, 2 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 | « no previous file | 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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import json 6 import json
7 import optparse 7 import optparse
8 import os 8 import os
9 import shutil 9 import shutil
10 import subprocess 10 import subprocess
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 'some shards did not complete: %s' % as_str, 87 'some shards did not complete: %s' % as_str,
88 MISSING_SHARDS_MSG % as_str) 88 MISSING_SHARDS_MSG % as_str)
89 # Not all tests run, combined JSON summary can not be trusted. 89 # Not all tests run, combined JSON summary can not be trusted.
90 merged['global_tags'].add('UNRELIABLE_RESULTS') 90 merged['global_tags'].add('UNRELIABLE_RESULTS')
91 91
92 # Convert to jsonish dict. 92 # Convert to jsonish dict.
93 for key in ('all_tests', 'disabled_tests', 'global_tags'): 93 for key in ('all_tests', 'disabled_tests', 'global_tags'):
94 merged[key] = sorted(merged[key]) 94 merged[key] = sorted(merged[key])
95 return merged 95 return merged
96 96
97 OUTPUT_JSON_SIZE_LIMIT = 2e7
98
97 99
98 def load_shard_json(output_dir, index): 100 def load_shard_json(output_dir, index):
99 """Reads JSON output of a single shard.""" 101 """Reads JSON output of a single shard."""
100 # 'output.json' is set in swarming/api.py, gtest_task method. 102 # 'output.json' is set in swarming/api.py, gtest_task method.
101 path = os.path.join(output_dir, str(index), 'output.json') 103 path = os.path.join(output_dir, str(index), 'output.json')
102 try: 104 try:
105 filesize = os.stat(path).st_size
106 if filesize > OUTPUT_JSON_SIZE_LIMIT:
107 raise ValueError
M-A Ruel 2016/09/26 21:04:07 ()
108
103 with open(path) as f: 109 with open(path) as f:
104 return json.load(f) 110 return json.load(f)
105 except (IOError, ValueError): 111 except (IOError, ValueError):
106 print >> sys.stderr, 'Missing or invalid gtest JSON file: %s' % path 112 print >> sys.stderr, 'Missing or invalid gtest JSON file: %s' % path
107 return None 113 return None
108 114
109 115
110 def merge_list_of_dicts(left, right): 116 def merge_list_of_dicts(left, right):
111 """Merges dicts left[0] with right[0], left[1] with right[1], etc.""" 117 """Merges dicts left[0] with right[0], left[1] with right[1], etc."""
112 output = [] 118 output = []
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 'failed to process gtest output JSON', traceback.format_exc()) 196 'failed to process gtest output JSON', traceback.format_exc())
191 197
192 finally: 198 finally:
193 shutil.rmtree(task_output_dir, ignore_errors=True) 199 shutil.rmtree(task_output_dir, ignore_errors=True)
194 200
195 return exit_code 201 return exit_code
196 202
197 203
198 if __name__ == '__main__': 204 if __name__ == '__main__':
199 sys.exit(main(sys.argv[1:])) 205 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698