blob: 054404edb9237596e2871b371566f24edaae98d5 [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
Andy Doan61b4d772012-04-24 10:03:28 -0500118
Fathi Boudrac14068b2012-12-06 17:42:11 +0200119 actions = [{
120 "command": "deploy_linaro_image",
121 "parameters": {
122 "image": "%s" % args.img_url,
123 },
124 "metadata": {
125 "ubuntu.name": "%s" % args.image_name,
Fathi Boudra62eb6a92012-12-06 19:02:56 +0200126 "ubuntu.build": "%s" % args.build_number,
127 "rootfs.type": "%s" % args.rootfs_type,
Fathi Boudrac14068b2012-12-06 17:42:11 +0200128 "ubuntu.distribution": "%s" % distribution,
129 }
130 },
131 {
132 "command": "boot_linaro_image"
133 }]
134
135 for test in tests:
136 actions.append({
137 "command": "lava_test_install",
138 "parameters": {
139 "test_name": test
140 }
141 })
142
143 for test in tests:
144 actions.append({
145 "command": "lava_test_run",
146 "parameters": {
147 "test_name": test
148 }
149 })
150
151 actions.append({
152 "command": "submit_results",
153 "parameters": {
154 "stream": bundle_stream_name,
155 "server": "%s%s" % ("http://", lava_server)
156 }
157 })
158
159 config = json.dumps({"timeout": 18000,
160 "actions": actions,
161 "job_name": args.job_name,
162 "device_type": args.device_type,
163 }, indent=2)
Fathi Boudra79c1e8b2012-12-02 10:36:57 +0200164
165 skip_lava = os.environ.get("SKIP_LAVA")
166 if skip_lava == None:
Fathi Boudra79c1e8b2012-12-02 10:36:57 +0200167 try:
Fathi Boudrac14068b2012-12-06 17:42:11 +0200168 server_url = \
169 "https://{lava_user:>s}:{lava_token:>s}@{lava_server:>s}"
170 server = \
171 xmlrpclib.ServerProxy(server_url.format(\
172 lava_user=lava_user, \
173 lava_token=lava_token, \
174 lava_server=lava_server))
175 lava_job_id = server.scheduler.submit_job(config)
Fathi Boudra79c1e8b2012-12-02 10:36:57 +0200176 except xmlrpclib.ProtocolError, e:
Fathi Boudrac14068b2012-12-06 17:42:11 +0200177 print "Error making a LAVA request:", obfuscate_credentials(str(e))
Fathi Boudra79c1e8b2012-12-02 10:36:57 +0200178 sys.exit(1)
Fathi Boudrac14068b2012-12-06 17:42:11 +0200179
180 print lava_job_id
181 json.dump({'lava_url': "http://" + lava_server_root,
182 'job_id': lava_job_id},
183 open('lava-job-info', 'w'))
Fathi Boudra79c1e8b2012-12-02 10:36:57 +0200184 else:
185 print "LAVA job submission skipped."
Andy Doan61b4d772012-04-24 10:03:28 -0500186
187if __name__ == "__main__":
188 main()