def test_core_filter_fails(self): self.filt_cls = core_filter.CoreFilter() filter_properties = {'instance_type': {'vcpus': 1}} self.flags(cpu_allocation_ratio=2) host = fakes.FakeHostState('host1', 'node1', {'vcpus_total': 4, 'vcpus_used': 8}) self.assertFalse(self.filt_cls.host_passes(host, filter_properties))
def test_core_filter_fails_safe(self): self.filt_cls = core_filter.CoreFilter() spec_obj = objects.RequestSpec(flavor=objects.Flavor(vcpus=1, extra_specs={}), image=IMAGE_PROPS) host = fakes.FakeHostState('host1', 'node1', {}) self.assertTrue(self.filt_cls.host_passes(host, spec_obj))
def test_core_filter_single_instance_overcommit_fails(self): self.filt_cls = core_filter.CoreFilter() spec_obj = objects.RequestSpec(flavor=objects.Flavor(vcpus=2)) host = fakes.FakeHostState('host1', 'node1', { 'vcpus_total': 1, 'vcpus_used': 0, 'cpu_allocation_ratio': 2 }) self.assertFalse(self.filt_cls.host_passes(host, spec_obj))
def test_core_filter_passes(self): self.filt_cls = core_filter.CoreFilter() spec_obj = objects.RequestSpec(flavor=objects.Flavor(vcpus=1)) host = fakes.FakeHostState('host1', 'node1', { 'vcpus_total': 4, 'vcpus_used': 7, 'cpu_allocation_ratio': 2 }) self.assertTrue(self.filt_cls.host_passes(host, spec_obj))
def test_core_filter_single_instance_overcommit_fails(self): self.filt_cls = core_filter.CoreFilter() filter_properties = {'instance_type': {'vcpus': 2}} host = fakes.FakeHostState('host1', 'node1', { 'vcpus_total': 1, 'vcpus_used': 0, 'cpu_allocation_ratio': 2 }) self.assertFalse(self.filt_cls.host_passes(host, filter_properties))
def test_core_filter_passes(self): self.filt_cls = core_filter.CoreFilter() filter_properties = {'instance_type': {'vcpus': 1}} host = fakes.FakeHostState('host1', 'node1', { 'vcpus_total': 4, 'vcpus_used': 7, 'cpu_allocation_ratio': 2 }) self.assertTrue(self.filt_cls.host_passes(host, filter_properties))
def test_core_filter_fails(self): self.filt_cls = core_filter.CoreFilter() spec_obj = objects.RequestSpec(flavor=objects.Flavor(vcpus=1, extra_specs={}), image=IMAGE_PROPS) cpu_allocation_ratio = 2 host = fakes.FakeHostState('host1', 'node1', {'vcpus_total': 4, 'vcpus_used': 8 / cpu_allocation_ratio, 'cpu_allocation_ratio': cpu_allocation_ratio}) self.assertFalse(self.filt_cls.host_passes(host, spec_obj))
def test_core_filter_fails_safe(self): self.filt_cls = core_filter.CoreFilter() filter_properties = {'instance_type': {'vcpus': 1}} host = fakes.FakeHostState('host1', 'node1', {}) self.assertTrue(self.filt_cls.host_passes(host, filter_properties))