blob: 06ea5d644d98d8fae80f95848e9ae2e67b4a4251 [file] [log] [blame]
mbligh67647152008-11-19 00:18:14 +00001# Copyright Martin J. Bligh, Google Inc 2008
2# Released under the GPL v2
3
4"""
5This class allows you to communicate with the frontend to submit jobs etc
6It is designed for writing more sophisiticated server-side control files that
7can recursively add and manage other jobs.
8
9We turn the JSON dictionaries into real objects that are more idiomatic
10
mblighc31e4022008-12-11 19:32:30 +000011For docs, see:
Aviv Keshet2c709f62013-05-07 12:52:15 -070012 http://www.chromium.org/chromium-os/testing/afe-rpc-infrastructure
mblighc31e4022008-12-11 19:32:30 +000013 http://docs.djangoproject.com/en/dev/ref/models/querysets/#queryset-api
mbligh67647152008-11-19 00:18:14 +000014"""
15
mblighdb59e3c2009-11-21 01:45:18 +000016import getpass, os, time, traceback, re
mbligh67647152008-11-19 00:18:14 +000017import common
18from autotest_lib.frontend.afe import rpc_client_lib
mbligh37eceaa2008-12-15 22:56:37 +000019from autotest_lib.client.common_lib import global_config
mbligh67647152008-11-19 00:18:14 +000020from autotest_lib.client.common_lib import utils
Aviv Keshet3dd8beb2013-05-13 17:36:04 -070021from autotest_lib.client.common_lib import control_data
Scott Zawalski63470dd2012-09-05 00:49:43 -040022from autotest_lib.tko import db
23
24
mbligh4e576612008-12-22 14:56:36 +000025try:
26 from autotest_lib.server.site_common import site_utils as server_utils
27except:
28 from autotest_lib.server import utils as server_utils
29form_ntuples_from_machines = server_utils.form_ntuples_from_machines
mbligh67647152008-11-19 00:18:14 +000030
mbligh37eceaa2008-12-15 22:56:37 +000031GLOBAL_CONFIG = global_config.global_config
32DEFAULT_SERVER = 'autotest'
33
mbligh67647152008-11-19 00:18:14 +000034def 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
mbligh5280e3b2008-12-22 14:39:28 +000047class RpcClient(object):
mbligh67647152008-11-19 00:18:14 +000048 """
mbligh451ede12009-02-12 21:54:03 +000049 Abstract RPC class for communicating with the autotest frontend
50 Inherited for both TKO and AFE uses.
mbligh67647152008-11-19 00:18:14 +000051
mbligh1ef218d2009-08-03 16:57:56 +000052 All the constructors go in the afe / tko class.
mbligh451ede12009-02-12 21:54:03 +000053 Manipulating methods go in the object classes themselves
mbligh67647152008-11-19 00:18:14 +000054 """
mbligh99b24f42009-06-08 16:45:55 +000055 def __init__(self, path, user, server, print_log, debug, reply_debug):
mbligh67647152008-11-19 00:18:14 +000056 """
mbligh451ede12009-02-12 21:54:03 +000057 Create a cached instance of a connection to the frontend
mbligh67647152008-11-19 00:18:14 +000058
59 user: username to connect as
mbligh451ede12009-02-12 21:54:03 +000060 server: frontend server to connect to
mbligh67647152008-11-19 00:18:14 +000061 print_log: pring a logging message to stdout on every operation
62 debug: print out all RPC traffic
63 """
mblighc31e4022008-12-11 19:32:30 +000064 if not user:
mblighdb59e3c2009-11-21 01:45:18 +000065 user = getpass.getuser()
mbligh451ede12009-02-12 21:54:03 +000066 if not server:
mbligh475f7762009-01-30 00:34:04 +000067 if 'AUTOTEST_WEB' in os.environ:
mbligh451ede12009-02-12 21:54:03 +000068 server = os.environ['AUTOTEST_WEB']
mbligh475f7762009-01-30 00:34:04 +000069 else:
mbligh451ede12009-02-12 21:54:03 +000070 server = GLOBAL_CONFIG.get_config_value('SERVER', 'hostname',
71 default=DEFAULT_SERVER)
72 self.server = server
mbligh67647152008-11-19 00:18:14 +000073 self.user = user
74 self.print_log = print_log
75 self.debug = debug
mbligh99b24f42009-06-08 16:45:55 +000076 self.reply_debug = reply_debug
Scott Zawalski347aaf42012-04-03 16:33:00 -040077 headers = {'AUTHORIZATION': self.user}
78 rpc_server = 'http://' + server + path
mbligh1354c9d2008-12-22 14:56:13 +000079 if debug:
80 print 'SERVER: %s' % rpc_server
81 print 'HEADERS: %s' % headers
mbligh67647152008-11-19 00:18:14 +000082 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)
mbligh451ede12009-02-12 21:54:03 +000092 try:
mbligh99b24f42009-06-08 16:45:55 +000093 result = utils.strip_unicode(rpc_call(**dargs))
94 if self.reply_debug:
95 print result
96 return result
mbligh451ede12009-02-12 21:54:03 +000097 except Exception:
98 print 'FAILED RPC CALL: %s %s' % (call, dargs)
99 raise
mbligh67647152008-11-19 00:18:14 +0000100
101
102 def log(self, message):
103 if self.print_log:
104 print message
105
106
jamesrenc3940222010-02-19 21:57:37 +0000107class 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
mbligh5280e3b2008-12-22 14:39:28 +0000118class TKO(RpcClient):
mbligh99b24f42009-06-08 16:45:55 +0000119 def __init__(self, user=None, server=None, print_log=True, debug=False,
120 reply_debug=False):
Scott Zawalski347aaf42012-04-03 16:33:00 -0400121 super(TKO, self).__init__(path='/new_tko/server/noauth/rpc/',
mbligh99b24f42009-06-08 16:45:55 +0000122 user=user,
123 server=server,
124 print_log=print_log,
125 debug=debug,
126 reply_debug=reply_debug)
Scott Zawalski63470dd2012-09-05 00:49:43 -0400127 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 Deng5c508332014-03-19 10:26:00 -0700143 fields = ['status', 'test_name', 'subdir', 'reason',
144 'test_started_time', 'test_finished_time', 'afe_job_id',
145 'job_owner', 'hostname', 'job_tag']
Scott Zawalski63470dd2012-09-05 00:49:43 -0400146 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]
mblighc31e4022008-12-11 19:32:30 +0000164
165
166 def get_status_counts(self, job, **data):
167 entries = self.run('get_status_counts',
mbligh1ef218d2009-08-03 16:57:56 +0000168 group_by=['hostname', 'test_name', 'reason'],
mblighc31e4022008-12-11 19:32:30 +0000169 job_tag__startswith='%s-' % job, **data)
mbligh5280e3b2008-12-22 14:39:28 +0000170 return [TestStatus(self, e) for e in entries['groups']]
mblighc31e4022008-12-11 19:32:30 +0000171
172
mbligh5280e3b2008-12-22 14:39:28 +0000173class AFE(RpcClient):
mbligh17c75e62009-06-08 16:18:21 +0000174 def __init__(self, user=None, server=None, print_log=True, debug=False,
mbligh99b24f42009-06-08 16:45:55 +0000175 reply_debug=False, job=None):
mbligh17c75e62009-06-08 16:18:21 +0000176 self.job = job
Scott Zawalski347aaf42012-04-03 16:33:00 -0400177 super(AFE, self).__init__(path='/afe/server/noauth/rpc/',
mbligh99b24f42009-06-08 16:45:55 +0000178 user=user,
179 server=server,
180 print_log=print_log,
181 debug=debug,
182 reply_debug=reply_debug)
mblighc31e4022008-12-11 19:32:30 +0000183
mbligh1ef218d2009-08-03 16:57:56 +0000184
mbligh67647152008-11-19 00:18:14 +0000185 def host_statuses(self, live=None):
jamesren121eee62010-04-13 19:10:12 +0000186 dead_statuses = ['Repair Failed', 'Repairing']
mbligh67647152008-11-19 00:18:14 +0000187 statuses = self.run('get_static_data')['host_statuses']
188 if live == True:
mblighc2847b72009-03-25 19:32:20 +0000189 return list(set(statuses) - set(dead_statuses))
mbligh67647152008-11-19 00:18:14 +0000190 if live == False:
191 return dead_statuses
192 else:
193 return statuses
194
195
mbligh71094012009-12-19 05:35:21 +0000196 @staticmethod
197 def _dict_for_host_query(hostnames=(), status=None, label=None):
198 query_args = {}
mbligh4e545a52009-12-19 05:30:39 +0000199 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
mbligh71094012009-12-19 05:35:21 +0000205 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))
mbligh4e545a52009-12-19 05:30:39 +0000231 return self.run('reverify_hosts', **query_args)
232
233
mbligh67647152008-11-19 00:18:14 +0000234 def create_host(self, hostname, **dargs):
mbligh54459c72009-01-21 19:26:44 +0000235 id = self.run('add_host', hostname=hostname, **dargs)
mbligh67647152008-11-19 00:18:14 +0000236 return self.get_hosts(id=id)[0]
237
238
MK Ryuacf35922014-10-03 14:56:49 -0700239 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 Masone8abb6fc2012-01-31 09:27:36 -0800244 def set_host_attribute(self, attr, val, **dargs):
245 self.run('set_host_attribute', attribute=attr, value=val, **dargs)
246
247
mbligh67647152008-11-19 00:18:14 +0000248 def get_labels(self, **dargs):
249 labels = self.run('get_labels', **dargs)
mbligh5280e3b2008-12-22 14:39:28 +0000250 return [Label(self, l) for l in labels]
mbligh67647152008-11-19 00:18:14 +0000251
252
253 def create_label(self, name, **dargs):
mbligh54459c72009-01-21 19:26:44 +0000254 id = self.run('add_label', name=name, **dargs)
mbligh67647152008-11-19 00:18:14 +0000255 return self.get_labels(id=id)[0]
256
257
258 def get_acls(self, **dargs):
259 acls = self.run('get_acl_groups', **dargs)
mbligh5280e3b2008-12-22 14:39:28 +0000260 return [Acl(self, a) for a in acls]
mbligh67647152008-11-19 00:18:14 +0000261
262
263 def create_acl(self, name, **dargs):
mbligh54459c72009-01-21 19:26:44 +0000264 id = self.run('add_acl_group', name=name, **dargs)
mbligh67647152008-11-19 00:18:14 +0000265 return self.get_acls(id=id)[0]
266
267
mbligh54459c72009-01-21 19:26:44 +0000268 def get_users(self, **dargs):
269 users = self.run('get_users', **dargs)
270 return [User(self, u) for u in users]
271
272
mbligh1354c9d2008-12-22 14:56:13 +0000273 def generate_control_file(self, tests, **dargs):
274 ret = self.run('generate_control_file', tests=tests, **dargs)
275 return ControlFile(self, ret)
276
277
mbligh67647152008-11-19 00:18:14 +0000278 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)
mblighafbba0c2009-06-08 16:44:45 +0000283 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
mbligh67647152008-11-19 00:18:14 +0000292
293
294 def get_host_queue_entries(self, **data):
295 entries = self.run('get_host_queue_entries', **data)
mblighf9e35862009-02-26 01:03:11 +0000296 job_statuses = [JobStatus(self, e) for e in entries]
mbligh99b24f42009-06-08 16:45:55 +0000297
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:
307 status.host = host_hash[status.host.hostname]
mblighf9e35862009-02-26 01:03:11 +0000308 # 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)]
mbligh67647152008-11-19 00:18:14 +0000311
312
mblighb9db5162009-04-17 22:21:41 +0000313 def create_job_by_test(self, tests, kernel=None, use_container=False,
Eric Lie0493a42010-11-15 13:05:43 -0800314 kernel_cmdline=None, **dargs):
mbligh67647152008-11-19 00:18:14 +0000315 """
316 Given a test name, fetch the appropriate control file from the server
mbligh4e576612008-12-22 14:56:36 +0000317 and submit it.
318
Eric Lie0493a42010-11-15 13:05:43 -0800319 @param kernel: A comma separated list of kernel versions to boot.
320 @param kernel_cmdline: The command line used to boot all kernels listed
321 in the kernel parameter.
322
mbligh4e576612008-12-22 14:56:36 +0000323 Returns a list of job objects
mbligh67647152008-11-19 00:18:14 +0000324 """
mblighb9db5162009-04-17 22:21:41 +0000325 assert ('hosts' in dargs or
326 'atomic_group_name' in dargs and 'synch_count' in dargs)
showarda2cd72b2009-10-01 18:43:53 +0000327 if kernel:
328 kernel_list = re.split('[\s,]+', kernel.strip())
Eric Lie0493a42010-11-15 13:05:43 -0800329 kernel_info = []
330 for version in kernel_list:
331 kernel_dict = {'version': version}
332 if kernel_cmdline is not None:
333 kernel_dict['cmdline'] = kernel_cmdline
334 kernel_info.append(kernel_dict)
showarda2cd72b2009-10-01 18:43:53 +0000335 else:
336 kernel_info = None
337 control_file = self.generate_control_file(
Dale Curtis74a314b2011-06-23 14:55:46 -0700338 tests=tests, kernel=kernel_info, use_container=use_container)
mbligh1354c9d2008-12-22 14:56:13 +0000339 if control_file.is_server:
Aviv Keshet3dd8beb2013-05-13 17:36:04 -0700340 dargs['control_type'] = control_data.CONTROL_TYPE_NAMES.SERVER
mbligh67647152008-11-19 00:18:14 +0000341 else:
Aviv Keshet3dd8beb2013-05-13 17:36:04 -0700342 dargs['control_type'] = control_data.CONTROL_TYPE_NAMES.CLIENT
mbligh67647152008-11-19 00:18:14 +0000343 dargs['dependencies'] = dargs.get('dependencies', []) + \
mbligh1354c9d2008-12-22 14:56:13 +0000344 control_file.dependencies
345 dargs['control_file'] = control_file.control_file
mbligh672666c2009-07-28 23:22:13 +0000346 if not dargs.get('synch_count', None):
mblighc99fccf2009-07-11 00:59:33 +0000347 dargs['synch_count'] = control_file.synch_count
mblighb9db5162009-04-17 22:21:41 +0000348 if 'hosts' in dargs and len(dargs['hosts']) < dargs['synch_count']:
349 # will not be able to satisfy this request
mbligh38b09152009-04-28 18:34:25 +0000350 return None
351 return self.create_job(**dargs)
mbligh67647152008-11-19 00:18:14 +0000352
353
354 def create_job(self, control_file, name=' ', priority='Medium',
Aviv Keshet3dd8beb2013-05-13 17:36:04 -0700355 control_type=control_data.CONTROL_TYPE_NAMES.CLIENT, **dargs):
mbligh67647152008-11-19 00:18:14 +0000356 id = self.run('create_job', name=name, priority=priority,
357 control_file=control_file, control_type=control_type, **dargs)
358 return self.get_jobs(id=id)[0]
359
360
mbligh282ce892010-01-06 18:40:17 +0000361 def run_test_suites(self, pairings, kernel, kernel_label=None,
362 priority='Medium', wait=True, poll_interval=10,
Simran Basi7e605742013-11-12 13:43:36 -0800363 email_from=None, email_to=None, timeout_mins=10080,
Simran Basi34217022012-11-06 13:43:15 -0800364 max_runtime_mins=10080, kernel_cmdline=None):
mbligh5b618382008-12-03 15:24:01 +0000365 """
366 Run a list of test suites on a particular kernel.
mbligh1ef218d2009-08-03 16:57:56 +0000367
mbligh5b618382008-12-03 15:24:01 +0000368 Poll for them to complete, and return whether they worked or not.
mbligh1ef218d2009-08-03 16:57:56 +0000369
mbligh282ce892010-01-06 18:40:17 +0000370 @param pairings: List of MachineTestPairing objects to invoke.
371 @param kernel: Name of the kernel to run.
372 @param kernel_label: Label (string) of the kernel to run such as
373 '<kernel-version> : <config> : <date>'
374 If any pairing object has its job_label attribute set it
375 will override this value for that particular job.
Eric Lie0493a42010-11-15 13:05:43 -0800376 @param kernel_cmdline: The command line to boot the kernel(s) with.
mbligh282ce892010-01-06 18:40:17 +0000377 @param wait: boolean - Wait for the results to come back?
378 @param poll_interval: Interval between polling for job results (in mins)
379 @param email_from: Send notification email upon completion from here.
380 @param email_from: Send notification email upon completion to here.
mbligh5b618382008-12-03 15:24:01 +0000381 """
382 jobs = []
383 for pairing in pairings:
mbligh0c4f8d72009-05-12 20:52:18 +0000384 try:
385 new_job = self.invoke_test(pairing, kernel, kernel_label,
Simran Basi7e605742013-11-12 13:43:36 -0800386 priority, timeout_mins=timeout_mins,
Eric Lie0493a42010-11-15 13:05:43 -0800387 kernel_cmdline=kernel_cmdline,
Simran Basi34217022012-11-06 13:43:15 -0800388 max_runtime_mins=max_runtime_mins)
mbligh0c4f8d72009-05-12 20:52:18 +0000389 if not new_job:
390 continue
mbligh0c4f8d72009-05-12 20:52:18 +0000391 jobs.append(new_job)
392 except Exception, e:
393 traceback.print_exc()
mblighb9db5162009-04-17 22:21:41 +0000394 if not wait or not jobs:
mbligh5b618382008-12-03 15:24:01 +0000395 return
mbligh5280e3b2008-12-22 14:39:28 +0000396 tko = TKO()
mbligh5b618382008-12-03 15:24:01 +0000397 while True:
398 time.sleep(60 * poll_interval)
mbligh5280e3b2008-12-22 14:39:28 +0000399 result = self.poll_all_jobs(tko, jobs, email_from, email_to)
mbligh5b618382008-12-03 15:24:01 +0000400 if result is not None:
401 return result
402
403
mbligh45ffc432008-12-09 23:35:17 +0000404 def result_notify(self, job, email_from, email_to):
mbligh5b618382008-12-03 15:24:01 +0000405 """
mbligh45ffc432008-12-09 23:35:17 +0000406 Notify about the result of a job. Will always print, if email data
407 is provided, will send email for it as well.
408
409 job: job object to notify about
410 email_from: send notification email upon completion from here
411 email_from: send notification email upon completion to here
412 """
413 if job.result == True:
414 subject = 'Testing PASSED: '
415 else:
416 subject = 'Testing FAILED: '
417 subject += '%s : %s\n' % (job.name, job.id)
418 text = []
419 for platform in job.results_platform_map:
420 for status in job.results_platform_map[platform]:
421 if status == 'Total':
422 continue
mbligh451ede12009-02-12 21:54:03 +0000423 for host in job.results_platform_map[platform][status]:
424 text.append('%20s %10s %10s' % (platform, status, host))
425 if status == 'Failed':
426 for test_status in job.test_status[host].fail:
427 text.append('(%s, %s) : %s' % \
428 (host, test_status.test_name,
429 test_status.reason))
430 text.append('')
mbligh37eceaa2008-12-15 22:56:37 +0000431
mbligh451ede12009-02-12 21:54:03 +0000432 base_url = 'http://' + self.server
mbligh37eceaa2008-12-15 22:56:37 +0000433
434 params = ('columns=test',
435 'rows=machine_group',
436 "condition=tag~'%s-%%25'" % job.id,
437 'title=Report')
438 query_string = '&'.join(params)
mbligh451ede12009-02-12 21:54:03 +0000439 url = '%s/tko/compose_query.cgi?%s' % (base_url, query_string)
440 text.append(url + '\n')
441 url = '%s/afe/#tab_id=view_job&object_id=%s' % (base_url, job.id)
442 text.append(url + '\n')
mbligh37eceaa2008-12-15 22:56:37 +0000443
444 body = '\n'.join(text)
445 print '---------------------------------------------------'
446 print 'Subject: ', subject
mbligh45ffc432008-12-09 23:35:17 +0000447 print body
mbligh37eceaa2008-12-15 22:56:37 +0000448 print '---------------------------------------------------'
mbligh45ffc432008-12-09 23:35:17 +0000449 if email_from and email_to:
mbligh37eceaa2008-12-15 22:56:37 +0000450 print 'Sending email ...'
mbligh45ffc432008-12-09 23:35:17 +0000451 utils.send_email(email_from, email_to, subject, body)
452 print
mbligh37eceaa2008-12-15 22:56:37 +0000453
mbligh45ffc432008-12-09 23:35:17 +0000454
mbligh1354c9d2008-12-22 14:56:13 +0000455 def print_job_result(self, job):
456 """
457 Print the result of a single job.
458 job: a job object
459 """
460 if job.result is None:
461 print 'PENDING',
462 elif job.result == True:
463 print 'PASSED',
464 elif job.result == False:
465 print 'FAILED',
mbligh912c3f32009-03-25 19:31:30 +0000466 elif job.result == "Abort":
467 print 'ABORT',
mbligh1354c9d2008-12-22 14:56:13 +0000468 print ' %s : %s' % (job.id, job.name)
469
470
mbligh451ede12009-02-12 21:54:03 +0000471 def poll_all_jobs(self, tko, jobs, email_from=None, email_to=None):
mbligh45ffc432008-12-09 23:35:17 +0000472 """
473 Poll all jobs in a list.
474 jobs: list of job objects to poll
475 email_from: send notification email upon completion from here
476 email_from: send notification email upon completion to here
477
478 Returns:
mbligh5b618382008-12-03 15:24:01 +0000479 a) All complete successfully (return True)
480 b) One or more has failed (return False)
481 c) Cannot tell yet (return None)
482 """
mbligh45ffc432008-12-09 23:35:17 +0000483 results = []
mbligh5b618382008-12-03 15:24:01 +0000484 for job in jobs:
mbligh676dcbe2009-06-15 21:57:27 +0000485 if getattr(job, 'result', None) is None:
Chris Masone6fed6462011-10-20 16:36:43 -0700486 job.result = self.poll_job_results(tko, job)
mbligh676dcbe2009-06-15 21:57:27 +0000487 if job.result is not None:
488 self.result_notify(job, email_from, email_to)
mbligh45ffc432008-12-09 23:35:17 +0000489
mbligh676dcbe2009-06-15 21:57:27 +0000490 results.append(job.result)
mbligh1354c9d2008-12-22 14:56:13 +0000491 self.print_job_result(job)
mbligh45ffc432008-12-09 23:35:17 +0000492
493 if None in results:
494 return None
mbligh912c3f32009-03-25 19:31:30 +0000495 elif False in results or "Abort" in results:
mbligh45ffc432008-12-09 23:35:17 +0000496 return False
497 else:
498 return True
mbligh5b618382008-12-03 15:24:01 +0000499
500
mbligh1f23f362008-12-22 14:46:12 +0000501 def _included_platform(self, host, platforms):
502 """
503 See if host's platforms matches any of the patterns in the included
504 platforms list.
505 """
506 if not platforms:
507 return True # No filtering of platforms
508 for platform in platforms:
509 if re.search(platform, host.platform):
510 return True
511 return False
512
513
mbligh7b312282009-01-07 16:45:43 +0000514 def invoke_test(self, pairing, kernel, kernel_label, priority='Medium',
Eric Lie0493a42010-11-15 13:05:43 -0800515 kernel_cmdline=None, **dargs):
mbligh5b618382008-12-03 15:24:01 +0000516 """
517 Given a pairing of a control file to a machine label, find all machines
518 with that label, and submit that control file to them.
mbligh1ef218d2009-08-03 16:57:56 +0000519
mbligh282ce892010-01-06 18:40:17 +0000520 @param kernel_label: Label (string) of the kernel to run such as
521 '<kernel-version> : <config> : <date>'
522 If any pairing object has its job_label attribute set it
523 will override this value for that particular job.
524
525 @returns A list of job objects.
mbligh5b618382008-12-03 15:24:01 +0000526 """
mbligh282ce892010-01-06 18:40:17 +0000527 # The pairing can override the job label.
528 if pairing.job_label:
529 kernel_label = pairing.job_label
mbligh5b618382008-12-03 15:24:01 +0000530 job_name = '%s : %s' % (pairing.machine_label, kernel_label)
531 hosts = self.get_hosts(multiple_labels=[pairing.machine_label])
mbligh1f23f362008-12-22 14:46:12 +0000532 platforms = pairing.platforms
533 hosts = [h for h in hosts if self._included_platform(h, platforms)]
mblighc2847b72009-03-25 19:32:20 +0000534 dead_statuses = self.host_statuses(live=False)
535 host_list = [h.hostname for h in hosts if h.status not in dead_statuses]
mbligh1f23f362008-12-22 14:46:12 +0000536 print 'HOSTS: %s' % host_list
mblighb9db5162009-04-17 22:21:41 +0000537 if pairing.atomic_group_sched:
mblighc99fccf2009-07-11 00:59:33 +0000538 dargs['synch_count'] = pairing.synch_count
mblighb9db5162009-04-17 22:21:41 +0000539 dargs['atomic_group_name'] = pairing.machine_label
540 else:
541 dargs['hosts'] = host_list
mbligh38b09152009-04-28 18:34:25 +0000542 new_job = self.create_job_by_test(name=job_name,
mbligh17c75e62009-06-08 16:18:21 +0000543 dependencies=[pairing.machine_label],
544 tests=[pairing.control_file],
545 priority=priority,
546 kernel=kernel,
Eric Lie0493a42010-11-15 13:05:43 -0800547 kernel_cmdline=kernel_cmdline,
mbligh17c75e62009-06-08 16:18:21 +0000548 use_container=pairing.container,
549 **dargs)
mbligh38b09152009-04-28 18:34:25 +0000550 if new_job:
mbligh17c75e62009-06-08 16:18:21 +0000551 if pairing.testname:
552 new_job.testname = pairing.testname
mbligh4e576612008-12-22 14:56:36 +0000553 print 'Invoked test %s : %s' % (new_job.id, job_name)
mbligh38b09152009-04-28 18:34:25 +0000554 return new_job
mbligh5b618382008-12-03 15:24:01 +0000555
556
mblighb9db5162009-04-17 22:21:41 +0000557 def _job_test_results(self, tko, job, debug, tests=[]):
mbligh5b618382008-12-03 15:24:01 +0000558 """
mbligh5280e3b2008-12-22 14:39:28 +0000559 Retrieve test results for a job
mbligh5b618382008-12-03 15:24:01 +0000560 """
mbligh5280e3b2008-12-22 14:39:28 +0000561 job.test_status = {}
562 try:
563 test_statuses = tko.get_status_counts(job=job.id)
564 except Exception:
565 print "Ignoring exception on poll job; RPC interface is flaky"
566 traceback.print_exc()
567 return
568
569 for test_status in test_statuses:
mbligh7479a182009-01-07 16:46:24 +0000570 # SERVER_JOB is buggy, and often gives false failures. Ignore it.
571 if test_status.test_name == 'SERVER_JOB':
572 continue
mblighb9db5162009-04-17 22:21:41 +0000573 # if tests is not empty, restrict list of test_statuses to tests
574 if tests and test_status.test_name not in tests:
575 continue
mbligh451ede12009-02-12 21:54:03 +0000576 if debug:
577 print test_status
mbligh5280e3b2008-12-22 14:39:28 +0000578 hostname = test_status.hostname
579 if hostname not in job.test_status:
580 job.test_status[hostname] = TestResults()
581 job.test_status[hostname].add(test_status)
582
583
mbligh451ede12009-02-12 21:54:03 +0000584 def _job_results_platform_map(self, job, debug):
mblighc9e427e2009-04-28 18:35:06 +0000585 # Figure out which hosts passed / failed / aborted in a job
586 # Creates a 2-dimensional hash, stored as job.results_platform_map
587 # 1st index - platform type (string)
588 # 2nd index - Status (string)
589 # 'Completed' / 'Failed' / 'Aborted'
590 # Data indexed by this hash is a list of hostnames (text strings)
mbligh5280e3b2008-12-22 14:39:28 +0000591 job.results_platform_map = {}
mbligh5b618382008-12-03 15:24:01 +0000592 try:
mbligh45ffc432008-12-09 23:35:17 +0000593 job_statuses = self.get_host_queue_entries(job=job.id)
mbligh5b618382008-12-03 15:24:01 +0000594 except Exception:
595 print "Ignoring exception on poll job; RPC interface is flaky"
596 traceback.print_exc()
597 return None
mbligh5280e3b2008-12-22 14:39:28 +0000598
mbligh5b618382008-12-03 15:24:01 +0000599 platform_map = {}
mbligh5280e3b2008-12-22 14:39:28 +0000600 job.job_status = {}
mbligh451ede12009-02-12 21:54:03 +0000601 job.metahost_index = {}
mbligh5b618382008-12-03 15:24:01 +0000602 for job_status in job_statuses:
mblighc9e427e2009-04-28 18:35:06 +0000603 # This is basically "for each host / metahost in the job"
mbligh451ede12009-02-12 21:54:03 +0000604 if job_status.host:
605 hostname = job_status.host.hostname
606 else: # This is a metahost
607 metahost = job_status.meta_host
608 index = job.metahost_index.get(metahost, 1)
609 job.metahost_index[metahost] = index + 1
610 hostname = '%s.%s' % (metahost, index)
mbligh5280e3b2008-12-22 14:39:28 +0000611 job.job_status[hostname] = job_status.status
mbligh5b618382008-12-03 15:24:01 +0000612 status = job_status.status
mbligh0ecbe632009-05-13 21:34:56 +0000613 # Skip hosts that failed verify or repair:
614 # that's a machine failure, not a job failure
mbligh451ede12009-02-12 21:54:03 +0000615 if hostname in job.test_status:
616 verify_failed = False
617 for failure in job.test_status[hostname].fail:
mbligh0ecbe632009-05-13 21:34:56 +0000618 if (failure.test_name == 'verify' or
619 failure.test_name == 'repair'):
mbligh451ede12009-02-12 21:54:03 +0000620 verify_failed = True
621 break
622 if verify_failed:
623 continue
mblighc9e427e2009-04-28 18:35:06 +0000624 if hostname in job.test_status and job.test_status[hostname].fail:
625 # If the any tests failed in the job, we want to mark the
626 # job result as failed, overriding the default job status.
627 if status != "Aborted": # except if it's an aborted job
628 status = 'Failed'
mbligh451ede12009-02-12 21:54:03 +0000629 if job_status.host:
630 platform = job_status.host.platform
631 else: # This is a metahost
632 platform = job_status.meta_host
mbligh5b618382008-12-03 15:24:01 +0000633 if platform not in platform_map:
634 platform_map[platform] = {'Total' : [hostname]}
635 else:
636 platform_map[platform]['Total'].append(hostname)
637 new_host_list = platform_map[platform].get(status, []) + [hostname]
638 platform_map[platform][status] = new_host_list
mbligh45ffc432008-12-09 23:35:17 +0000639 job.results_platform_map = platform_map
mbligh5280e3b2008-12-22 14:39:28 +0000640
641
mbligh17c75e62009-06-08 16:18:21 +0000642 def set_platform_results(self, test_job, platform, result):
643 """
644 Result must be None, 'FAIL', 'WARN' or 'GOOD'
645 """
646 if test_job.platform_results[platform] is not None:
647 # We're already done, and results recorded. This can't change later.
648 return
649 test_job.platform_results[platform] = result
650 # Note that self.job refers to the metajob we're IN, not the job
651 # that we're excuting from here.
652 testname = '%s.%s' % (test_job.testname, platform)
653 if self.job:
654 self.job.record(result, None, testname, status='')
655
Chris Masone6fed6462011-10-20 16:36:43 -0700656 def poll_job_results(self, tko, job, enough=1, debug=False):
mbligh5280e3b2008-12-22 14:39:28 +0000657 """
Chris Masone3a560bd2011-11-14 16:53:56 -0800658 Analyse all job results by platform
mbligh1ef218d2009-08-03 16:57:56 +0000659
Chris Masone3a560bd2011-11-14 16:53:56 -0800660 params:
661 tko: a TKO object representing the results DB.
662 job: the job to be examined.
Chris Masone6fed6462011-10-20 16:36:43 -0700663 enough: the acceptable delta between the number of completed
664 tests and the total number of tests.
Chris Masone3a560bd2011-11-14 16:53:56 -0800665 debug: enable debugging output.
666
667 returns:
Chris Masone6fed6462011-10-20 16:36:43 -0700668 False: if any platform has more than |enough| failures
669 None: if any platform has less than |enough| machines
Chris Masone3a560bd2011-11-14 16:53:56 -0800670 not yet Good.
Chris Masone6fed6462011-10-20 16:36:43 -0700671 True: if all platforms have at least |enough| machines
Chris Masone3a560bd2011-11-14 16:53:56 -0800672 Good.
mbligh5280e3b2008-12-22 14:39:28 +0000673 """
mbligh451ede12009-02-12 21:54:03 +0000674 self._job_test_results(tko, job, debug)
mblighe7fcf562009-05-21 01:43:17 +0000675 if job.test_status == {}:
676 return None
mbligh451ede12009-02-12 21:54:03 +0000677 self._job_results_platform_map(job, debug)
mbligh5280e3b2008-12-22 14:39:28 +0000678
mbligh5b618382008-12-03 15:24:01 +0000679 good_platforms = []
mbligh912c3f32009-03-25 19:31:30 +0000680 failed_platforms = []
681 aborted_platforms = []
mbligh5b618382008-12-03 15:24:01 +0000682 unknown_platforms = []
mbligh5280e3b2008-12-22 14:39:28 +0000683 platform_map = job.results_platform_map
mbligh5b618382008-12-03 15:24:01 +0000684 for platform in platform_map:
mbligh17c75e62009-06-08 16:18:21 +0000685 if not job.platform_results.has_key(platform):
686 # record test start, but there's no way to do this right now
687 job.platform_results[platform] = None
mbligh5b618382008-12-03 15:24:01 +0000688 total = len(platform_map[platform]['Total'])
689 completed = len(platform_map[platform].get('Completed', []))
mbligh912c3f32009-03-25 19:31:30 +0000690 failed = len(platform_map[platform].get('Failed', []))
691 aborted = len(platform_map[platform].get('Aborted', []))
mbligh17c75e62009-06-08 16:18:21 +0000692
mbligh1ef218d2009-08-03 16:57:56 +0000693 # We set up what we want to record here, but don't actually do
mbligh17c75e62009-06-08 16:18:21 +0000694 # it yet, until we have a decisive answer for this platform
695 if aborted or failed:
696 bad = aborted + failed
697 if (bad > 1) or (bad * 2 >= total):
698 platform_test_result = 'FAIL'
699 else:
700 platform_test_result = 'WARN'
701
Chris Masone6fed6462011-10-20 16:36:43 -0700702 if aborted > enough:
mbligh912c3f32009-03-25 19:31:30 +0000703 aborted_platforms.append(platform)
mbligh17c75e62009-06-08 16:18:21 +0000704 self.set_platform_results(job, platform, platform_test_result)
Chris Masone6fed6462011-10-20 16:36:43 -0700705 elif (failed * 2 >= total) or (failed > enough):
mbligh912c3f32009-03-25 19:31:30 +0000706 failed_platforms.append(platform)
mbligh17c75e62009-06-08 16:18:21 +0000707 self.set_platform_results(job, platform, platform_test_result)
Chris Masone6fed6462011-10-20 16:36:43 -0700708 elif (completed >= enough) and (completed + enough >= total):
mbligh5b618382008-12-03 15:24:01 +0000709 good_platforms.append(platform)
mbligh17c75e62009-06-08 16:18:21 +0000710 self.set_platform_results(job, platform, 'GOOD')
mbligh5b618382008-12-03 15:24:01 +0000711 else:
712 unknown_platforms.append(platform)
713 detail = []
714 for status in platform_map[platform]:
715 if status == 'Total':
716 continue
717 detail.append('%s=%s' % (status,platform_map[platform][status]))
718 if debug:
mbligh1ef218d2009-08-03 16:57:56 +0000719 print '%20s %d/%d %s' % (platform, completed, total,
mbligh5b618382008-12-03 15:24:01 +0000720 ' '.join(detail))
721 print
mbligh1ef218d2009-08-03 16:57:56 +0000722
mbligh912c3f32009-03-25 19:31:30 +0000723 if len(aborted_platforms) > 0:
mbligh5b618382008-12-03 15:24:01 +0000724 if debug:
mbligh17c75e62009-06-08 16:18:21 +0000725 print 'Result aborted - platforms: ',
726 print ' '.join(aborted_platforms)
mbligh912c3f32009-03-25 19:31:30 +0000727 return "Abort"
728 if len(failed_platforms) > 0:
729 if debug:
730 print 'Result bad - platforms: ' + ' '.join(failed_platforms)
mbligh5b618382008-12-03 15:24:01 +0000731 return False
732 if len(unknown_platforms) > 0:
733 if debug:
734 platform_list = ' '.join(unknown_platforms)
735 print 'Result unknown - platforms: ', platform_list
736 return None
737 if debug:
738 platform_list = ' '.join(good_platforms)
739 print 'Result good - all platforms passed: ', platform_list
740 return True
741
742
mbligh5280e3b2008-12-22 14:39:28 +0000743class TestResults(object):
744 """
745 Container class used to hold the results of the tests for a job
746 """
747 def __init__(self):
748 self.good = []
749 self.fail = []
mbligh451ede12009-02-12 21:54:03 +0000750 self.pending = []
mbligh5280e3b2008-12-22 14:39:28 +0000751
752
753 def add(self, result):
mbligh451ede12009-02-12 21:54:03 +0000754 if result.complete_count > result.pass_count:
755 self.fail.append(result)
756 elif result.incomplete_count > 0:
757 self.pending.append(result)
mbligh5280e3b2008-12-22 14:39:28 +0000758 else:
mbligh451ede12009-02-12 21:54:03 +0000759 self.good.append(result)
mbligh5280e3b2008-12-22 14:39:28 +0000760
761
762class RpcObject(object):
mbligh67647152008-11-19 00:18:14 +0000763 """
764 Generic object used to construct python objects from rpc calls
765 """
766 def __init__(self, afe, hash):
767 self.afe = afe
768 self.hash = hash
769 self.__dict__.update(hash)
770
771
772 def __str__(self):
773 return dump_object(self.__repr__(), self)
774
775
mbligh1354c9d2008-12-22 14:56:13 +0000776class ControlFile(RpcObject):
777 """
778 AFE control file object
779
780 Fields: synch_count, dependencies, control_file, is_server
781 """
782 def __repr__(self):
783 return 'CONTROL FILE: %s' % self.control_file
784
785
mbligh5280e3b2008-12-22 14:39:28 +0000786class Label(RpcObject):
mbligh67647152008-11-19 00:18:14 +0000787 """
788 AFE label object
789
790 Fields:
791 name, invalid, platform, kernel_config, id, only_if_needed
792 """
793 def __repr__(self):
794 return 'LABEL: %s' % self.name
795
796
797 def add_hosts(self, hosts):
Chris Masone3a560bd2011-11-14 16:53:56 -0800798 return self.afe.run('label_add_hosts', id=self.id, hosts=hosts)
mbligh67647152008-11-19 00:18:14 +0000799
800
801 def remove_hosts(self, hosts):
Chris Masone3a560bd2011-11-14 16:53:56 -0800802 return self.afe.run('label_remove_hosts', id=self.id, hosts=hosts)
mbligh67647152008-11-19 00:18:14 +0000803
804
mbligh5280e3b2008-12-22 14:39:28 +0000805class Acl(RpcObject):
mbligh67647152008-11-19 00:18:14 +0000806 """
807 AFE acl object
808
809 Fields:
810 users, hosts, description, name, id
811 """
812 def __repr__(self):
813 return 'ACL: %s' % self.name
814
815
816 def add_hosts(self, hosts):
817 self.afe.log('Adding hosts %s to ACL %s' % (hosts, self.name))
818 return self.afe.run('acl_group_add_hosts', self.id, hosts)
819
820
821 def remove_hosts(self, hosts):
822 self.afe.log('Removing hosts %s from ACL %s' % (hosts, self.name))
823 return self.afe.run('acl_group_remove_hosts', self.id, hosts)
824
825
mbligh54459c72009-01-21 19:26:44 +0000826 def add_users(self, users):
827 self.afe.log('Adding users %s to ACL %s' % (users, self.name))
828 return self.afe.run('acl_group_add_users', id=self.name, users=users)
829
830
mbligh5280e3b2008-12-22 14:39:28 +0000831class Job(RpcObject):
mbligh67647152008-11-19 00:18:14 +0000832 """
833 AFE job object
834
835 Fields:
836 name, control_file, control_type, synch_count, reboot_before,
837 run_verify, priority, email_list, created_on, dependencies,
838 timeout, owner, reboot_after, id
839 """
840 def __repr__(self):
841 return 'JOB: %s' % self.id
842
843
mbligh5280e3b2008-12-22 14:39:28 +0000844class JobStatus(RpcObject):
mbligh67647152008-11-19 00:18:14 +0000845 """
846 AFE job_status object
847
848 Fields:
849 status, complete, deleted, meta_host, host, active, execution_subdir, id
850 """
851 def __init__(self, afe, hash):
852 # This should call super
853 self.afe = afe
854 self.hash = hash
855 self.__dict__.update(hash)
mbligh5280e3b2008-12-22 14:39:28 +0000856 self.job = Job(afe, self.job)
Dale Curtis8adf7892011-09-08 16:13:36 -0700857 if getattr(self, 'host'):
mbligh99b24f42009-06-08 16:45:55 +0000858 self.host = Host(afe, self.host)
mbligh67647152008-11-19 00:18:14 +0000859
860
861 def __repr__(self):
mbligh451ede12009-02-12 21:54:03 +0000862 if self.host and self.host.hostname:
863 hostname = self.host.hostname
864 else:
865 hostname = 'None'
866 return 'JOB STATUS: %s-%s' % (self.job.id, hostname)
mbligh67647152008-11-19 00:18:14 +0000867
868
mbligh5280e3b2008-12-22 14:39:28 +0000869class Host(RpcObject):
mbligh67647152008-11-19 00:18:14 +0000870 """
871 AFE host object
872
873 Fields:
874 status, lock_time, locked_by, locked, hostname, invalid,
875 synch_id, labels, platform, protection, dirty, id
876 """
877 def __repr__(self):
878 return 'HOST OBJECT: %s' % self.hostname
879
880
881 def show(self):
882 labels = list(set(self.labels) - set([self.platform]))
883 print '%-6s %-7s %-7s %-16s %s' % (self.hostname, self.status,
884 self.locked, self.platform,
885 ', '.join(labels))
886
887
mbligh54459c72009-01-21 19:26:44 +0000888 def delete(self):
889 return self.afe.run('delete_host', id=self.id)
890
891
mbligh6463c4b2009-01-30 00:33:37 +0000892 def modify(self, **dargs):
893 return self.afe.run('modify_host', id=self.id, **dargs)
894
895
mbligh67647152008-11-19 00:18:14 +0000896 def get_acls(self):
897 return self.afe.get_acls(hosts__hostname=self.hostname)
898
899
900 def add_acl(self, acl_name):
901 self.afe.log('Adding ACL %s to host %s' % (acl_name, self.hostname))
902 return self.afe.run('acl_group_add_hosts', id=acl_name,
903 hosts=[self.hostname])
904
905
906 def remove_acl(self, acl_name):
907 self.afe.log('Removing ACL %s from host %s' % (acl_name, self.hostname))
908 return self.afe.run('acl_group_remove_hosts', id=acl_name,
909 hosts=[self.hostname])
910
911
912 def get_labels(self):
913 return self.afe.get_labels(host__hostname__in=[self.hostname])
914
915
916 def add_labels(self, labels):
917 self.afe.log('Adding labels %s to host %s' % (labels, self.hostname))
918 return self.afe.run('host_add_labels', id=self.id, labels=labels)
919
920
921 def remove_labels(self, labels):
922 self.afe.log('Removing labels %s from host %s' % (labels,self.hostname))
923 return self.afe.run('host_remove_labels', id=self.id, labels=labels)
mbligh5b618382008-12-03 15:24:01 +0000924
925
mbligh54459c72009-01-21 19:26:44 +0000926class User(RpcObject):
927 def __repr__(self):
928 return 'USER: %s' % self.login
929
930
mbligh5280e3b2008-12-22 14:39:28 +0000931class TestStatus(RpcObject):
mblighc31e4022008-12-11 19:32:30 +0000932 """
933 TKO test status object
934
935 Fields:
936 test_idx, hostname, testname, id
937 complete_count, incomplete_count, group_count, pass_count
938 """
939 def __repr__(self):
940 return 'TEST STATUS: %s' % self.id
941
942
MK Ryuacf35922014-10-03 14:56:49 -0700943class HostAttribute(RpcObject):
944 """
945 AFE host attribute object
946
947 Fields:
948 id, host, attribute, value
949 """
950 def __repr__(self):
951 return 'HOST ATTRIBUTE %d' % self.id
952
953
mbligh5b618382008-12-03 15:24:01 +0000954class MachineTestPairing(object):
955 """
956 Object representing the pairing of a machine label with a control file
mbligh1f23f362008-12-22 14:46:12 +0000957
958 machine_label: use machines from this label
959 control_file: use this control file (by name in the frontend)
960 platforms: list of rexeps to filter platforms by. [] => no filtering
mbligh282ce892010-01-06 18:40:17 +0000961 job_label: The label (name) to give to the autotest job launched
962 to run this pairing. '<kernel-version> : <config> : <date>'
mbligh5b618382008-12-03 15:24:01 +0000963 """
mbligh1354c9d2008-12-22 14:56:13 +0000964 def __init__(self, machine_label, control_file, platforms=[],
mbligh17c75e62009-06-08 16:18:21 +0000965 container=False, atomic_group_sched=False, synch_count=0,
mbligh282ce892010-01-06 18:40:17 +0000966 testname=None, job_label=None):
mbligh5b618382008-12-03 15:24:01 +0000967 self.machine_label = machine_label
968 self.control_file = control_file
mbligh1f23f362008-12-22 14:46:12 +0000969 self.platforms = platforms
mbligh1354c9d2008-12-22 14:56:13 +0000970 self.container = container
mblighb9db5162009-04-17 22:21:41 +0000971 self.atomic_group_sched = atomic_group_sched
972 self.synch_count = synch_count
mbligh17c75e62009-06-08 16:18:21 +0000973 self.testname = testname
mbligh282ce892010-01-06 18:40:17 +0000974 self.job_label = job_label
mbligh1354c9d2008-12-22 14:56:13 +0000975
976
977 def __repr__(self):
978 return '%s %s %s %s' % (self.machine_label, self.control_file,
979 self.platforms, self.container)