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

Side by Side Diff: tools/perf/benchmarks/system_health_smoke_test.py

Issue 2115623002: [tools/perf] Add system_health_smoke_test that run all system health stories (Reland) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Disable more tests 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 | « 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
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """Run all system health stories used by system health benchmarks.
6
7 Only memory benchmarks are used when running these stories to make the total
8 cycle time manageable. Other system health benchmarks should be using the same
9 stories as memory ones, only with fewer actions (no memory dumping).
10 """
11
12 import unittest
13
14 from core import perf_benchmark
15
16 from telemetry import benchmark as benchmark_module
17 from telemetry import decorators
18 from telemetry.core import discover
19 from telemetry.internal.browser import browser_finder
20 from telemetry.testing import options_for_unittests
21 from telemetry.testing import progress_reporter
22
23 from benchmarks import system_health
24
25
26 # We only cover memory system health
27 _SH_BENCHMARKS_TO_SMOKE_TEST = [
28 system_health.DesktopMemorySystemHealth,
29 system_health.MobileMemorySystemHealth,
30 ]
31
32
33 def GetSystemHealthBenchmarksToSmokeTest():
34 sh_benchmark_classes = discover.DiscoverClassesInModule(
35 system_health, perf_benchmark.PerfBenchmark,
36 index_by_class_name=True).values()
37 return list(b for b in sh_benchmark_classes if
38 b.Name().startswith('system_health.memory'))
39
40
41 _DISABLED_TESTS = [
42 # crbug.com/624474
43 'benchmarks.system_health_smoke_test.SystemHealthBenchmarkSmokeTest.system_hea lth.memory_desktop.load:tools:dropbox', # pylint: disable=line-too-long
44 'benchmarks.system_health_smoke_test.SystemHealthBenchmarkSmokeTest.system_hea lth.memory_desktop.load:tools:docs', # pylint: disable=line-too-long
45 # crbug.com/624587
46 'benchmarks.system_health_smoke_test.SystemHealthBenchmarkSmokeTest.system_hea lth.memory_desktop.load:search:ebay', # pylint: disable=line-too-long
47 'benchmarks.system_health_smoke_test.SystemHealthBenchmarkSmokeTest.system_hea lth.memory_desktop.load:news:cnn', # pylint: disable=line-too-long
48 # crbug.com/624607
49 'benchmarks.system_health_smoke_test.SystemHealthBenchmarkSmokeTest.system_hea lth.memory_desktop.load:media:dailymotion', # pylint: disable=line-too-long
50 # crbug.com/624701
51 'benchmarks.system_health_smoke_test.SystemHealthBenchmarkSmokeTest.system_hea lth.memory_mobile.load:games:bubbles', # pylint: disable=line-too-long
52 'benchmarks.system_health_smoke_test.SystemHealthBenchmarkSmokeTest.system_hea lth.memory_mobile.load:games:spychase', # pylint: disable=line-too-long
53 'benchmarks.system_health_smoke_test.SystemHealthBenchmarkSmokeTest.system_hea lth.memory_mobile.load:news:cnn', # pylint: disable=line-too-long
54 # crbug.com/624840
55 'benchmarks.system_health_smoke_test.SystemHealthBenchmarkSmokeTest.system_hea lth.memory_mobile.load:tools:drive', # pylint: disable=line-too-long
56 'benchmarks.system_health_smoke_test.SystemHealthBenchmarkSmokeTest.system_hea lth.memory_mobile.load:tools:dropbox', # pylint: disable=line-too-long
57 'benchmarks.system_health_smoke_test.SystemHealthBenchmarkSmokeTest.system_hea lth.memory_mobile.load:tools:gmail', # pylint: disable=line-too-long
58 ]
59
60
61 def _GenerateSmokeTestCase(benchmark_class, story_to_smoke_test):
62
63 # NOTE TO SHERIFFS: DO NOT DISABLE THIS TEST.
64 #
65 # This smoke test dynamically tests all system health user stories. So
66 # disabling it for one failing or flaky benchmark would disable a much
67 # wider swath of coverage than is usally intended. Instead, if a test is
68 # failing, disable it by putting it into the _DISABLED_TESTS list above.
69 @benchmark_module.Disabled('chromeos') # crbug.com/351114
70 def RunTest(self):
71
72 class SinglePageBenchmark(benchmark_class): # pylint: disable=no-init
73 def CreateStorySet(self, options):
74 # pylint: disable=super-on-old-class
75 story_set = super(SinglePageBenchmark, self).CreateStorySet(options)
76 assert story_to_smoke_test in story_set.stories
77 story_set.stories = [story_to_smoke_test]
78 return story_set
79
80 options = GenerateBenchmarkOptions(benchmark_class)
81 possible_browser = browser_finder.FindBrowser(options)
82 if possible_browser is None:
83 self.skipTest('Cannot find the browser to run the test.')
84 if (SinglePageBenchmark.ShouldDisable(possible_browser) or
85 not decorators.IsEnabled(benchmark_class, possible_browser)[0]):
86 self.skipTest('Benchmark %s is disabled' % SinglePageBenchmark.Name())
87
88 if self.id() in _DISABLED_TESTS:
89 self.skipTest('Test is explictly disabled')
90
91 self.assertEqual(0, SinglePageBenchmark().Run(options),
92 msg='Failed: %s' % benchmark_class)
93
94 # We attach the test method to SystemHealthBenchmarkSmokeTest dynamically
95 # so that we can set the test method name to include
96 # '<benchmark class name>.<story display name>'.
97 test_method_name = '%s.%s' % (
98 benchmark_class.Name(), story_to_smoke_test.display_name)
99
100 class SystemHealthBenchmarkSmokeTest(unittest.TestCase):
101 pass
102
103 setattr(SystemHealthBenchmarkSmokeTest, test_method_name, RunTest)
104
105 return SystemHealthBenchmarkSmokeTest(methodName=test_method_name)
106
107
108 def GenerateBenchmarkOptions(benchmark_class):
109 # Set the benchmark's default arguments.
110 options = options_for_unittests.GetCopy()
111 options.output_format = 'none'
112 parser = options.CreateParser()
113
114 # TODO(nednguyen): probably this logic of setting up the benchmark options
115 # parser & processing the options should be sharable with telemetry's
116 # core.
117 benchmark_class.AddCommandLineArgs(parser)
118 benchmark_module.AddCommandLineArgs(parser)
119 benchmark_class.SetArgumentDefaults(parser)
120 options.MergeDefaultValues(parser.get_default_values())
121
122 benchmark_class.ProcessCommandLineArgs(None, options)
123 benchmark_module.ProcessCommandLineArgs(None, options)
124 # Only measure a single story so that this test cycles reasonably quickly.
125 options.pageset_repeat = 1
126 options.page_repeat = 1
127 return options
128
129
130 def load_tests(loader, standard_tests, pattern):
131 del loader, standard_tests, pattern # unused
132 suite = progress_reporter.TestSuite()
133 benchmark_classes = GetSystemHealthBenchmarksToSmokeTest()
134 assert benchmark_classes, 'This list should never be empty'
135 for benchmark_class in benchmark_classes:
136
137 # HACK: these options should be derived from options_for_unittests which are
138 # the resolved options from run_tests' arguments. However, options is only
139 # parsed during test time which happens after load_tests are called.
140 # Since none of our system health benchmarks creates stories based on
141 # command line options, it should be ok to pass options=None to
142 # CreateStorySet.
143 for story_to_smoke_test in (
144 benchmark_class().CreateStorySet(options=None).stories):
145 suite.addTest(
146 _GenerateSmokeTestCase(benchmark_class, story_to_smoke_test))
147
148 return suite
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