def testCheckTestsRunStatuses(self, mocked_fn, _): build_info = BuildInfo(self.master_name, self.build_number, self.build_number) build_info.commit_position = 12345 build_info.chromium_revision = 'a1b2c3d4' mocked_fn.return_value = build_info analysis = MasterFlakeAnalysis.Create(self.master_name, self.builder_name, self.build_number, self.step_name, self.test_name) analysis.Save() task = FlakeSwarmingTask.Create(self.master_name, self.builder_name, self.build_number, self.step_name, self.test_name) task.put() call_params = ProcessFlakeSwarmingTaskResultPipeline._GetArgs( self.pipeline, self.master_name, self.builder_name, self.build_number, self.step_name, self.build_number, self.test_name, self.version_number) tests_statuses = ( ProcessFlakeSwarmingTaskResultPipeline._CheckTestsRunStatuses( self.pipeline, base_test._SAMPLE_FAILURE_LOG, *call_params)) self.assertEqual(base_test._EXPECTED_TESTS_STATUS, tests_statuses)
def testMonitorSwarmingTaskBuildException(self, mocked_fn, _): task_id = NO_TASK_EXCEPTION build_info = BuildInfo(self.master_name, self.build_number, self.build_number) build_info.commit_position = 12345 build_info.chromium_revision = 'a1b2c3d4' mocked_fn.return_value = build_info task = FlakeSwarmingTask.Create(self.master_name, self.builder_name, self.build_number, self.step_name, self.test_name) task.task_id = 'task_id' task.put() analysis = MasterFlakeAnalysis.Create(self.master_name, self.builder_name, self.build_number, self.step_name, self.test_name) analysis.Save() pipeline = ProcessFlakeSwarmingTaskResultPipeline() pipeline.start_test() pipeline.run(self.master_name, self.builder_name, self.build_number, self.step_name, task_id, self.build_number, self.test_name, 1) self.assertIsNone(task.task_id) self.assertEqual(analysis_status.SKIPPED, task.status) self.assertEqual(-1, analysis.data_points[-1].pass_rate) self.assertFalse(analysis.data_points[-1].has_valid_artifact)
def ExtractBuildInfo(master_name, builder_name, build_number, build_data): """Extracts and returns build information as an instance of BuildInfo.""" build_info = BuildInfo(master_name, builder_name, build_number) data_json = json.loads(build_data) chromium_revision = GetBuildProperty(data_json.get('properties', []), 'got_revision') commit_position_line = GetBuildProperty(data_json.get('properties', []), 'got_revision_cp') parent_buildername = GetBuildProperty(data_json.get('properties', []), 'parent_buildername') parent_mastername = GetBuildProperty(data_json.get('properties', []), 'parent_mastername') build_info.build_start_time = GetBuildStartTime(data_json) build_info.build_end_time = GetBuildEndTime(data_json) build_info.chromium_revision = chromium_revision build_info.commit_position = _GetCommitPosition(commit_position_line) build_info.completed = data_json.get('currentStep') is None build_info.result = GetBuildResult(data_json) build_info.parent_buildername = parent_buildername build_info.parent_mastername = parent_mastername changes = data_json.get('sourceStamp', {}).get('changes', []) for change in changes: if change['revision'] not in build_info.blame_list: build_info.blame_list.append(change['revision']) # Step categories: # 1. A step is passed if it is in SUCCESS or WARNINGS status. # 2. A step is failed if it is in FAILED status. # 3. A step is not passed if it is not in SUCCESS or WARNINGS status. This # category includes steps in statuses: FAILED, SKIPPED, EXCEPTION, RETRY, # CANCELLED, etc. steps = data_json.get('steps', []) for step_data in steps: step_name = step_data['name'] if not step_data.get('isFinished', False): # Skip steps that haven't started yet or are still running. continue step_result = GetStepResult(step_data) if step_result not in (SUCCESS, WARNINGS): build_info.not_passed_steps.append(step_name) step_logs = step_data.get('logs') if step_logs and 'preamble' == step_logs[0][0]: # Skip a annotating step like "steps" or "slave_steps", which wraps other # steps. A failed annotated step like "content_browsertests" will make # the annotating step like "steps" fail too. Such annotating steps have a # log with name "preamble". continue if step_result in (SUCCESS, WARNINGS): build_info.passed_steps.append(step_name) elif step_result == FAILURE: build_info.failed_steps.append(step_name) return build_info
def testUpdateSuspectedBuildUsingBuildInfo(self): analysis = MasterFlakeAnalysis.Create('m', 'b', 123, 's', 't') analysis.data_points = [ DataPoint.Create(commit_position=100, pass_rate=0.4), DataPoint.Create(commit_position=90, pass_rate=1.0), ] analysis.Save() lower_bound_build = BuildInfo('m', 'b', 122) lower_bound_build.commit_position = 90 upper_bound_build = BuildInfo('m', 'b', 123) upper_bound_build.commit_position = 100 analysis.UpdateSuspectedBuildUsingBuildInfo(lower_bound_build, upper_bound_build) self.assertEqual(123, analysis.suspected_flake_build_number)
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 testMonitorSwarmingTaskTimeOut(self, mocked_fn, _): build_info = BuildInfo(self.master_name, self.builder_name, self.build_number) build_info.commit_position = 12345 build_info.chromium_revision = 'a1b2c3d4' mocked_fn.return_value = build_info # Override swarming config settings to force a timeout. override_swarming_settings = {'task_timeout_hours': -1} self.UpdateUnitTestConfigSettings('swarming_settings', override_swarming_settings) task = FlakeSwarmingTask.Create(self.master_name, self.builder_name, self.build_number, self.step_name, self.test_name) task.task_id = 'task_id1' task.put() analysis = MasterFlakeAnalysis.Create(self.master_name, self.builder_name, self.build_number, self.step_name, self.test_name) analysis.Save() pipeline = ProcessFlakeSwarmingTaskResultPipeline(self.master_name, self.builder_name, self.build_number, self.step_name, self.build_number, self.test_name, 1, task_id='task_id1') pipeline.start_test() pipeline.run(self.master_name, self.builder_name, self.build_number, self.step_name, 'task_id1', self.build_number, self.test_name, 1) pipeline.callback(callback_params=pipeline.last_params) # Reload from ID to get all internal properties in sync. pipeline = ProcessFlakeSwarmingTaskResultPipeline.from_id( pipeline.pipeline_id) pipeline.finalized() step_name, task_info = pipeline.outputs.default.value self.assertEqual('abc_tests', task_info) self.assertEqual(self.step_name, step_name) task = FlakeSwarmingTask.Get(self.master_name, self.builder_name, self.build_number, self.step_name, self.test_name) self.assertEqual(analysis_status.ERROR, task.status) self.assertEqual({}, task.tests_statuses)
def testGetValidBuildSearchAscendingOutOfRange(self, mocked_get_build_info): master_name = 'm' builder_name = 'b' step_name = 's' invalid_build_100 = BuildInfo(master_name, builder_name, 100) invalid_build_101 = BuildInfo(master_name, builder_name, 101) valid_build_102 = BuildInfo(master_name, builder_name, 102) valid_build_102.commit_position = 1020 mocked_get_build_info.side_effect = [ invalid_build_100, invalid_build_101, valid_build_102, ] self.assertIsNone( step_util.GetValidBuild(master_name, builder_name, 100, step_name, True, 1))
def testGetValidBuildSearchDescending(self, mocked_get_build_info): master_name = 'm' builder_name = 'b' step_name = 's' invalid_build_100 = BuildInfo(master_name, builder_name, 100) invalid_build_99 = BuildInfo(master_name, builder_name, 99) valid_build_98 = BuildInfo(master_name, builder_name, 98) valid_build_98.commit_position = 980 mocked_get_build_info.side_effect = [ invalid_build_100, invalid_build_99, valid_build_98, ] self.assertEqual( valid_build_98, step_util.GetValidBuild(master_name, builder_name, 100, step_name, True, 2))
def testCheckTestsRunStatusesZeroBuildNumber(self, mocked_fn, _): build_info = BuildInfo(self.master_name, self.build_number, 0) build_info.commit_position = 12345 build_info.chromium_revision = 'a1b2c3d4' mocked_fn.return_value = build_info analysis = MasterFlakeAnalysis.Create(self.master_name, self.builder_name, 0, self.step_name, self.test_name) analysis.Save() task = FlakeSwarmingTask.Create(self.master_name, self.builder_name, 0, self.step_name, self.test_name) task.put() ProcessFlakeSwarmingTaskResultPipeline()._CheckTestsRunStatuses( {}, self.master_name, self.builder_name, 0, self.step_name, 0, self.test_name, 1) self.assertIsNone( analysis.data_points[0].previous_build_commit_position)
def testCheckTestsRunStatusesWhenTestDoesNotExist(self, mocked_fn, _): build_info = BuildInfo(self.master_name, self.builder_name, self.build_number) build_info.commit_position = 12345 build_info.chromium_revision = 'a1b2c3d4' mocked_fn.return_value = build_info test_name = 'TestSuite1.new_test' analysis = MasterFlakeAnalysis.Create(self.master_name, self.builder_name, self.build_number, self.step_name, test_name) analysis.Save() task = FlakeSwarmingTask.Create(self.master_name, self.builder_name, self.build_number, self.step_name, test_name) task.put() pipeline = ProcessFlakeSwarmingTaskResultPipeline() tests_statuses = pipeline._CheckTestsRunStatuses( base_test._SAMPLE_FAILURE_LOG, self.master_name, self.builder_name, self.build_number, self.step_name, self.build_number, test_name, self.version_number) self.assertEqual(base_test._EXPECTED_TESTS_STATUS, tests_statuses) task = FlakeSwarmingTask.Get(self.master_name, self.builder_name, self.build_number, self.step_name, test_name) self.assertEqual(0, task.tries) self.assertEqual(0, task.successes) analysis = MasterFlakeAnalysis.GetVersion(self.master_name, self.builder_name, self.build_number, self.step_name, test_name, self.version_number) self.assertTrue(analysis.data_points[-1].pass_rate < 0)
def testMonitorSwarmingTaskStepNotExist(self, mocked_fn, _): task_id = NO_TASK build_info = BuildInfo(self.master_name, self.build_number, self.build_number) build_info.commit_position = 12345 build_info.chromium_revision = 'a1b2c3d4' mocked_fn.return_value = build_info task = FlakeSwarmingTask.Create(self.master_name, self.builder_name, self.build_number, self.step_name, self.test_name) task.put() analysis = MasterFlakeAnalysis.Create(self.master_name, self.builder_name, self.build_number, self.step_name, self.test_name) analysis.Save() pipeline = ProcessFlakeSwarmingTaskResultPipeline( self.master_name, self.builder_name, self.build_number, self.step_name, task_id, self.build_number, self.test_name, 1) pipeline.start_test() pipeline.run(self.master_name, self.builder_name, self.build_number, self.step_name, task_id, self.build_number, self.test_name, 1) # Reload from ID to get all internal properties in sync. pipeline = ProcessFlakeSwarmingTaskResultPipeline.from_id( pipeline.pipeline_id) pipeline.finalized() _, step_name_no_platform = pipeline.outputs.default.value self.assertIsNone(task.task_id) self.assertEqual(analysis_status.SKIPPED, task.status) self.assertEqual(-1, analysis.data_points[-1].pass_rate) self.assertIsNone(step_name_no_platform)
def testNextCommitPositionPipelineContinueAnalysisFallbackToBuildInfo( self, mock_update, mock_heuristic, mock_targets, mock_bounding_builds, mock_next_commit, mock_reference_build): master_name = 'm' builder_name = 'b' build_number = 100 step_name = 's' test_name = 't' start_commit_position = 1000 expected_next_commit_id = CommitID(commit_position=990, revision='r990') mock_heuristic.return_value = False calculated_next_commit_id = CommitID(commit_position=999, revision='r999') mock_next_commit.return_value = (calculated_next_commit_id, None) target_name = 'browser_tests' step_metadata = StepMetadata( canonical_step_name=None, dimensions=None, full_step_name=None, isolate_target_name=target_name, patched=True, swarm_task_ids=None, waterfall_buildername=None, waterfall_mastername=None) reference_build = BuildInfo(master_name, builder_name, build_number) reference_build.commit_position = start_commit_position mock_reference_build.return_value = reference_build lower_bound_build = BuildInfo(master_name, builder_name, build_number - 1) lower_bound_build.commit_position = expected_next_commit_id.commit_position lower_bound_build.chromium_revision = expected_next_commit_id.revision upper_bound_build = BuildInfo(master_name, builder_name, build_number) upper_bound_build.commit_position = start_commit_position mock_bounding_builds.return_value = (lower_bound_build, upper_bound_build) mock_targets.side_effect = AssertionError() analysis = MasterFlakeAnalysis.Create(master_name, builder_name, build_number, step_name, test_name) analysis.data_points = [ DataPoint.Create(commit_position=start_commit_position) ] analysis.Save() next_commit_position_input = NextCommitPositionInput( analysis_urlsafe_key=analysis.key.urlsafe(), commit_position_range=IntRange(lower=None, upper=start_commit_position), step_metadata=step_metadata) pipeline_job = NextCommitPositionPipeline(next_commit_position_input) pipeline_job.start() self.execute_queued_tasks() mock_update.assert_called_once_with(lower_bound_build, upper_bound_build) pipeline_job = pipelines.pipeline.Pipeline.from_id(pipeline_job.pipeline_id) next_commit_position_output = pipeline_job.outputs.default.value self.assertFalse(pipeline_job.was_aborted) self.assertIsNone(next_commit_position_output['culprit_commit_id']) self.assertEqual(expected_next_commit_id.ToSerializable(), next_commit_position_output['next_commit_id'])
def testGetIsolateShaForCommitPositionPipelineFallbackBuildLevel( self, _, mocked_reference_build, mocked_url, mocked_build_info): master_name = 'm' builder_name = 'b' build_number = 100 step_name = 's' test_name = 't' requested_commit_position = 1000 requested_revision = 'r1000' expected_sha = 'sha1' build_url = 'url' isolate_target_name = 'browser_tests' step_metadata = StepMetadata(canonical_step_name=None, dimensions=None, full_step_name=None, isolate_target_name=isolate_target_name, patched=True, swarm_task_ids=None, waterfall_buildername=None, waterfall_mastername=None) mocked_url.return_value = build_url expected_output = GetIsolateShaOutput(isolate_sha=expected_sha, build_number=build_number, build_url=build_url, try_job_url=None) build = BuildInfo(master_name, builder_name, build_number) build.commit_position = requested_commit_position mocked_build_info.return_value = (None, build) mocked_reference_build.return_value = build analysis = MasterFlakeAnalysis.Create(master_name, builder_name, build_number, step_name, test_name) analysis.Save() get_build_sha_parameters = GetIsolateShaForBuildParameters( master_name=master_name, builder_name=builder_name, build_number=build_number, url=build_url, step_name=step_name) get_sha_input = GetIsolateShaForCommitPositionParameters( analysis_urlsafe_key=unicode(analysis.key.urlsafe()), commit_position=requested_commit_position, dimensions=ListOfBasestring.FromSerializable([]), revision=requested_revision, step_metadata=step_metadata, upper_bound_build_number=analysis.build_number) self.MockSynchronousPipeline(GetIsolateShaForBuildPipeline, get_build_sha_parameters, expected_output) pipeline_job = GetIsolateShaForCommitPositionPipeline(get_sha_input) pipeline_job.start() self.execute_queued_tasks() pipeline_job = pipelines.pipeline.Pipeline.from_id( pipeline_job.pipeline_id) pipeline_output = pipeline_job.outputs.default.value self.assertEqual(expected_output.ToSerializable(), pipeline_output)
def testGetIsolateShaForCommitPositionPipelineCommitLevel( self, mocked_reference_build, mocked_cache, mocked_dimensions): master_name = 'm' builder_name = 'b' build_number = 100 step_name = 's' test_name = 't' dimensions = ['dimensions'] requested_commit_position = 1000 containing_build_commit_position = 1001 containing_build_revision = 'r1001' requested_revision = 'r1000' expected_sha = 'sha1' cache_name = 'cache' try_job_id = 'try_job_id' url = 'url' isolate_target_name = 'browser_tests' step_metadata = StepMetadata(canonical_step_name=None, dimensions=None, full_step_name=None, isolate_target_name=isolate_target_name, patched=True, swarm_task_ids=None, waterfall_buildername=None, waterfall_mastername=None) build_id = 100 luci_name = 'chromium' bucket_name = 'ci' gitiles_host = 'chromium.googlesource.com' gitiles_project = 'chromium/src' gitiles_ref = 'refs/heads/master' gerrit_patch = '' isolated_hash = 'isolated_hash' isolated_target = IsolatedTarget.Create( build_id, luci_name, bucket_name, master_name, builder_name, gitiles_host, gitiles_project, gitiles_ref, gerrit_patch, isolate_target_name, isolated_hash, containing_build_commit_position, containing_build_revision) isolated_target.put() mocked_cache.return_value = cache_name mocked_dimensions.return_value = dimensions expected_isolated_tests = IsolatedTests() expected_isolated_tests[isolate_target_name] = expected_sha build = BuildInfo(master_name, builder_name, build_number) build.commit_position = containing_build_commit_position mocked_reference_build.return_value = build analysis = MasterFlakeAnalysis.Create(master_name, builder_name, build_number, step_name, test_name) analysis.Save() try_job = FlakeTryJob.Create(master_name, builder_name, step_name, test_name, requested_revision) try_job.put() run_flake_try_job_parameters = RunFlakeTryJobParameters( analysis_urlsafe_key=analysis.key.urlsafe(), revision=requested_revision, flake_cache_name=cache_name, isolate_target_name=isolate_target_name, dimensions=ListOfBasestring.FromSerializable(dimensions), urlsafe_try_job_key=try_job.key.urlsafe()) get_sha_input = GetIsolateShaForCommitPositionParameters( analysis_urlsafe_key=unicode(analysis.key.urlsafe()), commit_position=requested_commit_position, revision=requested_revision, dimensions=ListOfBasestring.FromSerializable(dimensions), step_metadata=step_metadata, upper_bound_build_number=analysis.build_number) expected_try_job_report = FlakeTryJobReport( isolated_tests=expected_isolated_tests, last_checked_out_revision=None, previously_cached_revision=None, previously_checked_out_revision=None, metadata=None) expected_try_job_result = FlakeTryJobResult( report=expected_try_job_report, url=url, try_job_id=try_job_id) get_isolate_sha_for_try_job_pipeline = GetIsolateShaForTryJobParameters( try_job_result=expected_try_job_result, step_name=step_name) self.MockAsynchronousPipeline(RunFlakeTryJobPipeline, run_flake_try_job_parameters, expected_try_job_report) self.MockSynchronousPipeline(GetIsolateShaForTryJobPipeline, get_isolate_sha_for_try_job_pipeline, expected_sha) pipeline_job = GetIsolateShaForCommitPositionPipeline(get_sha_input) pipeline_job.start() self.execute_queued_tasks()
def testGetIsolateShaForCommitPositionPipelineMatchingTarget( self, mocked_reference_build): master_name = 'm' builder_name = 'b' parent_mastername = 'p_m' parent_buildername = 'p_b' build_number = 100 build_id = 123 test_name = 't' requested_commit_position = 1000 requested_revision = 'r1000' expected_sha = 'sha1' build_url = 'url' luci_name = 'chromium' bucket_name = 'ci' gitiles_host = 'chromium.googlesource.com' gitiles_project = 'chromium/src' gitiles_ref = 'refs/heads/master' gerrit_patch = '' isolate_target_name = 'browser_tests' step_name = 's' isolated_hash = 'isolated_hash' expected_output = GetIsolateShaOutput(isolate_sha=expected_sha, build_number=None, build_url=build_url, try_job_url=None) analysis = MasterFlakeAnalysis.Create(master_name, builder_name, build_number, step_name, test_name) analysis.Save() build = BuildInfo(master_name, builder_name, build_number) build.commit_position = requested_commit_position build.parent_mastername = parent_mastername build.parent_buildername = parent_buildername mocked_reference_build.return_value = build isolated_target = IsolatedTarget.Create( build_id, luci_name, bucket_name, parent_mastername, parent_buildername, gitiles_host, gitiles_project, gitiles_ref, gerrit_patch, isolate_target_name, isolated_hash, requested_commit_position, requested_revision) isolated_target.put() step_metadata = StepMetadata(canonical_step_name=None, dimensions=None, full_step_name=None, isolate_target_name=isolate_target_name, patched=True, swarm_task_ids=None, waterfall_buildername=None, waterfall_mastername=None) get_sha_input = GetIsolateShaForCommitPositionParameters( analysis_urlsafe_key=unicode(analysis.key.urlsafe()), commit_position=requested_commit_position, dimensions=ListOfBasestring.FromSerializable([]), revision=requested_revision, step_metadata=step_metadata, upper_bound_build_number=analysis.build_number) get_sha_for_target_input = GetIsolateShaForTargetInput( isolated_target_urlsafe_key=isolated_target.key.urlsafe()) self.MockSynchronousPipeline(GetIsolateShaForTargetPipeline, get_sha_for_target_input, expected_output) pipeline_job = GetIsolateShaForCommitPositionPipeline(get_sha_input) pipeline_job.start() self.execute_queued_tasks() pipeline_job = pipelines.pipeline.Pipeline.from_id( pipeline_job.pipeline_id) pipeline_output = pipeline_job.outputs.default.value self.assertEqual(expected_output.ToSerializable(), pipeline_output)
def _MockedGetBuildInfo(master_name, builder_name, build_number): build = BuildInfo(master_name, builder_name, build_number) build.commit_position = (build_number + 1) * 10 build.result = (common_pb2.SUCCESS if build_number > 4 else common_pb2.INFRA_FAILURE) return build
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
def testNextCommitPositionPipelineContinueAnalysis( self, mock_reference_build, mock_heuristic, mock_next_commit, mock_bound_commits): master_name = 'm' builder_name = 'b' parent_mastername = 'p_m' parent_buildername = 'p_b' build_number = 100 build_id = 10000 step_name = 's' test_name = 't' start_commit_position = 1000 expected_next_commit_id = CommitID(commit_position=990, revision='r990') reference_build = BuildInfo(master_name, builder_name, build_number) reference_build.commit_position = start_commit_position reference_build.parent_mastername = parent_mastername reference_build.parent_buildername = parent_buildername mock_reference_build.return_value = reference_build mock_heuristic.return_value = False calculated_next_commit_id = CommitID(commit_position=999, revision='r999') mock_next_commit.return_value = (calculated_next_commit_id, None) target_name = 'browser_tests' step_metadata = StepMetadata( canonical_step_name=None, dimensions=None, full_step_name=None, isolate_target_name=target_name, patched=True, swarm_task_ids=None, waterfall_buildername=None, waterfall_mastername=None) luci_name = 'chromium' bucket_name = 'ci' gitiles_host = 'chromium.googlesource.com' gitiles_project = 'chromium/src' gitiles_ref = 'refs/heads/master' gerrit_patch = '' lower_bound_target = IsolatedTarget.Create( build_id - 1, luci_name, bucket_name, parent_mastername, parent_buildername, gitiles_host, gitiles_project, gitiles_ref, gerrit_patch, target_name, 'hash_1', expected_next_commit_id.commit_position, None) lower_bound_target.put() upper_bound_target = IsolatedTarget.Create( build_id, luci_name, bucket_name, parent_mastername, parent_buildername, gitiles_host, gitiles_project, gitiles_ref, gerrit_patch, target_name, 'hash_2', start_commit_position, None) upper_bound_target.put() mock_bound_commits.return_value = ( expected_next_commit_id, CommitID(commit_position=start_commit_position, revision='r1000')) analysis = MasterFlakeAnalysis.Create(master_name, builder_name, build_number, step_name, test_name) analysis.data_points = [ DataPoint.Create(commit_position=start_commit_position) ] analysis.Save() next_commit_position_input = NextCommitPositionInput( analysis_urlsafe_key=analysis.key.urlsafe(), commit_position_range=IntRange(lower=None, upper=start_commit_position), step_metadata=step_metadata) pipeline_job = NextCommitPositionPipeline(next_commit_position_input) pipeline_job.start() self.execute_queued_tasks() pipeline_job = pipelines.pipeline.Pipeline.from_id(pipeline_job.pipeline_id) next_commit_position_output = pipeline_job.outputs.default.value self.assertFalse(pipeline_job.was_aborted) self.assertIsNone(next_commit_position_output['culprit_commit_id']) self.assertEqual(expected_next_commit_id.ToSerializable(), next_commit_position_output['next_commit_id']) mock_bound_commits.assert_called_once_with( analysis.data_points, lower_bound_target, upper_bound_target)