• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2013 The Chromium OS 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"""Setting files for global, benchmark and labels."""
5
6from __future__ import print_function
7
8from field import BooleanField
9from field import IntegerField
10from field import ListField
11from field import TextField
12from settings import Settings
13
14
15class BenchmarkSettings(Settings):
16  """Settings used to configure individual benchmarks."""
17
18  def __init__(self, name):
19    super(BenchmarkSettings, self).__init__(name, 'benchmark')
20    self.AddField(
21        TextField(
22            'test_name',
23            description='The name of the test to run. '
24            'Defaults to the name of the benchmark.'))
25    self.AddField(
26        TextField(
27            'test_args', description='Arguments to be passed to the '
28            'test.'))
29    self.AddField(
30        IntegerField(
31            'iterations',
32            required=False,
33            default=0,
34            description='Number of iterations to run the test. '
35            'If not set, will run each benchmark test the optimum number of '
36            'times to get a stable result.'))
37    self.AddField(
38        TextField(
39            'suite', default='', description='The type of the benchmark.'))
40    self.AddField(
41        IntegerField(
42            'retries',
43            default=0,
44            description='Number of times to retry a '
45            'benchmark run.'))
46    self.AddField(
47        BooleanField(
48            'run_local',
49            description='Run benchmark harness on the DUT. '
50            'Currently only compatible with the suite: '
51            'telemetry_Crosperf.',
52            required=False,
53            default=True))
54
55
56class LabelSettings(Settings):
57  """Settings for each label."""
58
59  def __init__(self, name):
60    super(LabelSettings, self).__init__(name, 'label')
61    self.AddField(
62        TextField(
63            'chromeos_image',
64            required=False,
65            description='The path to the image to run tests '
66            'on, for local/custom-built images. See the '
67            "'build' option for official or trybot images."))
68    self.AddField(
69        TextField(
70            'autotest_path',
71            required=False,
72            description='Autotest directory path relative to chroot which '
73            'has autotest files for the image to run tests requiring autotest '
74            'files.'))
75    self.AddField(
76        TextField(
77            'chromeos_root',
78            description='The path to a chromeos checkout which '
79            'contains a src/scripts directory. Defaults to '
80            'the chromeos checkout which contains the '
81            'chromeos_image.'))
82    self.AddField(
83        ListField(
84            'remote',
85            description='A comma-separated list of IPs of chromeos'
86            'devices to run experiments on.'))
87    self.AddField(
88        TextField(
89            'image_args',
90            required=False,
91            default='',
92            description='Extra arguments to pass to '
93            'image_chromeos.py.'))
94    self.AddField(
95        TextField(
96            'cache_dir',
97            default='',
98            description='The cache dir for this image.'))
99    self.AddField(
100        TextField(
101            'compiler',
102            default='gcc',
103            description='The compiler used to build the '
104            'ChromeOS image (gcc or llvm).'))
105    self.AddField(
106        TextField(
107            'chrome_src',
108            description='The path to the source of chrome. '
109            'This is used to run telemetry benchmarks. '
110            'The default one is the src inside chroot.',
111            required=False,
112            default=''))
113    self.AddField(
114        TextField(
115            'build',
116            description='The xbuddy specification for an '
117            'official or trybot image to use for tests. '
118            "'/remote' is assumed, and the board is given "
119            "elsewhere, so omit the '/remote/<board>/' xbuddy "
120            'prefix.',
121            required=False,
122            default=''))
123
124
125class GlobalSettings(Settings):
126  """Settings that apply per-experiment."""
127
128  def __init__(self, name):
129    super(GlobalSettings, self).__init__(name, 'global')
130    self.AddField(
131        TextField(
132            'name',
133            description='The name of the experiment. Just an '
134            'identifier.'))
135    self.AddField(
136        TextField(
137            'board',
138            description='The target board for running '
139            'experiments on, e.g. x86-alex.'))
140    self.AddField(
141        ListField(
142            'remote',
143            description='A comma-separated list of IPs of '
144            'chromeos devices to run experiments on.'))
145    self.AddField(
146        BooleanField(
147            'rerun_if_failed',
148            description='Whether to re-run failed test runs '
149            'or not.',
150            default=False))
151    self.AddField(
152        BooleanField(
153            'rm_chroot_tmp',
154            default=False,
155            description='Whether to remove the test_that '
156            'result in the chroot.'))
157    self.AddField(
158        ListField(
159            'email',
160            description='Space-separated list of email '
161            'addresses to send email to.'))
162    self.AddField(
163        BooleanField(
164            'rerun',
165            description='Whether to ignore the cache and '
166            'for tests to be re-run.',
167            default=False))
168    self.AddField(
169        BooleanField(
170            'same_specs',
171            default=True,
172            description='Ensure cached runs are run on the '
173            'same kind of devices which are specified as a '
174            'remote.'))
175    self.AddField(
176        BooleanField(
177            'same_machine',
178            default=False,
179            description='Ensure cached runs are run on the '
180            'same remote.'))
181    self.AddField(
182        BooleanField(
183            'use_file_locks',
184            default=False,
185            description='Whether to use the file locks '
186            'mechanism (deprecated) instead of the AFE '
187            'server lock mechanism.'))
188    self.AddField(
189        IntegerField(
190            'iterations',
191            required=False,
192            default=0,
193            description='Number of iterations to run all tests. '
194            'If not set, will run each benchmark test the optimum number of '
195            'times to get a stable result.'))
196    self.AddField(
197        TextField(
198            'chromeos_root',
199            description='The path to a chromeos checkout which '
200            'contains a src/scripts directory. Defaults to '
201            'the chromeos checkout which contains the '
202            'chromeos_image.'))
203    self.AddField(
204        TextField(
205            'logging_level',
206            default='average',
207            description='The level of logging desired. '
208            "Options are 'quiet', 'average', and 'verbose'."))
209    self.AddField(
210        IntegerField(
211            'acquire_timeout',
212            default=0,
213            description='Number of seconds to wait for '
214            'machine before exit if all the machines in '
215            'the experiment file are busy. Default is 0.'))
216    self.AddField(
217        TextField(
218            'perf_args',
219            default='',
220            description='The optional profile command. It '
221            'enables perf commands to record perforamance '
222            'related counters. It must start with perf '
223            'command record or stat followed by arguments.'))
224    self.AddField(
225        TextField(
226            'cache_dir',
227            default='',
228            description='The abs path of cache dir. '
229            'Default is /home/$(whoami)/cros_scratch.'))
230    self.AddField(
231        BooleanField(
232            'cache_only',
233            default=False,
234            description='Whether to use only cached '
235            'results (do not rerun failed tests).'))
236    self.AddField(
237        BooleanField(
238            'no_email',
239            default=False,
240            description='Whether to disable the email to '
241            'user after crosperf finishes.'))
242    self.AddField(
243        BooleanField(
244            'json_report',
245            default=False,
246            description='Whether to generate a json version '
247            'of the report, for archiving.'))
248    self.AddField(
249        BooleanField(
250            'show_all_results',
251            default=False,
252            description='When running Telemetry tests, '
253            'whether to all the results, instead of just '
254            'the default (summary) results.'))
255    self.AddField(
256        TextField(
257            'share_cache',
258            default='',
259            description='Path to alternate cache whose data '
260            'you want to use. It accepts multiple directories '
261            'separated by a ",".'))
262    self.AddField(
263        TextField('results_dir', default='', description='The results dir.'))
264    self.AddField(
265        TextField(
266            'locks_dir',
267            default='',
268            description='An alternate directory to use for '
269            'storing/checking machine locks. Using this field '
270            'automatically sets use_file_locks to True.\n'
271            'WARNING: If you use your own locks directory, '
272            'there is no guarantee that someone else might not '
273            'hold a lock on the same machine in a different '
274            'locks directory.'))
275    self.AddField(
276        TextField(
277            'chrome_src',
278            description='The path to the source of chrome. '
279            'This is used to run telemetry benchmarks. '
280            'The default one is the src inside chroot.',
281            required=False,
282            default=''))
283    self.AddField(
284        IntegerField(
285            'retries',
286            default=0,
287            description='Number of times to retry a '
288            'benchmark run.'))
289
290
291class SettingsFactory(object):
292  """Factory class for building different types of Settings objects.
293
294  This factory is currently hardcoded to produce settings for ChromeOS
295  experiment files. The idea is that in the future, other types
296  of settings could be produced.
297  """
298
299  def GetSettings(self, name, settings_type):
300    if settings_type == 'label' or not settings_type:
301      return LabelSettings(name)
302    if settings_type == 'global':
303      return GlobalSettings(name)
304    if settings_type == 'benchmark':
305      return BenchmarkSettings(name)
306
307    raise TypeError("Invalid settings type: '%s'." % settings_type)
308