blob: 5c06c86afe634290f1e8a09dfbb3c2b39e58b434 [file] [log] [blame]
Andy Doan61b4d772012-04-24 10:03:28 -05001#!/usr/bin/python
2
3import argparse
Andy Doan61b4d772012-04-24 10:03:28 -05004import os
Andy Doan61b4d772012-04-24 10:03:28 -05005import sys
Fathi Boudrac14068b2012-12-06 17:42:11 +02006import json
Andy Doan61b4d772012-04-24 10:03:28 -05007import xmlrpclib
Fathi Boudrac14068b2012-12-06 17:42:11 +02008import re
Andy Doan61b4d772012-04-24 10:03:28 -05009
Fathi Boudrac14068b2012-12-06 17:42:11 +020010tests_nano = [
11 'device-tree',
12 'gatortests',
13 'perf',
14 'pwrmgmt',
15 ]
16
17tests_alip = [
18 'bootchart',
19 ]
20
21tests_desktop = [
22 'e2eaudiotest',
23 'bluetooth-enablement',
24 'wifi-enablement',
25 'leb-basic-graphics',
26 ]
27
28tests_openembedded = [
29 ]
Andy Doan61b4d772012-04-24 10:03:28 -050030
Andy Doan3462e4c2012-05-18 10:58:06 -050031DEVICE_STREAM = {
32 'panda': 'leb-panda-4430',
Paul Larson27308512012-08-17 14:09:05 -050033 'panda-es': 'leb-panda-es',
Andy Doan3462e4c2012-05-18 10:58:06 -050034 'origen': 'leb-origen',
35 'snowball_sd': 'leb-snowball',
36 'beaglexm': 'beaglexm',
Fathi Boudra76551e52012-09-19 17:51:33 +030037 'vexpress-a9': 'vexpress',
Ricardo Salveti de Araujo58cc7842012-06-23 15:04:25 -030038 'mx53loco': 'mx53loco',
Fathi Boudrac14068b2012-12-06 17:42:11 +020039 'rtsm_foundation-armv8': 'vexpress64'
Andy Doan3462e4c2012-05-18 10:58:06 -050040}
41
Andy Doan61b4d772012-04-24 10:03:28 -050042
43def obfuscate_credentials(s):
44 return re.sub(r"([^ ]:).+?(@)", r"\1xxx\2", s)
45
Fathi Boudrac14068b2012-12-06 17:42:11 +020046
Andy Doan61b4d772012-04-24 10:03:28 -050047def main():
48 p = argparse.ArgumentParser(description='submits a benchmark job to lava')
49 p.add_argument('-j', dest='job_name', required=True,
50 help='name of job for LAVA')
51 p.add_argument('-u', dest='img_url', required=True,
52 help='URL of image')
53 p.add_argument('-d', dest='device_type', required=True,
54 help='The device type to execute on. ie "panda"')
Fathi Boudra62eb6a92012-12-06 19:02:56 +020055 p.add_argument('-t', dest='rootfs_type', default='nano',
56 help='The rootfs type to execute on, nano (default)')
Michael Hudson-Doylea15402f2012-07-12 13:23:27 +120057 p.add_argument('-n', dest='image_name', required=True,
58 help='The name of the image for QA purposes, e.g. "lt-panda-x11-base"')
Fathi Boudra62eb6a92012-12-06 19:02:56 +020059 p.add_argument('-c', dest='build_number', required=True,
Michael Hudson-Doylea15402f2012-07-12 13:23:27 +120060 help='The build number for this image')
Andy Doan61b4d772012-04-24 10:03:28 -050061 args = p.parse_args()
62
Fathi Boudrac14068b2012-12-06 17:42:11 +020063 # Distribution
64 ret_split = args.job_name.split('-', 2)
65 distribution = ret_split[0]
66
67 # Bundle stream name
68 bundle_stream_name = os.environ.get("BUNDLE_STREAM_NAME", \
69 "/private/team/linaro/pre-built-%s/" % DEVICE_STREAM[args.device_type])
70 # LAVA user
71 lava_user = os.environ.get("LAVA_USER")
72 if lava_user == None:
73 f = open('/var/run/lava/lava-user')
74 lava_user = f.read().strip()
75 f.close()
76 # LAVA token
77 lava_token = os.environ.get("LAVA_TOKEN")
78 if lava_token == None:
79 f = open('/var/run/lava/lava-token')
80 lava_token = f.read().strip()
81 f.close()
82 # LAVA server URL
83 lava_server = os.environ.get("LAVA_SERVER", \
84 "validation.linaro.org/lava-server/RPC2/")
85 # LAVA server base URL
86 lava_server_root = lava_server.rstrip("/")
87 if lava_server_root.endswith("/RPC2"):
88 lava_server_root = lava_server_root[:-len("/RPC2")]
89
90 # test sets specific to an image
Fathi Boudrac51e0912012-06-15 18:18:41 +030091 tests = tests_nano
92
Ricardo Salveti de Araujoacf28542012-06-27 18:56:00 -030093 # if ubuntu-desktop, cover more test cases (LEB)
Fathi Boudra62eb6a92012-12-06 19:02:56 +020094 if args.rootfs_type == 'ubuntu-desktop':
Fathi Boudrac51e0912012-06-15 18:18:41 +030095 tests += tests_desktop
Andy Doanbc19b7c2012-05-17 12:08:16 -050096
Ricardo Salveti de Araujo6ad94332012-06-29 02:48:18 -030097 # if alip, specific tests like bootchart (which should be first)
Fathi Boudra62eb6a92012-12-06 19:02:56 +020098 if args.rootfs_type == 'alip':
Ricardo Salveti de Araujo6ad94332012-06-29 02:48:18 -030099 tests = tests_alip + tests
100
Ricardo Salveti de Araujoacf28542012-06-27 18:56:00 -0300101 # removing bluetooth and wifi for devices that don't support it
Fathi Boudra76551e52012-09-19 17:51:33 +0300102 if args.device_type in ['beaglexm', 'vexpress-a9', 'mx53loco']:
Ricardo Salveti de Araujodd780972012-06-29 11:48:47 -0300103 try:
104 tests.remove('bluetooth-enablement')
105 tests.remove('wifi-enablement')
106 except ValueError:
107 pass
Ricardo Salveti de Araujoacf28542012-06-27 18:56:00 -0300108
109 # vexpress doesn't support PM, so disable pwrmgmt
Fathi Boudra76551e52012-09-19 17:51:33 +0300110 if args.device_type in ['vexpress-a9']:
Ricardo Salveti de Araujodd780972012-06-29 11:48:47 -0300111 try:
112 tests.remove('pwrmgmt')
113 except ValueError:
114 pass
Andy Doane9bf2152012-06-12 15:42:10 -0500115
Fathi Boudra62eb6a92012-12-06 19:02:56 +0200116 if distribution == 'openembedded':
Fathi Boudrac14068b2012-12-06 17:42:11 +0200117 tests = tests_openembedded
Fathi Boudra4079a582012-12-06 19:42:58 +0200118 actions = [{
119 "command": "deploy_linaro_image",
120 "parameters": {
Fathi Boudrac14068b2012-12-06 17:42:11 +0200121 "image": "%s" % args.img_url,
Fathi Boudra4079a582012-12-06 19:42:58 +0200122 },
123 "metadata": {
124 "hwpack.type": "%s" % args.image_name,
125 "hwpack.build": "%s" % args.build_number,
126 "rootfs.type": "%s" % args.rootfs_type,
127 "distribution": "%s" % distribution,
128 }
129 }]
130 else: # Distribution is Ubuntu
131 actions = [{
132 "command": "deploy_linaro_image",
133 "parameters": {
134 "image": "%s" % args.img_url,
135 },
136 "metadata": {
Fathi Boudrac14068b2012-12-06 17:42:11 +0200137 "ubuntu.name": "%s" % args.image_name,
Fathi Boudra62eb6a92012-12-06 19:02:56 +0200138 "ubuntu.build": "%s" % args.build_number,
139 "rootfs.type": "%s" % args.rootfs_type,
Fathi Boudrac14068b2012-12-06 17:42:11 +0200140 "ubuntu.distribution": "%s" % distribution,
Fathi Boudra4079a582012-12-06 19:42:58 +0200141 }
142 }]
143
144 actions.append({
Fathi Boudrac14068b2012-12-06 17:42:11 +0200145 "command": "boot_linaro_image"
Fathi Boudra4079a582012-12-06 19:42:58 +0200146 })
Fathi Boudrac14068b2012-12-06 17:42:11 +0200147
148 for test in tests:
149 actions.append({
150 "command": "lava_test_install",
151 "parameters": {
152 "test_name": test
153 }
154 })
155
156 for test in tests:
157 actions.append({
158 "command": "lava_test_run",
159 "parameters": {
160 "test_name": test
161 }
162 })
163
164 actions.append({
165 "command": "submit_results",
166 "parameters": {
167 "stream": bundle_stream_name,
168 "server": "%s%s" % ("http://", lava_server)
169 }
170 })
171
172 config = json.dumps({"timeout": 18000,
173 "actions": actions,
174 "job_name": args.job_name,
175 "device_type": args.device_type,
176 }, indent=2)
Fathi Boudra79c1e8b2012-12-02 10:36:57 +0200177
178 skip_lava = os.environ.get("SKIP_LAVA")
179 if skip_lava == None:
Fathi Boudra79c1e8b2012-12-02 10:36:57 +0200180 try:
Fathi Boudrac14068b2012-12-06 17:42:11 +0200181 server_url = \
182 "https://{lava_user:>s}:{lava_token:>s}@{lava_server:>s}"
183 server = \
184 xmlrpclib.ServerProxy(server_url.format(\
185 lava_user=lava_user, \
186 lava_token=lava_token, \
187 lava_server=lava_server))
188 lava_job_id = server.scheduler.submit_job(config)
Fathi Boudra79c1e8b2012-12-02 10:36:57 +0200189 except xmlrpclib.ProtocolError, e:
Fathi Boudrac14068b2012-12-06 17:42:11 +0200190 print "Error making a LAVA request:", obfuscate_credentials(str(e))
Fathi Boudra79c1e8b2012-12-02 10:36:57 +0200191 sys.exit(1)
Fathi Boudrac14068b2012-12-06 17:42:11 +0200192
193 print lava_job_id
194 json.dump({'lava_url': "http://" + lava_server_root,
195 'job_id': lava_job_id},
196 open('lava-job-info', 'w'))
Fathi Boudra79c1e8b2012-12-02 10:36:57 +0200197 else:
198 print "LAVA job submission skipped."
Andy Doan61b4d772012-04-24 10:03:28 -0500199
200if __name__ == "__main__":
201 main()