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