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

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

Issue 2219593003: [content/test/gpu] Pushing the restart logic into start browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add TODO Created 4 years, 4 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 | content/test/gpu/gpu_tests/gpu_integration_test_unittest.py » ('j') | 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 from telemetry.util import screenshot
8 9
9 from gpu_tests import exception_formatter 10 from gpu_tests import exception_formatter
10 from gpu_tests import gpu_test_expectations 11 from gpu_tests import gpu_test_expectations
11 12
12 13
13 # Temporary class which bridges the gap beween these serially executed 14 # Temporary class which bridges the gap beween these serially executed
14 # browser tests and the old benchmark-based tests. As soon as all of 15 # browser tests and the old benchmark-based tests. As soon as all of
15 # the tests have been coverted over, this will be deleted. 16 # the tests have been coverted over, this will be deleted.
16 class _EmulatedPage(object): 17 class _EmulatedPage(object):
17 def __init__(self, url, name): 18 def __init__(self, url, name):
18 self.url = url 19 self.url = url
19 self.name = name 20 self.name = name
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
27 @classmethod 28 @classmethod
28 def GenerateTestCases__RunGpuTest(cls, options): 29 def GenerateTestCases__RunGpuTest(cls, options):
29 for test_name, url, args in cls.GenerateGpuTests(options): 30 for test_name, url, args in cls.GenerateGpuTests(options):
30 yield test_name, (url, test_name, args) 31 yield test_name, (url, test_name, args)
31 32
32 def _RestartBrowser(self, reason): 33 @classmethod
34 def StartBrowser(cls):
33 for x in range(0, 3): 35 for x in range(0, 3):
34 try: 36 try:
35 restart_attempt = ('Restarting browser %d time due to ' 37 restart = 'Starting browser, attempt %d of 3' % (x + 1)
36 % (x + 1)) 38 logging.warning(restart)
37 logging.warning(restart_attempt + reason) 39 super(GpuIntegrationTest, cls).StartBrowser()
38 self.StopBrowser()
39 self.SetBrowserOptions(self._finder_options)
40 self.StartBrowser()
41 self.tab = self.browser.tabs[0]
42 return 40 return
43 except Exception: 41 except Exception:
44 # If we are on the last try and there is an exception raise it 42 # If we are on the last try and there is an exception take a screenshot
43 # to try and capture more about the browser failure and raise
45 if x == 2: 44 if x == 2:
45 url = screenshot.TryCaptureScreenShotAndUploadToCloudStorage(
46 cls.platform)
47 if url is not None:
48 logging.info("GpuIntegrationTest screenshot of browser failure " +
49 "located at " + url)
50 else:
51 logging.warning("GpuIntegrationTest unable to take screenshot")
46 raise 52 raise
47 53
54 def _RestartBrowser(self, reason):
55 logging.warning('Restarting browser due to '+ reason)
56 self.StopBrowser()
57 self.SetBrowserOptions(self._finder_options)
58 self.StartBrowser()
59 self.tab = self.browser.tabs[0]
60
48 def _RunGpuTest(self, url, test_name, args): 61 def _RunGpuTest(self, url, test_name, args):
49 temp_page = _EmulatedPage(url, test_name) 62 temp_page = _EmulatedPage(url, test_name)
50 expectations = self.__class__.GetExpectations() 63 expectations = self.__class__.GetExpectations()
51 expectation = expectations.GetExpectationForPage( 64 expectation = expectations.GetExpectationForPage(
52 self.browser, temp_page) 65 self.browser, temp_page)
53 if expectation == 'skip': 66 if expectation == 'skip':
54 # skipTest in Python's unittest harness raises an exception, so 67 # skipTest in Python's unittest harness raises an exception, so
55 # aborts the control flow here. 68 # aborts the control flow here.
56 self.skipTest('SKIPPING TEST due to test expectations') 69 self.skipTest('SKIPPING TEST due to test expectations')
57 try: 70 try:
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 149
137 def setUp(self): 150 def setUp(self):
138 try: 151 try:
139 self.tab = self.browser.tabs[0] 152 self.tab = self.browser.tabs[0]
140 except Exception: 153 except Exception:
141 # restart the browser to make sure a failure in a test doesn't 154 # restart the browser to make sure a failure in a test doesn't
142 # propagate to the next test iteration. 155 # propagate to the next test iteration.
143 logging.exception("Failure during browser startup") 156 logging.exception("Failure during browser startup")
144 self._RestartBrowser('failure in setup') 157 self._RestartBrowser('failure in setup')
145 raise 158 raise
OLDNEW
« no previous file with comments | « no previous file | content/test/gpu/gpu_tests/gpu_integration_test_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698