Chromium Code Reviews| 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..a812ac2ee4c8225799056d7938dbd51a76e19463 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,72 @@ class SimpleIntegrationUnittest(gpu_integration_test.GpuIntegrationTest): |
| raise Exception('Expected exception') |
| +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 +168,14 @@ 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) |
| + |
|
nednguyen
2016/08/04 17:03:48
nits: this extra blank line is not needed
eyaich
2016/08/04 18:15:17
Done.
|