Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: telemetry/telemetry/internal/story_runner.py

Issue 2091103003: [Telemetry] Add Benchmark.ShouldTearDownStateAfterEachStorySetRun (Closed) Base URL: git@github.com:catapult-project/catapult@master
Patch Set: do not change default Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 sys 8 import sys
9 import time 9 import time
10 10
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 'allow_mixed_story_states.' % ( 165 'allow_mixed_story_states.' % (
166 story_groups[-1].shared_state_class, 166 story_groups[-1].shared_state_class,
167 story.shared_state_class)) 167 story.shared_state_class))
168 story_groups.append( 168 story_groups.append(
169 StoryGroup(story.shared_state_class)) 169 StoryGroup(story.shared_state_class))
170 story_groups[-1].AddStory(story) 170 story_groups[-1].AddStory(story)
171 return story_groups 171 return story_groups
172 172
173 173
174 def Run(test, story_set, finder_options, results, max_failures=None, 174 def Run(test, story_set, finder_options, results, max_failures=None,
175 should_tear_down_state_after_each_story_run=False): 175 tear_down_after_story=False, tear_down_after_story_set=False):
176 """Runs a given test against a given page_set with the given options. 176 """Runs a given test against a given page_set with the given options.
177 177
178 Stop execution for unexpected exceptions such as KeyboardInterrupt. 178 Stop execution for unexpected exceptions such as KeyboardInterrupt.
179 We "white list" certain exceptions for which the story runner 179 We "white list" certain exceptions for which the story runner
180 can continue running the remaining stories. 180 can continue running the remaining stories.
181 """ 181 """
182 # Filter page set based on options. 182 # Filter page set based on options.
183 stories = filter(story_module.StoryFilter.IsSelected, story_set) 183 stories = filter(story_module.StoryFilter.IsSelected, story_set)
184 184
185 if (not finder_options.use_live_sites and 185 if (not finder_options.use_live_sites and
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 try: 240 try:
241 if state: 241 if state:
242 _CheckThermalThrottling(state.platform) 242 _CheckThermalThrottling(state.platform)
243 results.DidRunPage(story) 243 results.DidRunPage(story)
244 except Exception: 244 except Exception:
245 if not has_existing_exception: 245 if not has_existing_exception:
246 raise 246 raise
247 # Print current exception and propagate existing exception. 247 # Print current exception and propagate existing exception.
248 exception_formatter.PrintFormattedException( 248 exception_formatter.PrintFormattedException(
249 msg='Exception from result processing:') 249 msg='Exception from result processing:')
250 if state and should_tear_down_state_after_each_story_run: 250 if state and tear_down_after_story:
251 state.TearDownState() 251 state.TearDownState()
252 state = None 252 state = None
253 if (effective_max_failures is not None and 253 if (effective_max_failures is not None and
254 len(results.failures) > effective_max_failures): 254 len(results.failures) > effective_max_failures):
255 logging.error('Too many failures. Aborting.') 255 logging.error('Too many failures. Aborting.')
256 return 256 return
257 if state and tear_down_after_story_set:
258 state.TearDownState()
259 state = None
257 finally: 260 finally:
258 if state: 261 if state:
259 has_existing_exception = sys.exc_info() != (None, None, None) 262 has_existing_exception = sys.exc_info() != (None, None, None)
260 try: 263 try:
261 state.TearDownState() 264 state.TearDownState()
262 except Exception: 265 except Exception:
263 if not has_existing_exception: 266 if not has_existing_exception:
264 raise 267 raise
265 # Print current exception and propagate existing exception. 268 # Print current exception and propagate existing exception.
266 exception_formatter.PrintFormattedException( 269 exception_formatter.PrintFormattedException(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 raise Exception( 306 raise Exception(
304 'PageTest must be used with StorySet containing only ' 307 'PageTest must be used with StorySet containing only '
305 'telemetry.page.Page stories.') 308 'telemetry.page.Page stories.')
306 309
307 benchmark_metadata = benchmark.GetMetadata() 310 benchmark_metadata = benchmark.GetMetadata()
308 with results_options.CreateResults( 311 with results_options.CreateResults(
309 benchmark_metadata, finder_options, 312 benchmark_metadata, finder_options,
310 benchmark.ValueCanBeAddedPredicate) as results: 313 benchmark.ValueCanBeAddedPredicate) as results:
311 try: 314 try:
312 Run(pt, stories, finder_options, results, benchmark.max_failures, 315 Run(pt, stories, finder_options, results, benchmark.max_failures,
313 benchmark.ShouldTearDownStateAfterEachStoryRun()) 316 benchmark.ShouldTearDownStateAfterEachStoryRun(),
317 benchmark.ShouldTearDownStateAfterEachStorySetRun())
314 return_code = min(254, len(results.failures)) 318 return_code = min(254, len(results.failures))
315 except Exception: 319 except Exception:
316 exception_formatter.PrintFormattedException() 320 exception_formatter.PrintFormattedException()
317 return_code = 255 321 return_code = 255
318 322
319 try: 323 try:
320 bucket = cloud_storage.BUCKET_ALIASES[finder_options.upload_bucket] 324 bucket = cloud_storage.BUCKET_ALIASES[finder_options.upload_bucket]
321 if finder_options.upload_results: 325 if finder_options.upload_results:
322 results.UploadTraceFilesToCloud(bucket) 326 results.UploadTraceFilesToCloud(bucket)
323 results.UploadProfilingFilesToCloud(bucket) 327 results.UploadProfilingFilesToCloud(bucket)
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 logging.warning('Device is thermally throttled before running ' 407 logging.warning('Device is thermally throttled before running '
404 'performance tests, results will vary.') 408 'performance tests, results will vary.')
405 409
406 410
407 def _CheckThermalThrottling(platform): 411 def _CheckThermalThrottling(platform):
408 if not platform.CanMonitorThermalThrottling(): 412 if not platform.CanMonitorThermalThrottling():
409 return 413 return
410 if platform.HasBeenThermallyThrottled(): 414 if platform.HasBeenThermallyThrottled():
411 logging.warning('Device has been thermally throttled during ' 415 logging.warning('Device has been thermally throttled during '
412 'performance tests, results will vary.') 416 'performance tests, results will vary.')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698