Andy Doan | 61b4d77 | 2012-04-24 10:03:28 -0500 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
Andy Doan | 61b4d77 | 2012-04-24 10:03:28 -0500 | [diff] [blame] | 3 | import os |
Andy Doan | 61b4d77 | 2012-04-24 10:03:28 -0500 | [diff] [blame] | 4 | import sys |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame] | 5 | import json |
Andy Doan | 61b4d77 | 2012-04-24 10:03:28 -0500 | [diff] [blame] | 6 | import xmlrpclib |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame] | 7 | import re |
Andy Doan | 61b4d77 | 2012-04-24 10:03:28 -0500 | [diff] [blame] | 8 | |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame] | 9 | tests_nano = [ |
| 10 | 'device-tree', |
| 11 | 'gatortests', |
| 12 | 'perf', |
| 13 | 'pwrmgmt', |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 14 | ] |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame] | 15 | |
| 16 | tests_alip = [ |
| 17 | 'bootchart', |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 18 | ] |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame] | 19 | |
| 20 | tests_desktop = [ |
| 21 | 'e2eaudiotest', |
| 22 | 'bluetooth-enablement', |
| 23 | 'wifi-enablement', |
| 24 | 'leb-basic-graphics', |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 25 | ] |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame] | 26 | |
Fathi Boudra | 60d0e97 | 2013-04-19 10:49:47 +0300 | [diff] [blame^] | 27 | tests_openembedded_minimal = [ |
Marcin Juszkiewicz | 5917283 | 2013-04-18 09:35:00 +0200 | [diff] [blame] | 28 | 'busybox', |
Marcin Juszkiewicz | 1678f11 | 2013-04-09 09:55:46 +0200 | [diff] [blame] | 29 | 'device-tree', |
Marcin Juszkiewicz | 5917283 | 2013-04-18 09:35:00 +0200 | [diff] [blame] | 30 | 'ethernet', |
| 31 | 'kernel-version', |
Marcin Juszkiewicz | 1678f11 | 2013-04-09 09:55:46 +0200 | [diff] [blame] | 32 | 'perf', |
Marcin Juszkiewicz | 5917283 | 2013-04-18 09:35:00 +0200 | [diff] [blame] | 33 | 'toolchain', |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 34 | ] |
Andy Doan | 61b4d77 | 2012-04-24 10:03:28 -0500 | [diff] [blame] | 35 | |
Fathi Boudra | 60d0e97 | 2013-04-19 10:49:47 +0300 | [diff] [blame^] | 36 | tests_openembedded_lamp = [ |
| 37 | 'pwrmgmt', |
| 38 | 'mysql', |
| 39 | 'phpinfo', |
| 40 | 'phpmysql', |
| 41 | 'sdkhelloc', |
| 42 | 'sdkhellocxx', |
| 43 | ] |
| 44 | |
Fathi Boudra | 8e4ce56 | 2012-12-08 14:35:17 +0200 | [diff] [blame] | 45 | # Mapping device type - bundle stream |
Andy Doan | 3462e4c | 2012-05-18 10:58:06 -0500 | [diff] [blame] | 46 | DEVICE_STREAM = { |
Fathi Boudra | 8b59a50 | 2013-01-18 10:20:04 +0200 | [diff] [blame] | 47 | 'arndale': 'arndale', |
Fathi Boudra | 8e4ce56 | 2012-12-08 14:35:17 +0200 | [diff] [blame] | 48 | 'beaglexm': 'beaglexm', |
Fathi Boudra | b97042a | 2013-04-04 17:49:22 +0300 | [diff] [blame] | 49 | 'highbank': 'highbank', |
Fathi Boudra | 8e4ce56 | 2012-12-08 14:35:17 +0200 | [diff] [blame] | 50 | 'origen': 'leb-origen', |
Andy Doan | 3462e4c | 2012-05-18 10:58:06 -0500 | [diff] [blame] | 51 | 'panda': 'leb-panda-4430', |
Paul Larson | 2730851 | 2012-08-17 14:09:05 -0500 | [diff] [blame] | 52 | 'panda-es': 'leb-panda-es', |
Fathi Boudra | 8e4ce56 | 2012-12-08 14:35:17 +0200 | [diff] [blame] | 53 | 'rtsm_foundation-armv8': 'vexpress64', |
| 54 | 'rtsm_ve-a15x1-a7x1': 'vexpress', |
| 55 | 'rtsm_ve-a15x4-a7x4': 'vexpress', |
| 56 | 'rtsm_ve-armv8': 'vexpress', |
Andy Doan | 3462e4c | 2012-05-18 10:58:06 -0500 | [diff] [blame] | 57 | 'snowball_sd': 'leb-snowball', |
Fathi Boudra | 8e4ce56 | 2012-12-08 14:35:17 +0200 | [diff] [blame] | 58 | 'vexpress-a5': 'vexpress', |
Fathi Boudra | 76551e5 | 2012-09-19 17:51:33 +0300 | [diff] [blame] | 59 | 'vexpress-a9': 'vexpress', |
Fathi Boudra | 8e4ce56 | 2012-12-08 14:35:17 +0200 | [diff] [blame] | 60 | 'vexpress-tc2': 'vexpress', |
Andy Doan | 3462e4c | 2012-05-18 10:58:06 -0500 | [diff] [blame] | 61 | } |
| 62 | |
Andy Doan | 61b4d77 | 2012-04-24 10:03:28 -0500 | [diff] [blame] | 63 | |
| 64 | def obfuscate_credentials(s): |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 65 | return re.sub(r'([^ ]:).+?(@)', r'\1xxx\2', s) |
Andy Doan | 61b4d77 | 2012-04-24 10:03:28 -0500 | [diff] [blame] | 66 | |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame] | 67 | |
Andy Doan | 61b4d77 | 2012-04-24 10:03:28 -0500 | [diff] [blame] | 68 | def main(): |
Fathi Boudra | 8e4ce56 | 2012-12-08 14:35:17 +0200 | [diff] [blame] | 69 | """Script entry point: return some JSON based on calling args. |
| 70 | We should be called from Jenkins and expect the following to be defined: |
| 71 | $HWPACK_BUILD_NUMBER $HWPACK_JOB_NAME HWPACK_FILE_NAME $DEVICE_TYPE |
| 72 | """ |
Andy Doan | 61b4d77 | 2012-04-24 10:03:28 -0500 | [diff] [blame] | 73 | |
Fathi Boudra | d1f9a86 | 2012-12-28 14:46:04 +0200 | [diff] [blame] | 74 | # CI base URL |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 75 | ci_base_url = 'https://ci.linaro.org/jenkins/job/' |
Fathi Boudra | 8e4ce56 | 2012-12-08 14:35:17 +0200 | [diff] [blame] | 76 | # Snapshots base URL |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 77 | snapshots_url = 'http://snapshots.linaro.org' |
Fathi Boudra | 8e4ce56 | 2012-12-08 14:35:17 +0200 | [diff] [blame] | 78 | |
| 79 | # Name of the hardware pack project |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 80 | hwpack_job_name = os.environ.get('HWPACK_JOB_NAME') |
Fathi Boudra | 8e4ce56 | 2012-12-08 14:35:17 +0200 | [diff] [blame] | 81 | # The hardware pack build number |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 82 | hwpack_build_number = os.environ.get('HWPACK_BUILD_NUMBER') |
Fathi Boudra | 8e4ce56 | 2012-12-08 14:35:17 +0200 | [diff] [blame] | 83 | # Hardware pack file name |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 84 | hwpack_file_name = os.environ.get('HWPACK_FILE_NAME', 'Undefined') |
| 85 | if hwpack_file_name == 'Undefined': |
| 86 | sys.exit('Hardware pack is not defined.') |
| 87 | |
Fathi Boudra | 8e4ce56 | 2012-12-08 14:35:17 +0200 | [diff] [blame] | 88 | # Device type |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 89 | device_type = os.environ.get('DEVICE_TYPE', 'Undefined') |
| 90 | if device_type == 'Undefined': |
| 91 | sys.exit('Device type is not defined.') |
Fathi Boudra | 8e4ce56 | 2012-12-08 14:35:17 +0200 | [diff] [blame] | 92 | |
| 93 | # Distribution, architecture and hardware pack type |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 94 | ret_split = hwpack_job_name.split('-', 2) |
| 95 | (distribution, architecture, hwpack_type) = \ |
| 96 | ret_split[0], ret_split[1], ret_split[2] |
Fathi Boudra | 8e4ce56 | 2012-12-08 14:35:17 +0200 | [diff] [blame] | 97 | if hwpack_type.startswith('pre-built-images-'): |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 98 | hwpack_type = hwpack_type[(len('pre-built-images-')):] |
Fathi Boudra | 65aaf1a | 2013-01-10 10:35:57 +0200 | [diff] [blame] | 99 | if '=' in hwpack_type: |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 100 | hwpack_type = hwpack_type[(len('pre-built-images/hwpack=')):] |
Fathi Boudra | 8e4ce56 | 2012-12-08 14:35:17 +0200 | [diff] [blame] | 101 | # Rootfs type, default is developer |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 102 | rootfs_type = os.getenv('ROOTFS_TYPE', 'developer') |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame] | 103 | |
| 104 | # Bundle stream name |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 105 | bundle_stream_name = os.environ.get( |
| 106 | 'BUNDLE_STREAM_NAME', |
| 107 | '/private/team/linaro/pre-built-%s/' % DEVICE_STREAM[device_type]) |
| 108 | |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame] | 109 | # LAVA user |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 110 | lava_user = os.environ.get('LAVA_USER') |
| 111 | if lava_user is None: |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame] | 112 | f = open('/var/run/lava/lava-user') |
| 113 | lava_user = f.read().strip() |
| 114 | f.close() |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 115 | |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame] | 116 | # LAVA token |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 117 | lava_token = os.environ.get('LAVA_TOKEN') |
| 118 | if lava_token is None: |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame] | 119 | f = open('/var/run/lava/lava-token') |
| 120 | lava_token = f.read().strip() |
| 121 | f.close() |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame] | 122 | |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 123 | # LAVA server URL |
| 124 | lava_server = os.environ.get('LAVA_SERVER', |
| 125 | 'validation.linaro.org/lava-server/RPC2/') |
| 126 | # LAVA server base URL |
| 127 | lava_server_root = lava_server.rstrip('/') |
| 128 | if lava_server_root.endswith('/RPC2'): |
| 129 | lava_server_root = lava_server_root[:-len('/RPC2')] |
| 130 | |
| 131 | image_url = '%s/%s/pre-built/%s/%s/%s' % \ |
| 132 | (snapshots_url, |
| 133 | distribution, |
| 134 | hwpack_type, |
| 135 | hwpack_build_number, |
Fathi Boudra | 8e4ce56 | 2012-12-08 14:35:17 +0200 | [diff] [blame] | 136 | hwpack_file_name) |
| 137 | |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 138 | git_repo = 'git://git.linaro.org/qa/test-definitions.git' |
Senthil Kumaran | 672ac4d | 2012-12-19 15:10:59 +0530 | [diff] [blame] | 139 | |
Fathi Boudra | 8e4ce56 | 2012-12-08 14:35:17 +0200 | [diff] [blame] | 140 | # tests set specific to an image |
Fathi Boudra | 60d0e97 | 2013-04-19 10:49:47 +0300 | [diff] [blame^] | 141 | if distribution == 'openembedded': |
| 142 | tests = tests_openembedded_minimal |
| 143 | elif distribution == 'ubuntu' or distribution == 'quantal': |
| 144 | tests = tests_nano |
Fathi Boudra | c51e091 | 2012-06-15 18:18:41 +0300 | [diff] [blame] | 145 | |
Ricardo Salveti de Araujo | acf2854 | 2012-06-27 18:56:00 -0300 | [diff] [blame] | 146 | # if ubuntu-desktop, cover more test cases (LEB) |
Fathi Boudra | 8e4ce56 | 2012-12-08 14:35:17 +0200 | [diff] [blame] | 147 | if rootfs_type == 'ubuntu-desktop': |
Fathi Boudra | c51e091 | 2012-06-15 18:18:41 +0300 | [diff] [blame] | 148 | tests += tests_desktop |
Andy Doan | bc19b7c | 2012-05-17 12:08:16 -0500 | [diff] [blame] | 149 | |
Ricardo Salveti de Araujo | 6ad9433 | 2012-06-29 02:48:18 -0300 | [diff] [blame] | 150 | # if alip, specific tests like bootchart (which should be first) |
Fathi Boudra | 8e4ce56 | 2012-12-08 14:35:17 +0200 | [diff] [blame] | 151 | if rootfs_type == 'alip': |
Ricardo Salveti de Araujo | 6ad9433 | 2012-06-29 02:48:18 -0300 | [diff] [blame] | 152 | tests = tests_alip + tests |
| 153 | |
Fathi Boudra | 60d0e97 | 2013-04-19 10:49:47 +0300 | [diff] [blame^] | 154 | if 'lamp' in rootfs_type: |
| 155 | tests += tests_openembedded_lamp |
| 156 | |
Ricardo Salveti de Araujo | acf2854 | 2012-06-27 18:56:00 -0300 | [diff] [blame] | 157 | # removing bluetooth and wifi for devices that don't support it |
Fathi Boudra | 8e4ce56 | 2012-12-08 14:35:17 +0200 | [diff] [blame] | 158 | if device_type in ['beaglexm', 'vexpress-a9', 'mx53loco']: |
Ricardo Salveti de Araujo | dd78097 | 2012-06-29 11:48:47 -0300 | [diff] [blame] | 159 | try: |
| 160 | tests.remove('bluetooth-enablement') |
| 161 | tests.remove('wifi-enablement') |
| 162 | except ValueError: |
| 163 | pass |
Ricardo Salveti de Araujo | acf2854 | 2012-06-27 18:56:00 -0300 | [diff] [blame] | 164 | |
| 165 | # vexpress doesn't support PM, so disable pwrmgmt |
Fathi Boudra | 8e4ce56 | 2012-12-08 14:35:17 +0200 | [diff] [blame] | 166 | if device_type in ['vexpress-a9']: |
Ricardo Salveti de Araujo | dd78097 | 2012-06-29 11:48:47 -0300 | [diff] [blame] | 167 | try: |
| 168 | tests.remove('pwrmgmt') |
| 169 | except ValueError: |
| 170 | pass |
Andy Doan | e9bf215 | 2012-06-12 15:42:10 -0500 | [diff] [blame] | 171 | |
Fathi Boudra | 62eb6a9 | 2012-12-06 19:02:56 +0200 | [diff] [blame] | 172 | if distribution == 'openembedded': |
Fathi Boudra | 4079a58 | 2012-12-06 19:42:58 +0200 | [diff] [blame] | 173 | actions = [{ |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 174 | 'command': 'deploy_linaro_image', |
| 175 | 'parameters': { |
| 176 | 'image': '%s' % image_url, |
| 177 | }, |
| 178 | 'metadata': { |
| 179 | 'hwpack.type': '%s' % hwpack_type, |
| 180 | 'hwpack.build': '%s' % hwpack_build_number, |
| 181 | 'rootfs.type': '%s' % rootfs_type, |
| 182 | 'distribution': '%s' % distribution, |
| 183 | } |
| 184 | }, |
| 185 | { |
| 186 | 'command': 'boot_linaro_image', |
| 187 | 'parameters': { |
| 188 | 'options': ['boot_cmds=boot_cmds_oe'] |
| 189 | } |
| 190 | }] |
Fathi Boudra | 60d0e97 | 2013-04-19 10:49:47 +0300 | [diff] [blame^] | 191 | elif distribution == 'ubuntu' or distribution == 'quantal': |
Fathi Boudra | 4079a58 | 2012-12-06 19:42:58 +0200 | [diff] [blame] | 192 | actions = [{ |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 193 | 'command': 'deploy_linaro_image', |
| 194 | 'parameters': { |
| 195 | 'image': '%s' % image_url, |
| 196 | }, |
| 197 | 'metadata': { |
| 198 | 'ubuntu.name': '%s' % hwpack_type, |
| 199 | 'ubuntu.build': '%s' % hwpack_build_number, |
| 200 | 'rootfs.type': '%s' % rootfs_type, |
| 201 | 'ubuntu.distribution': '%s' % distribution, |
| 202 | } |
| 203 | }] |
Fathi Boudra | 4079a58 | 2012-12-06 19:42:58 +0200 | [diff] [blame] | 204 | |
Fathi Boudra | a9bbadb | 2012-12-07 16:10:29 +0200 | [diff] [blame] | 205 | if len(tests) > 0: |
Fathi Boudra | 60d0e97 | 2013-04-19 10:49:47 +0300 | [diff] [blame^] | 206 | if distribution == 'quantal': |
| 207 | distribution = 'ubuntu' |
Senthil Kumaran | b30d738 | 2012-12-19 15:11:47 +0530 | [diff] [blame] | 208 | test_list = [] |
| 209 | for test in tests: |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 210 | test_list.append( |
| 211 | {'git-repo': git_repo, |
| 212 | 'testdef': '{distribution:>s}/{test:>s}.yaml'.format( |
| 213 | distribution=distribution, test=test)}) |
Senthil Kumaran | 007181c | 2013-04-16 14:43:19 +0530 | [diff] [blame] | 214 | |
| 215 | actions.append({ |
Fathi Boudra | 60d0e97 | 2013-04-19 10:49:47 +0300 | [diff] [blame^] | 216 | 'command': 'lava_test_shell', |
| 217 | 'parameters': { |
| 218 | 'timeout': 18000, |
| 219 | 'testdef_repos': test_list |
| 220 | } |
| 221 | }) |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame] | 222 | |
| 223 | actions.append({ |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 224 | 'command': 'submit_results', |
| 225 | 'parameters': { |
| 226 | 'stream': bundle_stream_name, |
| 227 | 'server': '%s%s' % ('http://', lava_server) |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame] | 228 | } |
| 229 | }) |
| 230 | |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 231 | config = json.dumps({'timeout': 18000, |
| 232 | 'actions': actions, |
| 233 | 'job_name': '%s%s/%s/' % (ci_base_url, |
| 234 | hwpack_job_name, |
Fathi Boudra | d1f9a86 | 2012-12-28 14:46:04 +0200 | [diff] [blame] | 235 | hwpack_build_number), |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 236 | 'device_type': device_type, |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame] | 237 | }, indent=2) |
Fathi Boudra | 79c1e8b | 2012-12-02 10:36:57 +0200 | [diff] [blame] | 238 | |
Fathi Boudra | 8e4ce56 | 2012-12-08 14:35:17 +0200 | [diff] [blame] | 239 | print config |
| 240 | |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 241 | skip_lava = os.environ.get('SKIP_LAVA') |
| 242 | if skip_lava is None: |
Fathi Boudra | 79c1e8b | 2012-12-02 10:36:57 +0200 | [diff] [blame] | 243 | try: |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame] | 244 | server_url = \ |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 245 | 'https://{lava_user:>s}:{lava_token:>s}@{lava_server:>s}' |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame] | 246 | server = \ |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 247 | xmlrpclib.ServerProxy(server_url.format( |
| 248 | lava_user=lava_user, |
| 249 | lava_token=lava_token, |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame] | 250 | lava_server=lava_server)) |
| 251 | lava_job_id = server.scheduler.submit_job(config) |
Fathi Boudra | 79c1e8b | 2012-12-02 10:36:57 +0200 | [diff] [blame] | 252 | except xmlrpclib.ProtocolError, e: |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 253 | print 'Error making a LAVA request:', obfuscate_credentials(str(e)) |
Fathi Boudra | 79c1e8b | 2012-12-02 10:36:57 +0200 | [diff] [blame] | 254 | sys.exit(1) |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame] | 255 | |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 256 | print 'LAVA Job Id: %s, URL: http://%s/scheduler/job/%s' % \ |
Fathi Boudra | 8e4ce56 | 2012-12-08 14:35:17 +0200 | [diff] [blame] | 257 | (lava_job_id, lava_server_root, lava_job_id) |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 258 | json.dump({'lava_url': 'http://' + lava_server_root, |
Fathi Boudra | c14068b | 2012-12-06 17:42:11 +0200 | [diff] [blame] | 259 | 'job_id': lava_job_id}, |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 260 | open('lava-job-info', 'w')) |
Fathi Boudra | 8e4ce56 | 2012-12-08 14:35:17 +0200 | [diff] [blame] | 261 | |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 262 | lava_job_info_orig = hwpack_file_name.replace('.img.gz', '.html') |
| 263 | top_dir = os.environ.get('WORKSPACE', '.') |
Fathi Boudra | de02059 | 2012-12-10 13:25:14 +0200 | [diff] [blame] | 264 | for root, dirs, files in os.walk(top_dir): |
| 265 | for file in files: |
| 266 | if file == lava_job_info_orig: |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 267 | lava_job_info_orig = os.path.join(root, file) |
Fathi Boudra | 5e48102 | 2012-12-08 19:21:16 +0200 | [diff] [blame] | 268 | |
Fathi Boudra | de02059 | 2012-12-10 13:25:14 +0200 | [diff] [blame] | 269 | with open(lava_job_info_orig) as f: |
| 270 | buffer = f.read() |
Fathi Boudra | 5e48102 | 2012-12-08 19:21:16 +0200 | [diff] [blame] | 271 | |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 272 | buffer = buffer.replace( |
| 273 | 'var lavaJobId = 0', |
| 274 | 'var lavaJobId = ' + str(lava_job_id), 1) |
Fathi Boudra | de02059 | 2012-12-10 13:25:14 +0200 | [diff] [blame] | 275 | |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 276 | lava_job_info = lava_job_info_orig.replace( |
| 277 | '.html', |
| 278 | '-' + device_type + '.html') |
Fathi Boudra | de02059 | 2012-12-10 13:25:14 +0200 | [diff] [blame] | 279 | with open(lava_job_info, 'w') as f: |
| 280 | f.write(buffer) |
| 281 | os.remove(lava_job_info_orig) |
Fathi Boudra | 79c1e8b | 2012-12-02 10:36:57 +0200 | [diff] [blame] | 282 | else: |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 283 | print 'LAVA job submission skipped.' |
Andy Doan | 61b4d77 | 2012-04-24 10:03:28 -0500 | [diff] [blame] | 284 | |
Fathi Boudra | 3f7ace9 | 2013-04-11 13:06:11 +0300 | [diff] [blame] | 285 | |
| 286 | if __name__ == '__main__': |
Andy Doan | 61b4d77 | 2012-04-24 10:03:28 -0500 | [diff] [blame] | 287 | main() |