Beispiel #1
0
    def testOnSwarmingTaskTimeout(self, mock_mon, _):
        master_name = 'm'
        builder_name = 'b'
        build_number = 16
        step_name = 's'
        swarming_task = WfSwarmingTask.Create(master_name, builder_name,
                                              build_number, step_name)
        swarming_task.put()
        parameters = RunSwarmingTaskParameters(build_key=BuildKey(
            master_name=master_name,
            builder_name=builder_name,
            build_number=build_number),
                                               step_name=step_name,
                                               tests=['tests'])
        test_swarming.OnSwarmingTaskTimeout(parameters, 'task_id')

        swarming_task = WfSwarmingTask.Get(master_name, builder_name,
                                           build_number, step_name)
        self.assertEqual(analysis_status.ERROR, swarming_task.status)
        self.assertEqual(
            {
                'code': swarming_task_error.RUNNER_TIMEOUT,
                'message': 'Runner to run swarming task timed out'
            }, swarming_task.error)
        mock_mon.assert_called_once_with(master_name, builder_name,
                                         build_number, step_name,
                                         analysis_status.ERROR,
                                         analysis_approach_type.SWARMING)
Beispiel #2
0
    def testTriggerSwarmingTask(self, mock_ref, mock_create, mock_trigger, _):
        runner_id = 'runner_id'
        master_name = 'm'
        builder_name = 'b'
        build_number = 6
        step_name = 's'
        tests = ['test']
        WfSwarmingTask.Create(master_name, builder_name, build_number,
                              step_name).put()
        parameters = RunSwarmingTaskParameters(build_key=BuildKey(
            master_name=master_name,
            builder_name=builder_name,
            build_number=build_number),
                                               step_name=step_name,
                                               tests=tests)
        new_request = SwarmingTaskRequest.FromSerializable(
            _SAMPLE_REQUEST_JSON)
        mock_create.return_value = new_request
        task_id = test_swarming.TriggerSwarmingTask(parameters, runner_id)
        self.assertEqual('new_task_id', task_id)

        mock_ref.assert_called_once_with(master_name, builder_name,
                                         build_number, step_name, None)
        mock_create.assert_called_once_with('runner_id', 'task_id',
                                            'ref_request', master_name,
                                            builder_name, step_name, tests, 10)
        mock_trigger.assert_called_once_with('chromium-swarm.appspot.com',
                                             new_request, None)
Beispiel #3
0
    def testRunSwarmingTasksPipeline(self, mock_fn):
        master_name = 'm'
        builder_name = 'b'
        build_number = 31

        build_key = {
            'master_name': master_name,
            'builder_name': builder_name,
            'build_number': build_number
        }
        wrapper_params_json = {
            'build_key': build_key,
            'heuristic_result': {},
            'force': False
        }

        sub_params1_json = {
            'build_key': build_key,
            'step_name': 'step1',
            'tests': ['test1']
        }
        sub_params1 = RunSwarmingTaskParameters.FromSerializable(
            sub_params1_json)
        self.MockAsynchronousPipeline(RunTestSwarmingTaskPipeline, sub_params1,
                                      True)

        wrapper_params = RunSwarmingTasksInput.FromSerializable(
            wrapper_params_json)
        p = RunSwarmingTasksPipeline(wrapper_params)
        p.start(queue_name=constants.DEFAULT_QUEUE)
        self.execute_queued_tasks()
        mock_fn.assert_called_once_with(wrapper_params)
Beispiel #4
0
 def RunImpl(self, run_swarming_tasks_input):
     steps = test_swarming.GetFirstTimeTestFailuresToRunSwarmingTasks(
         run_swarming_tasks_input)
     for step_name, base_tests in steps.iteritems():
         run_swarming_task_params = RunSwarmingTaskParameters(
             build_key=run_swarming_tasks_input.build_key,
             step_name=step_name,
             tests=base_tests)
         yield RunTestSwarmingTaskPipeline(run_swarming_task_params)
Beispiel #5
0
    def testOnSwarmingTaskStateChangedError(self, *_):
        master_name = 'm'
        builder_name = 'b'
        build_number = 10
        step_name = 's'
        WfSwarmingTask.Create(master_name, builder_name, build_number,
                              step_name).put()
        parameters = RunSwarmingTaskParameters(build_key=BuildKey(
            master_name=master_name,
            builder_name=builder_name,
            build_number=build_number),
                                               step_name=step_name,
                                               tests=['test'])

        self.assertFalse(
            test_swarming.OnSwarmingTaskStateChanged(parameters, 'task_id'))
Beispiel #6
0
    def testOnSwarmingTaskStateChangedNoTaskData(self, mock_error, _):
        master_name = 'm'
        builder_name = 'b'
        build_number = 11
        step_name = 's'
        task = WfSwarmingTask.Create(master_name, builder_name, build_number,
                                     step_name)
        task.put()
        parameters = RunSwarmingTaskParameters(build_key=BuildKey(
            master_name=master_name,
            builder_name=builder_name,
            build_number=build_number),
                                               step_name=step_name,
                                               tests=['test'])

        result = test_swarming.OnSwarmingTaskStateChanged(
            parameters, 'task_id')
        self.assertIsNone(result)
        mock_error.assert_called_once_with(master_name, builder_name,
                                           build_number, step_name, 'error',
                                           False)
Beispiel #7
0
    def testOnSwarmingTaskStateChangedCompleted(self, mock_complete, *_):
        master_name = 'm'
        builder_name = 'b'
        build_number = 8
        step_name = 's'
        task = WfSwarmingTask.Create(master_name, builder_name, build_number,
                                     step_name)
        task.put()
        parameters = RunSwarmingTaskParameters(build_key=BuildKey(
            master_name=master_name,
            builder_name=builder_name,
            build_number=build_number),
                                               step_name=step_name,
                                               tests=['test'])

        result = test_swarming.OnSwarmingTaskStateChanged(
            parameters, 'task_id')
        self.assertTrue(result)
        mock_complete.assert_called_once_with(
            master_name, builder_name, build_number, step_name,
            {'state': constants.STATE_COMPLETED}, 'content')
Beispiel #8
0
    def testOnSwarmingTaskStateChangedRunning(self, mock_update, _):
        master_name = 'm'
        builder_name = 'b'
        build_number = 9
        step_name = 's'
        task = WfSwarmingTask.Create(master_name, builder_name, build_number,
                                     step_name)
        task.put()
        parameters = RunSwarmingTaskParameters(build_key=BuildKey(
            master_name=master_name,
            builder_name=builder_name,
            build_number=build_number),
                                               step_name=step_name,
                                               tests=['test'])

        result = test_swarming.OnSwarmingTaskStateChanged(
            parameters, 'task_id')
        self.assertIsNone(result)
        mock_update.assert_called_once_with(master_name,
                                            builder_name,
                                            build_number,
                                            step_name,
                                            status=analysis_status.RUNNING)
 def setUp(self):
     super(RunTestSwarmingTaskPipelineTest, self).setUp()
     self.pipeline_input = RunSwarmingTaskParameters(build_key=BuildKey(
         master_name='m', builder_name='b', build_number=21),
                                                     step_name='s',
                                                     tests=['test'])