OLD | NEW |
---|---|
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 from slave import recipe_api | 5 from slave import recipe_api |
6 | 6 |
7 | 7 |
8 class AmpApi(recipe_api.RecipeApi): | 8 class AmpApi(recipe_api.RecipeApi): |
9 | 9 |
10 def __init__(self, *args, **kwargs): | 10 def __init__(self, *args, **kwargs): |
11 super(AmpApi, self).__init__(*args, **kwargs) | 11 super(AmpApi, self).__init__(*args, **kwargs) |
12 self._trigger_file_dir = None | 12 self._trigger_file_dir = None |
13 self._base_results_dir = None | 13 self._base_results_dir = None |
14 | 14 |
15 def setup(self): | |
16 """Call this once before any of the other APIs in this module.""" | |
jbudorick
2015/02/27 15:17:26
This should be rephrased.
| |
17 self.m.chromium_android.set_config('base_config') | |
18 | |
15 @recipe_api.non_step | 19 @recipe_api.non_step |
16 def _get_trigger_dir(self): | 20 def _get_trigger_dir(self): |
17 if not self._trigger_file_dir: | 21 if not self._trigger_file_dir: |
18 self._trigger_file_dir = self.m.path.mkdtemp('amp_trigger') | 22 self._trigger_file_dir = self.m.path.mkdtemp('amp_trigger') |
19 return self._trigger_file_dir | 23 return self._trigger_file_dir |
20 | 24 |
21 @recipe_api.non_step | 25 @recipe_api.non_step |
22 def _get_trigger_file_for_suite(self, suite): | 26 def _get_trigger_file_for_suite(self, suite): |
23 return self._get_trigger_dir().join('%s.json' % suite) | 27 return self._get_trigger_dir().join('%s.json' % suite) |
24 | 28 |
(...skipping 28 matching lines...) Expand all Loading... | |
53 'env': { | 57 'env': { |
54 'device': { | 58 'device': { |
55 'brand': 'Foo', | 59 'brand': 'Foo', |
56 'name': 'Fone', | 60 'name': 'Fone', |
57 'os_version': '1.2.3', | 61 'os_version': '1.2.3', |
58 }, | 62 }, |
59 }, | 63 }, |
60 }) | 64 }) |
61 step_result = self.m.python( | 65 step_result = self.m.python( |
62 '[trigger] %s' % suite, | 66 '[trigger] %s' % suite, |
63 self.m.path['checkout'].join('build', 'android', 'test_runner.py'), | 67 self.m.chromium_android.c.test_runner, |
64 args=args, | 68 args=args, |
65 step_test_data=step_test_data) | 69 step_test_data=step_test_data) |
66 trigger_data = step_result.json.output | 70 trigger_data = step_result.json.output |
67 try: | 71 try: |
68 device_data = trigger_data['env']['device'] | 72 device_data = trigger_data['env']['device'] |
69 step_result.presentation.step_text = 'on %s %s %s' % ( | 73 step_result.presentation.step_text = 'on %s %s %s' % ( |
70 device_data['brand'], | 74 device_data['brand'], |
71 device_data['name'], | 75 device_data['name'], |
72 device_data['os_version']) | 76 device_data['os_version']) |
73 except KeyError: | 77 except KeyError: |
(...skipping 30 matching lines...) Expand all Loading... | |
104 device_data['os_version']) | 108 device_data['os_version']) |
105 except KeyError: | 109 except KeyError: |
106 device_data = None | 110 device_data = None |
107 device_info_text = 'unable to find device info' | 111 device_info_text = 'unable to find device info' |
108 | 112 |
109 if verbose: | 113 if verbose: |
110 args += ['--verbose'] | 114 args += ['--verbose'] |
111 try: | 115 try: |
112 step_result = self.m.python( | 116 step_result = self.m.python( |
113 '[collect] %s' % suite, | 117 '[collect] %s' % suite, |
114 self.m.path['checkout'].join('build', 'android', 'test_runner.py'), | 118 self.m.chromium_android.c.test_runner, |
115 args=args) | 119 args=args) |
116 except self.m.step.StepFailure as f: | 120 except self.m.step.StepFailure as f: |
117 step_result = f.result | 121 step_result = f.result |
118 raise | 122 raise |
119 finally: | 123 finally: |
120 step_result.presentation.step_text = device_info_text | 124 step_result.presentation.step_text = device_info_text |
125 if (step_result.retcode == | |
126 self.m.chromium_android.c.test_runner_exit_codes['INFRA']): | |
127 step_result.presentation.status = self.m.step.EXCEPTION | |
121 if (not device_data and | 128 if (not device_data and |
122 step_result.presentation.status != self.m.step.FAILURE): | 129 step_result.presentation.status == self.m.step.SUCCESS): |
mikecase (-- gone --)
2015/02/27 18:10:58
Also will need to add this logic to the trigger st
| |
123 step_result.presentation.status = self.m.step.WARNING | 130 step_result.presentation.status = self.m.step.WARNING |
124 | 131 |
125 def upload_logcat_to_gs(self, bucket, suite): | 132 def upload_logcat_to_gs(self, bucket, suite): |
126 """Upload the logcat file returned from the appurify results to | 133 """Upload the logcat file returned from the appurify results to |
127 Google Storage. | 134 Google Storage. |
128 """ | 135 """ |
129 step_result = self.m.json.read( | 136 step_result = self.m.json.read( |
130 '[upload logcat] load %s data' % suite, | 137 '[upload logcat] load %s data' % suite, |
131 self._get_trigger_file_for_suite(suite), | 138 self._get_trigger_file_for_suite(suite), |
132 step_test_data=lambda: self.m.json.test_api.output({ | 139 step_test_data=lambda: self.m.json.test_api.output({ |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 amp_args += ['--device-oem', d] | 251 amp_args += ['--device-oem', d] |
245 | 252 |
246 for d in device_os or []: | 253 for d in device_os or []: |
247 amp_args += ['--remote-device-os', d] | 254 amp_args += ['--remote-device-os', d] |
248 | 255 |
249 if device_timeout: | 256 if device_timeout: |
250 amp_args += ['--remote-device-timeout', device_timeout] | 257 amp_args += ['--remote-device-timeout', device_timeout] |
251 | 258 |
252 return amp_args | 259 return amp_args |
253 | 260 |
OLD | NEW |