def testRerunAnalysisWithAnalyzeFlakePipeline( self, mocked_analysis, mocked_pipeline, mocked_need_analysis, mocked_build_info, mock_dimensions, *_): buildbucket_id = 'id' mock_dimensions.return_value = ['os:Mac', 'cpu:x86'] start_commit_position = 1000 start_build_info = BuildInfo('m', 'b 1', 123) start_build_info.commit_position = start_commit_position start_build_info.chromium_revision = 'r1000' start_build_info.buildbucket_id = buildbucket_id mocked_build_info.return_value = start_build_info mocked_analysis.pipeline_status_path.return_value = 'status' mocked_analysis.key.urlsafe.return_value = 'urlsafe_key' mocked_need_analysis.return_value = (True, mocked_analysis) test = TestInfo('m', 'b 1', 123, 's', 't') manually_triggered = False flake = Flake.Create('chromium', 's', 't', 'l') analysis = initialize_flake_pipeline.ScheduleAnalysisIfNeeded( test, test, flake.key, bug_id=None, allow_new_analysis=True, manually_triggered=manually_triggered, force=True, queue_name=constants.DEFAULT_QUEUE) self.assertIsNotNone(analysis) self.assertEqual(buildbucket_id, analysis.build_id) self.assertEqual(buildbucket_id, analysis.original_build_id) analyze_flake_input = AnalyzeFlakeInput( analysis_urlsafe_key='urlsafe_key', analyze_commit_position_parameters=NextCommitPositionOutput( culprit_commit_id=None, next_commit_id=CommitID( commit_position=start_commit_position, revision=start_build_info.chromium_revision)), commit_position_range=IntRange(lower=None, upper=start_commit_position), dimensions=ListOfBasestring.FromSerializable( ['os:Mac', 'cpu:x86', 'pool:luci.chromium.findit']), manually_triggered=manually_triggered, rerun=True, retries=0, step_metadata=StepMetadata.FromSerializable({})) mocked_pipeline.assert_has_calls([ mock.call(analyze_flake_input), mock.call().start(queue_name=constants.DEFAULT_QUEUE) ])
def ExtractBuildInfoFromV2Build(master_name, builder_name, build_number, build): """Generates BuildInfo using bb v2 build info. This conversion is needed to keep Findit v1 running, will be deprecated in v2 (TODO: crbug.com/966982). Args: master_name (str): The name of the master. builder_name (str): The name of the builder. build_number (int): The build number. build (build_pb2.Build): All info about the build. Returns: (BuildInfo) """ build_info = BuildInfo(master_name, builder_name, build_number) input_properties = json_format.MessageToDict(build.input.properties) chromium_revision = build.input.gitiles_commit.id runtime = input_properties.get('$recipe_engine/runtime') or {} build_info.chromium_revision = chromium_revision repo_url = git.GetRepoUrlFromV2Build(build) build_info.commit_position = git.GetCommitPositionFromRevision( build.input.gitiles_commit.id, repo_url=repo_url) build_info.build_start_time = build.create_time.ToDatetime() build_info.build_end_time = build.end_time.ToDatetime() build_info.completed = bool(build_info.build_end_time) build_info.result = build.status build_info.parent_buildername = input_properties.get('parent_buildername') build_info.parent_mastername = input_properties.get('parent_mastername') build_info.buildbucket_id = str(build.id) build_info.buildbucket_bucket = build.builder.bucket build_info.is_luci = runtime.get('is_luci') build_info.blame_list = GetBlameListForV2Build(build) # Step categories: # 1. A step is passed if it is in SUCCESS status. # 2. A step is failed if it is in FAILURE status. # 3. A step is not passed if it is not in SUCCESS status. This category # includes steps in statuses: FAILURE, INFRA_FAILURE, CANCELED, etc. for step in build.steps: step_name = step.name step_status = step.status if step_status in [ common_pb2.STATUS_UNSPECIFIED, common_pb2.SCHEDULED, common_pb2.STARTED ]: continue if step_status != common_pb2.SUCCESS: build_info.not_passed_steps.append(step_name) if step_name == 'Failure reason': # 'Failure reason' is always red when the build breaks or has exception, # but it is not a failed step. continue if not step.logs: # Skip wrapping steps. continue if step_status == common_pb2.SUCCESS: build_info.passed_steps.append(step_name) elif step_status == common_pb2.FAILURE: build_info.failed_steps.append(step_name) return build_info