OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 """Runs perf tests. | 5 """Runs perf tests. |
6 | 6 |
7 Our buildbot infrastructure requires each slave to run steps serially. | 7 Our buildbot infrastructure requires each slave to run steps serially. |
8 This is sub-optimal for android, where these steps can run independently on | 8 This is sub-optimal for android, where these steps can run independently on |
9 multiple connected devices. | 9 multiple connected devices. |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 import pickle | 54 import pickle |
55 import sys | 55 import sys |
56 import threading | 56 import threading |
57 import time | 57 import time |
58 | 58 |
59 from pylib import cmd_helper | 59 from pylib import cmd_helper |
60 from pylib import constants | 60 from pylib import constants |
61 from pylib import forwarder | 61 from pylib import forwarder |
62 from pylib.base import base_test_result | 62 from pylib.base import base_test_result |
63 from pylib.base import base_test_runner | 63 from pylib.base import base_test_runner |
| 64 from pylib.device import device_errors |
64 | 65 |
65 | 66 |
66 def OutputJsonList(json_input, json_output): | 67 def OutputJsonList(json_input, json_output): |
67 with file(json_input, 'r') as i: | 68 with file(json_input, 'r') as i: |
68 all_steps = json.load(i) | 69 all_steps = json.load(i) |
69 step_names = all_steps['steps'].keys() | 70 step_names = all_steps['steps'].keys() |
70 with file(json_output, 'w') as o: | 71 with file(json_output, 'w') as o: |
71 o.write(json.dumps(step_names)) | 72 o.write(json.dumps(step_names)) |
72 return 0 | 73 return 0 |
73 | 74 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 output = str(e) | 246 output = str(e) |
246 finally: | 247 finally: |
247 if self._options.single_step: | 248 if self._options.single_step: |
248 logfile.stop() | 249 logfile.stop() |
249 end_time = datetime.datetime.now() | 250 end_time = datetime.datetime.now() |
250 if exit_code is None: | 251 if exit_code is None: |
251 exit_code = -1 | 252 exit_code = -1 |
252 logging.info('%s : exit_code=%d in %d secs at %s', | 253 logging.info('%s : exit_code=%d in %d secs at %s', |
253 test_name, exit_code, (end_time - start_time).seconds, | 254 test_name, exit_code, (end_time - start_time).seconds, |
254 self.device_serial) | 255 self.device_serial) |
255 result_type = base_test_result.ResultType.FAIL | 256 |
256 if exit_code == 0: | 257 if exit_code == 0: |
257 result_type = base_test_result.ResultType.PASS | 258 result_type = base_test_result.ResultType.PASS |
| 259 else: |
| 260 result_type = base_test_result.ResultType.FAIL |
| 261 # Since perf tests use device affinity, give the device a chance to |
| 262 # recover if it is offline after a failure. Otherwise, the master sharder |
| 263 # will remove it from the pool and future tests on this device will fail. |
| 264 try: |
| 265 self.device.WaitUntilFullyBooted(timeout=120) |
| 266 except device_errors.CommandTimeoutError as e: |
| 267 logging.error('Device failed to return after %s: %s' % (test_name, e)) |
| 268 |
258 actual_exit_code = exit_code | 269 actual_exit_code = exit_code |
259 if test_name in self._flaky_tests: | 270 if test_name in self._flaky_tests: |
260 # The exit_code is used at the second stage when printing the | 271 # The exit_code is used at the second stage when printing the |
261 # test output. If the test is flaky, force to "0" to get that step green | 272 # test output. If the test is flaky, force to "0" to get that step green |
262 # whilst still gathering data to the perf dashboards. | 273 # whilst still gathering data to the perf dashboards. |
263 # The result_type is used by the test_dispatcher to retry the test. | 274 # The result_type is used by the test_dispatcher to retry the test. |
264 exit_code = 0 | 275 exit_code = 0 |
265 | 276 |
266 persisted_result = { | 277 persisted_result = { |
267 'name': test_name, | 278 'name': test_name, |
(...skipping 18 matching lines...) Expand all Loading... |
286 Returns: | 297 Returns: |
287 A tuple of (TestRunResults, retry). | 298 A tuple of (TestRunResults, retry). |
288 """ | 299 """ |
289 _, result_type = self._LaunchPerfTest(test_name) | 300 _, result_type = self._LaunchPerfTest(test_name) |
290 results = base_test_result.TestRunResults() | 301 results = base_test_result.TestRunResults() |
291 results.AddResult(base_test_result.BaseTestResult(test_name, result_type)) | 302 results.AddResult(base_test_result.BaseTestResult(test_name, result_type)) |
292 retry = None | 303 retry = None |
293 if not results.DidRunPass(): | 304 if not results.DidRunPass(): |
294 retry = test_name | 305 retry = test_name |
295 return results, retry | 306 return results, retry |
OLD | NEW |