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

Side by Side Diff: tools/telemetry/telemetry/user_story/user_story_runner_unittest.py

Issue 748013003: Better error messages on archive failures, and stop running with partial page sets in user_story_ru… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fail more gracefully with warnings instead of exceptions. Created 6 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
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 unittest 5 import unittest
6 import StringIO 6 import StringIO
7 import sys 7 import sys
8 8
9 from telemetry import benchmark 9 from telemetry import benchmark
10 from telemetry import user_story 10 from telemetry import user_story
11 from telemetry.core import exceptions 11 from telemetry.core import exceptions
12 from telemetry.page import page_set
12 from telemetry.page import page_test 13 from telemetry.page import page_test
13 from telemetry.page import test_expectations 14 from telemetry.page import test_expectations
14 from telemetry.results import results_options 15 from telemetry.results import results_options
16 from unittest_data import test_simple_one_page_set
15 from telemetry.unittest_util import options_for_unittests 17 from telemetry.unittest_util import options_for_unittests
16 from telemetry.unittest_util import system_stub 18 from telemetry.unittest_util import system_stub
17 from telemetry.user_story import shared_user_story_state 19 from telemetry.user_story import shared_user_story_state
18 from telemetry.user_story import user_story_runner 20 from telemetry.user_story import user_story_runner
19 from telemetry.user_story import user_story_set 21 from telemetry.user_story import user_story_set
20 from telemetry.util import exception_formatter as exception_formatter_module 22 from telemetry.util import exception_formatter as exception_formatter_module
21 from telemetry.value import scalar 23 from telemetry.value import scalar
22 from telemetry.value import string 24 from telemetry.value import string
23 25
24 # This linter complains if we define classes nested inside functions. 26 # This linter complains if we define classes nested inside functions.
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 Measurement(), us, self.expectations, self.options, results) 335 Measurement(), us, self.expectations, self.options, results)
334 results.PrintSummary() 336 results.PrintSummary()
335 contents = output.getvalue() 337 contents = output.getvalue()
336 self.assertEquals(4, GetNumberOfSuccessfulPageRuns(results)) 338 self.assertEquals(4, GetNumberOfSuccessfulPageRuns(results))
337 self.assertEquals(0, len(results.failures)) 339 self.assertEquals(0, len(results.failures))
338 self.assertIn('RESULT metric: blank= [1,3] unit', contents) 340 self.assertIn('RESULT metric: blank= [1,3] unit', contents)
339 self.assertIn('RESULT metric: green= [2,4] unit', contents) 341 self.assertIn('RESULT metric: green= [2,4] unit', contents)
340 self.assertIn('*RESULT metric: metric= [1,2,3,4] unit', contents) 342 self.assertIn('*RESULT metric: metric= [1,2,3,4] unit', contents)
341 finally: 343 finally:
342 sys.stdout = real_stdout 344 sys.stdout = real_stdout
345
346 def testCheckArchives(self):
347 ps = page_set.PageSet()
nednguyen 2014/12/03 18:27:43 If this test use real page_set, it shouldn't be in
aiolos (Not reviewing) 2014/12/04 00:29:31 Is this something I should be considering still? I
nednguyen 2014/12/04 05:17:31 Yes, my bad. Please ignore the original comment.
348 # Empty page set.
349 self.assertFalse(user_story_runner._CheckArchives(ps, ps.pages))
350 ps.AddPageWithDefaultRunNavigate('http://127.0.0.1:62350/blank.html')
nednguyen 2014/12/03 19:35:59 Is there any reason why you choose 'http://127.0.0
aiolos (Not reviewing) 2014/12/04 00:29:31 I pulled it from an existing test page set. I don'
351 # Page set missing archive_data_file.
352 self.assertFalse(user_story_runner._CheckArchives(ps, ps.pages))
353
354 ps = page_set.PageSet(archive_data_file='missing_archive_data_file.json')
355 ps.AddPageWithDefaultRunNavigate('http://127.0.0.1:62350/blank.html')
356 # Page set missing json file specified in archive_data_file.
357 self.assertFalse(user_story_runner._CheckArchives(ps, ps.pages))
358
359 ps = page_set.PageSet(archive_data_file='../../unittest_data/test.json',
360 bucket=page_set.PUBLIC_BUCKET)
361 self.assertFalse(user_story_runner._CheckArchives(ps, ps.pages))
362 # Empty page set with an archive_data_file which exists.
363 ps.AddPageWithDefaultRunNavigate('http://127.0.0.1:62350/blank.html')
364 # Page set with valid archive_data_file.
365 self.assertTrue(user_story_runner._CheckArchives(ps, ps.pages))
366 ps.AddPageWithDefaultRunNavigate('http://www.google.com')
367 # Page set with an archive_data_file which exists but is missing a page.
368 self.assertFalse(user_story_runner._CheckArchives(ps, ps.pages))
369
370 ps = page_set.PageSet(
371 archive_data_file='../../unittest_data/test_missing_wpr_file.json',
372 bucket=page_set.PUBLIC_BUCKET)
373 ps.AddPageWithDefaultRunNavigate('http://127.0.0.1:62350/blank.html')
374 ps.AddPageWithDefaultRunNavigate('http://www.google.com')
375 # Page set with an archive_data_file which exists and contains all pages
376 # but fails to find a wpr file.
377 self.assertFalse(user_story_runner._CheckArchives(ps, ps.pages))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698