Example #1
0
 def test_filter_aggregate_num_instances_value_error(self, agg_mock):
     self.flags(max_instances_per_host=6)
     self.filt_cls = num_instances_filter.AggregateNumInstancesFilter()
     host = fakes.FakeHostState('host1', 'node1', {})
     filter_properties = {'context': mock.sentinel.ctx}
     agg_mock.return_value = set(['XXX'])
     self.assertTrue(self.filt_cls.host_passes(host, filter_properties))
     agg_mock.assert_called_once_with(host, 'max_instances_per_host')
Example #2
0
 def test_filter_aggregate_num_instances_value_error(self, agg_mock):
     self.flags(max_instances_per_host=6, group='filter_scheduler')
     self.filt_cls = num_instances_filter.AggregateNumInstancesFilter()
     host = fakes.FakeHostState('host1', 'node1', {})
     spec_obj = objects.RequestSpec(context=mock.sentinel.ctx)
     agg_mock.return_value = set(['XXX'])
     self.assertTrue(self.filt_cls.host_passes(host, spec_obj))
     agg_mock.assert_called_once_with(host, 'max_instances_per_host')
Example #3
0
 def test_filter_aggregate_num_instances_value(self, agg_mock):
     self.flags(max_instances_per_host=4)
     self.filt_cls = num_instances_filter.AggregateNumInstancesFilter()
     host = fakes.FakeHostState('host1', 'node1', {'num_instances': 5})
     filter_properties = {'context': mock.sentinel.ctx}
     agg_mock.return_value = set([])
     # No aggregate defined for that host.
     self.assertFalse(self.filt_cls.host_passes(host, filter_properties))
     agg_mock.assert_called_once_with(host, 'max_instances_per_host')
     agg_mock.return_value = set(['6'])
     # Aggregate defined for that host.
     self.assertTrue(self.filt_cls.host_passes(host, filter_properties))