Пример #1
0
    def testBackwardTraverseBuildsWhenGettingTestLevelFailureInfo(
            self, mock_fun, *_):
        master_name = 'm'
        builder_name = 'b'
        build_number = 221
        step_name = 'abc_test'
        failed_steps = {
            'abc_test': {
                'current_failure':
                223,
                'first_failure':
                223,
                'supported':
                True,
                'list_isolated_data': [{
                    'isolatedserver': 'https://isolateserver.appspot.com',
                    'namespace': 'default-gzip',
                    'digest': 'isolatedhashabctest-223'
                }]
            }
        }
        builds = {
            '221': {
                'blame_list': ['commit1'],
                'chromium_revision': 'commit1'
            },
            '222': {
                'blame_list': ['commit2'],
                'chromium_revision': 'commit2'
            },
            '223': {
                'blame_list': ['commit3', 'commit4'],
                'chromium_revision': 'commit4'
            }
        }

        failure_info = {
            'master_name': master_name,
            'builder_name': builder_name,
            'build_number': build_number,
            'failed_steps': failed_steps,
            'builds': builds
        }
        failure_info = TestFailureInfo.FromSerializable(failure_info)

        expected_failed_steps = failed_steps
        expected_failed_steps['abc_test']['tests'] = None
        expected_failed_steps['abc_test']['last_pass'] = None
        step = WfStep.Create(master_name, builder_name, build_number,
                             step_name)
        step.isolated = True
        step.put()

        ci_test_failure.CheckFirstKnownFailureForSwarmingTests(
            master_name, builder_name, build_number, failure_info)
        mock_fun.assert_called_once_with(
            master_name, builder_name, build_number, step_name,
            TestFailedStep.FromSerializable(failed_steps[step_name]),
            ['223', '222', '221'], None)
Пример #2
0
    def testCheckFirstKnownFailureForSwarmingTestsNoResult(self, _):
        master_name = 'm'
        builder_name = 'b'
        build_number = 224
        failed_steps = {}
        builds = {}
        failure_info = {
            'master_name': master_name,
            'builder_name': builder_name,
            'build_number': build_number,
            'failed_steps': failed_steps,
            'builds': builds
        }
        failure_info = TestFailureInfo.FromSerializable(failure_info)

        ci_test_failure.CheckFirstKnownFailureForSwarmingTests(
            master_name, builder_name, build_number, failure_info)
        self.assertEqual({}, failure_info.failed_steps.ToSerializable())
def HeuristicAnalysisForTest(heuristic_params):
  """Identifies culprit CL.

  Args:
    heuristic_params (TestHeuristicAnalysisParameters): A structured object
    with 2 fields:
      failure_info (TestFailureInfo): An object of failure info for the
      current failed build.
      build_completed (bool): If the build is completed.

  Returns:
    A TestHeuristicAnalysisOutput object with information about
    failure_info and heuristic_result.
  """
  failure_info = heuristic_params.failure_info
  master_name = failure_info.master_name
  builder_name = failure_info.builder_name
  build_number = failure_info.build_number

  # 1. Detects first failed builds for failed test step, updates failure_info.
  failure_info = ci_failure.CheckForFirstKnownFailure(
      master_name, builder_name, build_number, failure_info)

  # Checks first failed builds for each failed test.
  ci_test_failure.CheckFirstKnownFailureForSwarmingTests(
      master_name, builder_name, build_number, failure_info)

  analysis = WfAnalysis.Get(master_name, builder_name, build_number)
  analysis.failure_info = failure_info.ToSerializable()
  analysis.put()

  # Lacking chromium_revision indicates something is wrong in Findit,
  assert failure_info.chromium_revision, (
      'No end_revision when pulling change logs.')

  # 2. Extracts failure signal.
  signals = extract_test_signal.ExtractSignalsForTestFailure(
      failure_info, FinditHttpClient())

  # 3. Gets change_logs.
  change_logs = git.PullChangeLogs(
      ci_failure.GetGoodRevision(failure_info), failure_info.chromium_revision)

  # 4. Gets deps info.
  deps_info = deps.ExtractDepsInfo(failure_info, change_logs)

  # 5. Analyzes the test failure using information collected above.
  heuristic_result, suspected_cls = AnalyzeTestFailure(
      failure_info, change_logs, deps_info, signals)

  # Save results and other info to analysis.
  build_failure_analysis.SaveAnalysisAfterHeuristicAnalysisCompletes(
      master_name, builder_name, build_number, heuristic_result, suspected_cls)

  # Save suspected_cls to data_store.
  build_failure_analysis.SaveSuspectedCLs(
      suspected_cls, failure_info.master_name, failure_info.builder_name,
      failure_info.build_number, failure_info.failure_type)

  # Monitors analysis status change.
  # Only record one metric for each analysis.
  RecordTestFailureAnalysisStateChange(master_name, builder_name,
                                       analysis_status.COMPLETED,
                                       analysis_approach_type.HEURISTIC)

  return TestHeuristicAnalysisOutput(
      failure_info=failure_info,
      heuristic_result=TestHeuristicResult.FromSerializable(heuristic_result))
Пример #4
0
    def testCheckFirstKnownFailureForSwarmingTestsFoundFlaky(
            self, mock_module, *_):
        master_name = 'm'
        builder_name = 'b'
        build_number = 221
        step_name = 'abc_test'
        failed_steps = {
            'abc_test': {
                'current_failure':
                221,
                'first_failure':
                221,
                'supported':
                True,
                'list_isolated_data': [{
                    'isolatedserver': 'https://isolateserver.appspot.com',
                    'namespace': 'default-gzip',
                    'digest': 'isolatedhashabctest-223'
                }]
            }
        }
        builds = {
            '221': {
                'blame_list': ['commit1'],
                'chromium_revision': 'commit1'
            },
            '222': {
                'blame_list': ['commit2'],
                'chromium_revision': 'commit2'
            },
            '223': {
                'blame_list': ['commit3', 'commit4'],
                'chromium_revision': 'commit4'
            }
        }

        failure_info = {
            'master_name': master_name,
            'builder_name': builder_name,
            'build_number': build_number,
            'failed_steps': failed_steps,
            'builds': builds
        }
        failure_info = TestFailureInfo.FromSerializable(failure_info)

        expected_failed_steps = failed_steps
        expected_failed_steps['abc_test']['tests'] = None
        expected_failed_steps['abc_test']['last_pass'] = None
        step = WfStep.Create(master_name, builder_name, build_number,
                             step_name)
        step.isolated = True
        step.put()

        mock_module.RetrieveShardedTestResultsFromIsolatedServer.return_value = {
            'disabled_tests': [],
            'all_tests': [
                'Unittest1.Subtest1',
                'Unittest1.Subtest2',
                'Unittest2.Subtest1',
            ],
            'per_iteration_data': [{
                'Unittest1.Subtest1': [{
                    'elapsed_time_ms':
                    1,
                    'losless_snippet':
                    True,
                    'output_snippet':
                    '[       OK ]\\n',
                    'status':
                    'SUCCESS',
                    'output_snippet_base64':
                    'WyAgICAgICBPSyBdCg=='
                }],
                'Unittest1.Subtest2': [{
                    'elapsed_time_ms':
                    66,
                    'losless_snippet':
                    True,
                    'output_snippet':
                    'a/b/u1s2.cc:1234: Failure\\n',
                    'status':
                    'FAILURE',
                    'output_snippet_base64':
                    'YS9iL3UxczIuY2M6MTIzNDogRmF'
                }, {
                    'elapsed_time_ms':
                    50,
                    'losless_snippet':
                    True,
                    'output_snippet':
                    '[       OK ]\\n',
                    'status':
                    'SUCCESS',
                    'output_snippet_base64':
                    'WyAgICAgICBPSyBdCg=='
                }],
                'Unittest2.Subtest1': [{
                    'elapsed_time_ms':
                    56,
                    'losless_snippet':
                    True,
                    'output_snippet':
                    'ERROR',
                    'status':
                    'FAILURE',
                    'output_snippet_base64':
                    'RVJST1I6eF90ZXN0LmN'
                }, {
                    'elapsed_time_ms':
                    1,
                    'losless_snippet':
                    True,
                    'output_snippet':
                    '[       OK ]\\n',
                    'status':
                    'SUCCESS',
                    'output_snippet_base64':
                    'WyAgICAgICBPSyBdCg=='
                }],
            }]
        }

        mock_module.GetFailedTestsInformation.return_value = ({}, {})

        ci_test_failure.CheckFirstKnownFailureForSwarmingTests(
            master_name, builder_name, build_number, failure_info)

        self.assertEqual(expected_failed_steps,
                         failure_info.failed_steps.ToSerializable())