blob: 50f31ae72ac23546ca773b9624322ececf610026 [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
Andy Doan61b4d772012-04-24 10:03:28 -05008import sys
9import xmlrpclib
10
11SERVER='validation.linaro.org/lava-server/RPC2/'
Andy Doan61b4d772012-04-24 10:03:28 -050012
Andy Doan3462e4c2012-05-18 10:58:06 -050013DEVICE_STREAM = {
14 'panda': 'leb-panda-4430',
Paul Larson27308512012-08-17 14:09:05 -050015 'panda-es': 'leb-panda-es',
Andy Doan3462e4c2012-05-18 10:58:06 -050016 'origen': 'leb-origen',
17 'snowball_sd': 'leb-snowball',
18 'beaglexm': 'beaglexm',
Fathi Boudra76551e52012-09-19 17:51:33 +030019 'vexpress-a9': '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-Doyleafa68ce2012-07-16 11:38:16 +120057def get_job(jobname, device_type, img_url, tests, image_name, image_number,
Paul Larsoneca44492012-08-17 13:51:48 -050058 image_type):
Andy Doanea529ba2012-05-21 18:49:05 -050059 stream = '/private/team/linaro/pre-built-%s/' % DEVICE_STREAM[device_type]
Andy Doan3462e4c2012-05-18 10:58:06 -050060
Andy Doanbc19b7c2012-05-17 12:08:16 -050061 job = collections.OrderedDict()
62 job['job_name'] = jobname
63 job['device_type'] = device_type
64 job['timeout'] = 18000
65 job['actions'] = [
Fathi Boudra73d3b832012-06-15 17:49:14 +030066 {
Andy Doanbc19b7c2012-05-17 12:08:16 -050067 'command': "deploy_linaro_image",
68 'parameters': {
Fathi Boudra73d3b832012-06-15 17:49:14 +030069 'image': img_url
Michael Hudson-Doylea15402f2012-07-12 13:23:27 +120070 },
71 'metadata': {
72 'ubuntu.name': image_name,
Michael Hudson-Doyleafa68ce2012-07-16 11:38:16 +120073 'ubuntu.build': image_number,
74 'ubuntu.image_type': image_type,
Andy Doanbc19b7c2012-05-17 12:08:16 -050075 }
76 },
Fathi Boudra73d3b832012-06-15 17:49:14 +030077 {
78 'command': 'boot_linaro_image'
79 }
Andy Doanbc19b7c2012-05-17 12:08:16 -050080 ]
81 job['actions'].append(get_install_action(tests))
82 job['actions'].extend(get_test_actions(tests))
83 job['actions'].append(
84 {
85 'command': 'submit_results',
86 'parameters': {
Andy Doan3462e4c2012-05-18 10:58:06 -050087 'stream': stream,
Andy Doanbc19b7c2012-05-17 12:08:16 -050088 'server': 'http://validation.linaro.org/lava-server/RPC2/'
89 }
90 }
91 )
92 return json.dumps(job, indent=4)
Andy Doan61b4d772012-04-24 10:03:28 -050093
94def obfuscate_credentials(s):
95 return re.sub(r"([^ ]:).+?(@)", r"\1xxx\2", s)
96
97def main():
98 p = argparse.ArgumentParser(description='submits a benchmark job to lava')
99 p.add_argument('-j', dest='job_name', required=True,
100 help='name of job for LAVA')
101 p.add_argument('-u', dest='img_url', required=True,
102 help='URL of image')
103 p.add_argument('-d', dest='device_type', required=True,
104 help='The device type to execute on. ie "panda"')
Ricardo Salveti de Araujo42b0a242012-05-29 14:07:56 -0300105 p.add_argument('-t', dest='image_type', default='nano',
106 help='The image type to execute on, nano (default) or ubuntu-desktop')
Michael Hudson-Doylea15402f2012-07-12 13:23:27 +1200107 p.add_argument('-n', dest='image_name', required=True,
108 help='The name of the image for QA purposes, e.g. "lt-panda-x11-base"')
109 p.add_argument('-c', dest='image_number', required=True,
110 help='The build number for this image')
Andy Doan61b4d772012-04-24 10:03:28 -0500111 args = p.parse_args()
112
Ricardo Salveti de Araujoacf28542012-06-27 18:56:00 -0300113 # test sets specific to images and boards
Fathi Boudrac51e0912012-06-15 18:18:41 +0300114 tests = tests_nano
115
Ricardo Salveti de Araujoacf28542012-06-27 18:56:00 -0300116 # if ubuntu-desktop, cover more test cases (LEB)
Ricardo Salveti de Araujo070048a2012-05-31 00:30:14 +0800117 if args.image_type == 'ubuntu-desktop':
Fathi Boudrac51e0912012-06-15 18:18:41 +0300118 tests += tests_desktop
Andy Doanbc19b7c2012-05-17 12:08:16 -0500119
Ricardo Salveti de Araujo6ad94332012-06-29 02:48:18 -0300120 # if alip, specific tests like bootchart (which should be first)
121 if args.image_type == 'alip':
122 tests = tests_alip + tests
123
Ricardo Salveti de Araujoacf28542012-06-27 18:56:00 -0300124 # removing bluetooth and wifi for devices that don't support it
Fathi Boudra76551e52012-09-19 17:51:33 +0300125 if args.device_type in ['beaglexm', 'vexpress-a9', 'mx53loco']:
Ricardo Salveti de Araujodd780972012-06-29 11:48:47 -0300126 try:
127 tests.remove('bluetooth-enablement')
128 tests.remove('wifi-enablement')
129 except ValueError:
130 pass
Ricardo Salveti de Araujoacf28542012-06-27 18:56:00 -0300131
132 # vexpress doesn't support PM, so disable pwrmgmt
Fathi Boudra76551e52012-09-19 17:51:33 +0300133 if args.device_type in ['vexpress-a9']:
Ricardo Salveti de Araujodd780972012-06-29 11:48:47 -0300134 try:
135 tests.remove('pwrmgmt')
136 except ValueError:
137 pass
Andy Doane9bf2152012-06-12 15:42:10 -0500138
Michael Hudson-Doylea15402f2012-07-12 13:23:27 +1200139 job = get_job(args.job_name, args.device_type, args.img_url, tests,
Paul Larsoneca44492012-08-17 13:51:48 -0500140 args.image_name, args.image_number, args.image_type)
Andy Doan61b4d772012-04-24 10:03:28 -0500141
142 user = os.environ.get('LAVA_USER')
143 token = os.environ.get('LAVA_TOKEN')
144 if user is None or token is None:
Ricardo Salveti de Araujoba7dacf2012-06-23 01:08:24 -0300145 print "ERROR: LAVA_USER and LAVA_TOKEN environment variables are required"
Andy Doan35ee9dc2012-05-11 01:10:12 -0500146 sys.exit(1)
Andy Doan61b4d772012-04-24 10:03:28 -0500147 server = xmlrpclib.ServerProxy("https://%s:%s@%s" % (user, token, SERVER))
148 try:
149 lava_job_id = server.scheduler.submit_job(job)
Andy Doan35ee9dc2012-05-11 01:10:12 -0500150 print lava_job_id
Andy Doan61b4d772012-04-24 10:03:28 -0500151 except xmlrpclib.ProtocolError, e:
Ricardo Salveti de Araujoba7dacf2012-06-23 01:08:24 -0300152 print "ERROR: Error making a LAVA request:", obfuscate_credentials(str(e))
Andy Doan61b4d772012-04-24 10:03:28 -0500153 sys.exit(1)
154
155if __name__ == "__main__":
156 main()