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

Side by Side Diff: scripts/slave/recipe_modules/swarming/tests/collect_gtest_task_test.py

Issue 2375663003: Add json test results format support for SwarmingIsolatedScriptTest (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
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 cStringIO 6 import cStringIO
7 import json 7 import json
8 import logging 8 import logging
9 import os 9 import os
10 import shutil 10 import shutil
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 }], 142 }],
143 'swarming_summary': { 143 'swarming_summary': {
144 'shards': [{ 144 'shards': [{
145 'outputs_ref': { 145 'outputs_ref': {
146 'view_url': 'blah', 146 'view_url': 'blah',
147 }, 147 },
148 }], 148 }],
149 }, 149 },
150 } 150 }
151 151
152 GOOD_JSON_TEST_RESULT_0 = {
153 'tests': {
154 'car': {
155 'honda': {
156 'expected': 'PASS',
157 'actual': 'PASS'
158 },
159 'toyota': {
160 'expected': 'FAIL',
161 'actual': 'FAIL'
162 }
163 },
164 'computer': {
165 'dell': {
166 'expected': 'PASS',
167 'actual': 'PASS'
168 }
169 },
170 },
171 'interrupted': False,
172 'path_delimiter': '.',
173 'version': 3,
174 'seconds_since_epoch': 1406662289.76,
175 'num_failures_by_type': {
176 'FAIL': 0,
177 'PASS': 2
178 }
179 }
180
181 GOOD_JSON_TEST_RESULT_1 = {
182 'tests': {
183 'car': {
184 'tesla': {
185 'expected': 'pass',
186 'actual': 'pass'
187 },
188 },
189 'burger': {
190 'mcdonald': {
191 'expected': 'pass',
192 'actual': 'pass'
193 }
194 },
195 },
196 'interrupted': False,
197 'path_delimiter': '.',
198 'version': 3,
199 'seconds_since_epoch': 1406662283.11,
200 'num_failures_by_type': {
201 'fail': 0,
202 'pass': 2
203 }
204 }
205
206 GOOD_JSON_TEST_RESULT_2 = {
207 'tests': {
208 'car': {
209 'mercedes': {
210 'expected': 'pass',
211 'actual': 'fail'
212 },
213 },
214 'burger': {
215 'in n out': {
216 'expected': 'pass',
217 'actual': 'pass'
218 }
219 },
220 },
221 'interrupted': True,
222 'path_delimiter': '.',
223 'version': 3,
224 'seconds_since_epoch': 1406662200.01,
225 'num_failures_by_type': {
226 'fail': 1,
227 'pass': 1
228 }
229 }
230
231 GOOD_JSON_TEST_RESULT_MERGED = {
232 }
Ken Russell (switch to Gerrit) 2016/09/30 23:37:53 Sorry, I don't understand: why is this empty?
nednguyen 2016/10/04 00:10:11 Sorry, I wasn't quite sure how to test this. Pleas
233
152 234
153 # Only shard #1 finished. UNRELIABLE_RESULTS is set. 235 # Only shard #1 finished. UNRELIABLE_RESULTS is set.
154 BAD_GTEST_JSON_ONLY_1_SHARD = { 236 BAD_GTEST_JSON_ONLY_1_SHARD = {
155 'all_tests': [ 237 'all_tests': [
156 'AlignedMemoryTest.DynamicAllocation', 238 'AlignedMemoryTest.DynamicAllocation',
157 'AlignedMemoryTest.ScopedDynamicAllocation', 239 'AlignedMemoryTest.ScopedDynamicAllocation',
158 'AlignedMemoryTest.StackAlignment', 240 'AlignedMemoryTest.StackAlignment',
159 'AlignedMemoryTest.StaticAlignment', 241 'AlignedMemoryTest.StaticAlignment',
160 ], 242 ],
161 'disabled_tests': [ 243 'disabled_tests': [
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 merged['swarming_summary'] = { 416 merged['swarming_summary'] = {
335 'shards': [{ 417 'shards': [{
336 'outputs_ref': { 418 'outputs_ref': {
337 'view_url': 'blah', 419 'view_url': 'blah',
338 }, 420 },
339 }], 421 }],
340 } 422 }
341 self.assertEqual(GOOD_GTEST_JSON_MERGED, merged) 423 self.assertEqual(GOOD_GTEST_JSON_MERGED, merged)
342 self.assertEqual('', stdout) 424 self.assertEqual('', stdout)
343 425
426 def test_merged_json_result_ok(self):
427 self.stage({
428 'summary.json': {'shards': [{'dummy': 0}, {'dummy': 0}, {'dummy': 0}]},
429 '0/output.json': GOOD_JSON_TEST_RESULT_0,
430 '1/output.json': GOOD_JSON_TEST_RESULT_1,
431 '2/output.json': GOOD_JSON_TEST_RESULT_2,
432 })
433 merged, stdout = self.call()
434 merged['swarming_summary'] = {
435 'shards': [{
436 'outputs_ref': {
437 'view_url': 'blah',
438 },
439 }],
440 }
441 self.assertEqual(GOOD_JSON_TEST_RESULT_MERGED, merged)
442 self.assertEqual('', stdout)
443
444
344 def test_missing_summary_json(self): 445 def test_missing_summary_json(self):
345 # summary.json is missing, should return None and emit warning. 446 # summary.json is missing, should return None and emit warning.
346 merged, output = self.call() 447 merged, output = self.call()
347 self.assertEqual(None, merged) 448 self.assertEqual(None, merged)
348 self.assertIn('@@@STEP_WARNINGS@@@', output) 449 self.assertIn('@@@STEP_WARNINGS@@@', output)
349 self.assertIn('summary.json is missing or can not be read', output) 450 self.assertIn('summary.json is missing or can not be read', output)
350 451
351 def test_unfinished_shards(self): 452 def test_unfinished_shards(self):
352 # Only one shard (#1) finished. Shard #0 did not. 453 # Only one shard (#1) finished. Shard #0 did not.
353 self.stage({ 454 self.stage({
(...skipping 27 matching lines...) Expand all
381 '@@@STEP_TEXT@3 disabled@@@', 482 '@@@STEP_TEXT@3 disabled@@@',
382 stdout) 483 stdout)
383 484
384 485
385 if __name__ == '__main__': 486 if __name__ == '__main__':
386 logging.basicConfig( 487 logging.basicConfig(
387 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR) 488 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR)
388 if '-v' in sys.argv: 489 if '-v' in sys.argv:
389 unittest.TestCase.maxDiff = None 490 unittest.TestCase.maxDiff = None
390 unittest.main() 491 unittest.main()
OLDNEW
« scripts/slave/recipe_modules/swarming/api.py ('K') | « scripts/slave/recipe_modules/swarming/api.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698