def testPullChangelogs(self, mock_fn): change_log_rev1_dict = { 'author': { 'name': '*****@*****.**', 'email': '*****@*****.**', 'time': datetime.strptime('Wed Jun 11 19:35:32 2014', '%a %b %d %H:%M:%S %Y'), }, 'committer': { 'name': '*****@*****.**', 'email': '*****@*****.**', 'time': datetime.strptime('Wed Jun 11 19:35:32 2014', '%a %b %d %H:%M:%S %Y'), }, 'message': 'Cr-Commit-Position: refs/heads/master@{#175976}', 'commit_position': 175976, 'touched_files': [{ 'new_path': 'added_file.js', 'change_type': 'add', 'old_path': '/dev/null' }], 'commit_url': 'https://chromium.googlesource.com/chromium/src.git/+log/rev0', 'code_review_url': None, 'revision': 'rev1', 'reverted_revision': None, 'review_server_host': None, 'review_change_id': None, } change_log_rev1 = ChangeLog.FromDict(change_log_rev1_dict) mock_fn.return_value = [change_log_rev1] expected_change_logs = {'rev1': change_log_rev1} change_logs = git.PullChangeLogs('rev0', 'rev1') self.assertEqual(expected_change_logs, change_logs)
def GetSuspectedCulprits(self, project_api, context, build, first_failures_in_current_build): failure_info = project_api.GetTestFailureInfo( context, build, first_failures_in_current_build) # Projects that support heuristic analysis must implement GetFailureInfo if not failure_info: return None signals = project_api.ExtractSignalsForTestFailure(failure_info) change_logs = git.PullChangeLogs( first_failures_in_current_build['last_passed_build']['commit_id'], context.gitiles_id) deps_info = deps.ExtractDepsInfo(failure_info, change_logs) return project_api.HeuristicAnalysisForTest(failure_info, change_logs, deps_info, signals)
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))
def testPullChangelogsNoStartRevision(self): self.assertEqual({}, git.PullChangeLogs(None, 'rev1'))