blob: 054404edb9237596e2871b371566f24edaae98d5 [file] [log] [blame]
#!/usr/bin/python
import argparse
import os
import sys
import json
import xmlrpclib
import re
tests_nano = [
'device-tree',
'gatortests',
'perf',
'pwrmgmt',
]
tests_alip = [
'bootchart',
]
tests_desktop = [
'e2eaudiotest',
'bluetooth-enablement',
'wifi-enablement',
'leb-basic-graphics',
]
tests_openembedded = [
]
DEVICE_STREAM = {
'panda': 'leb-panda-4430',
'panda-es': 'leb-panda-es',
'origen': 'leb-origen',
'snowball_sd': 'leb-snowball',
'beaglexm': 'beaglexm',
'vexpress-a9': 'vexpress',
'mx53loco': 'mx53loco',
'rtsm_foundation-armv8': 'vexpress64'
}
def obfuscate_credentials(s):
return re.sub(r"([^ ]:).+?(@)", r"\1xxx\2", s)
def main():
p = argparse.ArgumentParser(description='submits a benchmark job to lava')
p.add_argument('-j', dest='job_name', required=True,
help='name of job for LAVA')
p.add_argument('-u', dest='img_url', required=True,
help='URL of image')
p.add_argument('-d', dest='device_type', required=True,
help='The device type to execute on. ie "panda"')
p.add_argument('-t', dest='rootfs_type', default='nano',
help='The rootfs type to execute on, nano (default)')
p.add_argument('-n', dest='image_name', required=True,
help='The name of the image for QA purposes, e.g. "lt-panda-x11-base"')
p.add_argument('-c', dest='build_number', required=True,
help='The build number for this image')
args = p.parse_args()
# Distribution
ret_split = args.job_name.split('-', 2)
distribution = ret_split[0]
# Bundle stream name
bundle_stream_name = os.environ.get("BUNDLE_STREAM_NAME", \
"/private/team/linaro/pre-built-%s/" % DEVICE_STREAM[args.device_type])
# LAVA user
lava_user = os.environ.get("LAVA_USER")
if lava_user == None:
f = open('/var/run/lava/lava-user')
lava_user = f.read().strip()
f.close()
# LAVA token
lava_token = os.environ.get("LAVA_TOKEN")
if lava_token == None:
f = open('/var/run/lava/lava-token')
lava_token = f.read().strip()
f.close()
# LAVA server URL
lava_server = os.environ.get("LAVA_SERVER", \
"validation.linaro.org/lava-server/RPC2/")
# LAVA server base URL
lava_server_root = lava_server.rstrip("/")
if lava_server_root.endswith("/RPC2"):
lava_server_root = lava_server_root[:-len("/RPC2")]
# test sets specific to an image
tests = tests_nano
# if ubuntu-desktop, cover more test cases (LEB)
if args.rootfs_type == 'ubuntu-desktop':
tests += tests_desktop
# if alip, specific tests like bootchart (which should be first)
if args.rootfs_type == 'alip':
tests = tests_alip + tests
# removing bluetooth and wifi for devices that don't support it
if args.device_type in ['beaglexm', 'vexpress-a9', 'mx53loco']:
try:
tests.remove('bluetooth-enablement')
tests.remove('wifi-enablement')
except ValueError:
pass
# vexpress doesn't support PM, so disable pwrmgmt
if args.device_type in ['vexpress-a9']:
try:
tests.remove('pwrmgmt')
except ValueError:
pass
if distribution == 'openembedded':
tests = tests_openembedded
actions = [{
"command": "deploy_linaro_image",
"parameters": {
"image": "%s" % args.img_url,
},
"metadata": {
"ubuntu.name": "%s" % args.image_name,
"ubuntu.build": "%s" % args.build_number,
"rootfs.type": "%s" % args.rootfs_type,
"ubuntu.distribution": "%s" % distribution,
}
},
{
"command": "boot_linaro_image"
}]
for test in tests:
actions.append({
"command": "lava_test_install",
"parameters": {
"test_name": test
}
})
for test in tests:
actions.append({
"command": "lava_test_run",
"parameters": {
"test_name": test
}
})
actions.append({
"command": "submit_results",
"parameters": {
"stream": bundle_stream_name,
"server": "%s%s" % ("http://", lava_server)
}
})
config = json.dumps({"timeout": 18000,
"actions": actions,
"job_name": args.job_name,
"device_type": args.device_type,
}, indent=2)
skip_lava = os.environ.get("SKIP_LAVA")
if skip_lava == None:
try:
server_url = \
"https://{lava_user:>s}:{lava_token:>s}@{lava_server:>s}"
server = \
xmlrpclib.ServerProxy(server_url.format(\
lava_user=lava_user, \
lava_token=lava_token, \
lava_server=lava_server))
lava_job_id = server.scheduler.submit_job(config)
except xmlrpclib.ProtocolError, e:
print "Error making a LAVA request:", obfuscate_credentials(str(e))
sys.exit(1)
print lava_job_id
json.dump({'lava_url': "http://" + lava_server_root,
'job_id': lava_job_id},
open('lava-job-info', 'w'))
else:
print "LAVA job submission skipped."
if __name__ == "__main__":
main()