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