Commit 202a0925 authored by eyaich's avatar eyaich Committed by Commit bot

Adding logic to restart the browser if there is an exception

in the setUp of GpuIntegrationTest

Note: I am not certain there is a good way to test the setup
functionality of GpuIntegrationTest in a unittest.  Given that
we are using a Fakes, I have added a hack to simulate throwing
an error in the setup method, but it is not how it would behave
in practice.  Any suggestions for a better way to unittest this
are appreciated.

Dependent on https://codereview.chromium.org/2148283003 landing in telemetry first

BUG=628022
CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:linux_optional_gpu_tests_rel;tryserver.chromium.mac:mac_optional_gpu_tests_rel;tryserver.chromium.win:win_optional_gpu_tests_rel

Review-Url: https://codereview.chromium.org/2151983002
Cr-Commit-Position: refs/heads/master@{#407022}
parent ae0dd7ed
...@@ -126,4 +126,11 @@ class GpuIntegrationTest( ...@@ -126,4 +126,11 @@ class GpuIntegrationTest(
raise NotImplementedError raise NotImplementedError
def setUp(self): def setUp(self):
self.tab = self.browser.tabs[0] try:
self.tab = self.browser.tabs[0]
except Exception:
# restart the browser to make sure a failure in a test doesn't
# propagate to the next test iteration.
logging.exception("Failure during browser startup")
self._RestartBrowser('failure in setup')
raise
...@@ -16,6 +16,7 @@ import gpu_project_config ...@@ -16,6 +16,7 @@ import gpu_project_config
from gpu_tests import gpu_integration_test from gpu_tests import gpu_integration_test
from gpu_tests import gpu_test_expectations from gpu_tests import gpu_test_expectations
_GLOBAL_TEST_COUNT = 0
class SimpleIntegrationUnittest(gpu_integration_test.GpuIntegrationTest): class SimpleIntegrationUnittest(gpu_integration_test.GpuIntegrationTest):
# Must be class-scoped since instances aren't reused across runs. # Must be class-scoped since instances aren't reused across runs.
...@@ -27,6 +28,16 @@ class SimpleIntegrationUnittest(gpu_integration_test.GpuIntegrationTest): ...@@ -27,6 +28,16 @@ class SimpleIntegrationUnittest(gpu_integration_test.GpuIntegrationTest):
def Name(cls): def Name(cls):
return 'simple_integration_unittest' return 'simple_integration_unittest'
def setUp(self):
global _GLOBAL_TEST_COUNT
_GLOBAL_TEST_COUNT += 1
# If this is the first test, fail on setup to ensure that the
# gpu_integration_test handles failures in setup and remaining tests
# can be executed
if _GLOBAL_TEST_COUNT == 1:
self.tab.Navigate('chrome://crash')
super(SimpleIntegrationUnittest, self).setUp()
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
finder_options = fakes.CreateBrowserFinderOptions() finder_options = fakes.CreateBrowserFinderOptions()
...@@ -44,6 +55,7 @@ class SimpleIntegrationUnittest(gpu_integration_test.GpuIntegrationTest): ...@@ -44,6 +55,7 @@ class SimpleIntegrationUnittest(gpu_integration_test.GpuIntegrationTest):
@classmethod @classmethod
def GenerateGpuTests(cls, options): def GenerateGpuTests(cls, options):
yield ('setup', 'failure.html', ())
yield ('expected_failure', 'failure.html', ()) yield ('expected_failure', 'failure.html', ())
yield ('expected_flaky', 'flaky.html', ()) yield ('expected_flaky', 'flaky.html', ())
yield ('expected_skip', 'failure.html', ()) yield ('expected_skip', 'failure.html', ())
...@@ -92,14 +104,15 @@ class GpuIntegrationTestUnittest(unittest.TestCase): ...@@ -92,14 +104,15 @@ class GpuIntegrationTestUnittest(unittest.TestCase):
with open(temp_file_name) as f: with open(temp_file_name) as f:
test_result = json.load(f) test_result = json.load(f)
self.assertEquals(test_result['failures'], [ self.assertEquals(test_result['failures'], [
'expected_failure',
'setup',
'unexpected_error', 'unexpected_error',
'unexpected_failure']) 'unexpected_failure'])
self.assertEquals(test_result['successes'], [ self.assertEquals(test_result['successes'], [
'expected_failure',
'expected_flaky']) 'expected_flaky'])
self.assertEquals(test_result['valid'], True) self.assertEquals(test_result['valid'], True)
# It might be nice to be more precise about the order of operations # It might be nice to be more precise about the order of operations
# with these browser restarts, but this is at least a start. # with these browser restarts, but this is at least a start.
self.assertEquals(SimpleIntegrationUnittest._num_browser_starts, 5) self.assertEquals(SimpleIntegrationUnittest._num_browser_starts, 6)
finally: finally:
os.remove(temp_file_name) os.remove(temp_file_name)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment