OLD | NEW |
---|---|
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 import collections | 5 import collections |
6 import io | 6 import io |
7 import json | 7 import json |
8 import logging | 8 import logging |
9 import os | 9 import os |
10 import pickle | 10 import pickle |
(...skipping 11 matching lines...) Expand all Loading... | |
22 from devil.android.tools import device_recovery | 22 from devil.android.tools import device_recovery |
23 from devil.android.tools import device_status | 23 from devil.android.tools import device_status |
24 from devil.utils import cmd_helper | 24 from devil.utils import cmd_helper |
25 from devil.utils import parallelizer | 25 from devil.utils import parallelizer |
26 from devil.utils import reraiser_thread | 26 from devil.utils import reraiser_thread |
27 from pylib import constants | 27 from pylib import constants |
28 from pylib.base import base_test_result | 28 from pylib.base import base_test_result |
29 from pylib.constants import host_paths | 29 from pylib.constants import host_paths |
30 from pylib.local.device import local_device_environment | 30 from pylib.local.device import local_device_environment |
31 from pylib.local.device import local_device_test_run | 31 from pylib.local.device import local_device_test_run |
32 from py_trace_event import trace_event | |
rnephew (Reviews Here)
2016/12/15 19:24:58
I keep getting:
** Presubmit Warnings **
Pylint (1
mikecase (-- gone --)
2016/12/15 19:46:47
Here I think.
https://cs.chromium.org/chromium/sr
rnephew (Reviews Here)
2016/12/15 19:55:13
Thanks.
| |
32 | 33 |
33 | 34 |
34 class HeartBeat(object): | 35 class HeartBeat(object): |
35 | 36 |
36 def __init__(self, shard, wait_time=60*10): | 37 def __init__(self, shard, wait_time=60*10): |
37 """ HeartBeat Logger constructor. | 38 """ HeartBeat Logger constructor. |
38 | 39 |
39 Args: | 40 Args: |
40 shard: A perf test runner device shard. | 41 shard: A perf test runner device shard. |
41 wait_time: time to wait between heartbeat messages. | 42 wait_time: time to wait between heartbeat messages. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 self._test_instance.WriteBuildBotJson(self._output_dir) | 90 self._test_instance.WriteBuildBotJson(self._output_dir) |
90 | 91 |
91 timeout = self._tests[test].get('timeout', self._timeout) | 92 timeout = self._tests[test].get('timeout', self._timeout) |
92 cmd = self._CreateCmd(test) | 93 cmd = self._CreateCmd(test) |
93 cwd = os.path.abspath(host_paths.DIR_SOURCE_ROOT) | 94 cwd = os.path.abspath(host_paths.DIR_SOURCE_ROOT) |
94 | 95 |
95 self._LogTest(test, cmd, timeout) | 96 self._LogTest(test, cmd, timeout) |
96 | 97 |
97 try: | 98 try: |
98 start_time = time.time() | 99 start_time = time.time() |
100 if self._test_instance.trace_output: | |
101 trace_event.trace_begin(test) | |
99 exit_code, output = cmd_helper.GetCmdStatusAndOutputWithTimeout( | 102 exit_code, output = cmd_helper.GetCmdStatusAndOutputWithTimeout( |
100 cmd, timeout, cwd=cwd, shell=True) | 103 cmd, timeout, cwd=cwd, shell=True) |
104 if self._test_instance.trace_output: | |
105 trace_event.trace_end(test) | |
101 end_time = time.time() | 106 end_time = time.time() |
102 json_output = self._test_instance.ReadChartjsonOutput(self._output_dir) | 107 json_output = self._test_instance.ReadChartjsonOutput(self._output_dir) |
103 if exit_code == 0: | 108 if exit_code == 0: |
104 result_type = base_test_result.ResultType.PASS | 109 result_type = base_test_result.ResultType.PASS |
105 else: | 110 else: |
106 result_type = base_test_result.ResultType.FAIL | 111 result_type = base_test_result.ResultType.FAIL |
107 except cmd_helper.TimeoutError as e: | 112 except cmd_helper.TimeoutError as e: |
108 end_time = time.time() | 113 end_time = time.time() |
109 exit_code = -1 | 114 exit_code = -1 |
110 output = e.output | 115 output = e.output |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
403 'affinity to work properly, it must be passed.') | 408 'affinity to work properly, it must be passed.') |
404 devices = active_devices | 409 devices = active_devices |
405 except IOError as e: | 410 except IOError as e: |
406 logging.error('Unable to find %s [%s]', devices_path, e) | 411 logging.error('Unable to find %s [%s]', devices_path, e) |
407 devices = active_devices | 412 devices = active_devices |
408 return sorted(devices) | 413 return sorted(devices) |
409 | 414 |
410 #override | 415 #override |
411 def RunTests(self): | 416 def RunTests(self): |
412 # Affinitize the tests. | 417 # Affinitize the tests. |
418 if self._test_instance.trace_output: | |
419 assert not trace_event.trace_is_enabled(), 'Tracing already running.' | |
420 trace_event.trace_enable(self._test_instance.trace_output) | |
421 assert trace_event.trace_is_enabled(), 'Tracing didn\'t enable properly.' | |
mikecase (-- gone --)
2016/12/15 19:56:02
nit: Maybe just didn't -> "did not enable" or just
rnephew (Reviews Here)
2016/12/15 20:02:10
Thats how I do it in telemetry when using trace_ev
| |
413 self._SplitTestsByAffinity() | 422 self._SplitTestsByAffinity() |
414 if not self._test_buckets and not self._no_device_tests: | 423 if not self._test_buckets and not self._no_device_tests: |
415 raise local_device_test_run.NoTestsError() | 424 raise local_device_test_run.NoTestsError() |
416 | 425 |
417 def run_no_devices_tests(): | 426 def run_no_devices_tests(): |
418 if not self._no_device_tests: | 427 if not self._no_device_tests: |
419 return [] | 428 return [] |
420 s = HostTestShard(self._env, self._test_instance, self._no_device_tests, | 429 s = HostTestShard(self._env, self._test_instance, self._no_device_tests, |
421 retries=3, timeout=self._timeout) | 430 retries=3, timeout=self._timeout) |
422 return [s.RunTestsOnShard()] | 431 return [s.RunTestsOnShard()] |
(...skipping 17 matching lines...) Expand all Loading... | |
440 self._devices = self._GetAllDevices( | 449 self._devices = self._GetAllDevices( |
441 self._env.devices, self._test_instance.known_devices_file) | 450 self._env.devices, self._test_instance.known_devices_file) |
442 | 451 |
443 device_indices = range(min(len(self._devices), len(self._test_buckets))) | 452 device_indices = range(min(len(self._devices), len(self._test_buckets))) |
444 shards = parallelizer.Parallelizer(device_indices).pMap( | 453 shards = parallelizer.Parallelizer(device_indices).pMap( |
445 device_shard_helper) | 454 device_shard_helper) |
446 return [x for x in shards.pGet(self._timeout) if x is not None] | 455 return [x for x in shards.pGet(self._timeout) if x is not None] |
447 | 456 |
448 host_test_results, device_test_results = reraiser_thread.RunAsync( | 457 host_test_results, device_test_results = reraiser_thread.RunAsync( |
449 [run_no_devices_tests, run_devices_tests]) | 458 [run_no_devices_tests, run_devices_tests]) |
459 if self._test_instance.trace_output: | |
460 assert trace_event.trace_is_enabled(), 'Tracing not running.' | |
461 trace_event.trace_disable() | |
462 assert not trace_event.trace_is_enabled(), 'Tracing not disabled.' | |
450 return host_test_results + device_test_results | 463 return host_test_results + device_test_results |
451 | 464 |
452 # override | 465 # override |
453 def TestPackage(self): | 466 def TestPackage(self): |
454 return 'perf' | 467 return 'perf' |
455 | 468 |
456 # override | 469 # override |
457 def _CreateShards(self, _tests): | 470 def _CreateShards(self, _tests): |
458 raise NotImplementedError | 471 raise NotImplementedError |
459 | 472 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
512 # override | 525 # override |
513 def _RunTest(self, _device, _test): | 526 def _RunTest(self, _device, _test): |
514 raise NotImplementedError | 527 raise NotImplementedError |
515 | 528 |
516 | 529 |
517 class TestDictVersionError(Exception): | 530 class TestDictVersionError(Exception): |
518 pass | 531 pass |
519 | 532 |
520 class PerfTestRunGetStepsError(Exception): | 533 class PerfTestRunGetStepsError(Exception): |
521 pass | 534 pass |
OLD | NEW |