mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 1 | # Copyright Martin J. Bligh, Google Inc 2008 |
| 2 | # Released under the GPL v2 |
| 3 | |
| 4 | """ |
| 5 | This class allows you to communicate with the frontend to submit jobs etc |
| 6 | It is designed for writing more sophisiticated server-side control files that |
| 7 | can recursively add and manage other jobs. |
| 8 | |
| 9 | We turn the JSON dictionaries into real objects that are more idiomatic |
| 10 | |
mbligh | c31e402 | 2008-12-11 19:32:30 +0000 | [diff] [blame] | 11 | For docs, see: |
Aviv Keshet | 2c709f6 | 2013-05-07 12:52:15 -0700 | [diff] [blame] | 12 | http://www.chromium.org/chromium-os/testing/afe-rpc-infrastructure |
mbligh | c31e402 | 2008-12-11 19:32:30 +0000 | [diff] [blame] | 13 | http://docs.djangoproject.com/en/dev/ref/models/querysets/#queryset-api |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 14 | """ |
| 15 | |
mbligh | db59e3c | 2009-11-21 01:45:18 +0000 | [diff] [blame] | 16 | import getpass, os, time, traceback, re |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 17 | import common |
| 18 | from autotest_lib.frontend.afe import rpc_client_lib |
mbligh | 37eceaa | 2008-12-15 22:56:37 +0000 | [diff] [blame] | 19 | from autotest_lib.client.common_lib import global_config |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 20 | from autotest_lib.client.common_lib import utils |
Aviv Keshet | 3dd8beb | 2013-05-13 17:36:04 -0700 | [diff] [blame] | 21 | from autotest_lib.client.common_lib import control_data |
Scott Zawalski | 63470dd | 2012-09-05 00:49:43 -0400 | [diff] [blame] | 22 | from autotest_lib.tko import db |
| 23 | |
| 24 | |
mbligh | 4e57661 | 2008-12-22 14:56:36 +0000 | [diff] [blame] | 25 | try: |
| 26 | from autotest_lib.server.site_common import site_utils as server_utils |
| 27 | except: |
| 28 | from autotest_lib.server import utils as server_utils |
| 29 | form_ntuples_from_machines = server_utils.form_ntuples_from_machines |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 30 | |
mbligh | 37eceaa | 2008-12-15 22:56:37 +0000 | [diff] [blame] | 31 | GLOBAL_CONFIG = global_config.global_config |
| 32 | DEFAULT_SERVER = 'autotest' |
| 33 | |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 34 | def dump_object(header, obj): |
| 35 | """ |
| 36 | Standard way to print out the frontend objects (eg job, host, acl, label) |
| 37 | in a human-readable fashion for debugging |
| 38 | """ |
| 39 | result = header + '\n' |
| 40 | for key in obj.hash: |
| 41 | if key == 'afe' or key == 'hash': |
| 42 | continue |
| 43 | result += '%20s: %s\n' % (key, obj.hash[key]) |
| 44 | return result |
| 45 | |
| 46 | |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 47 | class RpcClient(object): |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 48 | """ |
mbligh | 451ede1 | 2009-02-12 21:54:03 +0000 | [diff] [blame] | 49 | Abstract RPC class for communicating with the autotest frontend |
| 50 | Inherited for both TKO and AFE uses. |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 51 | |
mbligh | 1ef218d | 2009-08-03 16:57:56 +0000 | [diff] [blame] | 52 | All the constructors go in the afe / tko class. |
mbligh | 451ede1 | 2009-02-12 21:54:03 +0000 | [diff] [blame] | 53 | Manipulating methods go in the object classes themselves |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 54 | """ |
mbligh | 99b24f4 | 2009-06-08 16:45:55 +0000 | [diff] [blame] | 55 | def __init__(self, path, user, server, print_log, debug, reply_debug): |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 56 | """ |
mbligh | 451ede1 | 2009-02-12 21:54:03 +0000 | [diff] [blame] | 57 | Create a cached instance of a connection to the frontend |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 58 | |
| 59 | user: username to connect as |
mbligh | 451ede1 | 2009-02-12 21:54:03 +0000 | [diff] [blame] | 60 | server: frontend server to connect to |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 61 | print_log: pring a logging message to stdout on every operation |
| 62 | debug: print out all RPC traffic |
| 63 | """ |
mbligh | c31e402 | 2008-12-11 19:32:30 +0000 | [diff] [blame] | 64 | if not user: |
mbligh | db59e3c | 2009-11-21 01:45:18 +0000 | [diff] [blame] | 65 | user = getpass.getuser() |
mbligh | 451ede1 | 2009-02-12 21:54:03 +0000 | [diff] [blame] | 66 | if not server: |
mbligh | 475f776 | 2009-01-30 00:34:04 +0000 | [diff] [blame] | 67 | if 'AUTOTEST_WEB' in os.environ: |
mbligh | 451ede1 | 2009-02-12 21:54:03 +0000 | [diff] [blame] | 68 | server = os.environ['AUTOTEST_WEB'] |
mbligh | 475f776 | 2009-01-30 00:34:04 +0000 | [diff] [blame] | 69 | else: |
mbligh | 451ede1 | 2009-02-12 21:54:03 +0000 | [diff] [blame] | 70 | server = GLOBAL_CONFIG.get_config_value('SERVER', 'hostname', |
| 71 | default=DEFAULT_SERVER) |
| 72 | self.server = server |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 73 | self.user = user |
| 74 | self.print_log = print_log |
| 75 | self.debug = debug |
mbligh | 99b24f4 | 2009-06-08 16:45:55 +0000 | [diff] [blame] | 76 | self.reply_debug = reply_debug |
Scott Zawalski | 347aaf4 | 2012-04-03 16:33:00 -0400 | [diff] [blame] | 77 | headers = {'AUTHORIZATION': self.user} |
| 78 | rpc_server = 'http://' + server + path |
mbligh | 1354c9d | 2008-12-22 14:56:13 +0000 | [diff] [blame] | 79 | if debug: |
| 80 | print 'SERVER: %s' % rpc_server |
| 81 | print 'HEADERS: %s' % headers |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 82 | self.proxy = rpc_client_lib.get_proxy(rpc_server, headers=headers) |
| 83 | |
| 84 | |
| 85 | def run(self, call, **dargs): |
| 86 | """ |
| 87 | Make a RPC call to the AFE server |
| 88 | """ |
| 89 | rpc_call = getattr(self.proxy, call) |
| 90 | if self.debug: |
| 91 | print 'DEBUG: %s %s' % (call, dargs) |
mbligh | 451ede1 | 2009-02-12 21:54:03 +0000 | [diff] [blame] | 92 | try: |
mbligh | 99b24f4 | 2009-06-08 16:45:55 +0000 | [diff] [blame] | 93 | result = utils.strip_unicode(rpc_call(**dargs)) |
| 94 | if self.reply_debug: |
| 95 | print result |
| 96 | return result |
mbligh | 451ede1 | 2009-02-12 21:54:03 +0000 | [diff] [blame] | 97 | except Exception: |
| 98 | print 'FAILED RPC CALL: %s %s' % (call, dargs) |
| 99 | raise |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 100 | |
| 101 | |
| 102 | def log(self, message): |
| 103 | if self.print_log: |
| 104 | print message |
| 105 | |
| 106 | |
jamesren | c394022 | 2010-02-19 21:57:37 +0000 | [diff] [blame] | 107 | class Planner(RpcClient): |
| 108 | def __init__(self, user=None, server=None, print_log=True, debug=False, |
| 109 | reply_debug=False): |
| 110 | super(Planner, self).__init__(path='/planner/server/rpc/', |
| 111 | user=user, |
| 112 | server=server, |
| 113 | print_log=print_log, |
| 114 | debug=debug, |
| 115 | reply_debug=reply_debug) |
| 116 | |
| 117 | |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 118 | class TKO(RpcClient): |
mbligh | 99b24f4 | 2009-06-08 16:45:55 +0000 | [diff] [blame] | 119 | def __init__(self, user=None, server=None, print_log=True, debug=False, |
| 120 | reply_debug=False): |
Scott Zawalski | 347aaf4 | 2012-04-03 16:33:00 -0400 | [diff] [blame] | 121 | super(TKO, self).__init__(path='/new_tko/server/noauth/rpc/', |
mbligh | 99b24f4 | 2009-06-08 16:45:55 +0000 | [diff] [blame] | 122 | user=user, |
| 123 | server=server, |
| 124 | print_log=print_log, |
| 125 | debug=debug, |
| 126 | reply_debug=reply_debug) |
Scott Zawalski | 63470dd | 2012-09-05 00:49:43 -0400 | [diff] [blame] | 127 | self._db = None |
| 128 | |
| 129 | |
| 130 | def get_job_test_statuses_from_db(self, job_id): |
| 131 | """Get job test statuses from the database. |
| 132 | |
| 133 | Retrieve a set of fields from a job that reflect the status of each test |
| 134 | run within a job. |
| 135 | fields retrieved: status, test_name, reason, test_started_time, |
| 136 | test_finished_time, afe_job_id, job_owner, hostname. |
| 137 | |
| 138 | @param job_id: The afe job id to look up. |
| 139 | @returns a TestStatus object of the resulting information. |
| 140 | """ |
| 141 | if self._db is None: |
| 142 | self._db = db.db() |
Fang Deng | 5c50833 | 2014-03-19 10:26:00 -0700 | [diff] [blame] | 143 | fields = ['status', 'test_name', 'subdir', 'reason', |
| 144 | 'test_started_time', 'test_finished_time', 'afe_job_id', |
| 145 | 'job_owner', 'hostname', 'job_tag'] |
Scott Zawalski | 63470dd | 2012-09-05 00:49:43 -0400 | [diff] [blame] | 146 | table = 'tko_test_view_2' |
| 147 | where = 'job_tag like "%s-%%"' % job_id |
| 148 | test_status = [] |
| 149 | # Run commit before we query to ensure that we are pulling the latest |
| 150 | # results. |
| 151 | self._db.commit() |
| 152 | for entry in self._db.select(','.join(fields), table, (where, None)): |
| 153 | status_dict = {} |
| 154 | for key,value in zip(fields, entry): |
| 155 | # All callers expect values to be a str object. |
| 156 | status_dict[key] = str(value) |
| 157 | # id is used by TestStatus to uniquely identify each Test Status |
| 158 | # obj. |
| 159 | status_dict['id'] = [status_dict['reason'], status_dict['hostname'], |
| 160 | status_dict['test_name']] |
| 161 | test_status.append(status_dict) |
| 162 | |
| 163 | return [TestStatus(self, e) for e in test_status] |
mbligh | c31e402 | 2008-12-11 19:32:30 +0000 | [diff] [blame] | 164 | |
| 165 | |
| 166 | def get_status_counts(self, job, **data): |
| 167 | entries = self.run('get_status_counts', |
mbligh | 1ef218d | 2009-08-03 16:57:56 +0000 | [diff] [blame] | 168 | group_by=['hostname', 'test_name', 'reason'], |
mbligh | c31e402 | 2008-12-11 19:32:30 +0000 | [diff] [blame] | 169 | job_tag__startswith='%s-' % job, **data) |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 170 | return [TestStatus(self, e) for e in entries['groups']] |
mbligh | c31e402 | 2008-12-11 19:32:30 +0000 | [diff] [blame] | 171 | |
| 172 | |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 173 | class AFE(RpcClient): |
mbligh | 17c75e6 | 2009-06-08 16:18:21 +0000 | [diff] [blame] | 174 | def __init__(self, user=None, server=None, print_log=True, debug=False, |
mbligh | 99b24f4 | 2009-06-08 16:45:55 +0000 | [diff] [blame] | 175 | reply_debug=False, job=None): |
mbligh | 17c75e6 | 2009-06-08 16:18:21 +0000 | [diff] [blame] | 176 | self.job = job |
Scott Zawalski | 347aaf4 | 2012-04-03 16:33:00 -0400 | [diff] [blame] | 177 | super(AFE, self).__init__(path='/afe/server/noauth/rpc/', |
mbligh | 99b24f4 | 2009-06-08 16:45:55 +0000 | [diff] [blame] | 178 | user=user, |
| 179 | server=server, |
| 180 | print_log=print_log, |
| 181 | debug=debug, |
| 182 | reply_debug=reply_debug) |
mbligh | c31e402 | 2008-12-11 19:32:30 +0000 | [diff] [blame] | 183 | |
mbligh | 1ef218d | 2009-08-03 16:57:56 +0000 | [diff] [blame] | 184 | |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 185 | def host_statuses(self, live=None): |
jamesren | 121eee6 | 2010-04-13 19:10:12 +0000 | [diff] [blame] | 186 | dead_statuses = ['Repair Failed', 'Repairing'] |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 187 | statuses = self.run('get_static_data')['host_statuses'] |
| 188 | if live == True: |
mbligh | c2847b7 | 2009-03-25 19:32:20 +0000 | [diff] [blame] | 189 | return list(set(statuses) - set(dead_statuses)) |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 190 | if live == False: |
| 191 | return dead_statuses |
| 192 | else: |
| 193 | return statuses |
| 194 | |
| 195 | |
mbligh | 7109401 | 2009-12-19 05:35:21 +0000 | [diff] [blame] | 196 | @staticmethod |
| 197 | def _dict_for_host_query(hostnames=(), status=None, label=None): |
| 198 | query_args = {} |
mbligh | 4e545a5 | 2009-12-19 05:30:39 +0000 | [diff] [blame] | 199 | if hostnames: |
| 200 | query_args['hostname__in'] = hostnames |
| 201 | if status: |
| 202 | query_args['status'] = status |
| 203 | if label: |
| 204 | query_args['labels__name'] = label |
mbligh | 7109401 | 2009-12-19 05:35:21 +0000 | [diff] [blame] | 205 | return query_args |
| 206 | |
| 207 | |
| 208 | def get_hosts(self, hostnames=(), status=None, label=None, **dargs): |
| 209 | query_args = dict(dargs) |
| 210 | query_args.update(self._dict_for_host_query(hostnames=hostnames, |
| 211 | status=status, |
| 212 | label=label)) |
| 213 | hosts = self.run('get_hosts', **query_args) |
| 214 | return [Host(self, h) for h in hosts] |
| 215 | |
| 216 | |
| 217 | def get_hostnames(self, status=None, label=None, **dargs): |
| 218 | """Like get_hosts() but returns hostnames instead of Host objects.""" |
| 219 | # This implementation can be replaced with a more efficient one |
| 220 | # that does not query for entire host objects in the future. |
| 221 | return [host_obj.hostname for host_obj in |
| 222 | self.get_hosts(status=status, label=label, **dargs)] |
| 223 | |
| 224 | |
| 225 | def reverify_hosts(self, hostnames=(), status=None, label=None): |
| 226 | query_args = dict(locked=False, |
| 227 | aclgroup__users__login=self.user) |
| 228 | query_args.update(self._dict_for_host_query(hostnames=hostnames, |
| 229 | status=status, |
| 230 | label=label)) |
mbligh | 4e545a5 | 2009-12-19 05:30:39 +0000 | [diff] [blame] | 231 | return self.run('reverify_hosts', **query_args) |
| 232 | |
| 233 | |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 234 | def create_host(self, hostname, **dargs): |
mbligh | 54459c7 | 2009-01-21 19:26:44 +0000 | [diff] [blame] | 235 | id = self.run('add_host', hostname=hostname, **dargs) |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 236 | return self.get_hosts(id=id)[0] |
| 237 | |
| 238 | |
MK Ryu | acf3592 | 2014-10-03 14:56:49 -0700 | [diff] [blame] | 239 | def get_host_attribute(self, attr, **dargs): |
| 240 | host_attrs = self.run('get_host_attribute', attribute=attr, **dargs) |
| 241 | return [HostAttribute(self, a) for a in host_attrs] |
| 242 | |
| 243 | |
Chris Masone | 8abb6fc | 2012-01-31 09:27:36 -0800 | [diff] [blame] | 244 | def set_host_attribute(self, attr, val, **dargs): |
| 245 | self.run('set_host_attribute', attribute=attr, value=val, **dargs) |
| 246 | |
| 247 | |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 248 | def get_labels(self, **dargs): |
| 249 | labels = self.run('get_labels', **dargs) |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 250 | return [Label(self, l) for l in labels] |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 251 | |
| 252 | |
| 253 | def create_label(self, name, **dargs): |
mbligh | 54459c7 | 2009-01-21 19:26:44 +0000 | [diff] [blame] | 254 | id = self.run('add_label', name=name, **dargs) |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 255 | return self.get_labels(id=id)[0] |
| 256 | |
| 257 | |
| 258 | def get_acls(self, **dargs): |
| 259 | acls = self.run('get_acl_groups', **dargs) |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 260 | return [Acl(self, a) for a in acls] |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 261 | |
| 262 | |
| 263 | def create_acl(self, name, **dargs): |
mbligh | 54459c7 | 2009-01-21 19:26:44 +0000 | [diff] [blame] | 264 | id = self.run('add_acl_group', name=name, **dargs) |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 265 | return self.get_acls(id=id)[0] |
| 266 | |
| 267 | |
mbligh | 54459c7 | 2009-01-21 19:26:44 +0000 | [diff] [blame] | 268 | def get_users(self, **dargs): |
| 269 | users = self.run('get_users', **dargs) |
| 270 | return [User(self, u) for u in users] |
| 271 | |
| 272 | |
mbligh | 1354c9d | 2008-12-22 14:56:13 +0000 | [diff] [blame] | 273 | def generate_control_file(self, tests, **dargs): |
| 274 | ret = self.run('generate_control_file', tests=tests, **dargs) |
| 275 | return ControlFile(self, ret) |
| 276 | |
| 277 | |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 278 | def get_jobs(self, summary=False, **dargs): |
| 279 | if summary: |
| 280 | jobs_data = self.run('get_jobs_summary', **dargs) |
| 281 | else: |
| 282 | jobs_data = self.run('get_jobs', **dargs) |
mbligh | afbba0c | 2009-06-08 16:44:45 +0000 | [diff] [blame] | 283 | jobs = [] |
| 284 | for j in jobs_data: |
| 285 | job = Job(self, j) |
| 286 | # Set up some extra information defaults |
| 287 | job.testname = re.sub('\s.*', '', job.name) # arbitrary default |
| 288 | job.platform_results = {} |
| 289 | job.platform_reasons = {} |
| 290 | jobs.append(job) |
| 291 | return jobs |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 292 | |
| 293 | |
| 294 | def get_host_queue_entries(self, **data): |
| 295 | entries = self.run('get_host_queue_entries', **data) |
mbligh | f9e3586 | 2009-02-26 01:03:11 +0000 | [diff] [blame] | 296 | job_statuses = [JobStatus(self, e) for e in entries] |
mbligh | 99b24f4 | 2009-06-08 16:45:55 +0000 | [diff] [blame] | 297 | |
| 298 | # Sadly, get_host_queue_entries doesn't return platforms, we have |
| 299 | # to get those back from an explicit get_hosts queury, then patch |
| 300 | # the new host objects back into the host list. |
| 301 | hostnames = [s.host.hostname for s in job_statuses if s.host] |
| 302 | host_hash = {} |
| 303 | for host in self.get_hosts(hostname__in=hostnames): |
| 304 | host_hash[host.hostname] = host |
| 305 | for status in job_statuses: |
| 306 | if status.host: |
Fang Deng | 97dafbc | 2015-04-23 23:06:18 -0700 | [diff] [blame] | 307 | status.host = host_hash.get(status.host.hostname) |
mbligh | f9e3586 | 2009-02-26 01:03:11 +0000 | [diff] [blame] | 308 | # filter job statuses that have either host or meta_host |
| 309 | return [status for status in job_statuses if (status.host or |
| 310 | status.meta_host)] |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 311 | |
| 312 | |
MK Ryu | 1b2d7f9 | 2015-02-24 17:45:02 -0800 | [diff] [blame] | 313 | def get_special_tasks(self, **data): |
| 314 | tasks = self.run('get_special_tasks', **data) |
| 315 | return [SpecialTask(self, t) for t in tasks] |
| 316 | |
| 317 | |
J. Richard Barnette | 9f10c9f | 2015-04-13 16:44:50 -0700 | [diff] [blame] | 318 | def get_host_special_tasks(self, host_id, **data): |
| 319 | tasks = self.run('get_host_special_tasks', |
| 320 | host_id=host_id, **data) |
| 321 | return [SpecialTask(self, t) for t in tasks] |
| 322 | |
| 323 | |
J. Richard Barnette | 8dbd6d3 | 2015-05-01 11:01:12 -0700 | [diff] [blame] | 324 | def get_host_status_task(self, host_id, end_time): |
| 325 | task = self.run('get_host_status_task', |
J. Richard Barnette | bc9a795 | 2015-04-16 17:43:27 -0700 | [diff] [blame] | 326 | host_id=host_id, end_time=end_time) |
| 327 | return SpecialTask(self, task) if task else None |
| 328 | |
| 329 | |
mbligh | b9db516 | 2009-04-17 22:21:41 +0000 | [diff] [blame] | 330 | def create_job_by_test(self, tests, kernel=None, use_container=False, |
Eric Li | e0493a4 | 2010-11-15 13:05:43 -0800 | [diff] [blame] | 331 | kernel_cmdline=None, **dargs): |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 332 | """ |
| 333 | Given a test name, fetch the appropriate control file from the server |
mbligh | 4e57661 | 2008-12-22 14:56:36 +0000 | [diff] [blame] | 334 | and submit it. |
| 335 | |
Eric Li | e0493a4 | 2010-11-15 13:05:43 -0800 | [diff] [blame] | 336 | @param kernel: A comma separated list of kernel versions to boot. |
| 337 | @param kernel_cmdline: The command line used to boot all kernels listed |
| 338 | in the kernel parameter. |
| 339 | |
mbligh | 4e57661 | 2008-12-22 14:56:36 +0000 | [diff] [blame] | 340 | Returns a list of job objects |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 341 | """ |
mbligh | b9db516 | 2009-04-17 22:21:41 +0000 | [diff] [blame] | 342 | assert ('hosts' in dargs or |
| 343 | 'atomic_group_name' in dargs and 'synch_count' in dargs) |
showard | a2cd72b | 2009-10-01 18:43:53 +0000 | [diff] [blame] | 344 | if kernel: |
| 345 | kernel_list = re.split('[\s,]+', kernel.strip()) |
Eric Li | e0493a4 | 2010-11-15 13:05:43 -0800 | [diff] [blame] | 346 | kernel_info = [] |
| 347 | for version in kernel_list: |
| 348 | kernel_dict = {'version': version} |
| 349 | if kernel_cmdline is not None: |
| 350 | kernel_dict['cmdline'] = kernel_cmdline |
| 351 | kernel_info.append(kernel_dict) |
showard | a2cd72b | 2009-10-01 18:43:53 +0000 | [diff] [blame] | 352 | else: |
| 353 | kernel_info = None |
| 354 | control_file = self.generate_control_file( |
Dale Curtis | 74a314b | 2011-06-23 14:55:46 -0700 | [diff] [blame] | 355 | tests=tests, kernel=kernel_info, use_container=use_container) |
mbligh | 1354c9d | 2008-12-22 14:56:13 +0000 | [diff] [blame] | 356 | if control_file.is_server: |
Aviv Keshet | 3dd8beb | 2013-05-13 17:36:04 -0700 | [diff] [blame] | 357 | dargs['control_type'] = control_data.CONTROL_TYPE_NAMES.SERVER |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 358 | else: |
Aviv Keshet | 3dd8beb | 2013-05-13 17:36:04 -0700 | [diff] [blame] | 359 | dargs['control_type'] = control_data.CONTROL_TYPE_NAMES.CLIENT |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 360 | dargs['dependencies'] = dargs.get('dependencies', []) + \ |
mbligh | 1354c9d | 2008-12-22 14:56:13 +0000 | [diff] [blame] | 361 | control_file.dependencies |
| 362 | dargs['control_file'] = control_file.control_file |
mbligh | 672666c | 2009-07-28 23:22:13 +0000 | [diff] [blame] | 363 | if not dargs.get('synch_count', None): |
mbligh | c99fccf | 2009-07-11 00:59:33 +0000 | [diff] [blame] | 364 | dargs['synch_count'] = control_file.synch_count |
mbligh | b9db516 | 2009-04-17 22:21:41 +0000 | [diff] [blame] | 365 | if 'hosts' in dargs and len(dargs['hosts']) < dargs['synch_count']: |
| 366 | # will not be able to satisfy this request |
mbligh | 38b0915 | 2009-04-28 18:34:25 +0000 | [diff] [blame] | 367 | return None |
| 368 | return self.create_job(**dargs) |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 369 | |
| 370 | |
| 371 | def create_job(self, control_file, name=' ', priority='Medium', |
Aviv Keshet | 3dd8beb | 2013-05-13 17:36:04 -0700 | [diff] [blame] | 372 | control_type=control_data.CONTROL_TYPE_NAMES.CLIENT, **dargs): |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 373 | id = self.run('create_job', name=name, priority=priority, |
| 374 | control_file=control_file, control_type=control_type, **dargs) |
| 375 | return self.get_jobs(id=id)[0] |
| 376 | |
| 377 | |
mbligh | 282ce89 | 2010-01-06 18:40:17 +0000 | [diff] [blame] | 378 | def run_test_suites(self, pairings, kernel, kernel_label=None, |
| 379 | priority='Medium', wait=True, poll_interval=10, |
Simran Basi | 7e60574 | 2013-11-12 13:43:36 -0800 | [diff] [blame] | 380 | email_from=None, email_to=None, timeout_mins=10080, |
Simran Basi | 3421702 | 2012-11-06 13:43:15 -0800 | [diff] [blame] | 381 | max_runtime_mins=10080, kernel_cmdline=None): |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 382 | """ |
| 383 | Run a list of test suites on a particular kernel. |
mbligh | 1ef218d | 2009-08-03 16:57:56 +0000 | [diff] [blame] | 384 | |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 385 | Poll for them to complete, and return whether they worked or not. |
mbligh | 1ef218d | 2009-08-03 16:57:56 +0000 | [diff] [blame] | 386 | |
mbligh | 282ce89 | 2010-01-06 18:40:17 +0000 | [diff] [blame] | 387 | @param pairings: List of MachineTestPairing objects to invoke. |
| 388 | @param kernel: Name of the kernel to run. |
| 389 | @param kernel_label: Label (string) of the kernel to run such as |
| 390 | '<kernel-version> : <config> : <date>' |
| 391 | If any pairing object has its job_label attribute set it |
| 392 | will override this value for that particular job. |
Eric Li | e0493a4 | 2010-11-15 13:05:43 -0800 | [diff] [blame] | 393 | @param kernel_cmdline: The command line to boot the kernel(s) with. |
mbligh | 282ce89 | 2010-01-06 18:40:17 +0000 | [diff] [blame] | 394 | @param wait: boolean - Wait for the results to come back? |
| 395 | @param poll_interval: Interval between polling for job results (in mins) |
| 396 | @param email_from: Send notification email upon completion from here. |
| 397 | @param email_from: Send notification email upon completion to here. |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 398 | """ |
| 399 | jobs = [] |
| 400 | for pairing in pairings: |
mbligh | 0c4f8d7 | 2009-05-12 20:52:18 +0000 | [diff] [blame] | 401 | try: |
| 402 | new_job = self.invoke_test(pairing, kernel, kernel_label, |
Simran Basi | 7e60574 | 2013-11-12 13:43:36 -0800 | [diff] [blame] | 403 | priority, timeout_mins=timeout_mins, |
Eric Li | e0493a4 | 2010-11-15 13:05:43 -0800 | [diff] [blame] | 404 | kernel_cmdline=kernel_cmdline, |
Simran Basi | 3421702 | 2012-11-06 13:43:15 -0800 | [diff] [blame] | 405 | max_runtime_mins=max_runtime_mins) |
mbligh | 0c4f8d7 | 2009-05-12 20:52:18 +0000 | [diff] [blame] | 406 | if not new_job: |
| 407 | continue |
mbligh | 0c4f8d7 | 2009-05-12 20:52:18 +0000 | [diff] [blame] | 408 | jobs.append(new_job) |
| 409 | except Exception, e: |
| 410 | traceback.print_exc() |
mbligh | b9db516 | 2009-04-17 22:21:41 +0000 | [diff] [blame] | 411 | if not wait or not jobs: |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 412 | return |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 413 | tko = TKO() |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 414 | while True: |
| 415 | time.sleep(60 * poll_interval) |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 416 | result = self.poll_all_jobs(tko, jobs, email_from, email_to) |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 417 | if result is not None: |
| 418 | return result |
| 419 | |
| 420 | |
mbligh | 45ffc43 | 2008-12-09 23:35:17 +0000 | [diff] [blame] | 421 | def result_notify(self, job, email_from, email_to): |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 422 | """ |
mbligh | 45ffc43 | 2008-12-09 23:35:17 +0000 | [diff] [blame] | 423 | Notify about the result of a job. Will always print, if email data |
| 424 | is provided, will send email for it as well. |
| 425 | |
| 426 | job: job object to notify about |
| 427 | email_from: send notification email upon completion from here |
| 428 | email_from: send notification email upon completion to here |
| 429 | """ |
| 430 | if job.result == True: |
| 431 | subject = 'Testing PASSED: ' |
| 432 | else: |
| 433 | subject = 'Testing FAILED: ' |
| 434 | subject += '%s : %s\n' % (job.name, job.id) |
| 435 | text = [] |
| 436 | for platform in job.results_platform_map: |
| 437 | for status in job.results_platform_map[platform]: |
| 438 | if status == 'Total': |
| 439 | continue |
mbligh | 451ede1 | 2009-02-12 21:54:03 +0000 | [diff] [blame] | 440 | for host in job.results_platform_map[platform][status]: |
| 441 | text.append('%20s %10s %10s' % (platform, status, host)) |
| 442 | if status == 'Failed': |
| 443 | for test_status in job.test_status[host].fail: |
| 444 | text.append('(%s, %s) : %s' % \ |
| 445 | (host, test_status.test_name, |
| 446 | test_status.reason)) |
| 447 | text.append('') |
mbligh | 37eceaa | 2008-12-15 22:56:37 +0000 | [diff] [blame] | 448 | |
mbligh | 451ede1 | 2009-02-12 21:54:03 +0000 | [diff] [blame] | 449 | base_url = 'http://' + self.server |
mbligh | 37eceaa | 2008-12-15 22:56:37 +0000 | [diff] [blame] | 450 | |
| 451 | params = ('columns=test', |
| 452 | 'rows=machine_group', |
| 453 | "condition=tag~'%s-%%25'" % job.id, |
| 454 | 'title=Report') |
| 455 | query_string = '&'.join(params) |
mbligh | 451ede1 | 2009-02-12 21:54:03 +0000 | [diff] [blame] | 456 | url = '%s/tko/compose_query.cgi?%s' % (base_url, query_string) |
| 457 | text.append(url + '\n') |
| 458 | url = '%s/afe/#tab_id=view_job&object_id=%s' % (base_url, job.id) |
| 459 | text.append(url + '\n') |
mbligh | 37eceaa | 2008-12-15 22:56:37 +0000 | [diff] [blame] | 460 | |
| 461 | body = '\n'.join(text) |
| 462 | print '---------------------------------------------------' |
| 463 | print 'Subject: ', subject |
mbligh | 45ffc43 | 2008-12-09 23:35:17 +0000 | [diff] [blame] | 464 | print body |
mbligh | 37eceaa | 2008-12-15 22:56:37 +0000 | [diff] [blame] | 465 | print '---------------------------------------------------' |
mbligh | 45ffc43 | 2008-12-09 23:35:17 +0000 | [diff] [blame] | 466 | if email_from and email_to: |
mbligh | 37eceaa | 2008-12-15 22:56:37 +0000 | [diff] [blame] | 467 | print 'Sending email ...' |
mbligh | 45ffc43 | 2008-12-09 23:35:17 +0000 | [diff] [blame] | 468 | utils.send_email(email_from, email_to, subject, body) |
| 469 | print |
mbligh | 37eceaa | 2008-12-15 22:56:37 +0000 | [diff] [blame] | 470 | |
mbligh | 45ffc43 | 2008-12-09 23:35:17 +0000 | [diff] [blame] | 471 | |
mbligh | 1354c9d | 2008-12-22 14:56:13 +0000 | [diff] [blame] | 472 | def print_job_result(self, job): |
| 473 | """ |
| 474 | Print the result of a single job. |
| 475 | job: a job object |
| 476 | """ |
| 477 | if job.result is None: |
| 478 | print 'PENDING', |
| 479 | elif job.result == True: |
| 480 | print 'PASSED', |
| 481 | elif job.result == False: |
| 482 | print 'FAILED', |
mbligh | 912c3f3 | 2009-03-25 19:31:30 +0000 | [diff] [blame] | 483 | elif job.result == "Abort": |
| 484 | print 'ABORT', |
mbligh | 1354c9d | 2008-12-22 14:56:13 +0000 | [diff] [blame] | 485 | print ' %s : %s' % (job.id, job.name) |
| 486 | |
| 487 | |
mbligh | 451ede1 | 2009-02-12 21:54:03 +0000 | [diff] [blame] | 488 | def poll_all_jobs(self, tko, jobs, email_from=None, email_to=None): |
mbligh | 45ffc43 | 2008-12-09 23:35:17 +0000 | [diff] [blame] | 489 | """ |
| 490 | Poll all jobs in a list. |
| 491 | jobs: list of job objects to poll |
| 492 | email_from: send notification email upon completion from here |
| 493 | email_from: send notification email upon completion to here |
| 494 | |
| 495 | Returns: |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 496 | a) All complete successfully (return True) |
| 497 | b) One or more has failed (return False) |
| 498 | c) Cannot tell yet (return None) |
| 499 | """ |
mbligh | 45ffc43 | 2008-12-09 23:35:17 +0000 | [diff] [blame] | 500 | results = [] |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 501 | for job in jobs: |
mbligh | 676dcbe | 2009-06-15 21:57:27 +0000 | [diff] [blame] | 502 | if getattr(job, 'result', None) is None: |
Chris Masone | 6fed646 | 2011-10-20 16:36:43 -0700 | [diff] [blame] | 503 | job.result = self.poll_job_results(tko, job) |
mbligh | 676dcbe | 2009-06-15 21:57:27 +0000 | [diff] [blame] | 504 | if job.result is not None: |
| 505 | self.result_notify(job, email_from, email_to) |
mbligh | 45ffc43 | 2008-12-09 23:35:17 +0000 | [diff] [blame] | 506 | |
mbligh | 676dcbe | 2009-06-15 21:57:27 +0000 | [diff] [blame] | 507 | results.append(job.result) |
mbligh | 1354c9d | 2008-12-22 14:56:13 +0000 | [diff] [blame] | 508 | self.print_job_result(job) |
mbligh | 45ffc43 | 2008-12-09 23:35:17 +0000 | [diff] [blame] | 509 | |
| 510 | if None in results: |
| 511 | return None |
mbligh | 912c3f3 | 2009-03-25 19:31:30 +0000 | [diff] [blame] | 512 | elif False in results or "Abort" in results: |
mbligh | 45ffc43 | 2008-12-09 23:35:17 +0000 | [diff] [blame] | 513 | return False |
| 514 | else: |
| 515 | return True |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 516 | |
| 517 | |
mbligh | 1f23f36 | 2008-12-22 14:46:12 +0000 | [diff] [blame] | 518 | def _included_platform(self, host, platforms): |
| 519 | """ |
| 520 | See if host's platforms matches any of the patterns in the included |
| 521 | platforms list. |
| 522 | """ |
| 523 | if not platforms: |
| 524 | return True # No filtering of platforms |
| 525 | for platform in platforms: |
| 526 | if re.search(platform, host.platform): |
| 527 | return True |
| 528 | return False |
| 529 | |
| 530 | |
mbligh | 7b31228 | 2009-01-07 16:45:43 +0000 | [diff] [blame] | 531 | def invoke_test(self, pairing, kernel, kernel_label, priority='Medium', |
Eric Li | e0493a4 | 2010-11-15 13:05:43 -0800 | [diff] [blame] | 532 | kernel_cmdline=None, **dargs): |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 533 | """ |
| 534 | Given a pairing of a control file to a machine label, find all machines |
| 535 | with that label, and submit that control file to them. |
mbligh | 1ef218d | 2009-08-03 16:57:56 +0000 | [diff] [blame] | 536 | |
mbligh | 282ce89 | 2010-01-06 18:40:17 +0000 | [diff] [blame] | 537 | @param kernel_label: Label (string) of the kernel to run such as |
| 538 | '<kernel-version> : <config> : <date>' |
| 539 | If any pairing object has its job_label attribute set it |
| 540 | will override this value for that particular job. |
| 541 | |
| 542 | @returns A list of job objects. |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 543 | """ |
mbligh | 282ce89 | 2010-01-06 18:40:17 +0000 | [diff] [blame] | 544 | # The pairing can override the job label. |
| 545 | if pairing.job_label: |
| 546 | kernel_label = pairing.job_label |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 547 | job_name = '%s : %s' % (pairing.machine_label, kernel_label) |
| 548 | hosts = self.get_hosts(multiple_labels=[pairing.machine_label]) |
mbligh | 1f23f36 | 2008-12-22 14:46:12 +0000 | [diff] [blame] | 549 | platforms = pairing.platforms |
| 550 | hosts = [h for h in hosts if self._included_platform(h, platforms)] |
mbligh | c2847b7 | 2009-03-25 19:32:20 +0000 | [diff] [blame] | 551 | dead_statuses = self.host_statuses(live=False) |
| 552 | host_list = [h.hostname for h in hosts if h.status not in dead_statuses] |
mbligh | 1f23f36 | 2008-12-22 14:46:12 +0000 | [diff] [blame] | 553 | print 'HOSTS: %s' % host_list |
mbligh | b9db516 | 2009-04-17 22:21:41 +0000 | [diff] [blame] | 554 | if pairing.atomic_group_sched: |
mbligh | c99fccf | 2009-07-11 00:59:33 +0000 | [diff] [blame] | 555 | dargs['synch_count'] = pairing.synch_count |
mbligh | b9db516 | 2009-04-17 22:21:41 +0000 | [diff] [blame] | 556 | dargs['atomic_group_name'] = pairing.machine_label |
| 557 | else: |
| 558 | dargs['hosts'] = host_list |
mbligh | 38b0915 | 2009-04-28 18:34:25 +0000 | [diff] [blame] | 559 | new_job = self.create_job_by_test(name=job_name, |
mbligh | 17c75e6 | 2009-06-08 16:18:21 +0000 | [diff] [blame] | 560 | dependencies=[pairing.machine_label], |
| 561 | tests=[pairing.control_file], |
| 562 | priority=priority, |
| 563 | kernel=kernel, |
Eric Li | e0493a4 | 2010-11-15 13:05:43 -0800 | [diff] [blame] | 564 | kernel_cmdline=kernel_cmdline, |
mbligh | 17c75e6 | 2009-06-08 16:18:21 +0000 | [diff] [blame] | 565 | use_container=pairing.container, |
| 566 | **dargs) |
mbligh | 38b0915 | 2009-04-28 18:34:25 +0000 | [diff] [blame] | 567 | if new_job: |
mbligh | 17c75e6 | 2009-06-08 16:18:21 +0000 | [diff] [blame] | 568 | if pairing.testname: |
| 569 | new_job.testname = pairing.testname |
mbligh | 4e57661 | 2008-12-22 14:56:36 +0000 | [diff] [blame] | 570 | print 'Invoked test %s : %s' % (new_job.id, job_name) |
mbligh | 38b0915 | 2009-04-28 18:34:25 +0000 | [diff] [blame] | 571 | return new_job |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 572 | |
| 573 | |
mbligh | b9db516 | 2009-04-17 22:21:41 +0000 | [diff] [blame] | 574 | def _job_test_results(self, tko, job, debug, tests=[]): |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 575 | """ |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 576 | Retrieve test results for a job |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 577 | """ |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 578 | job.test_status = {} |
| 579 | try: |
| 580 | test_statuses = tko.get_status_counts(job=job.id) |
| 581 | except Exception: |
| 582 | print "Ignoring exception on poll job; RPC interface is flaky" |
| 583 | traceback.print_exc() |
| 584 | return |
| 585 | |
| 586 | for test_status in test_statuses: |
mbligh | 7479a18 | 2009-01-07 16:46:24 +0000 | [diff] [blame] | 587 | # SERVER_JOB is buggy, and often gives false failures. Ignore it. |
| 588 | if test_status.test_name == 'SERVER_JOB': |
| 589 | continue |
mbligh | b9db516 | 2009-04-17 22:21:41 +0000 | [diff] [blame] | 590 | # if tests is not empty, restrict list of test_statuses to tests |
| 591 | if tests and test_status.test_name not in tests: |
| 592 | continue |
mbligh | 451ede1 | 2009-02-12 21:54:03 +0000 | [diff] [blame] | 593 | if debug: |
| 594 | print test_status |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 595 | hostname = test_status.hostname |
| 596 | if hostname not in job.test_status: |
| 597 | job.test_status[hostname] = TestResults() |
| 598 | job.test_status[hostname].add(test_status) |
| 599 | |
| 600 | |
mbligh | 451ede1 | 2009-02-12 21:54:03 +0000 | [diff] [blame] | 601 | def _job_results_platform_map(self, job, debug): |
mbligh | c9e427e | 2009-04-28 18:35:06 +0000 | [diff] [blame] | 602 | # Figure out which hosts passed / failed / aborted in a job |
| 603 | # Creates a 2-dimensional hash, stored as job.results_platform_map |
| 604 | # 1st index - platform type (string) |
| 605 | # 2nd index - Status (string) |
| 606 | # 'Completed' / 'Failed' / 'Aborted' |
| 607 | # Data indexed by this hash is a list of hostnames (text strings) |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 608 | job.results_platform_map = {} |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 609 | try: |
mbligh | 45ffc43 | 2008-12-09 23:35:17 +0000 | [diff] [blame] | 610 | job_statuses = self.get_host_queue_entries(job=job.id) |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 611 | except Exception: |
| 612 | print "Ignoring exception on poll job; RPC interface is flaky" |
| 613 | traceback.print_exc() |
| 614 | return None |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 615 | |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 616 | platform_map = {} |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 617 | job.job_status = {} |
mbligh | 451ede1 | 2009-02-12 21:54:03 +0000 | [diff] [blame] | 618 | job.metahost_index = {} |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 619 | for job_status in job_statuses: |
mbligh | c9e427e | 2009-04-28 18:35:06 +0000 | [diff] [blame] | 620 | # This is basically "for each host / metahost in the job" |
mbligh | 451ede1 | 2009-02-12 21:54:03 +0000 | [diff] [blame] | 621 | if job_status.host: |
| 622 | hostname = job_status.host.hostname |
| 623 | else: # This is a metahost |
| 624 | metahost = job_status.meta_host |
| 625 | index = job.metahost_index.get(metahost, 1) |
| 626 | job.metahost_index[metahost] = index + 1 |
| 627 | hostname = '%s.%s' % (metahost, index) |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 628 | job.job_status[hostname] = job_status.status |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 629 | status = job_status.status |
mbligh | 0ecbe63 | 2009-05-13 21:34:56 +0000 | [diff] [blame] | 630 | # Skip hosts that failed verify or repair: |
| 631 | # that's a machine failure, not a job failure |
mbligh | 451ede1 | 2009-02-12 21:54:03 +0000 | [diff] [blame] | 632 | if hostname in job.test_status: |
| 633 | verify_failed = False |
| 634 | for failure in job.test_status[hostname].fail: |
mbligh | 0ecbe63 | 2009-05-13 21:34:56 +0000 | [diff] [blame] | 635 | if (failure.test_name == 'verify' or |
| 636 | failure.test_name == 'repair'): |
mbligh | 451ede1 | 2009-02-12 21:54:03 +0000 | [diff] [blame] | 637 | verify_failed = True |
| 638 | break |
| 639 | if verify_failed: |
| 640 | continue |
mbligh | c9e427e | 2009-04-28 18:35:06 +0000 | [diff] [blame] | 641 | if hostname in job.test_status and job.test_status[hostname].fail: |
| 642 | # If the any tests failed in the job, we want to mark the |
| 643 | # job result as failed, overriding the default job status. |
| 644 | if status != "Aborted": # except if it's an aborted job |
| 645 | status = 'Failed' |
mbligh | 451ede1 | 2009-02-12 21:54:03 +0000 | [diff] [blame] | 646 | if job_status.host: |
| 647 | platform = job_status.host.platform |
| 648 | else: # This is a metahost |
| 649 | platform = job_status.meta_host |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 650 | if platform not in platform_map: |
| 651 | platform_map[platform] = {'Total' : [hostname]} |
| 652 | else: |
| 653 | platform_map[platform]['Total'].append(hostname) |
| 654 | new_host_list = platform_map[platform].get(status, []) + [hostname] |
| 655 | platform_map[platform][status] = new_host_list |
mbligh | 45ffc43 | 2008-12-09 23:35:17 +0000 | [diff] [blame] | 656 | job.results_platform_map = platform_map |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 657 | |
| 658 | |
mbligh | 17c75e6 | 2009-06-08 16:18:21 +0000 | [diff] [blame] | 659 | def set_platform_results(self, test_job, platform, result): |
| 660 | """ |
| 661 | Result must be None, 'FAIL', 'WARN' or 'GOOD' |
| 662 | """ |
| 663 | if test_job.platform_results[platform] is not None: |
| 664 | # We're already done, and results recorded. This can't change later. |
| 665 | return |
| 666 | test_job.platform_results[platform] = result |
| 667 | # Note that self.job refers to the metajob we're IN, not the job |
| 668 | # that we're excuting from here. |
| 669 | testname = '%s.%s' % (test_job.testname, platform) |
| 670 | if self.job: |
| 671 | self.job.record(result, None, testname, status='') |
| 672 | |
MK Ryu | 9c5fbbe | 2015-02-11 15:46:22 -0800 | [diff] [blame] | 673 | |
Chris Masone | 6fed646 | 2011-10-20 16:36:43 -0700 | [diff] [blame] | 674 | def poll_job_results(self, tko, job, enough=1, debug=False): |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 675 | """ |
Chris Masone | 3a560bd | 2011-11-14 16:53:56 -0800 | [diff] [blame] | 676 | Analyse all job results by platform |
mbligh | 1ef218d | 2009-08-03 16:57:56 +0000 | [diff] [blame] | 677 | |
Chris Masone | 3a560bd | 2011-11-14 16:53:56 -0800 | [diff] [blame] | 678 | params: |
| 679 | tko: a TKO object representing the results DB. |
| 680 | job: the job to be examined. |
Chris Masone | 6fed646 | 2011-10-20 16:36:43 -0700 | [diff] [blame] | 681 | enough: the acceptable delta between the number of completed |
| 682 | tests and the total number of tests. |
Chris Masone | 3a560bd | 2011-11-14 16:53:56 -0800 | [diff] [blame] | 683 | debug: enable debugging output. |
| 684 | |
| 685 | returns: |
Chris Masone | 6fed646 | 2011-10-20 16:36:43 -0700 | [diff] [blame] | 686 | False: if any platform has more than |enough| failures |
| 687 | None: if any platform has less than |enough| machines |
Chris Masone | 3a560bd | 2011-11-14 16:53:56 -0800 | [diff] [blame] | 688 | not yet Good. |
Chris Masone | 6fed646 | 2011-10-20 16:36:43 -0700 | [diff] [blame] | 689 | True: if all platforms have at least |enough| machines |
Chris Masone | 3a560bd | 2011-11-14 16:53:56 -0800 | [diff] [blame] | 690 | Good. |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 691 | """ |
mbligh | 451ede1 | 2009-02-12 21:54:03 +0000 | [diff] [blame] | 692 | self._job_test_results(tko, job, debug) |
mbligh | e7fcf56 | 2009-05-21 01:43:17 +0000 | [diff] [blame] | 693 | if job.test_status == {}: |
| 694 | return None |
mbligh | 451ede1 | 2009-02-12 21:54:03 +0000 | [diff] [blame] | 695 | self._job_results_platform_map(job, debug) |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 696 | |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 697 | good_platforms = [] |
mbligh | 912c3f3 | 2009-03-25 19:31:30 +0000 | [diff] [blame] | 698 | failed_platforms = [] |
| 699 | aborted_platforms = [] |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 700 | unknown_platforms = [] |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 701 | platform_map = job.results_platform_map |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 702 | for platform in platform_map: |
mbligh | 17c75e6 | 2009-06-08 16:18:21 +0000 | [diff] [blame] | 703 | if not job.platform_results.has_key(platform): |
| 704 | # record test start, but there's no way to do this right now |
| 705 | job.platform_results[platform] = None |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 706 | total = len(platform_map[platform]['Total']) |
| 707 | completed = len(platform_map[platform].get('Completed', [])) |
mbligh | 912c3f3 | 2009-03-25 19:31:30 +0000 | [diff] [blame] | 708 | failed = len(platform_map[platform].get('Failed', [])) |
| 709 | aborted = len(platform_map[platform].get('Aborted', [])) |
mbligh | 17c75e6 | 2009-06-08 16:18:21 +0000 | [diff] [blame] | 710 | |
mbligh | 1ef218d | 2009-08-03 16:57:56 +0000 | [diff] [blame] | 711 | # We set up what we want to record here, but don't actually do |
mbligh | 17c75e6 | 2009-06-08 16:18:21 +0000 | [diff] [blame] | 712 | # it yet, until we have a decisive answer for this platform |
| 713 | if aborted or failed: |
| 714 | bad = aborted + failed |
| 715 | if (bad > 1) or (bad * 2 >= total): |
| 716 | platform_test_result = 'FAIL' |
| 717 | else: |
| 718 | platform_test_result = 'WARN' |
| 719 | |
Chris Masone | 6fed646 | 2011-10-20 16:36:43 -0700 | [diff] [blame] | 720 | if aborted > enough: |
mbligh | 912c3f3 | 2009-03-25 19:31:30 +0000 | [diff] [blame] | 721 | aborted_platforms.append(platform) |
mbligh | 17c75e6 | 2009-06-08 16:18:21 +0000 | [diff] [blame] | 722 | self.set_platform_results(job, platform, platform_test_result) |
Chris Masone | 6fed646 | 2011-10-20 16:36:43 -0700 | [diff] [blame] | 723 | elif (failed * 2 >= total) or (failed > enough): |
mbligh | 912c3f3 | 2009-03-25 19:31:30 +0000 | [diff] [blame] | 724 | failed_platforms.append(platform) |
mbligh | 17c75e6 | 2009-06-08 16:18:21 +0000 | [diff] [blame] | 725 | self.set_platform_results(job, platform, platform_test_result) |
Chris Masone | 6fed646 | 2011-10-20 16:36:43 -0700 | [diff] [blame] | 726 | elif (completed >= enough) and (completed + enough >= total): |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 727 | good_platforms.append(platform) |
mbligh | 17c75e6 | 2009-06-08 16:18:21 +0000 | [diff] [blame] | 728 | self.set_platform_results(job, platform, 'GOOD') |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 729 | else: |
| 730 | unknown_platforms.append(platform) |
| 731 | detail = [] |
| 732 | for status in platform_map[platform]: |
| 733 | if status == 'Total': |
| 734 | continue |
| 735 | detail.append('%s=%s' % (status,platform_map[platform][status])) |
| 736 | if debug: |
mbligh | 1ef218d | 2009-08-03 16:57:56 +0000 | [diff] [blame] | 737 | print '%20s %d/%d %s' % (platform, completed, total, |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 738 | ' '.join(detail)) |
| 739 | print |
mbligh | 1ef218d | 2009-08-03 16:57:56 +0000 | [diff] [blame] | 740 | |
mbligh | 912c3f3 | 2009-03-25 19:31:30 +0000 | [diff] [blame] | 741 | if len(aborted_platforms) > 0: |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 742 | if debug: |
mbligh | 17c75e6 | 2009-06-08 16:18:21 +0000 | [diff] [blame] | 743 | print 'Result aborted - platforms: ', |
| 744 | print ' '.join(aborted_platforms) |
mbligh | 912c3f3 | 2009-03-25 19:31:30 +0000 | [diff] [blame] | 745 | return "Abort" |
| 746 | if len(failed_platforms) > 0: |
| 747 | if debug: |
| 748 | print 'Result bad - platforms: ' + ' '.join(failed_platforms) |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 749 | return False |
| 750 | if len(unknown_platforms) > 0: |
| 751 | if debug: |
| 752 | platform_list = ' '.join(unknown_platforms) |
| 753 | print 'Result unknown - platforms: ', platform_list |
| 754 | return None |
| 755 | if debug: |
| 756 | platform_list = ' '.join(good_platforms) |
| 757 | print 'Result good - all platforms passed: ', platform_list |
| 758 | return True |
| 759 | |
| 760 | |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 761 | class TestResults(object): |
| 762 | """ |
| 763 | Container class used to hold the results of the tests for a job |
| 764 | """ |
| 765 | def __init__(self): |
| 766 | self.good = [] |
| 767 | self.fail = [] |
mbligh | 451ede1 | 2009-02-12 21:54:03 +0000 | [diff] [blame] | 768 | self.pending = [] |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 769 | |
| 770 | |
| 771 | def add(self, result): |
mbligh | 451ede1 | 2009-02-12 21:54:03 +0000 | [diff] [blame] | 772 | if result.complete_count > result.pass_count: |
| 773 | self.fail.append(result) |
| 774 | elif result.incomplete_count > 0: |
| 775 | self.pending.append(result) |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 776 | else: |
mbligh | 451ede1 | 2009-02-12 21:54:03 +0000 | [diff] [blame] | 777 | self.good.append(result) |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 778 | |
| 779 | |
| 780 | class RpcObject(object): |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 781 | """ |
| 782 | Generic object used to construct python objects from rpc calls |
| 783 | """ |
| 784 | def __init__(self, afe, hash): |
| 785 | self.afe = afe |
| 786 | self.hash = hash |
| 787 | self.__dict__.update(hash) |
| 788 | |
| 789 | |
| 790 | def __str__(self): |
| 791 | return dump_object(self.__repr__(), self) |
| 792 | |
| 793 | |
mbligh | 1354c9d | 2008-12-22 14:56:13 +0000 | [diff] [blame] | 794 | class ControlFile(RpcObject): |
| 795 | """ |
| 796 | AFE control file object |
| 797 | |
| 798 | Fields: synch_count, dependencies, control_file, is_server |
| 799 | """ |
| 800 | def __repr__(self): |
| 801 | return 'CONTROL FILE: %s' % self.control_file |
| 802 | |
| 803 | |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 804 | class Label(RpcObject): |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 805 | """ |
| 806 | AFE label object |
| 807 | |
| 808 | Fields: |
| 809 | name, invalid, platform, kernel_config, id, only_if_needed |
| 810 | """ |
| 811 | def __repr__(self): |
| 812 | return 'LABEL: %s' % self.name |
| 813 | |
| 814 | |
| 815 | def add_hosts(self, hosts): |
Chris Masone | 3a560bd | 2011-11-14 16:53:56 -0800 | [diff] [blame] | 816 | return self.afe.run('label_add_hosts', id=self.id, hosts=hosts) |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 817 | |
| 818 | |
| 819 | def remove_hosts(self, hosts): |
Chris Masone | 3a560bd | 2011-11-14 16:53:56 -0800 | [diff] [blame] | 820 | return self.afe.run('label_remove_hosts', id=self.id, hosts=hosts) |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 821 | |
| 822 | |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 823 | class Acl(RpcObject): |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 824 | """ |
| 825 | AFE acl object |
| 826 | |
| 827 | Fields: |
| 828 | users, hosts, description, name, id |
| 829 | """ |
| 830 | def __repr__(self): |
| 831 | return 'ACL: %s' % self.name |
| 832 | |
| 833 | |
| 834 | def add_hosts(self, hosts): |
| 835 | self.afe.log('Adding hosts %s to ACL %s' % (hosts, self.name)) |
| 836 | return self.afe.run('acl_group_add_hosts', self.id, hosts) |
| 837 | |
| 838 | |
| 839 | def remove_hosts(self, hosts): |
| 840 | self.afe.log('Removing hosts %s from ACL %s' % (hosts, self.name)) |
| 841 | return self.afe.run('acl_group_remove_hosts', self.id, hosts) |
| 842 | |
| 843 | |
mbligh | 54459c7 | 2009-01-21 19:26:44 +0000 | [diff] [blame] | 844 | def add_users(self, users): |
| 845 | self.afe.log('Adding users %s to ACL %s' % (users, self.name)) |
| 846 | return self.afe.run('acl_group_add_users', id=self.name, users=users) |
| 847 | |
| 848 | |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 849 | class Job(RpcObject): |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 850 | """ |
| 851 | AFE job object |
| 852 | |
| 853 | Fields: |
| 854 | name, control_file, control_type, synch_count, reboot_before, |
| 855 | run_verify, priority, email_list, created_on, dependencies, |
| 856 | timeout, owner, reboot_after, id |
| 857 | """ |
| 858 | def __repr__(self): |
| 859 | return 'JOB: %s' % self.id |
| 860 | |
| 861 | |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 862 | class JobStatus(RpcObject): |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 863 | """ |
| 864 | AFE job_status object |
| 865 | |
| 866 | Fields: |
| 867 | status, complete, deleted, meta_host, host, active, execution_subdir, id |
| 868 | """ |
| 869 | def __init__(self, afe, hash): |
MK Ryu | 1b2d7f9 | 2015-02-24 17:45:02 -0800 | [diff] [blame] | 870 | super(JobStatus, self).__init__(afe, hash) |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 871 | self.job = Job(afe, self.job) |
Dale Curtis | 8adf789 | 2011-09-08 16:13:36 -0700 | [diff] [blame] | 872 | if getattr(self, 'host'): |
mbligh | 99b24f4 | 2009-06-08 16:45:55 +0000 | [diff] [blame] | 873 | self.host = Host(afe, self.host) |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 874 | |
| 875 | |
| 876 | def __repr__(self): |
mbligh | 451ede1 | 2009-02-12 21:54:03 +0000 | [diff] [blame] | 877 | if self.host and self.host.hostname: |
| 878 | hostname = self.host.hostname |
| 879 | else: |
| 880 | hostname = 'None' |
| 881 | return 'JOB STATUS: %s-%s' % (self.job.id, hostname) |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 882 | |
| 883 | |
MK Ryu | 1b2d7f9 | 2015-02-24 17:45:02 -0800 | [diff] [blame] | 884 | class SpecialTask(RpcObject): |
| 885 | """ |
| 886 | AFE special task object |
| 887 | """ |
| 888 | def __init__(self, afe, hash): |
| 889 | super(SpecialTask, self).__init__(afe, hash) |
| 890 | self.host = Host(afe, self.host) |
| 891 | |
| 892 | |
| 893 | def __repr__(self): |
| 894 | return 'SPECIAL TASK: %s' % self.id |
| 895 | |
| 896 | |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 897 | class Host(RpcObject): |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 898 | """ |
| 899 | AFE host object |
| 900 | |
| 901 | Fields: |
| 902 | status, lock_time, locked_by, locked, hostname, invalid, |
| 903 | synch_id, labels, platform, protection, dirty, id |
| 904 | """ |
| 905 | def __repr__(self): |
| 906 | return 'HOST OBJECT: %s' % self.hostname |
| 907 | |
| 908 | |
| 909 | def show(self): |
| 910 | labels = list(set(self.labels) - set([self.platform])) |
| 911 | print '%-6s %-7s %-7s %-16s %s' % (self.hostname, self.status, |
| 912 | self.locked, self.platform, |
| 913 | ', '.join(labels)) |
| 914 | |
| 915 | |
mbligh | 54459c7 | 2009-01-21 19:26:44 +0000 | [diff] [blame] | 916 | def delete(self): |
| 917 | return self.afe.run('delete_host', id=self.id) |
| 918 | |
| 919 | |
mbligh | 6463c4b | 2009-01-30 00:33:37 +0000 | [diff] [blame] | 920 | def modify(self, **dargs): |
| 921 | return self.afe.run('modify_host', id=self.id, **dargs) |
| 922 | |
| 923 | |
mbligh | 6764715 | 2008-11-19 00:18:14 +0000 | [diff] [blame] | 924 | def get_acls(self): |
| 925 | return self.afe.get_acls(hosts__hostname=self.hostname) |
| 926 | |
| 927 | |
| 928 | def add_acl(self, acl_name): |
| 929 | self.afe.log('Adding ACL %s to host %s' % (acl_name, self.hostname)) |
| 930 | return self.afe.run('acl_group_add_hosts', id=acl_name, |
| 931 | hosts=[self.hostname]) |
| 932 | |
| 933 | |
| 934 | def remove_acl(self, acl_name): |
| 935 | self.afe.log('Removing ACL %s from host %s' % (acl_name, self.hostname)) |
| 936 | return self.afe.run('acl_group_remove_hosts', id=acl_name, |
| 937 | hosts=[self.hostname]) |
| 938 | |
| 939 | |
| 940 | def get_labels(self): |
| 941 | return self.afe.get_labels(host__hostname__in=[self.hostname]) |
| 942 | |
| 943 | |
| 944 | def add_labels(self, labels): |
| 945 | self.afe.log('Adding labels %s to host %s' % (labels, self.hostname)) |
| 946 | return self.afe.run('host_add_labels', id=self.id, labels=labels) |
| 947 | |
| 948 | |
| 949 | def remove_labels(self, labels): |
| 950 | self.afe.log('Removing labels %s from host %s' % (labels,self.hostname)) |
| 951 | return self.afe.run('host_remove_labels', id=self.id, labels=labels) |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 952 | |
| 953 | |
mbligh | 54459c7 | 2009-01-21 19:26:44 +0000 | [diff] [blame] | 954 | class User(RpcObject): |
| 955 | def __repr__(self): |
| 956 | return 'USER: %s' % self.login |
| 957 | |
| 958 | |
mbligh | 5280e3b | 2008-12-22 14:39:28 +0000 | [diff] [blame] | 959 | class TestStatus(RpcObject): |
mbligh | c31e402 | 2008-12-11 19:32:30 +0000 | [diff] [blame] | 960 | """ |
| 961 | TKO test status object |
| 962 | |
| 963 | Fields: |
| 964 | test_idx, hostname, testname, id |
| 965 | complete_count, incomplete_count, group_count, pass_count |
| 966 | """ |
| 967 | def __repr__(self): |
| 968 | return 'TEST STATUS: %s' % self.id |
| 969 | |
| 970 | |
MK Ryu | acf3592 | 2014-10-03 14:56:49 -0700 | [diff] [blame] | 971 | class HostAttribute(RpcObject): |
| 972 | """ |
| 973 | AFE host attribute object |
| 974 | |
| 975 | Fields: |
| 976 | id, host, attribute, value |
| 977 | """ |
| 978 | def __repr__(self): |
| 979 | return 'HOST ATTRIBUTE %d' % self.id |
| 980 | |
| 981 | |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 982 | class MachineTestPairing(object): |
| 983 | """ |
| 984 | Object representing the pairing of a machine label with a control file |
mbligh | 1f23f36 | 2008-12-22 14:46:12 +0000 | [diff] [blame] | 985 | |
| 986 | machine_label: use machines from this label |
| 987 | control_file: use this control file (by name in the frontend) |
| 988 | platforms: list of rexeps to filter platforms by. [] => no filtering |
mbligh | 282ce89 | 2010-01-06 18:40:17 +0000 | [diff] [blame] | 989 | job_label: The label (name) to give to the autotest job launched |
| 990 | to run this pairing. '<kernel-version> : <config> : <date>' |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 991 | """ |
mbligh | 1354c9d | 2008-12-22 14:56:13 +0000 | [diff] [blame] | 992 | def __init__(self, machine_label, control_file, platforms=[], |
mbligh | 17c75e6 | 2009-06-08 16:18:21 +0000 | [diff] [blame] | 993 | container=False, atomic_group_sched=False, synch_count=0, |
mbligh | 282ce89 | 2010-01-06 18:40:17 +0000 | [diff] [blame] | 994 | testname=None, job_label=None): |
mbligh | 5b61838 | 2008-12-03 15:24:01 +0000 | [diff] [blame] | 995 | self.machine_label = machine_label |
| 996 | self.control_file = control_file |
mbligh | 1f23f36 | 2008-12-22 14:46:12 +0000 | [diff] [blame] | 997 | self.platforms = platforms |
mbligh | 1354c9d | 2008-12-22 14:56:13 +0000 | [diff] [blame] | 998 | self.container = container |
mbligh | b9db516 | 2009-04-17 22:21:41 +0000 | [diff] [blame] | 999 | self.atomic_group_sched = atomic_group_sched |
| 1000 | self.synch_count = synch_count |
mbligh | 17c75e6 | 2009-06-08 16:18:21 +0000 | [diff] [blame] | 1001 | self.testname = testname |
mbligh | 282ce89 | 2010-01-06 18:40:17 +0000 | [diff] [blame] | 1002 | self.job_label = job_label |
mbligh | 1354c9d | 2008-12-22 14:56:13 +0000 | [diff] [blame] | 1003 | |
| 1004 | |
| 1005 | def __repr__(self): |
| 1006 | return '%s %s %s %s' % (self.machine_label, self.control_file, |
| 1007 | self.platforms, self.container) |