OLD | NEW |
---|---|
(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 the first page of one benchmark for every module. | |
petrcermak
2016/06/29 06:53:27
I don't think that this is the case. You seem to b
nednguyen
2016/06/29 18:16:41
Update the description completely. I was just copy
| |
6 | |
7 Only benchmarks that have a composable measurement are included. | |
petrcermak
2016/06/29 06:53:27
Not sure what this means.
nednguyen
2016/06/29 18:16:41
Removed this part.
| |
8 Ideally this test would be comprehensive, however, running one page | |
9 of every benchmark would run impractically long. | |
10 """ | |
11 | |
12 import sys | |
13 import unittest | |
14 | |
15 from telemetry import benchmark as benchmark_module | |
16 from telemetry import decorators | |
17 from telemetry.internal.browser import browser_finder | |
18 from telemetry.testing import options_for_unittests | |
19 from telemetry.testing import progress_reporter | |
20 | |
21 from benchmarks import system_health | |
22 | |
23 | |
24 # We only cover memory system health benchmarks because other system health | |
25 # benchmarks should be using the same stories as memory's ones, only with less | |
petrcermak
2016/06/29 06:53:27
nit: s/less/fewer/ ("actions" are countable)
nednguyen
2016/06/29 18:16:41
Done.
| |
26 # actions (no memory dumping). | |
27 _SH_BENCHMARKS_TO_SMOKE_TEST = [ | |
28 system_health.DesktopMemorySystemHealth, | |
29 system_health.MobileMemorySystemHealth, | |
30 ] | |
31 | |
32 | |
33 _DISABLED_TESTS = [ | |
34 'benchmarks.system_health_smoke_test.SystemHealthBenchmarkSmokeTest.system_hea lth.memory_desktop.load:tools:dropbox', # pylint: disable=line-too-long | |
petrcermak
2016/06/29 06:53:28
Could you please add a bug for each of these?
nednguyen
2016/06/29 18:16:41
Done.
Looks like memory_mobile.load:games:bubbles
| |
35 'benchmarks.system_health_smoke_test.SystemHealthBenchmarkSmokeTest.system_hea lth.memory_mobile.load:games:bubbles', # pylint: disable=line-too-long | |
36 ] | |
37 | |
38 | |
39 def SmokeTestGenerator(benchmark_class, story_to_smoke_test): | |
40 # NOTE TO SHERIFFS: DO NOT DISABLE THIS TEST. | |
41 # | |
42 # This smoke test dynamically tests all benchmarks. So disabling it for one | |
petrcermak
2016/06/29 06:53:27
s/all benchmarks/all system health user stories/ ?
nednguyen
2016/06/29 18:16:41
Done.
| |
43 # failing or flaky benchmark would disable a much wider swath of coverage | |
44 # than is usally intended. Instead, if a test is failing, disable it by | |
45 # putting it in _DISABLED_TESTS list above. | |
46 | |
47 @benchmark_module.Disabled('chromeos') # crbug.com/351114 | |
48 def SmokeTest(self): | |
49 # Only measure a single story so that this test cycles reasonably quickly. | |
50 benchmark_class.options['pageset_repeat'] = 1 | |
petrcermak
2016/06/29 06:53:27
Isn't this modifying the top-level benchmark? Why
nednguyen
2016/06/29 18:16:41
Done. Set these in options to make sure instead.
| |
51 benchmark_class.options['page_repeat'] = 1 | |
52 | |
53 class SinglePageBenchmark(benchmark_class): # pylint: disable=no-init | |
54 | |
55 def CreateStorySet(self, options): | |
56 # pylint: disable=super-on-old-class | |
57 story_set = super(SinglePageBenchmark, self).CreateStorySet(options) | |
58 assert story_to_smoke_test in story_set.stories | |
59 story_set.stories = [story_to_smoke_test] | |
60 return story_set | |
61 | |
62 options = GenerateBenchmarkOptions(benchmark_class) | |
63 possible_browser = browser_finder.FindBrowser(options) | |
64 if possible_browser is None: | |
65 self.skipTest('Cannot find the browser to run the test.') | |
66 if (SinglePageBenchmark.ShouldDisable(possible_browser) or | |
67 not decorators.IsEnabled(benchmark_class, possible_browser)[0]): | |
68 self.skipTest('Benchmark %s is disabled' % SinglePageBenchmark.Name()) | |
69 | |
70 if self.id() in _DISABLED_TESTS: | |
71 self.skipTest('Test is explictly disabled') | |
72 | |
73 self.assertEqual(0, SinglePageBenchmark().Run(options), | |
74 msg='Failed: %s' % benchmark_class) | |
75 | |
76 return SmokeTest | |
77 | |
78 | |
79 def GenerateBenchmarkOptions(benchmark_class): | |
80 # Set the benchmark's default arguments. | |
81 options = options_for_unittests.GetCopy() | |
82 options.output_format = 'none' | |
83 parser = options.CreateParser() | |
84 | |
85 benchmark_class.AddCommandLineArgs(parser) | |
86 benchmark_module.AddCommandLineArgs(parser) | |
87 benchmark_class.SetArgumentDefaults(parser) | |
88 options.MergeDefaultValues(parser.get_default_values()) | |
89 | |
90 benchmark_class.ProcessCommandLineArgs(None, options) | |
91 benchmark_module.ProcessCommandLineArgs(None, options) | |
92 return options | |
93 | |
94 | |
95 def load_tests(loader, standard_tests, pattern): | |
96 del loader, standard_tests, pattern # unused | |
97 suite = progress_reporter.TestSuite() | |
98 for benchmark_class in _SH_BENCHMARKS_TO_SMOKE_TEST: | |
99 assert sys.modules[benchmark_class.__module__] is system_health | |
petrcermak
2016/06/29 06:53:27
This seems unnecessary
nednguyen
2016/06/29 18:16:42
I was wanting to make sure that people don't add n
| |
100 class SystemHealthBenchmarkSmokeTest(unittest.TestCase): | |
101 pass | |
102 | |
103 # HACK: this options should be derived from options_for_unittests which is | |
petrcermak
2016/06/29 06:53:28
nit: s/this options/these options/
nednguyen
2016/06/29 18:16:41
Done.
| |
104 # the resolved options from run_tests' arguments. However, options is only | |
105 # parsed during test time which happens after load_tests is called. | |
106 # Since none of our system health benchmark create stories based on | |
petrcermak
2016/06/29 06:53:27
This comment is not complete.
| |
107 options = None | |
108 | |
109 for story_to_smoke_test in ( | |
110 benchmark_class().CreateStorySet(options).stories): | |
petrcermak
2016/06/29 06:53:27
Why do you name |options| when you could just pass
nednguyen
2016/06/29 18:16:42
I thought it was easier to add documentation there
| |
111 test_method_name = '%s.%s' % ( | |
112 benchmark_class.Name(), story_to_smoke_test.display_name) | |
113 method = SmokeTestGenerator(benchmark_class, story_to_smoke_test) | |
114 setattr(SystemHealthBenchmarkSmokeTest, test_method_name, method) | |
petrcermak
2016/06/29 06:53:27
This seems unnecessarily complicated. Why don't yo
nednguyen
2016/06/29 18:16:41
Because we need to make the test method name conta
| |
115 | |
116 suite.addTest(SystemHealthBenchmarkSmokeTest(test_method_name)) | |
petrcermak
2016/06/29 06:53:28
I suggest you name the parameter:
SystemHealthBen
nednguyen
2016/06/29 18:16:41
Done.
| |
117 | |
118 return suite | |
OLD | NEW |