OLD | NEW |
---|---|
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 optparse | 6 import optparse |
7 import os | 7 import os |
8 import random | 8 import random |
9 import sys | 9 import sys |
10 import time | 10 import time |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
198 | 198 |
199 # Reorder page set based on options. | 199 # Reorder page set based on options. |
200 user_stories = _ShuffleAndFilterUserStorySet(user_story_set, finder_options) | 200 user_stories = _ShuffleAndFilterUserStorySet(user_story_set, finder_options) |
201 | 201 |
202 if (not finder_options.use_live_sites and | 202 if (not finder_options.use_live_sites and |
203 finder_options.browser_options.wpr_mode != wpr_modes.WPR_RECORD and | 203 finder_options.browser_options.wpr_mode != wpr_modes.WPR_RECORD and |
204 # TODO(nednguyen): also handle these logic for user_story_set in next | 204 # TODO(nednguyen): also handle these logic for user_story_set in next |
205 # patch. | 205 # patch. |
206 isinstance(user_story_set, page_set_module.PageSet)): | 206 isinstance(user_story_set, page_set_module.PageSet)): |
207 _UpdateUserStoryArchivesIfChanged(user_story_set) | 207 _UpdateUserStoryArchivesIfChanged(user_story_set) |
208 user_stories = _CheckArchives(user_story_set, user_stories, results) | 208 user_stories = _CheckArchives(user_story_set, user_stories) |
209 | 209 |
210 for user_story in list(user_stories): | 210 for user_story in list(user_stories): |
211 if not test.CanRunForPage(user_story): | 211 if not test.CanRunForPage(user_story): |
212 results.WillRunPage(user_story) | 212 results.WillRunPage(user_story) |
213 logging.debug('Skipping test: it cannot run for %s', | 213 logging.debug('Skipping test: it cannot run for %s', |
214 user_story.display_name) | 214 user_story.display_name) |
215 results.AddValue(skip.SkipValue(user_story, 'Test cannot run')) | 215 results.AddValue(skip.SkipValue(user_story, 'Test cannot run')) |
216 results.DidRunPage(user_story) | 216 results.DidRunPage(user_story) |
217 user_stories.remove(user_story) | 217 user_stories.remove(user_story) |
218 | 218 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
272 else: | 272 else: |
273 raise Exception( | 273 raise Exception( |
274 'pageset-shuffle-order-file flag can only be used with page set') | 274 'pageset-shuffle-order-file flag can only be used with page set') |
275 user_stories = [u for u in user_story_set[:] | 275 user_stories = [u for u in user_story_set[:] |
276 if user_story_filter.UserStoryFilter.IsSelected(u)] | 276 if user_story_filter.UserStoryFilter.IsSelected(u)] |
277 if finder_options.pageset_shuffle: | 277 if finder_options.pageset_shuffle: |
278 random.shuffle(user_stories) | 278 random.shuffle(user_stories) |
279 return user_stories | 279 return user_stories |
280 | 280 |
281 | 281 |
282 def _CheckArchives(page_set, pages, results): | 282 def _CheckArchives(page_set, pages): |
283 """Returns a subset of pages that are local or have WPR archives. | 283 """Returns a subset of pages that are local or have WPR archives. |
284 | 284 |
285 Logs warnings if any are missing. | 285 Logs warnings if any are missing. |
286 """ | 286 """ |
287 # Warn of any problems with the entire page set. | 287 # Error if there are any problems with the entire page set. |
288 if any(not p.is_local for p in pages): | 288 if any(not p.is_local for p in pages): |
289 if not page_set.archive_data_file: | 289 if not page_set.archive_data_file: |
290 logging.warning('The page set is missing an "archive_data_file" ' | 290 logging.error('The page set is missing an "archive_data_file" ' |
291 'property. Skipping any live sites. To include them, ' | 291 'property. To run from live sites pass the flag ' |
292 'pass the flag --use-live-sites.') | 292 '--use-live-sites. To create an archive file add an ' |
293 'archive_data_file property to the page set and then ' | |
294 'run record_wpr.') | |
295 raise Exception('No archive_data_file for page set.') | |
dtu
2014/11/22 00:48:29
nit: raise some other kind of Error, not a generic
| |
293 if not page_set.wpr_archive_info: | 296 if not page_set.wpr_archive_info: |
294 logging.warning('The archive info file is missing. ' | 297 logging.error('The archive info file is missing. ' |
295 'To fix this, either add svn-internal to your ' | 298 'To fix this, either add svn-internal to your ' |
296 '.gclient using http://goto/read-src-internal, ' | 299 '.gclient using http://goto/read-src-internal, ' |
297 'or create a new archive using record_wpr.') | 300 'or create a new archive using record_wpr.') |
301 raise Exception('No wpr_archive_info for page set.') | |
298 | 302 |
299 # Warn of any problems with individual pages and return valid pages. | 303 # Warn of any problems with individual pages and either throw an error or |
304 # return valid pages. | |
300 pages_missing_archive_path = [] | 305 pages_missing_archive_path = [] |
301 pages_missing_archive_data = [] | 306 pages_missing_archive_data = [] |
302 valid_pages = [] | 307 valid_pages = [] |
303 for page in pages: | 308 for page in pages: |
304 if not page.is_local and not page.archive_path: | 309 if not page.is_local and not page.archive_path: |
305 pages_missing_archive_path.append(page) | 310 pages_missing_archive_path.append(page) |
306 elif not page.is_local and not os.path.isfile(page.archive_path): | 311 elif not page.is_local and not os.path.isfile(page.archive_path): |
307 pages_missing_archive_data.append(page) | 312 pages_missing_archive_data.append(page) |
308 else: | 313 else: |
309 valid_pages.append(page) | 314 valid_pages.append(page) |
310 if pages_missing_archive_path: | 315 if pages_missing_archive_path: |
311 logging.warning('The page set archives for some pages do not exist. ' | 316 logging.error('The page set archives for some pages do not exist. ' |
312 'Skipping those pages. To fix this, record those pages ' | 317 'To fix this, record those pages using record_wpr. ' |
313 'using record_wpr. To ignore this warning and run ' | 318 'To ignore this warning and run against live sites, ' |
314 'against live sites, pass the flag --use-live-sites.') | 319 'pass the flag --use-live-sites.') |
320 logging.error( | |
321 'Pages without archives: %s', | |
322 ', '.join(page.display_name for page in pages_missing_archive_path)) | |
315 if pages_missing_archive_data: | 323 if pages_missing_archive_data: |
316 logging.warning('The page set archives for some pages are missing. ' | 324 logging.error('The page set archives for some pages are missing. ' |
317 'Someone forgot to check them in, or they were deleted. ' | 325 'Someone forgot to check them in, uploaded them to the ' |
318 'Skipping those pages. To fix this, record those pages ' | 326 'wrong cloud storage bucket, or they were deleted. ' |
319 'using record_wpr. To ignore this warning and run ' | 327 'To fix this, record those pages using record_wpr. ' |
320 'against live sites, pass the flag --use-live-sites.') | 328 'To ignore this warning and run against live sites, ' |
321 for page in pages_missing_archive_path + pages_missing_archive_data: | 329 'pass the flag --use-live-sites.') |
322 results.WillRunPage(page) | 330 logging.error( |
323 results.AddValue(failure.FailureValue.FromMessage( | 331 'Pages missing archives: %s', |
324 page, 'Page set archive doesn\'t exist.')) | 332 ', '.join(page.display_name for page in pages_missing_archive_data)) |
325 results.DidRunPage(page) | 333 if pages_missing_archive_path or pages_missing_archive_data: |
334 raise Exception('Missing archives for some pages in page set.') | |
326 return valid_pages | 335 return valid_pages |
327 | 336 |
328 | 337 |
329 def _WaitForThermalThrottlingIfNeeded(platform): | 338 def _WaitForThermalThrottlingIfNeeded(platform): |
330 if not platform.CanMonitorThermalThrottling(): | 339 if not platform.CanMonitorThermalThrottling(): |
331 return | 340 return |
332 thermal_throttling_retry = 0 | 341 thermal_throttling_retry = 0 |
333 while (platform.IsThermallyThrottled() and | 342 while (platform.IsThermallyThrottled() and |
334 thermal_throttling_retry < 3): | 343 thermal_throttling_retry < 3): |
335 logging.warning('Thermally throttled, waiting (%d)...', | 344 logging.warning('Thermally throttled, waiting (%d)...', |
336 thermal_throttling_retry) | 345 thermal_throttling_retry) |
337 thermal_throttling_retry += 1 | 346 thermal_throttling_retry += 1 |
338 time.sleep(thermal_throttling_retry * 2) | 347 time.sleep(thermal_throttling_retry * 2) |
339 | 348 |
340 if thermal_throttling_retry and platform.IsThermallyThrottled(): | 349 if thermal_throttling_retry and platform.IsThermallyThrottled(): |
341 logging.warning('Device is thermally throttled before running ' | 350 logging.warning('Device is thermally throttled before running ' |
342 'performance tests, results will vary.') | 351 'performance tests, results will vary.') |
343 | 352 |
344 | 353 |
345 def _CheckThermalThrottling(platform): | 354 def _CheckThermalThrottling(platform): |
346 if not platform.CanMonitorThermalThrottling(): | 355 if not platform.CanMonitorThermalThrottling(): |
347 return | 356 return |
348 if platform.HasBeenThermallyThrottled(): | 357 if platform.HasBeenThermallyThrottled(): |
349 logging.warning('Device has been thermally throttled during ' | 358 logging.warning('Device has been thermally throttled during ' |
350 'performance tests, results will vary.') | 359 'performance tests, results will vary.') |
OLD | NEW |