blob: 2b65c3ac6382951ec86b07de3f60e7c1b38084eb [file] [log] [blame]
Andy Doan61b4d772012-04-24 10:03:28 -05001#!/usr/bin/python
2
3import argparse
Andy Doanbc19b7c2012-05-17 12:08:16 -05004import collections
Andy Doan61b4d772012-04-24 10:03:28 -05005import json
6import os
7import re
8import string
9import sys
10import xmlrpclib
11
12SERVER='validation.linaro.org/lava-server/RPC2/'
Andy Doan61b4d772012-04-24 10:03:28 -050013
Andy Doan3462e4c2012-05-18 10:58:06 -050014DEVICE_STREAM = {
15 'panda': 'leb-panda-4430',
16 'origen': 'leb-origen',
17 'snowball_sd': 'leb-snowball',
18 'beaglexm': 'beaglexm',
Andy Doan58e90012012-06-08 12:13:53 -050019 'vexpress': 'vexpress',
Ricardo Salveti de Araujo58cc7842012-06-23 15:04:25 -030020 'mx53loco': 'mx53loco',
Andy Doan3462e4c2012-05-18 10:58:06 -050021}
22
Ricardo Salveti de Araujo42b0a242012-05-29 14:07:56 -030023tests_nano = [
Ricardo Salveti de Araujo42b0a242012-05-29 14:07:56 -030024 'gatortests',
Ricardo Salveti de Araujoacf28542012-06-27 18:56:00 -030025 'pwrmgmt',
Ricardo Salveti de Araujo42b0a242012-05-29 14:07:56 -030026 'perf',
Ricardo Salveti de Araujo42b0a242012-05-29 14:07:56 -030027]
28
Ricardo Salveti de Araujo6ad94332012-06-29 02:48:18 -030029tests_alip = [
30 'bootchart',
31]
32
Ricardo Salveti de Araujo42b0a242012-05-29 14:07:56 -030033tests_desktop = [
34 'e2eaudiotest',
35 'bluetooth-enablement',
Ricardo Salveti de Araujoacf28542012-06-27 18:56:00 -030036 'wifi-enablement',
Ricardo Salveti de Araujo42b0a242012-05-29 14:07:56 -030037 'leb-basic-graphics',
38]
39
Andy Doanbc19b7c2012-05-17 12:08:16 -050040def get_install_action(tests):
41 return {
42 'command': 'lava_test_install',
43 'parameters': {
44 'tests': tests
45 }
46 }
Andy Doan61b4d772012-04-24 10:03:28 -050047
Andy Doanbc19b7c2012-05-17 12:08:16 -050048def get_test_actions(tests):
49 actions = []
50 for t in tests:
51 actions.append( {
52 'command': 'lava_test_run',
Fathi Boudra73d3b832012-06-15 17:49:14 +030053 'parameters': { 'test_name': t }
Andy Doanbc19b7c2012-05-17 12:08:16 -050054 })
55 return actions
Andy Doan7fb9f7c2012-05-03 22:49:02 -050056
Michael Hudson-Doylea15402f2012-07-12 13:23:27 +120057def get_job(jobname, device_type, img_url, tests, image_name, image_number):
Andy Doanea529ba2012-05-21 18:49:05 -050058 stream = '/private/team/linaro/pre-built-%s/' % DEVICE_STREAM[device_type]
Andy Doan3462e4c2012-05-18 10:58:06 -050059
Andy Doanbc19b7c2012-05-17 12:08:16 -050060 job = collections.OrderedDict()
61 job['job_name'] = jobname
62 job['device_type'] = device_type
63 job['timeout'] = 18000
64 job['actions'] = [
Fathi Boudra73d3b832012-06-15 17:49:14 +030065 {
Andy Doanbc19b7c2012-05-17 12:08:16 -050066 'command': "deploy_linaro_image",
67 'parameters': {
Fathi Boudra73d3b832012-06-15 17:49:14 +030068 'image': img_url
Michael Hudson-Doylea15402f2012-07-12 13:23:27 +120069 },
70 'metadata': {
71 'ubuntu.name': image_name,
72 'ubuntu.build': image_number
Andy Doanbc19b7c2012-05-17 12:08:16 -050073 }
74 },
Fathi Boudra73d3b832012-06-15 17:49:14 +030075 {
76 'command': 'boot_linaro_image'
77 }
Andy Doanbc19b7c2012-05-17 12:08:16 -050078 ]
79 job['actions'].append(get_install_action(tests))
80 job['actions'].extend(get_test_actions(tests))
81 job['actions'].append(
82 {
83 'command': 'submit_results',
84 'parameters': {
Andy Doan3462e4c2012-05-18 10:58:06 -050085 'stream': stream,
Andy Doanbc19b7c2012-05-17 12:08:16 -050086 'server': 'http://validation.linaro.org/lava-server/RPC2/'
87 }
88 }
89 )
90 return json.dumps(job, indent=4)
Andy Doan61b4d772012-04-24 10:03:28 -050091
92def obfuscate_credentials(s):
93 return re.sub(r"([^ ]:).+?(@)", r"\1xxx\2", s)
94
95def main():
96 p = argparse.ArgumentParser(description='submits a benchmark job to lava')
97 p.add_argument('-j', dest='job_name', required=True,
98 help='name of job for LAVA')
99 p.add_argument('-u', dest='img_url', required=True,
100 help='URL of image')
101 p.add_argument('-d', dest='device_type', required=True,
102 help='The device type to execute on. ie "panda"')
Ricardo Salveti de Araujo42b0a242012-05-29 14:07:56 -0300103 p.add_argument('-t', dest='image_type', default='nano',
104 help='The image type to execute on, nano (default) or ubuntu-desktop')
Michael Hudson-Doylea15402f2012-07-12 13:23:27 +1200105 p.add_argument('-n', dest='image_name', required=True,
106 help='The name of the image for QA purposes, e.g. "lt-panda-x11-base"')
107 p.add_argument('-c', dest='image_number', required=True,
108 help='The build number for this image')
Andy Doan61b4d772012-04-24 10:03:28 -0500109 args = p.parse_args()
110
Ricardo Salveti de Araujoacf28542012-06-27 18:56:00 -0300111 # test sets specific to images and boards
Fathi Boudrac51e0912012-06-15 18:18:41 +0300112 tests = tests_nano
113
Ricardo Salveti de Araujoacf28542012-06-27 18:56:00 -0300114 # if ubuntu-desktop, cover more test cases (LEB)
Ricardo Salveti de Araujo070048a2012-05-31 00:30:14 +0800115 if args.image_type == 'ubuntu-desktop':
Fathi Boudrac51e0912012-06-15 18:18:41 +0300116 tests += tests_desktop
Andy Doanbc19b7c2012-05-17 12:08:16 -0500117
Ricardo Salveti de Araujo6ad94332012-06-29 02:48:18 -0300118 # if alip, specific tests like bootchart (which should be first)
119 if args.image_type == 'alip':
120 tests = tests_alip + tests
121
Ricardo Salveti de Araujoacf28542012-06-27 18:56:00 -0300122 # removing bluetooth and wifi for devices that don't support it
123 if args.device_type in ['beaglexm', 'vexpress', 'mx53loco']:
Ricardo Salveti de Araujodd780972012-06-29 11:48:47 -0300124 try:
125 tests.remove('bluetooth-enablement')
126 tests.remove('wifi-enablement')
127 except ValueError:
128 pass
Ricardo Salveti de Araujoacf28542012-06-27 18:56:00 -0300129
130 # vexpress doesn't support PM, so disable pwrmgmt
131 if args.device_type in ['vexpress']:
Ricardo Salveti de Araujodd780972012-06-29 11:48:47 -0300132 try:
133 tests.remove('pwrmgmt')
134 except ValueError:
135 pass
Andy Doane9bf2152012-06-12 15:42:10 -0500136
Michael Hudson-Doylea15402f2012-07-12 13:23:27 +1200137 job = get_job(args.job_name, args.device_type, args.img_url, tests,
138 args.image_name, args.image_number)
Andy Doan61b4d772012-04-24 10:03:28 -0500139
140 user = os.environ.get('LAVA_USER')
141 token = os.environ.get('LAVA_TOKEN')
142 if user is None or token is None:
Ricardo Salveti de Araujoba7dacf2012-06-23 01:08:24 -0300143 print "ERROR: LAVA_USER and LAVA_TOKEN environment variables are required"
Andy Doan35ee9dc2012-05-11 01:10:12 -0500144 sys.exit(1)
Andy Doan61b4d772012-04-24 10:03:28 -0500145 server = xmlrpclib.ServerProxy("https://%s:%s@%s" % (user, token, SERVER))
146 try:
147 lava_job_id = server.scheduler.submit_job(job)
Andy Doan35ee9dc2012-05-11 01:10:12 -0500148 print lava_job_id
Andy Doan61b4d772012-04-24 10:03:28 -0500149 except xmlrpclib.ProtocolError, e:
Ricardo Salveti de Araujoba7dacf2012-06-23 01:08:24 -0300150 print "ERROR: Error making a LAVA request:", obfuscate_credentials(str(e))
Andy Doan61b4d772012-04-24 10:03:28 -0500151 sys.exit(1)
152
153if __name__ == "__main__":
154 main()