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

Side by Side Diff: content/test/gpu/gpu_tests/gpu_integration_test.py

Issue 2181673002: Adding 3 attempts at starting the browser for a gpu integration test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 6
7 from telemetry.testing import serially_executed_browser_test_case 7 from telemetry.testing import serially_executed_browser_test_case
8 8
9 from gpu_tests import exception_formatter 9 from gpu_tests import exception_formatter
10 from gpu_tests import gpu_test_expectations 10 from gpu_tests import gpu_test_expectations
11 11
12 12
13 # Temporary class which bridges the gap beween these serially executed 13 # Temporary class which bridges the gap beween these serially executed
14 # browser tests and the old benchmark-based tests. As soon as all of 14 # browser tests and the old benchmark-based tests. As soon as all of
15 # the tests have been coverted over, this will be deleted. 15 # the tests have been coverted over, this will be deleted.
16 class _EmulatedPage(object): 16 class _EmulatedPage(object):
17 def __init__(self, url, name): 17 def __init__(self, url, name):
18 self.url = url 18 self.url = url
19 self.name = name 19 self.name = name
20 20
21 21
22
22 class GpuIntegrationTest( 23 class GpuIntegrationTest(
23 serially_executed_browser_test_case.SeriallyExecutedBrowserTestCase): 24 serially_executed_browser_test_case.SeriallyExecutedBrowserTestCase):
24 25
25 _cached_expectations = None 26 _cached_expectations = None
26 27
28 def __init__(self, methodName):
29 super(GpuIntegrationTest, self).__init__(methodName)
30 self._num_retries = 0
31
27 @classmethod 32 @classmethod
28 def GenerateTestCases__RunGpuTest(cls, options): 33 def GenerateTestCases__RunGpuTest(cls, options):
29 for test_name, url, args in cls.GenerateGpuTests(options): 34 for test_name, url, args in cls.GenerateGpuTests(options):
30 yield test_name, (url, test_name, args) 35 yield test_name, (url, test_name, args)
31 36
32 def _RestartBrowser(self, reason): 37 def _RestartBrowser(self, reason):
33 logging.warning('Restarting browser due to ' + reason) 38 try:
34 self.StopBrowser() 39 restart_attempt = ('Restarting browser %d time due to '
35 self.SetBrowserOptions(self._finder_options) 40 % (self._num_retries + 1))
36 self.StartBrowser() 41 logging.warning(restart_attempt + reason)
37 self.tab = self.browser.tabs[0] 42 self.StopBrowser()
43 self.SetBrowserOptions(self._finder_options)
44 self.StartBrowser()
45 self.tab = self.browser.tabs[0]
46 except Exception:
47 if self._num_retries < 3:
48 self._num_retries += 1
49 # Attempt to resart the browser 3 times on failure
50 self._RestartBrowser(reason)
nednguyen 2016/07/25 15:13:31 Can you do a for loop instead of recursion?
eyaich 2016/07/26 13:15:33 Done.
51 else:
52 raise
38 53
39 def _RunGpuTest(self, url, test_name, args): 54 def _RunGpuTest(self, url, test_name, args):
40 temp_page = _EmulatedPage(url, test_name) 55 temp_page = _EmulatedPage(url, test_name)
41 expectations = self.__class__.GetExpectations() 56 expectations = self.__class__.GetExpectations()
42 expectation = expectations.GetExpectationForPage( 57 expectation = expectations.GetExpectationForPage(
43 self.browser, temp_page) 58 self.browser, temp_page)
44 if expectation == 'skip': 59 if expectation == 'skip':
45 # skipTest in Python's unittest harness raises an exception, so 60 # skipTest in Python's unittest harness raises an exception, so
46 # aborts the control flow here. 61 # aborts the control flow here.
47 self.skipTest('SKIPPING TEST due to test expectations') 62 self.skipTest('SKIPPING TEST due to test expectations')
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 142
128 def setUp(self): 143 def setUp(self):
129 try: 144 try:
130 self.tab = self.browser.tabs[0] 145 self.tab = self.browser.tabs[0]
131 except Exception: 146 except Exception:
132 # restart the browser to make sure a failure in a test doesn't 147 # restart the browser to make sure a failure in a test doesn't
133 # propagate to the next test iteration. 148 # propagate to the next test iteration.
134 logging.exception("Failure during browser startup") 149 logging.exception("Failure during browser startup")
135 self._RestartBrowser('failure in setup') 150 self._RestartBrowser('failure in setup')
136 raise 151 raise
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698