Ahmad Sharif | 0dcbc4b | 2012-02-02 16:37:18 -0800 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
Yunlian Jiang | 00cc30e | 2013-03-28 13:23:57 -0700 | [diff] [blame] | 3 | # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
Ahmad Sharif | 4467f00 | 2012-12-20 12:09:49 -0800 | [diff] [blame] | 7 | """Setting files for global, benchmark and labels.""" |
Ahmad Sharif | 0dcbc4b | 2012-02-02 16:37:18 -0800 | [diff] [blame] | 8 | |
| 9 | from field import BooleanField |
Ahmad Sharif | 0dcbc4b | 2012-02-02 16:37:18 -0800 | [diff] [blame] | 10 | from field import FloatField |
| 11 | from field import IntegerField |
| 12 | from field import ListField |
| 13 | from field import TextField |
| 14 | from settings import Settings |
| 15 | |
| 16 | |
| 17 | class BenchmarkSettings(Settings): |
| 18 | def __init__(self, name): |
| 19 | super(BenchmarkSettings, self).__init__(name, "benchmark") |
Yunlian Jiang | 04dc5dc | 2013-04-23 15:05:05 -0700 | [diff] [blame] | 20 | self.AddField(TextField("test_name", |
| 21 | description="The name of the test to run." |
Ahmad Sharif | 0dcbc4b | 2012-02-02 16:37:18 -0800 | [diff] [blame] | 22 | "Defaults to the name of the benchmark.")) |
Yunlian Jiang | 04dc5dc | 2013-04-23 15:05:05 -0700 | [diff] [blame] | 23 | self.AddField(TextField("test_args", |
Ahmad Sharif | 0dcbc4b | 2012-02-02 16:37:18 -0800 | [diff] [blame] | 24 | description="Arguments to be passed to the " |
Yunlian Jiang | 04dc5dc | 2013-04-23 15:05:05 -0700 | [diff] [blame] | 25 | "test.")) |
Ahmad Sharif | ee988c8 | 2012-05-14 17:11:56 -0700 | [diff] [blame] | 26 | self.AddField(IntegerField("iterations", default=1, |
Ahmad Sharif | 0dcbc4b | 2012-02-02 16:37:18 -0800 | [diff] [blame] | 27 | description="Number of iterations to run the " |
Yunlian Jiang | 04dc5dc | 2013-04-23 15:05:05 -0700 | [diff] [blame] | 28 | "test.")) |
Ahmad Sharif | 0dcbc4b | 2012-02-02 16:37:18 -0800 | [diff] [blame] | 29 | self.AddField(FloatField("outlier_range", default=0.2, |
| 30 | description="The percentage of highest/lowest " |
| 31 | "values to omit when computing the average.")) |
Luis Lozano | f81680c | 2013-03-15 14:44:13 -0700 | [diff] [blame] | 32 | self.AddField(BooleanField("rm_chroot_tmp", default=False, |
| 33 | description="Whether remove the run_remote_test" |
| 34 | "result in the chroot")) |
| 35 | self.AddField(BooleanField("key_results_only", default=True, |
| 36 | description="Whether only show the key results" |
| 37 | "of pyautoperf")) |
Ahmad Sharif | f395c26 | 2012-10-09 17:48:09 -0700 | [diff] [blame] | 38 | self.AddField(TextField("perf_args", default="", |
| 39 | description="The optional profile command. It " |
| 40 | "enables perf commands to record perforamance " |
| 41 | "related counters. It must start with perf " |
| 42 | "command record or stat followed by arguments.")) |
Yunlian Jiang | 04dc5dc | 2013-04-23 15:05:05 -0700 | [diff] [blame] | 43 | self.AddField(TextField("suite", default="pyauto", |
| 44 | description="The type of the benchmark")) |
Ahmad Sharif | 0dcbc4b | 2012-02-02 16:37:18 -0800 | [diff] [blame] | 45 | |
| 46 | |
| 47 | class LabelSettings(Settings): |
| 48 | def __init__(self, name): |
| 49 | super(LabelSettings, self).__init__(name, "label") |
| 50 | self.AddField(TextField("chromeos_image", required=True, |
| 51 | description="The path to the image to run tests " |
| 52 | "on.")) |
| 53 | self.AddField(TextField("chromeos_root", |
| 54 | description="The path to a chromeos checkout which " |
| 55 | "contains a src/scripts directory. Defaults to " |
| 56 | "the chromeos checkout which contains the " |
| 57 | "chromeos_image.")) |
Luis Lozano | f81680c | 2013-03-15 14:44:13 -0700 | [diff] [blame] | 58 | self.AddField(TextField("md5sum", default="", |
| 59 | description="The md5sum of this image")) |
Ahmad Sharif | 0dcbc4b | 2012-02-02 16:37:18 -0800 | [diff] [blame] | 60 | self.AddField(TextField("board", required=True, description="The target " |
| 61 | "board for running experiments on, e.g. x86-alex.")) |
Ahmad Sharif | 4467f00 | 2012-12-20 12:09:49 -0800 | [diff] [blame] | 62 | self.AddField(ListField("remote", description= |
| 63 | "A comma-separated list of ip's of chromeos" |
| 64 | "devices to run experiments on.")) |
| 65 | self.AddField(TextField("image_args", required=False, |
| 66 | default="", |
| 67 | description="Extra arguments to pass to " |
| 68 | "image_chromeos.py.")) |
Luis Lozano | f81680c | 2013-03-15 14:44:13 -0700 | [diff] [blame] | 69 | self.AddField(TextField("cache_dir", default="", |
| 70 | description="The cache dir for this image.")) |
Yunlian Jiang | 04dc5dc | 2013-04-23 15:05:05 -0700 | [diff] [blame] | 71 | self.AddField(TextField("chrome_src", |
| 72 | description="The path to the source of chrome. " |
| 73 | "This is used to run telemetry benchmarks. " |
| 74 | "The default one is the src inside chroot.", |
| 75 | required=False, default="")) |
Ahmad Sharif | 0dcbc4b | 2012-02-02 16:37:18 -0800 | [diff] [blame] | 76 | |
| 77 | |
| 78 | class GlobalSettings(Settings): |
| 79 | def __init__(self, name): |
| 80 | super(GlobalSettings, self).__init__(name, "global") |
Ahmad Sharif | 822c55d | 2012-02-08 20:55:47 -0800 | [diff] [blame] | 81 | self.AddField(TextField("name", |
Ahmad Sharif | 0dcbc4b | 2012-02-02 16:37:18 -0800 | [diff] [blame] | 82 | description="The name of the experiment. Just an " |
| 83 | "identifier.")) |
| 84 | self.AddField(TextField("board", description="The target " |
| 85 | "board for running experiments on, e.g. x86-alex.")) |
Ahmad Sharif | 4467f00 | 2012-12-20 12:09:49 -0800 | [diff] [blame] | 86 | self.AddField(ListField("remote", |
Ahmad Sharif | 0dcbc4b | 2012-02-02 16:37:18 -0800 | [diff] [blame] | 87 | description="A comma-separated list of ip's of " |
| 88 | "chromeos devices to run experiments on.")) |
| 89 | self.AddField(BooleanField("rerun_if_failed", description="Whether to " |
Yunlian Jiang | 04dc5dc | 2013-04-23 15:05:05 -0700 | [diff] [blame] | 90 | "re-run failed test runs or not.", |
Ahmad Sharif | 0dcbc4b | 2012-02-02 16:37:18 -0800 | [diff] [blame] | 91 | default=False)) |
Luis Lozano | f81680c | 2013-03-15 14:44:13 -0700 | [diff] [blame] | 92 | self.AddField(BooleanField("rm_chroot_tmp", default=False, |
| 93 | description="Whether remove the run_remote_test" |
| 94 | "result in the chroot")) |
Ahmad Sharif | f395c26 | 2012-10-09 17:48:09 -0700 | [diff] [blame] | 95 | self.AddField(ListField("email", description="Space-seperated" |
Ahmad Sharif | 4467f00 | 2012-12-20 12:09:49 -0800 | [diff] [blame] | 96 | "list of email addresses to send email to.")) |
Ahmad Sharif | 0dcbc4b | 2012-02-02 16:37:18 -0800 | [diff] [blame] | 97 | self.AddField(BooleanField("rerun", description="Whether to ignore the " |
Yunlian Jiang | 04dc5dc | 2013-04-23 15:05:05 -0700 | [diff] [blame] | 98 | "cache and for tests to be re-run.", |
Ahmad Sharif | 0dcbc4b | 2012-02-02 16:37:18 -0800 | [diff] [blame] | 99 | default=False)) |
Ahmad Sharif | 4467f00 | 2012-12-20 12:09:49 -0800 | [diff] [blame] | 100 | self.AddField(BooleanField("same_specs", default=True, |
Ahmad Sharif | 0dcbc4b | 2012-02-02 16:37:18 -0800 | [diff] [blame] | 101 | description="Ensure cached runs are run on the " |
Ahmad Sharif | 4467f00 | 2012-12-20 12:09:49 -0800 | [diff] [blame] | 102 | "same kind of devices which are specified as a " |
| 103 | "remote.")) |
| 104 | self.AddField(BooleanField("same_machine", default=False, |
| 105 | description="Ensure cached runs are run on the " |
| 106 | "exact the same remote")) |
Ahmad Sharif | ee988c8 | 2012-05-14 17:11:56 -0700 | [diff] [blame] | 107 | self.AddField(IntegerField("iterations", default=1, |
Ahmad Sharif | 0dcbc4b | 2012-02-02 16:37:18 -0800 | [diff] [blame] | 108 | description="Number of iterations to run all " |
Yunlian Jiang | 04dc5dc | 2013-04-23 15:05:05 -0700 | [diff] [blame] | 109 | "tests.")) |
Ahmad Sharif | 0dcbc4b | 2012-02-02 16:37:18 -0800 | [diff] [blame] | 110 | self.AddField(TextField("chromeos_root", |
| 111 | description="The path to a chromeos checkout which " |
| 112 | "contains a src/scripts directory. Defaults to " |
| 113 | "the chromeos checkout which contains the " |
| 114 | "chromeos_image.")) |
Luis Lozano | f81680c | 2013-03-15 14:44:13 -0700 | [diff] [blame] | 115 | self.AddField(BooleanField("key_results_only", default=True, |
| 116 | description="Whether only show the key results" |
| 117 | "of pyautoperf")) |
| 118 | self.AddField(IntegerField("acquire_timeout", default=0, |
| 119 | description="Number of seconds to wait for " |
| 120 | "machine before exit if all the machines in " |
| 121 | "the experiment file are busy. Default is 0")) |
Ahmad Sharif | f395c26 | 2012-10-09 17:48:09 -0700 | [diff] [blame] | 122 | self.AddField(TextField("perf_args", default="", |
| 123 | description="The optional profile command. It " |
| 124 | "enables perf commands to record perforamance " |
| 125 | "related counters. It must start with perf " |
| 126 | "command record or stat followed by arguments.")) |
Luis Lozano | f81680c | 2013-03-15 14:44:13 -0700 | [diff] [blame] | 127 | self.AddField(TextField("cache_dir", default="", |
| 128 | description="The abs path of cache dir. " |
| 129 | "Default is /home/$(whoami)/cros_scratch.")) |
| 130 | self.AddField(BooleanField("no_email", default=False, |
| 131 | description="Whether to disable the email to " |
| 132 | "user after crosperf finishes.")) |
| 133 | self.AddField(TextField("share_users", default="", |
| 134 | description="Who's cache data you want to " |
| 135 | "use. It accepts multiple users seperated by \",\"")) |
Yunlian Jiang | 00cc30e | 2013-03-28 13:23:57 -0700 | [diff] [blame] | 136 | self.AddField(TextField("results_dir", default="", |
| 137 | description="The results dir")) |
Yunlian Jiang | 04dc5dc | 2013-04-23 15:05:05 -0700 | [diff] [blame] | 138 | self.AddField(TextField("chrome_src", |
| 139 | description="The path to the source of chrome. " |
| 140 | "This is used to run telemetry benchmarks. " |
| 141 | "The default one is the src inside chroot.", |
| 142 | |
| 143 | required=False, default="")) |
Ahmad Sharif | 0dcbc4b | 2012-02-02 16:37:18 -0800 | [diff] [blame] | 144 | |
| 145 | |
| 146 | class SettingsFactory(object): |
| 147 | """Factory class for building different types of Settings objects. |
| 148 | |
| 149 | This factory is currently hardcoded to produce settings for ChromeOS |
| 150 | experiment files. The idea is that in the future, other types |
| 151 | of settings could be produced. |
| 152 | """ |
| 153 | |
| 154 | def GetSettings(self, name, settings_type): |
| 155 | if settings_type == "label" or not settings_type: |
| 156 | return LabelSettings(name) |
| 157 | if settings_type == "global": |
| 158 | return GlobalSettings(name) |
| 159 | if settings_type == "benchmark": |
| 160 | return BenchmarkSettings(name) |
| 161 | |
| 162 | raise Exception("Invalid settings type: '%s'." % settings_type) |