Cells: Add filtering and weight support
This adds filtering and weighing support to the cells scheduler. Adds the following config options to the 'cells' group: scheduler_filter_classes -- list of filter classes scheduler_weight_classes -- list of weight classes Adds a couple of weighing modules as defaults (which removes the random cell selection): ram_by_instance_type: Select cells with the most capacity for the instance type being requested. weight_offset: Allows modifying the DB to weight a particular cell (useful for disabling a cell) Adds a filter class (TargetCellFilter) that allows specifying a scheduler hint to direct a build to a particular cell if you're an admin. DocImpact Implements blueprint cells-filter-scheduler Change-Id: I027c5734e3d6134127fcd4dd28b8ff39047416dc
This commit is contained in:
@@ -123,3 +123,36 @@ class FiltersTestCase(test.TestCase):
|
||||
filter_objs_initial,
|
||||
filter_properties)
|
||||
self.assertEqual(filter_objs_last, result)
|
||||
|
||||
def test_get_filtered_objects_none_response(self):
|
||||
filter_objs_initial = ['initial', 'filter1', 'objects1']
|
||||
filter_properties = 'fake_filter_properties'
|
||||
|
||||
def _fake_base_loader_init(*args, **kwargs):
|
||||
pass
|
||||
|
||||
self.stubs.Set(loadables.BaseLoader, '__init__',
|
||||
_fake_base_loader_init)
|
||||
|
||||
filt1_mock = self.mox.CreateMock(Filter1)
|
||||
filt2_mock = self.mox.CreateMock(Filter2)
|
||||
|
||||
self.mox.StubOutWithMock(sys.modules[__name__], 'Filter1',
|
||||
use_mock_anything=True)
|
||||
self.mox.StubOutWithMock(filt1_mock, 'filter_all')
|
||||
# Shouldn't be called.
|
||||
self.mox.StubOutWithMock(sys.modules[__name__], 'Filter2',
|
||||
use_mock_anything=True)
|
||||
self.mox.StubOutWithMock(filt2_mock, 'filter_all')
|
||||
|
||||
Filter1().AndReturn(filt1_mock)
|
||||
filt1_mock.filter_all(filter_objs_initial,
|
||||
filter_properties).AndReturn(None)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
filter_handler = filters.BaseFilterHandler(filters.BaseFilter)
|
||||
filter_classes = [Filter1, Filter2]
|
||||
result = filter_handler.get_filtered_objects(filter_classes,
|
||||
filter_objs_initial,
|
||||
filter_properties)
|
||||
self.assertEqual(None, result)
|
||||
|
||||
Reference in New Issue
Block a user