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

Side by Side Diff: tools/perf/measurements/measurement_smoke_test.py

Issue 928573003: [Telemetry] Make sure all page_test use 'action_name_to_run' except RasterizeAndMicro measurement. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 # 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 """Measurement smoke test to make sure that no new action_name_to_run is 4 """Measurement smoke test to make sure that no new action_name_to_run is
5 defined.""" 5 defined."""
6 6
7 import os 7 import os
8 import optparse
8 import logging 9 import logging
9 import unittest 10 import unittest
10 11
12 from measurements import rasterize_and_record_micro
13
11 from telemetry import benchmark as benchmark_module 14 from telemetry import benchmark as benchmark_module
12 from telemetry.core import discover 15 from telemetry.core import discover
13 from telemetry.page import page_test 16 from telemetry.page import page_test
14 from telemetry.unittest_util import options_for_unittests 17 from telemetry.unittest_util import options_for_unittests
15 from telemetry.util import classes 18 from telemetry.util import classes
16 from telemetry.web_perf import timeline_based_measurement 19 from telemetry.web_perf import timeline_based_measurement
17 20
18 21
19 # Do NOT add new items to this list! 22 # Do NOT add new items to this list!
20 # crbug.com/418375 23 # crbug.com/418375
21 _ACTION_NAMES_WHITE_LIST = ( 24 _ACTION_NAMES_WHITE_LIST = (
22 '',
23 'RunPageInteractions', 25 'RunPageInteractions',
24 ) 26 )
25 27
26 28
27 def _GetAllPossiblePageTestInstances(): 29 def _GetAllPossiblePageTestInstances():
28 page_test_instances = [] 30 page_test_instances = []
29 measurements_dir = os.path.dirname(__file__) 31 measurements_dir = os.path.dirname(__file__)
30 top_level_dir = os.path.dirname(measurements_dir) 32 top_level_dir = os.path.dirname(measurements_dir)
31 benchmarks_dir = os.path.join(top_level_dir, 'benchmarks') 33 benchmarks_dir = os.path.join(top_level_dir, 'benchmarks')
32 34
33 # Get all page test instances from measurement classes that are directly 35 # Get all page test instances from measurement classes that are directly
34 # constructable 36 # constructable
35 all_measurement_classes = discover.DiscoverClasses( 37 all_measurement_classes = discover.DiscoverClasses(
36 measurements_dir, top_level_dir, page_test.PageTest).values() 38 measurements_dir, top_level_dir, page_test.PageTest).values()
37 for measurement_class in all_measurement_classes: 39 for measurement_class in all_measurement_classes:
38 if classes.IsDirectlyConstructable(measurement_class): 40 if classes.IsDirectlyConstructable(measurement_class):
39 page_test_instances.append(measurement_class()) 41 page_test_instances.append(measurement_class())
40 42
41 all_benchmarks_classes = discover.DiscoverClasses( 43 all_benchmarks_classes = discover.DiscoverClasses(
42 benchmarks_dir, top_level_dir, benchmark_module.Benchmark).values() 44 benchmarks_dir, top_level_dir, benchmark_module.Benchmark).values()
43 45
44 # Get all page test instances from defined benchmarks. 46 # Get all page test instances from defined benchmarks.
45 # Note: since this depends on the command line options, there is no guaranteed 47 # Note: since this depends on the command line options, there is no guaranteed
46 # that this will generate all possible page test instances but it's worth 48 # that this will generate all possible page test instances but it's worth
47 # enough for smoke test purpose. 49 # enough for smoke test purpose.
48 for benchmark_class in all_benchmarks_classes: 50 for benchmark_class in all_benchmarks_classes:
49 options = options_for_unittests.GetCopy() 51 options = options_for_unittests.GetCopy()
50 parser = options.CreateParser() 52 parser = optparse.OptionParser()
51 benchmark_class.AddCommandLineArgs(parser) 53 benchmark_class.AddCommandLineArgs(parser)
52 benchmark_module.AddCommandLineArgs(parser) 54 benchmark_module.AddCommandLineArgs(parser)
53 benchmark_class.SetArgumentDefaults(parser) 55 benchmark_class.SetArgumentDefaults(parser)
54 options.MergeDefaultValues(parser.get_default_values()) 56 options.MergeDefaultValues(parser.get_default_values())
55 pt = benchmark_class().CreatePageTest(options) 57 pt = benchmark_class().CreatePageTest(options)
56 if not isinstance(pt, timeline_based_measurement.TimelineBasedMeasurement): 58 if not isinstance(pt, timeline_based_measurement.TimelineBasedMeasurement):
57 page_test_instances.append(pt) 59 page_test_instances.append(pt)
58 60
59 return page_test_instances 61 return page_test_instances
60 62
61 63
62 class MeasurementSmokeTest(unittest.TestCase): 64 class MeasurementSmokeTest(unittest.TestCase):
63 # TODO(nednguyen): Remove this test when crbug.com/418375 is marked fixed. 65 # TODO(nednguyen): Remove this test when crbug.com/418375 is marked fixed.
64 def testNoNewActionNameToRunUsed(self): 66 def testNoNewActionNameToRunUsed(self):
65 invalid_tests = [] 67 invalid_tests = []
66 for test in _GetAllPossiblePageTestInstances(): 68 for test in _GetAllPossiblePageTestInstances():
69 if isinstance(test, rasterize_and_record_micro.RasterizeAndRecordMicro):
70 continue
67 if not hasattr(test, 'action_name_to_run'): 71 if not hasattr(test, 'action_name_to_run'):
68 invalid_tests.append(test) 72 invalid_tests.append(test)
69 logging.error('Test %s missing action_name_to_run attribute.', 73 logging.error('Test %s missing action_name_to_run attribute.',
70 test.__class__.__name__) 74 test.__class__.__name__)
71 if test.action_name_to_run not in _ACTION_NAMES_WHITE_LIST: 75 if test.action_name_to_run not in _ACTION_NAMES_WHITE_LIST:
72 invalid_tests.append(test) 76 invalid_tests.append(test)
73 logging.error('Page test %s has invalid action_name_to_run: %s' % 77 logging.error('Page test %s has invalid action_name_to_run: %s' %
74 (test.__class__.__name__, repr(test.action_name_to_run))) 78 (test.__class__.__name__, repr(test.action_name_to_run)))
75 self.assertFalse( 79 self.assertFalse(
76 invalid_tests, 80 invalid_tests,
77 'New page tests with invalid action_name_to_run found. Please only use ' 81 'New page tests with invalid action_name_to_run found. Please only use '
78 'action_name_to_run="RunPageInteractions" (crbug.com/418375).') 82 'action_name_to_run="RunPageInteractions" (crbug.com/418375).')
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