Andy Doan | 61b4d77 | 2012-04-24 10:03:28 -0500 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | import argparse |
Andy Doan | 61b4d77 | 2012-04-24 10:03:28 -0500 | [diff] [blame] | 4 | import os |
Andy Doan | 61b4d77 | 2012-04-24 10:03:28 -0500 | [diff] [blame] | 5 | import sys |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame^] | 6 | import json |
Andy Doan | 61b4d77 | 2012-04-24 10:03:28 -0500 | [diff] [blame] | 7 | import xmlrpclib |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame^] | 8 | import re |
Andy Doan | 61b4d77 | 2012-04-24 10:03:28 -0500 | [diff] [blame] | 9 | |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame^] | 10 | tests_nano = [ |
| 11 | 'device-tree', |
| 12 | 'gatortests', |
| 13 | 'perf', |
| 14 | 'pwrmgmt', |
| 15 | ] |
| 16 | |
| 17 | tests_alip = [ |
| 18 | 'bootchart', |
| 19 | ] |
| 20 | |
| 21 | tests_desktop = [ |
| 22 | 'e2eaudiotest', |
| 23 | 'bluetooth-enablement', |
| 24 | 'wifi-enablement', |
| 25 | 'leb-basic-graphics', |
| 26 | ] |
| 27 | |
| 28 | tests_openembedded = [ |
| 29 | ] |
Andy Doan | 61b4d77 | 2012-04-24 10:03:28 -0500 | [diff] [blame] | 30 | |
Andy Doan | 3462e4c | 2012-05-18 10:58:06 -0500 | [diff] [blame] | 31 | DEVICE_STREAM = { |
| 32 | 'panda': 'leb-panda-4430', |
Paul Larson | 2730851 | 2012-08-17 14:09:05 -0500 | [diff] [blame] | 33 | 'panda-es': 'leb-panda-es', |
Andy Doan | 3462e4c | 2012-05-18 10:58:06 -0500 | [diff] [blame] | 34 | 'origen': 'leb-origen', |
| 35 | 'snowball_sd': 'leb-snowball', |
| 36 | 'beaglexm': 'beaglexm', |
Fathi Boudra | 76551e5 | 2012-09-19 17:51:33 +0300 | [diff] [blame] | 37 | 'vexpress-a9': 'vexpress', |
Ricardo Salveti de Araujo | 58cc784 | 2012-06-23 15:04:25 -0300 | [diff] [blame] | 38 | 'mx53loco': 'mx53loco', |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame^] | 39 | 'rtsm_foundation-armv8': 'vexpress64' |
Andy Doan | 3462e4c | 2012-05-18 10:58:06 -0500 | [diff] [blame] | 40 | } |
| 41 | |
Andy Doan | 61b4d77 | 2012-04-24 10:03:28 -0500 | [diff] [blame] | 42 | |
| 43 | def obfuscate_credentials(s): |
| 44 | return re.sub(r"([^ ]:).+?(@)", r"\1xxx\2", s) |
| 45 | |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame^] | 46 | |
Andy Doan | 61b4d77 | 2012-04-24 10:03:28 -0500 | [diff] [blame] | 47 | def 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"') |
Ricardo Salveti de Araujo | 42b0a24 | 2012-05-29 14:07:56 -0300 | [diff] [blame] | 55 | p.add_argument('-t', dest='image_type', default='nano', |
| 56 | help='The image type to execute on, nano (default) or ubuntu-desktop') |
Michael Hudson-Doyle | a15402f | 2012-07-12 13:23:27 +1200 | [diff] [blame] | 57 | 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"') |
| 59 | p.add_argument('-c', dest='image_number', required=True, |
| 60 | help='The build number for this image') |
Andy Doan | 61b4d77 | 2012-04-24 10:03:28 -0500 | [diff] [blame] | 61 | args = p.parse_args() |
| 62 | |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame^] | 63 | # 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 Boudra | c51e091 | 2012-06-15 18:18:41 +0300 | [diff] [blame] | 91 | tests = tests_nano |
| 92 | |
Ricardo Salveti de Araujo | acf2854 | 2012-06-27 18:56:00 -0300 | [diff] [blame] | 93 | # if ubuntu-desktop, cover more test cases (LEB) |
Ricardo Salveti de Araujo | 070048a | 2012-05-31 00:30:14 +0800 | [diff] [blame] | 94 | if args.image_type == 'ubuntu-desktop': |
Fathi Boudra | c51e091 | 2012-06-15 18:18:41 +0300 | [diff] [blame] | 95 | tests += tests_desktop |
Andy Doan | bc19b7c | 2012-05-17 12:08:16 -0500 | [diff] [blame] | 96 | |
Ricardo Salveti de Araujo | 6ad9433 | 2012-06-29 02:48:18 -0300 | [diff] [blame] | 97 | # if alip, specific tests like bootchart (which should be first) |
| 98 | if args.image_type == 'alip': |
| 99 | tests = tests_alip + tests |
| 100 | |
Ricardo Salveti de Araujo | acf2854 | 2012-06-27 18:56:00 -0300 | [diff] [blame] | 101 | # removing bluetooth and wifi for devices that don't support it |
Fathi Boudra | 76551e5 | 2012-09-19 17:51:33 +0300 | [diff] [blame] | 102 | if args.device_type in ['beaglexm', 'vexpress-a9', 'mx53loco']: |
Ricardo Salveti de Araujo | dd78097 | 2012-06-29 11:48:47 -0300 | [diff] [blame] | 103 | try: |
| 104 | tests.remove('bluetooth-enablement') |
| 105 | tests.remove('wifi-enablement') |
| 106 | except ValueError: |
| 107 | pass |
Ricardo Salveti de Araujo | acf2854 | 2012-06-27 18:56:00 -0300 | [diff] [blame] | 108 | |
| 109 | # vexpress doesn't support PM, so disable pwrmgmt |
Fathi Boudra | 76551e5 | 2012-09-19 17:51:33 +0300 | [diff] [blame] | 110 | if args.device_type in ['vexpress-a9']: |
Ricardo Salveti de Araujo | dd78097 | 2012-06-29 11:48:47 -0300 | [diff] [blame] | 111 | try: |
| 112 | tests.remove('pwrmgmt') |
| 113 | except ValueError: |
| 114 | pass |
Andy Doan | e9bf215 | 2012-06-12 15:42:10 -0500 | [diff] [blame] | 115 | |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame^] | 116 | if args.image_type == 'lamp-armv8' or 'lamp-armv8' or 'minimal-armv8': |
| 117 | tests = tests_openembedded |
Andy Doan | 61b4d77 | 2012-04-24 10:03:28 -0500 | [diff] [blame] | 118 | |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame^] | 119 | actions = [{ |
| 120 | "command": "deploy_linaro_image", |
| 121 | "parameters": { |
| 122 | "image": "%s" % args.img_url, |
| 123 | }, |
| 124 | "metadata": { |
| 125 | "ubuntu.name": "%s" % args.image_name, |
| 126 | "ubuntu.build": "%s" % args.image_number, |
| 127 | "ubuntu.image_type": "%s" % args.image_type, |
| 128 | "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 Boudra | 79c1e8b | 2012-12-02 10:36:57 +0200 | [diff] [blame] | 164 | |
| 165 | skip_lava = os.environ.get("SKIP_LAVA") |
| 166 | if skip_lava == None: |
Fathi Boudra | 79c1e8b | 2012-12-02 10:36:57 +0200 | [diff] [blame] | 167 | try: |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame^] | 168 | 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 Boudra | 79c1e8b | 2012-12-02 10:36:57 +0200 | [diff] [blame] | 176 | except xmlrpclib.ProtocolError, e: |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame^] | 177 | print "Error making a LAVA request:", obfuscate_credentials(str(e)) |
Fathi Boudra | 79c1e8b | 2012-12-02 10:36:57 +0200 | [diff] [blame] | 178 | sys.exit(1) |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame^] | 179 | |
| 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 Boudra | 79c1e8b | 2012-12-02 10:36:57 +0200 | [diff] [blame] | 184 | else: |
| 185 | print "LAVA job submission skipped." |
Andy Doan | 61b4d77 | 2012-04-24 10:03:28 -0500 | [diff] [blame] | 186 | |
| 187 | if __name__ == "__main__": |
| 188 | main() |