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 logging | 5 import logging |
6 import os | 6 import os |
7 import shutil | 7 import shutil |
8 import sys | 8 import sys |
9 import tempfile | 9 import tempfile |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... |
40 _DEVTOOLS_TIMEOUT = 60 | 40 _DEVTOOLS_TIMEOUT = 60 |
41 | 41 |
42 # Categories to enable or disable for all traces collected. Disabled categories | 42 # Categories to enable or disable for all traces collected. Disabled categories |
43 # are prefixed with '-'. | 43 # are prefixed with '-'. |
44 _TRACING_CATEGORIES = [ | 44 _TRACING_CATEGORIES = [ |
45 'blink', | 45 'blink', |
46 'blink.net', | 46 'blink.net', |
47 'blink.user_timing', | 47 'blink.user_timing', |
48 'devtools.timeline', | 48 'devtools.timeline', |
49 'java', | 49 'java', |
| 50 'navigation', |
50 'toplevel', | 51 'toplevel', |
51 'v8', | 52 'v8', |
52 '-cc', # A lot of unnecessary events are enabled by default in "cc". | 53 '-cc', # A lot of unnecessary events are enabled by default in "cc". |
53 ] | 54 ] |
54 | 55 |
55 TTFMP_ADDITIONAL_CATEGORIES = [ | 56 TTFMP_ADDITIONAL_CATEGORIES = [ |
56 'loading', | 57 'loading', |
57 'disabled-by-default-blink.debug.layout', | 58 'disabled-by-default-blink.debug.layout', |
58 ] | 59 ] |
59 | 60 |
(...skipping 12 matching lines...) Expand all Loading... |
72 int(dirname) | 73 int(dirname) |
73 except ValueError: | 74 except ValueError: |
74 continue | 75 continue |
75 shutil.rmtree(directory_path) | 76 shutil.rmtree(directory_path) |
76 | 77 |
77 | 78 |
78 class CacheOperation(object): | 79 class CacheOperation(object): |
79 CLEAR, SAVE, PUSH = range(3) | 80 CLEAR, SAVE, PUSH = range(3) |
80 | 81 |
81 | 82 |
| 83 class SandwichRunnerError(Exception): |
| 84 pass |
| 85 |
| 86 |
82 class SandwichRunner(object): | 87 class SandwichRunner(object): |
83 """Sandwich runner. | 88 """Sandwich runner. |
84 | 89 |
85 This object is meant to be configured first and then run using the Run() | 90 This object is meant to be configured first and then run using the Run() |
86 method. | 91 method. |
87 """ | 92 """ |
88 _ATTEMPT_COUNT = 3 | 93 _ATTEMPT_COUNT = 3 |
89 _STOP_DELAY_MULTIPLIER = 2 | 94 _STOP_DELAY_MULTIPLIER = 2 |
90 _ABORT_RUN_TIMEOUT_SECONDS = 30 * 60 | 95 _ABORT_RUN_TIMEOUT_SECONDS = 30 * 60 |
91 | 96 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 if run_path is not None and self.record_video: | 207 if run_path is not None and self.record_video: |
203 device = self._chrome_ctl.GetDevice() | 208 device = self._chrome_ctl.GetDevice() |
204 if device is None: | 209 if device is None: |
205 raise RuntimeError('Can only record video on a remote device.') | 210 raise RuntimeError('Can only record video on a remote device.') |
206 video_recording_path = os.path.join(run_path, VIDEO_FILENAME) | 211 video_recording_path = os.path.join(run_path, VIDEO_FILENAME) |
207 with device_setup.RemoteSpeedIndexRecorder(device, connection, | 212 with device_setup.RemoteSpeedIndexRecorder(device, connection, |
208 video_recording_path): | 213 video_recording_path): |
209 trace = RecordTrace() | 214 trace = RecordTrace() |
210 else: | 215 else: |
211 trace = RecordTrace() | 216 trace = RecordTrace() |
| 217 for event in trace.request_track.GetEvents(): |
| 218 if event.failed: |
| 219 logging.warning( |
| 220 'request to %s failed: %s', event.url, event.error_text) |
| 221 if not trace.tracing_track.HasLoadingSucceeded(): |
| 222 raise SandwichRunnerError('Page load has failed.') |
212 if run_path is not None: | 223 if run_path is not None: |
213 trace_path = os.path.join(run_path, TRACE_FILENAME) | 224 trace_path = os.path.join(run_path, TRACE_FILENAME) |
214 trace.ToJsonFile(trace_path) | 225 trace.ToJsonFile(trace_path) |
215 | 226 |
216 def _RunInRetryLoop(self, repeat_id, perform_dry_run_before): | 227 def _RunInRetryLoop(self, repeat_id, perform_dry_run_before): |
217 """Attempts to run monitoring navigation. | 228 """Attempts to run monitoring navigation. |
218 | 229 |
219 Args: | 230 Args: |
220 repeat_id: Id of the run in the output directory. | 231 repeat_id: Id of the run in the output directory. |
221 perform_dry_run_before: Whether it should do a dry run attempt before the | 232 perform_dry_run_before: Whether it should do a dry run attempt before the |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 if not os.path.isdir(repeat_dir): | 367 if not os.path.isdir(repeat_dir): |
357 continue | 368 continue |
358 try: | 369 try: |
359 repeat_id = int(node_name) | 370 repeat_id = int(node_name) |
360 except ValueError: | 371 except ValueError: |
361 continue | 372 continue |
362 yield repeat_id, repeat_dir | 373 yield repeat_id, repeat_dir |
363 repeated_run_count += 1 | 374 repeated_run_count += 1 |
364 assert repeated_run_count > 0, ('Error: not a sandwich runner output ' | 375 assert repeated_run_count > 0, ('Error: not a sandwich runner output ' |
365 'directory: {}').format(runner_output_dir) | 376 'directory: {}').format(runner_output_dir) |
OLD | NEW |