Example #1
0
 def test_get_group_details_with_no_affinity_filters(self):
     self.flags(scheduler_default_filters=['fake'])
     scheduler_utils._SUPPORTS_ANTI_AFFINITY = None
     scheduler_utils._SUPPORTS_AFFINITY = None
     group_info = scheduler_utils._get_group_details(self.context,
                                                     ['fake-uuid'])
     self.assertIsNone(group_info)
Example #2
0
    def _get_group_details(self, group, policy=None):
        group_hosts = ['hostB']
        spec = objects.RequestSpec(instance_uuid=uuids.instance)
        spec.num_instances = 1
        spec.min_num_instances = 1

        with test.nested(
                mock.patch.object(objects.InstanceGroup,
                                  'get_by_instance_uuid',
                                  return_value=group),
                mock.patch.object(objects.InstanceGroup,
                                  'get_hosts',
                                  return_value=['hostA']),
                mock.patch.object(objects.InstanceGroup,
                                  'get_members_launched',
                                  return_value=['FakE-uuid']),
        ) as (get_group, get_hosts, get_members):
            scheduler_utils._SUPPORTS_ANTI_AFFINITY = None
            scheduler_utils._SUPPORTS_AFFINITY = None
            group_info = scheduler_utils._get_group_details(
                self.context, 'fake_uuid', spec, user_group_hosts=group_hosts)
            self.assertEqual(
                (set(['hostA', 'hostB']), [policy], group.members, {
                    "wrs-sg:best_effort": "true",
                    "wrs-sg:group_size": "2",
                    "wrs-sg:group_exceed": "0"
                }, 'pele'), group_info)
Example #3
0
    def _get_group_details(self, group, policy=None):
        group_hosts = ['hostB']

        with test.nested(
            mock.patch.object(objects.InstanceGroup, 'get_by_instance_uuid',
                              return_value=group),
            mock.patch.object(objects.InstanceGroup, 'get_hosts',
                              return_value=['hostA']),
        ) as (get_group, get_hosts):
            scheduler_utils._SUPPORTS_ANTI_AFFINITY = None
            scheduler_utils._SUPPORTS_AFFINITY = None
            group_info = scheduler_utils._get_group_details(
                self.context, 'fake_uuid', group_hosts)
            self.assertEqual(
                (set(['hostA', 'hostB']), [policy], group.members),
                group_info)
Example #4
0
 def test_get_group_details_with_no_instance_uuid(self):
     group_info = scheduler_utils._get_group_details(self.context, None)
     self.assertIsNone(group_info)