aboutsummaryrefslogtreecommitdiff
path: root/crosperf/settings_factory.py
blob: efbb534f0d3c6d1f4591453e2a6fa0f85579e4d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Setting files for global, benchmark and labels."""

from __future__ import print_function

from field import BooleanField
from field import IntegerField
from field import ListField
from field import TextField
from settings import Settings


class BenchmarkSettings(Settings):
  """Settings used to configure individual benchmarks."""

  def __init__(self, name):
    super(BenchmarkSettings, self).__init__(name, 'benchmark')
    self.AddField(
        TextField(
            'test_name',
            description='The name of the test to run. '
            'Defaults to the name of the benchmark.'))
    self.AddField(
        TextField(
            'test_args', description='Arguments to be passed to the '
            'test.'))
    self.AddField(
        IntegerField(
            'iterations',
            required=False,
            default=0,
            description='Number of iterations to run the test. '
            'If not set, will run each benchmark test the optimum number of '
            'times to get a stable result.'))
    self.AddField(
        TextField(
            'suite', default='', description='The type of the benchmark.'))
    self.AddField(
        IntegerField(
            'retries',
            default=0,
            description='Number of times to retry a '
            'benchmark run.'))
    self.AddField(
        BooleanField(
            'run_local',
            description='Run benchmark harness on the DUT. '
            'Currently only compatible with the suite: '
            'telemetry_Crosperf.',
            required=False,
            default=True))


class LabelSettings(Settings):
  """Settings for each label."""

  def __init__(self, name):
    super(LabelSettings, self).__init__(name, 'label')
    self.AddField(
        TextField(
            'chromeos_image',
            required=False,
            description='The path to the image to run tests '
            'on, for local/custom-built images. See the '
            "'build' option for official or trybot images."))
    self.AddField(
        TextField(
            'autotest_path',
            required=False,
            description='Autotest directory path relative to chroot which '
            'has autotest files for the image to run tests requiring autotest '
            'files.'))
    self.AddField(
        TextField(
            'chromeos_root',
            description='The path to a chromeos checkout which '
            'contains a src/scripts directory. Defaults to '
            'the chromeos checkout which contains the '
            'chromeos_image.'))
    self.AddField(
        ListField(
            'remote',
            description='A comma-separated list of IPs of chromeos'
            'devices to run experiments on.'))
    self.AddField(
        TextField(
            'image_args',
            required=False,
            default='',
            description='Extra arguments to pass to '
            'image_chromeos.py.'))
    self.AddField(
        TextField(
            'cache_dir',
            default='',
            description='The cache dir for this image.'))
    self.AddField(
        TextField(
            'compiler',
            default='gcc',
            description='The compiler used to build the '
            'ChromeOS image (gcc or llvm).'))
    self.AddField(
        TextField(
            'chrome_src',
            description='The path to the source of chrome. '
            'This is used to run telemetry benchmarks. '
            'The default one is the src inside chroot.',
            required=False,
            default=''))
    self.AddField(
        TextField(
            'build',
            description='The xbuddy specification for an '
            'official or trybot image to use for tests. '
            "'/remote' is assumed, and the board is given "
            "elsewhere, so omit the '/remote/<board>/' xbuddy "
            'prefix.',
            required=False,
            default=''))


class GlobalSettings(Settings):
  """Settings that apply per-experiment."""

  def __init__(self, name):
    super(GlobalSettings, self).__init__(name, 'global')
    self.AddField(
        TextField(
            'name',
            description='The name of the experiment. Just an '
            'identifier.'))
    self.AddField(
        TextField(
            'board',
            description='The target board for running '
            'experiments on, e.g. x86-alex.'))
    self.AddField(
        ListField(
            'remote',
            description='A comma-separated list of IPs of '
            'chromeos devices to run experiments on.'))
    self.AddField(
        BooleanField(
            'rerun_if_failed',
            description='Whether to re-run failed test runs '
            'or not.',
            default=False))
    self.AddField(
        BooleanField(
            'rm_chroot_tmp',
            default=False,
            description='Whether to remove the test_that '
            'result in the chroot.'))
    self.AddField(
        ListField(
            'email',
            description='Space-separated list of email '
            'addresses to send email to.'))
    self.AddField(
        BooleanField(
            'rerun',
            description='Whether to ignore the cache and '
            'for tests to be re-run.',
            default=False))
    self.AddField(
        BooleanField(
            'same_specs',
            default=True,
            description='Ensure cached runs are run on the '
            'same kind of devices which are specified as a '
            'remote.'))
    self.AddField(
        BooleanField(
            'same_machine',
            default=False,
            description='Ensure cached runs are run on the '
            'same remote.'))
    self.AddField(
        BooleanField(
            'use_file_locks',
            default=False,
            description='Whether to use the file locks '
            'mechanism (deprecated) instead of the AFE '
            'server lock mechanism.'))
    self.AddField(
        IntegerField(
            'iterations',
            required=False,
            default=0,
            description='Number of iterations to run all tests. '
            'If not set, will run each benchmark test the optimum number of '
            'times to get a stable result.'))
    self.AddField(
        TextField(
            'chromeos_root',
            description='The path to a chromeos checkout which '
            'contains a src/scripts directory. Defaults to '
            'the chromeos checkout which contains the '
            'chromeos_image.'))
    self.AddField(
        TextField(
            'logging_level',
            default='average',
            description='The level of logging desired. '
            "Options are 'quiet', 'average', and 'verbose'."))
    self.AddField(
        IntegerField(
            'acquire_timeout',
            default=0,
            description='Number of seconds to wait for '
            'machine before exit if all the machines in '
            'the experiment file are busy. Default is 0.'))
    self.AddField(
        TextField(
            'perf_args',
            default='',
            description='The optional profile command. It '
            'enables perf commands to record perforamance '
            'related counters. It must start with perf '
            'command record or stat followed by arguments.'))
    self.AddField(
        TextField(
            'cache_dir',
            default='',
            description='The abs path of cache dir. '
            'Default is /home/$(whoami)/cros_scratch.'))
    self.AddField(
        BooleanField(
            'cache_only',
            default=False,
            description='Whether to use only cached '
            'results (do not rerun failed tests).'))
    self.AddField(
        BooleanField(
            'no_email',
            default=False,
            description='Whether to disable the email to '
            'user after crosperf finishes.'))
    self.AddField(
        BooleanField(
            'json_report',
            default=False,
            description='Whether to generate a json version '
            'of the report, for archiving.'))
    self.AddField(
        BooleanField(
            'show_all_results',
            default=False,
            description='When running Telemetry tests, '
            'whether to all the results, instead of just '
            'the default (summary) results.'))
    self.AddField(
        TextField(
            'share_cache',
            default='',
            description='Path to alternate cache whose data '
            'you want to use. It accepts multiple directories '
            'separated by a ",".'))
    self.AddField(
        TextField('results_dir', default='', description='The results dir.'))
    self.AddField(
        TextField(
            'locks_dir',
            default='',
            description='An alternate directory to use for '
            'storing/checking machine locks. Using this field '
            'automatically sets use_file_locks to True.\n'
            'WARNING: If you use your own locks directory, '
            'there is no guarantee that someone else might not '
            'hold a lock on the same machine in a different '
            'locks directory.'))
    self.AddField(
        TextField(
            'chrome_src',
            description='The path to the source of chrome. '
            'This is used to run telemetry benchmarks. '
            'The default one is the src inside chroot.',
            required=False,
            default=''))
    self.AddField(
        IntegerField(
            'retries',
            default=0,
            description='Number of times to retry a '
            'benchmark run.'))


class SettingsFactory(object):
  """Factory class for building different types of Settings objects.

  This factory is currently hardcoded to produce settings for ChromeOS
  experiment files. The idea is that in the future, other types
  of settings could be produced.
  """

  def GetSettings(self, name, settings_type):
    if settings_type == 'label' or not settings_type:
      return LabelSettings(name)
    if settings_type == 'global':
      return GlobalSettings(name)
    if settings_type == 'benchmark':
      return BenchmarkSettings(name)

    raise TypeError("Invalid settings type: '%s'." % settings_type)