def setUp(self): super(CollectSwarmingTaskResultsPipelineTest, self).setUp() self.pipeline_input = CollectSwarmingTaskResultsInputs( build_key=BuildKey(master_name='m', builder_name='b', build_number=41), build_completed=True)
def testCollectSwarmingTaskResultsError(self, mock_monitoring, *_): master_name = 'm' builder_name = 'b' build_number = 15 params = CollectSwarmingTaskResultsInputs(build_key=BuildKey( master_name=master_name, builder_name=builder_name, build_number=build_number), build_completed=True) steps = ['step1', 'step2'] task1 = WfSwarmingTask.Create(master_name, builder_name, build_number, 'step1') task1.status = analysis_status.ERROR task1.put() task2 = WfSwarmingTask.Create(master_name, builder_name, build_number, 'step2') task2.status = analysis_status.COMPLETED task2.tests_statuses = { 'TestSuite1.test1': { 'total_run': 2, 'SUCCESS': 2 }, 'TestSuite1.test2': { 'total_run': 4, 'SUCCESS': 2, 'FAILURE': 2 }, 'TestSuite1.test3': { 'total_run': 6, 'FAILURE': 6 }, 'TestSuite1.test4': { 'total_run': 6, 'SKIPPED': 6 }, 'TestSuite1.test5': { 'total_run': 6, 'UNKNOWN': 6 } } task2.put() expected_result_json = { 'consistent_failures': { 'step2': ['TestSuite1.test3', 'TestSuite1.test4'] } } self.assertEqual( CollectSwarmingTaskResultsOutputs.FromSerializable( expected_result_json), test_swarming.GetConsistentFailuresWhenAllTasksComplete( params, steps)) mock_monitoring.assert_called_once_with('step2', 'step2', 'skip', 1)
def testGetStepsToCollectSwarmingTaskResultsBuildNotComplete( self, mock_fn): master_name = 'm' builder_name = 'b' build_number = 14 params = CollectSwarmingTaskResultsInputs(build_key=BuildKey( master_name=master_name, builder_name=builder_name, build_number=build_number), build_completed=False) self.assertEqual( [], test_swarming.GetStepsToCollectSwarmingTaskResults(params)) self.assertFalse(mock_fn.called)
def testGetStepsToCollectSwarmingTaskResults(self, mock_fn): master_name = 'm' builder_name = 'b' build_number = 13 params = CollectSwarmingTaskResultsInputs(build_key=BuildKey( master_name=master_name, builder_name=builder_name, build_number=build_number), build_completed=True) self.assertEqual( ['step'], test_swarming.GetStepsToCollectSwarmingTaskResults(params)) mock_fn.assert_called_once_with(master_name, builder_name, build_number)
def testCollectSwarmingTaskResultsNoResult(self, _): master_name = 'm' builder_name = 'b' build_number = 16 params = CollectSwarmingTaskResultsInputs(build_key=BuildKey( master_name=master_name, builder_name=builder_name, build_number=build_number), build_completed=True) steps = ['step1'] task1 = WfSwarmingTask.Create(master_name, builder_name, build_number, 'step1') task1.status = analysis_status.COMPLETED task1.put() self.assertEqual( CollectSwarmingTaskResultsOutputs.FromSerializable({}), test_swarming.GetConsistentFailuresWhenAllTasksComplete( params, steps))
def testCollectSwarmingTaskResultsAllFlaky(self, mock_monitoring, mock_update_analysis, mock_save_flakes, _): master_name = 'm' builder_name = 'b' build_number = 17 params = CollectSwarmingTaskResultsInputs(build_key=BuildKey( master_name=master_name, builder_name=builder_name, build_number=build_number), build_completed=True) steps = ['step2'] task2 = WfSwarmingTask.Create(master_name, builder_name, build_number, 'step2') task2.status = analysis_status.COMPLETED task2.tests_statuses = { 'TestSuite1.test1': { 'total_run': 2, 'SUCCESS': 2 }, 'TestSuite1.test2': { 'total_run': 4, 'SUCCESS': 2, 'FAILURE': 2 }, } task2.put() self.assertEqual( CollectSwarmingTaskResultsOutputs.FromSerializable({}), test_swarming.GetConsistentFailuresWhenAllTasksComplete( params, steps)) flake_tests = {'step2': ['TestSuite1.test2']} mock_update_analysis.assert_called_once_with(master_name, builder_name, build_number, flake_tests) mock_monitoring.assert_called_once_with('step2', 'step2', 'skip', 1) mock_save_flakes.assert_called_once_with(master_name, builder_name, build_number, flake_tests)
def testCollectSwarmingTaskResultsTaskRunning(self, mock_monitoring, _): master_name = 'm' builder_name = 'b' build_number = 15 params = CollectSwarmingTaskResultsInputs(build_key=BuildKey( master_name=master_name, builder_name=builder_name, build_number=build_number), build_completed=True) steps = ['step1', 'step2'] task1 = WfSwarmingTask.Create(master_name, builder_name, build_number, 'step2') task1.status = analysis_status.COMPLETED task1.put() WfSwarmingTask.Create(master_name, builder_name, build_number, 'step1').put() self.assertIsNone( test_swarming.GetConsistentFailuresWhenAllTasksComplete( params, steps)) self.assertFalse(mock_monitoring.called)
def testTimeoutSeconds(self): p = CollectSwarmingTaskResultsPipeline( CollectSwarmingTaskResultsInputs.FromSerializable({})) self.assertEqual(82800, p.TimeoutSeconds())
def testBuildFailurePipelineFlow(self): master_name = 'm' builder_name = 'b' build_number = 124 analysis = WfAnalysis.Create(master_name, builder_name, build_number) analysis.put() current_failure_info = {'failed_steps': {'a_test': {'first_failure': 124}}} self._SetupAnalysis(master_name, builder_name, build_number) heuristic_params = TestHeuristicAnalysisParameters.FromSerializable({ 'failure_info': current_failure_info, 'build_completed': True }) heuristic_output = TestHeuristicAnalysisOutput.FromSerializable({}) self.MockSynchronousPipeline( analyze_test_failure_pipeline.HeuristicAnalysisForTestPipeline, heuristic_params, heuristic_output) build_key = BuildKey( master_name=master_name, builder_name=builder_name, build_number=build_number) run_tasks_inputs = RunSwarmingTasksInput( build_key=build_key, heuristic_result=heuristic_output, force=False) self.MockGeneratorPipeline( analyze_test_failure_pipeline.RunSwarmingTasksPipeline, run_tasks_inputs, None) collect_task_results_inputs = CollectSwarmingTaskResultsInputs( build_key=build_key, build_completed=True) consistent_failures = CollectSwarmingTaskResultsOutputs.FromSerializable({}) self.MockAsynchronousPipeline( analyze_test_failure_pipeline.CollectSwarmingTaskResultsPipeline, collect_task_results_inputs, consistent_failures) start_waterfall_try_job_inputs = StartTestTryJobInputs( build_key=build_key, build_completed=True, force=False, heuristic_result=heuristic_output, consistent_failures=consistent_failures, ) self.MockGeneratorPipeline( analyze_test_failure_pipeline.StartTestTryJobPipeline, start_waterfall_try_job_inputs, None) self.MockGeneratorPipeline( analyze_test_failure_pipeline.TriggerFlakeAnalysesPipeline, build_key, None) report_event_input = report_event_pipeline.ReportEventInput( analysis_urlsafe_key=analysis.key.urlsafe()) self.MockGeneratorPipeline( report_event_pipeline.ReportAnalysisEventPipeline, report_event_input, None) pipeline_input = AnalyzeTestFailureInput( build_key=BuildKey( master_name=master_name, builder_name=builder_name, build_number=build_number), current_failure_info=TestFailureInfo.FromSerializable( current_failure_info), build_completed=True, force=False) root_pipeline = AnalyzeTestFailurePipeline(pipeline_input) root_pipeline.start(queue_name=constants.DEFAULT_QUEUE) self.execute_queued_tasks() analysis = WfAnalysis.Get(master_name, builder_name, build_number) self.assertEqual(analysis_status.RUNNING, analysis.status)