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

Unified Diff: content/test/gpu/gpu_tests/gpu_integration_test_unittest.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/test/gpu/gpu_tests/gpu_integration_test.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/test/gpu/gpu_tests/gpu_integration_test_unittest.py
diff --git a/content/test/gpu/gpu_tests/gpu_integration_test_unittest.py b/content/test/gpu/gpu_tests/gpu_integration_test_unittest.py
index c62317566251953e49294f5170a01336e3ee6ac6..90f54f92b10bae0c693a560e56c221a2dd43e202 100644
--- a/content/test/gpu/gpu_tests/gpu_integration_test_unittest.py
+++ b/content/test/gpu/gpu_tests/gpu_integration_test_unittest.py
@@ -17,7 +17,6 @@ from gpu_tests import gpu_integration_test
from gpu_tests import gpu_test_expectations
_GLOBAL_TEST_COUNT = 0
-_GLOBAL_RESTART_CRASH = False
class SimpleIntegrationUnittest(gpu_integration_test.GpuIntegrationTest):
# Must be class-scoped since instances aren't reused across runs.
@@ -25,8 +24,6 @@ class SimpleIntegrationUnittest(gpu_integration_test.GpuIntegrationTest):
_num_browser_starts = 0
- _num_restart_failures = 0
-
@classmethod
def Name(cls):
return 'simple_integration_unittest'
@@ -48,8 +45,8 @@ class SimpleIntegrationUnittest(gpu_integration_test.GpuIntegrationTest):
finder_options.output_formats = ['none']
finder_options.suppress_gtest_report = True
finder_options.output_dir = None
- finder_options.upload_bucket = 'public'
- finder_options.upload_results = False
+ finder_options .upload_bucket = 'public'
+ finder_options .upload_results = False
cls._finder_options = finder_options
cls.platform = None
cls.browser = None
@@ -64,9 +61,6 @@ class SimpleIntegrationUnittest(gpu_integration_test.GpuIntegrationTest):
yield ('expected_skip', 'failure.html', ())
yield ('unexpected_failure', 'failure.html', ())
yield ('unexpected_error', 'error.html', ())
- # This test causes the browser to restart 2 times (max allowed 3) and then
- # succeeds on the third attempt
- yield ('restart', 'restart.html', ())
@classmethod
def _CreateExpectations(cls):
@@ -81,26 +75,15 @@ class SimpleIntegrationUnittest(gpu_integration_test.GpuIntegrationTest):
super(SimpleIntegrationUnittest, cls).StartBrowser()
cls._num_browser_starts += 1
- @classmethod
- def StopBrowser(cls):
- global _GLOBAL_RESTART_CRASH
- if _GLOBAL_RESTART_CRASH:
- if cls._num_restart_failures < 2:
- cls._num_restart_failures += 1
- raise Exception
- else:
- _GLOBAL_RESTART_CRASH = False
-
- super(SimpleIntegrationUnittest, cls).StopBrowser()
-
-
def RunActualGpuTest(self, file_path, *args):
if file_path == 'failure.html':
self.fail('Expected failure')
elif file_path == 'restart.html':
- global _GLOBAL_RESTART_CRASH
- _GLOBAL_RESTART_CRASH = True
- self._RestartBrowser("testing restart on failure")
+ try:
+ # This will fail because the browser is already started
+ self.StartBrowser()
+ finally:
+ self.StopBrowser()
elif file_path == 'flaky.html':
if self.__class__._num_flaky_runs_to_fail > 0:
self.__class__._num_flaky_runs_to_fail -= 1
@@ -109,9 +92,73 @@ class SimpleIntegrationUnittest(gpu_integration_test.GpuIntegrationTest):
raise Exception('Expected exception')
+# TODO(eyaich@): add the actual unittest for start-up retrying logic.
+class BrowserStartFailureIntegrationUnittest(
+ gpu_integration_test.GpuIntegrationTest):
+ # Must be class-scoped since instances aren't reused across runs.
+ _num_restart_failures = 0
+
+ @classmethod
+ def setUpClass(cls):
+ finder_options = fakes.CreateBrowserFinderOptions()
+ finder_options.browser_options.platform = fakes.FakeLinuxPlatform()
+ finder_options.output_formats = ['none']
+ finder_options.suppress_gtest_report = True
+ finder_options.output_dir = None
+ finder_options .upload_bucket = 'public'
+ finder_options .upload_results = False
+ cls._finder_options = finder_options
+ cls.platform = None
+ cls.browser = None
+ cls.SetBrowserOptions(cls._finder_options)
+ cls.StartBrowser()
+
+ @classmethod
+ def _CreateExpectations(cls):
+ expectations = gpu_test_expectations.GpuTestExpectations()
+ expectations.Fail('expected_failure')
+ expectations.Flaky('expected_flaky', max_num_retries=3)
+ expectations.Skip('expected_skip')
+ return expectations
+
+ @classmethod
+ def Name(cls):
+ return 'browser_start_failure_integration_unittest'
+
+ @classmethod
+ def GenerateGpuTests(cls, options):
+ # This test causes the browser to try and restart the browser 3 times.
+ yield ('restart', 'restart.html', ())
+
+ def RunActualGpuTest(self, file_path, *args):
+ if file_path == 'restart.html':
+ try:
+ # This will fail because the browser is already started
+ self.StartBrowser()
+ finally:
+ self.StopBrowser()
+
+
class GpuIntegrationTestUnittest(unittest.TestCase):
@mock.patch('telemetry.internal.util.binary_manager.InitDependencyManager')
def testSimpleIntegrationUnittest(self, mockInitDependencyManager):
+ self._RunIntegrationTest(
+ 'simple_integration_unittest', [
+ 'expected_failure',
+ 'setup',
+ 'unexpected_error',
+ 'unexpected_failure'], ['expected_flaky'])
+ # It might be nice to be more precise about the order of operations
+ # with these browser restarts, but this is at least a start.
+ self.assertEquals(SimpleIntegrationUnittest._num_browser_starts, 6)
+
+ @mock.patch('telemetry.internal.util.binary_manager.InitDependencyManager')
+ def testIntegrationUnittestWithBrowserFailure(
+ self, mockInitDependencyManager):
+ self._RunIntegrationTest(
+ 'browser_start_failure_integration_unittest', ['restart'], [])
+
+ def _RunIntegrationTest(self, test_name, failures, successes):
options = browser_test_runner.TestRunOptions()
# Suppress printing out information for passing tests.
options.verbosity = 0
@@ -122,22 +169,13 @@ class GpuIntegrationTestUnittest(unittest.TestCase):
try:
browser_test_runner.Run(
config, options,
- ['simple_integration_unittest',
+ [test_name,
'--write-abbreviated-json-results-to=%s' % temp_file_name])
with open(temp_file_name) as f:
test_result = json.load(f)
- self.assertEquals(test_result['failures'], [
- 'expected_failure',
- 'setup',
- 'unexpected_error',
- 'unexpected_failure'])
- self.assertEquals(test_result['successes'], [
- 'expected_flaky', 'restart'])
+ self.assertEquals(test_result['failures'], failures)
+ self.assertEquals(test_result['successes'], successes)
self.assertEquals(test_result['valid'], True)
- # It might be nice to be more precise about the order of operations
- # with these browser restarts, but this is at least a start.
- self.assertEquals(SimpleIntegrationUnittest._num_browser_starts, 7)
- # Assert that we restarted the browser 2 times due to failure in restart
- self.assertEquals(SimpleIntegrationUnittest._num_restart_failures, 2)
+
finally:
os.remove(temp_file_name)
« no previous file with comments | « content/test/gpu/gpu_tests/gpu_integration_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698