Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: server/frontend.py

Issue 4823005: Merge remote branch 'cros/upstream' into tempbranch (Closed) Base URL: http://git.chromium.org/git/autotest.git@master
Patch Set: patch Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « scheduler/scheduler_config.py ('k') | server/git_kernel.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright Martin J. Bligh, Google Inc 2008 1 # Copyright Martin J. Bligh, Google Inc 2008
2 # Released under the GPL v2 2 # Released under the GPL v2
3 3
4 """ 4 """
5 This class allows you to communicate with the frontend to submit jobs etc 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 6 It is designed for writing more sophisiticated server-side control files that
7 can recursively add and manage other jobs. 7 can recursively add and manage other jobs.
8 8
9 We turn the JSON dictionaries into real objects that are more idiomatic 9 We turn the JSON dictionaries into real objects that are more idiomatic
10 10
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 host_hash[host.hostname] = host 256 host_hash[host.hostname] = host
257 for status in job_statuses: 257 for status in job_statuses:
258 if status.host: 258 if status.host:
259 status.host = host_hash[status.host.hostname] 259 status.host = host_hash[status.host.hostname]
260 # filter job statuses that have either host or meta_host 260 # filter job statuses that have either host or meta_host
261 return [status for status in job_statuses if (status.host or 261 return [status for status in job_statuses if (status.host or
262 status.meta_host)] 262 status.meta_host)]
263 263
264 264
265 def create_job_by_test(self, tests, kernel=None, use_container=False, 265 def create_job_by_test(self, tests, kernel=None, use_container=False,
266 **dargs): 266 kernel_cmdline=None, **dargs):
267 """ 267 """
268 Given a test name, fetch the appropriate control file from the server 268 Given a test name, fetch the appropriate control file from the server
269 and submit it. 269 and submit it.
270 270
271 @param kernel: A comma separated list of kernel versions to boot.
272 @param kernel_cmdline: The command line used to boot all kernels listed
273 in the kernel parameter.
274
271 Returns a list of job objects 275 Returns a list of job objects
272 """ 276 """
273 assert ('hosts' in dargs or 277 assert ('hosts' in dargs or
274 'atomic_group_name' in dargs and 'synch_count' in dargs) 278 'atomic_group_name' in dargs and 'synch_count' in dargs)
275 if kernel: 279 if kernel:
276 kernel_list = re.split('[\s,]+', kernel.strip()) 280 kernel_list = re.split('[\s,]+', kernel.strip())
277 kernel_info = [{'version': version} for version in kernel_list] 281 kernel_info = []
282 for version in kernel_list:
283 kernel_dict = {'version': version}
284 if kernel_cmdline is not None:
285 kernel_dict['cmdline'] = kernel_cmdline
286 kernel_info.append(kernel_dict)
278 else: 287 else:
279 kernel_info = None 288 kernel_info = None
280 control_file = self.generate_control_file( 289 control_file = self.generate_control_file(
281 tests=tests, kernel=kernel_info, use_container=use_container, 290 tests=tests, kernel=kernel_info, use_container=use_container,
282 do_push_packages=True) 291 do_push_packages=True)
283 if control_file.is_server: 292 if control_file.is_server:
284 dargs['control_type'] = 'Server' 293 dargs['control_type'] = 'Server'
285 else: 294 else:
286 dargs['control_type'] = 'Client' 295 dargs['control_type'] = 'Client'
287 dargs['dependencies'] = dargs.get('dependencies', []) + \ 296 dargs['dependencies'] = dargs.get('dependencies', []) + \
(...skipping 10 matching lines...) Expand all
298 def create_job(self, control_file, name=' ', priority='Medium', 307 def create_job(self, control_file, name=' ', priority='Medium',
299 control_type='Client', **dargs): 308 control_type='Client', **dargs):
300 id = self.run('create_job', name=name, priority=priority, 309 id = self.run('create_job', name=name, priority=priority,
301 control_file=control_file, control_type=control_type, **dargs) 310 control_file=control_file, control_type=control_type, **dargs)
302 return self.get_jobs(id=id)[0] 311 return self.get_jobs(id=id)[0]
303 312
304 313
305 def run_test_suites(self, pairings, kernel, kernel_label=None, 314 def run_test_suites(self, pairings, kernel, kernel_label=None,
306 priority='Medium', wait=True, poll_interval=10, 315 priority='Medium', wait=True, poll_interval=10,
307 email_from=None, email_to=None, timeout=168, 316 email_from=None, email_to=None, timeout=168,
308 max_runtime_hrs=168): 317 max_runtime_hrs=168, kernel_cmdline=None):
309 """ 318 """
310 Run a list of test suites on a particular kernel. 319 Run a list of test suites on a particular kernel.
311 320
312 Poll for them to complete, and return whether they worked or not. 321 Poll for them to complete, and return whether they worked or not.
313 322
314 @param pairings: List of MachineTestPairing objects to invoke. 323 @param pairings: List of MachineTestPairing objects to invoke.
315 @param kernel: Name of the kernel to run. 324 @param kernel: Name of the kernel to run.
316 @param kernel_label: Label (string) of the kernel to run such as 325 @param kernel_label: Label (string) of the kernel to run such as
317 '<kernel-version> : <config> : <date>' 326 '<kernel-version> : <config> : <date>'
318 If any pairing object has its job_label attribute set it 327 If any pairing object has its job_label attribute set it
319 will override this value for that particular job. 328 will override this value for that particular job.
329 @param kernel_cmdline: The command line to boot the kernel(s) with.
320 @param wait: boolean - Wait for the results to come back? 330 @param wait: boolean - Wait for the results to come back?
321 @param poll_interval: Interval between polling for job results (in mins) 331 @param poll_interval: Interval between polling for job results (in mins)
322 @param email_from: Send notification email upon completion from here. 332 @param email_from: Send notification email upon completion from here.
323 @param email_from: Send notification email upon completion to here. 333 @param email_from: Send notification email upon completion to here.
324 """ 334 """
325 jobs = [] 335 jobs = []
326 for pairing in pairings: 336 for pairing in pairings:
327 try: 337 try:
328 new_job = self.invoke_test(pairing, kernel, kernel_label, 338 new_job = self.invoke_test(pairing, kernel, kernel_label,
329 priority, timeout=timeout, 339 priority, timeout=timeout,
340 kernel_cmdline=kernel_cmdline,
330 max_runtime_hrs=max_runtime_hrs) 341 max_runtime_hrs=max_runtime_hrs)
331 if not new_job: 342 if not new_job:
332 continue 343 continue
333 jobs.append(new_job) 344 jobs.append(new_job)
334 except Exception, e: 345 except Exception, e:
335 traceback.print_exc() 346 traceback.print_exc()
336 if not wait or not jobs: 347 if not wait or not jobs:
337 return 348 return
338 tko = TKO() 349 tko = TKO()
339 while True: 350 while True:
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 """ 458 """
448 if not platforms: 459 if not platforms:
449 return True # No filtering of platforms 460 return True # No filtering of platforms
450 for platform in platforms: 461 for platform in platforms:
451 if re.search(platform, host.platform): 462 if re.search(platform, host.platform):
452 return True 463 return True
453 return False 464 return False
454 465
455 466
456 def invoke_test(self, pairing, kernel, kernel_label, priority='Medium', 467 def invoke_test(self, pairing, kernel, kernel_label, priority='Medium',
457 **dargs): 468 kernel_cmdline=None, **dargs):
458 """ 469 """
459 Given a pairing of a control file to a machine label, find all machines 470 Given a pairing of a control file to a machine label, find all machines
460 with that label, and submit that control file to them. 471 with that label, and submit that control file to them.
461 472
462 @param kernel_label: Label (string) of the kernel to run such as 473 @param kernel_label: Label (string) of the kernel to run such as
463 '<kernel-version> : <config> : <date>' 474 '<kernel-version> : <config> : <date>'
464 If any pairing object has its job_label attribute set it 475 If any pairing object has its job_label attribute set it
465 will override this value for that particular job. 476 will override this value for that particular job.
466 477
467 @returns A list of job objects. 478 @returns A list of job objects.
(...skipping 11 matching lines...) Expand all
479 if pairing.atomic_group_sched: 490 if pairing.atomic_group_sched:
480 dargs['synch_count'] = pairing.synch_count 491 dargs['synch_count'] = pairing.synch_count
481 dargs['atomic_group_name'] = pairing.machine_label 492 dargs['atomic_group_name'] = pairing.machine_label
482 else: 493 else:
483 dargs['hosts'] = host_list 494 dargs['hosts'] = host_list
484 new_job = self.create_job_by_test(name=job_name, 495 new_job = self.create_job_by_test(name=job_name,
485 dependencies=[pairing.machine_label], 496 dependencies=[pairing.machine_label],
486 tests=[pairing.control_file], 497 tests=[pairing.control_file],
487 priority=priority, 498 priority=priority,
488 kernel=kernel, 499 kernel=kernel,
500 kernel_cmdline=kernel_cmdline,
489 use_container=pairing.container, 501 use_container=pairing.container,
490 **dargs) 502 **dargs)
491 if new_job: 503 if new_job:
492 if pairing.testname: 504 if pairing.testname:
493 new_job.testname = pairing.testname 505 new_job.testname = pairing.testname
494 print 'Invoked test %s : %s' % (new_job.id, job_name) 506 print 'Invoked test %s : %s' % (new_job.id, job_name)
495 return new_job 507 return new_job
496 508
497 509
498 def _job_test_results(self, tko, job, debug, tests=[]): 510 def _job_test_results(self, tko, job, debug, tests=[]):
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 self.container = container 904 self.container = container
893 self.atomic_group_sched = atomic_group_sched 905 self.atomic_group_sched = atomic_group_sched
894 self.synch_count = synch_count 906 self.synch_count = synch_count
895 self.testname = testname 907 self.testname = testname
896 self.job_label = job_label 908 self.job_label = job_label
897 909
898 910
899 def __repr__(self): 911 def __repr__(self):
900 return '%s %s %s %s' % (self.machine_label, self.control_file, 912 return '%s %s %s %s' % (self.machine_label, self.control_file,
901 self.platforms, self.container) 913 self.platforms, self.container)
OLDNEW
« no previous file with comments | « scheduler/scheduler_config.py ('k') | server/git_kernel.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698