diff options
Diffstat (limited to 'post-build-lava.py')
-rwxr-xr-x | post-build-lava.py | 139 |
1 files changed, 100 insertions, 39 deletions
diff --git a/post-build-lava.py b/post-build-lava.py index b25a9c2..6ab275b 100755 --- a/post-build-lava.py +++ b/post-build-lava.py @@ -7,9 +7,18 @@ import xmlrpclib import urllib2 import re +tests_nano = [ + 'device-tree', + 'gatortests', + 'perf', + 'pwrmgmt', + ] + + def obfuscate_credentials(s): return re.sub(r"([^ ]:).+?(@)", r"\1xxx\2", s) + def main(): """Script entry point: return some JSON based on calling args. We should be called from Jenkins and expect the following to be defined: @@ -35,13 +44,21 @@ def main(): sys.exit("Device type is not defined.") # Distribution, architecture and hardware pack type - ret_split = hwpack_job_name.split("-",2) - (distribution, architecture, hwpack_type) = ret_split[0], ret_split[1], ret_split[2] + if hwpack_job_name.startswith('package-and-publish'): + ret_split = hwpack_job_name.split("-", 3) + distribution = 'precise' + architecture = 'armhf' + hwpack_type = ret_split[3] + else: + ret_split = hwpack_job_name.split("-", 2) + (distribution, architecture, hwpack_type) = \ + ret_split[0], ret_split[1], ret_split[2] # Rootfs type, default is nano-lava rootfs_type = os.getenv("ROOTFS_TYPE", "nano-lava") # Bundle stream name - bundle_stream_name = os.environ.get("BUNDLE_STREAM_NAME", "/private/team/linaro/developers-and-community-builds/") + bundle_stream_name = os.environ.get("BUNDLE_STREAM_NAME", \ + "/private/team/linaro/developers-and-community-builds/") # LAVA user lava_user = os.environ.get("LAVA_USER") if lava_user == None: @@ -55,13 +72,20 @@ def main(): 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 = 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")] - ci_url = "%s%s-%s-%s%s" % (ci_base_url, distribution, architecture, rootfs_type, "/lastSuccessfulBuild/buildNumber") + # Rootfs last successful build number + ci_url = "%s%s-%s-%s%s" % \ + (ci_base_url, \ + distribution, \ + architecture, \ + rootfs_type, \ + "/lastSuccessfulBuild/buildNumber") request = urllib2.Request(ci_url) try: response = urllib2.urlopen(request) @@ -76,7 +100,13 @@ def main(): rootfs_build_number = eval(response.read()) - ci_url = "%s%s-%s-%s%s" % (ci_base_url, distribution, architecture, rootfs_type, "/lastSuccessfulBuild/buildTimestamp?format=yyyyMMdd") + # Rootfs last successful build timestamp + ci_url = "%s%s-%s-%s%s" % \ + (ci_base_url, \ + distribution, \ + architecture, \ + rootfs_type, \ + "/lastSuccessfulBuild/buildTimestamp?format=yyyyMMdd") request = urllib2.Request(ci_url) try: response = urllib2.urlopen(request) @@ -91,11 +121,48 @@ def main(): rootfs_build_timestamp = eval(response.read()) - rootfs_file_name = "linaro-%s-%s-%s-%s.tar.gz" % (distribution, rootfs_type, rootfs_build_timestamp, rootfs_build_number) + rootfs_file_name = "linaro-%s-%s-%s-%s.tar.gz" % \ + (distribution, \ + rootfs_type, \ + rootfs_build_timestamp, \ + rootfs_build_number) # Convert CI URLs to snapshots URLs - hwpack_url = "%s/%s/%s/%s/%s/%s" % (snapshots_url, distribution, "hwpacks", hwpack_type, hwpack_build_number, hwpack_file_name) - rootfs_url = "%s/%s/%s/%s/%s/%s" % (snapshots_url, distribution, "images", rootfs_type, rootfs_build_number, rootfs_file_name) + if hwpack_job_name.startswith('package-and-publish'): + hwpack_job_name_fixup = hwpack_job_name.replace('.', '_') + hwpack_url = "%s/%s/%s/%s/%s/%s" % \ + (snapshots_url, \ + "kernel-hwpack",\ + hwpack_job_name_fixup, \ + hwpack_job_name, \ + hwpack_build_number, \ + hwpack_file_name) + else: + hwpack_url = "%s/%s/%s/%s/%s/%s" % \ + (snapshots_url, \ + distribution, \ + "hwpacks", \ + hwpack_type, \ + hwpack_build_number, \ + hwpack_file_name) + + rootfs_url = "%s/%s/%s/%s/%s/%s" % \ + (snapshots_url, \ + distribution, \ + "images", \ + rootfs_type, \ + rootfs_build_number, \ + rootfs_file_name) + + # tests set specific to an image + tests = tests_nano + + # vexpress doesn't support PM, so disable pwrmgmt + if device_type in ['vexpress-a9']: + try: + tests.remove('pwrmgmt') + except ValueError: + pass actions = [{ "command": "deploy_linaro_image", @@ -113,42 +180,29 @@ def main(): }, { "command": "boot_linaro_image" - }, - { - "command": "lava_test_run", - "parameters": { - "test_name": "pwrmgmt" - } - }, - { - "command": "lava_test_run", - "parameters": { - "test_name": "gatortests" - } - }, - { - "command": "lava_test_run", - "parameters": { - "test_name": "perf" - } - }, - { - "command": "lava_test_run", - "parameters": { - "test_name": "wifi-enablement" - } - }, - { + }] + + 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": "%s%s/%s/" % (ci_base_url, hwpack_job_name, hwpack_build_number), + "job_name": "%s%s/%s/" % (ci_base_url, \ + hwpack_job_name, \ + hwpack_build_number), "device_type": device_type, }, indent=2) @@ -157,13 +211,20 @@ def main(): skip_lava = os.environ.get("SKIP_LAVA") if skip_lava == None: try: - server = xmlrpclib.ServerProxy("https://{lava_user:>s}:{lava_token:>s}@{lava_server:>s}".format(lava_user=lava_user, lava_token=lava_token, lava_server=lava_server)) + 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: %s, URL: http://%s/scheduler/job/%s" % (lava_job_id, lava_server_root, lava_job_id) + print "LAVA Job Id: %s, URL: http://%s/scheduler/job/%s" % \ + (lava_job_id, lava_server_root, lava_job_id) json.dump({'lava_url': "http://" + lava_server_root, 'job_id': lava_job_id}, open('lava-job-info', 'w')) |