Exemplo n.º 1
0
 def test_error_payload_multiple_instances(self):
     instances = ['instance_uuid1', 'instance_uuid2']
     aggregates = ['aggregate']
     sched_payload = fakes.make_scheduling_payload(instances, aggregates)
     self.endpoint.error(None, None, None, sched_payload, None)
     event = events.SchedulingEvent.get_by_instance_uuid('instance_uuid1')
     self.assertEqual(2, event.count_scheduling_instances(handled=False))
Exemplo n.º 2
0
    def test_trigger_reaper_multiple_instances(self):
        instances = ["instance_uuid1", "instance_uuid2"]
        new_state = "pending"
        old_state = "building"
        image_uuid = "image_uuid"
        flavor_uuid = "flavor_uuid"
        request_id = 123
        aggs = ['agg1', 'agg2']
        e_type = ra.ActionEvent.BUILD_REQUEST

        scheduling_payload = fakes.make_scheduling_payload(instances,
                                                           req_id=request_id,
                                                           aggregates=aggs)
        scheduling_event = events.SchedulingEvent.from_payload(
            scheduling_payload)
        payload = fakes.make_state_update_payload(instances, new_state,
                                                  old_state, image_uuid,
                                                  flavor_uuid)
        scheduling_event.create()
        flavor = payload['nova_object.data']['flavor']['nova_object.data']

        self.endpoint.trigger_reaper(instances[0], flavor, image_uuid, e_type)
        self.assertTrue(not self.endpoint.job_manager.post_job.called)

        self.endpoint.trigger_reaper(instances[1], flavor, image_uuid, e_type)
        self.endpoint.job_manager.post_job.assert_called_once()
        self.assertEqual(0, scheduling_event.count_scheduling_instances())
Exemplo n.º 3
0
 def test_scheduling_event_no_aggregates(self, mock_aggs):
     mock_aggs.return_value = []
     instances = ["instance_uuid1"]
     payload = fakes.make_scheduling_payload(instances)
     event = events.SchedulingEvent.from_payload(payload)
     self.assertEqual(instances, event.instance_uuids)
     self.assertEqual(0, len(event.aggregates))
     self.assertTrue(not event.multiple_instances)
Exemplo n.º 4
0
 def test_scheduling_event(self):
     instances = ["instance_uuid1", "instance_uuid2"]
     aggs = ["agg1", "agg2"]
     request_id = 123
     project = "project"
     payload = fakes.make_scheduling_payload(instances,
                                             aggregates=aggs,
                                             req_id=request_id,
                                             project=project)
     event = events.SchedulingEvent.from_payload(payload)
     self.assertEqual(instances, event.instance_uuids)
     self.assertEqual(aggs, event.aggregates)
     self.assertEqual(request_id, event.request_id)
     self.assertEqual(project, event.project_id)
     self.assertTrue(event.multiple_instances)
Exemplo n.º 5
0
    def test_trigger_reaper_failure(self, mock_reset, mock_list):
        instance = "instance_uuid"
        new_state = "pending"
        old_state = "building"
        image_uuid = "image_uuid"
        flavor_uuid = "flavor_uuid"
        event_type = ra.ActionEvent.BUILD_REQUEST

        scheduling_payload = fakes.make_scheduling_payload([instance])
        scheduling_event = events.SchedulingEvent.from_payload(
            scheduling_payload)
        scheduling_event.create()
        payload = fakes.make_state_update_payload(instance, new_state,
                                                  old_state, image_uuid,
                                                  flavor_uuid)
        flavor = payload['nova_object.data']['flavor']['nova_object.data']

        self.endpoint.job_manager.post_job.side_effect = \
            exception.ReaperException()
        self.endpoint.trigger_reaper(instance, flavor, image_uuid, event_type)
        mock_reset.assert_called_once_with(instance)
        self.assertEqual(0, scheduling_event.count_scheduling_instances())
Exemplo n.º 6
0
    def test_trigger_reaper(self):
        instance = "instance_uuid"
        new_state = "pending"
        old_state = "building"
        image_uuid = "image_uuid"
        flavor_uuid = "flavor_uuid"
        aggs = ['agg1']
        e_type = ra.ActionEvent.BUILD_REQUEST

        scheduling_payload = fakes.make_scheduling_payload([instance],
                                                           aggregates=aggs)
        scheduling_event = events.SchedulingEvent.from_payload(
            scheduling_payload)
        scheduling_event.create()
        payload = fakes.make_state_update_payload(instance, new_state,
                                                  old_state, image_uuid,
                                                  flavor_uuid)
        flavor = payload['nova_object.data']['flavor']['nova_object.data']

        self.endpoint.trigger_reaper(instance, flavor, image_uuid, e_type)
        self.assertTrue(self.endpoint.job_manager.post_job.called)
        self.assertEqual(0, scheduling_event.count_scheduling_instances())
Exemplo n.º 7
0
 def test_error_payload(self):
     instances = ['instance_uuid']
     aggregates = ['aggregate']
     sched_payload = fakes.make_scheduling_payload(instances, aggregates)
     self.endpoint.error(None, None, None, sched_payload, None)
Exemplo n.º 8
0
 def _get_noop_payload(self):
     return fakes.make_scheduling_payload([], None)