Example #1
0
    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)
Example #2
0
    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))
Example #3
0
  def CallbackImpl(self, collect_consistent_failure_params, parameters):
    """Checks the WfSwarmingTask entities to get consistently failed tests."""
    steps = parameters['steps']

    callback_count = parameters['callback_count'] + 1
    try:
      consistent_failures = (
          test_swarming.GetConsistentFailuresWhenAllTasksComplete(
              collect_consistent_failure_params, steps))
      if not consistent_failures:
        self.SaveCallbackParameters({
            'steps': steps,
            'callback_count': callback_count
        })
        self.ScheduleCallbackTask(countdown=_GetCountDown(callback_count))
        return None
      return None, consistent_failures
    except exceptions.RetryException as e:  # Indicate an error to retry.
      return ('Error on updating swarming task result: %s' % e.error_message,
              None)
Example #4
0
    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)
Example #5
0
    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)