diff options
author | Sean Dague <sean@dague.net> | 2014-11-07 14:27:03 +0100 |
---|---|---|
committer | Sean Dague <sean@dague.net> | 2014-11-12 15:31:08 -0500 |
commit | 89cd6a0c493e26b5a9e017c99d731464292abbaf (patch) | |
tree | c2bf790d1684cd539b820247113492495123a163 /nova/tests/scheduler/filters/test_ram_filters.py | |
parent | 5c8bbaafef590e4d346a03051a0ba55c8be26c5c (diff) | |
download | nova-89cd6a0c493e26b5a9e017c99d731464292abbaf.tar.gz |
move all tests to nova/tests/unit
As part of the split of functional and unit tests we need to isolate
the unit tests into a separate directory for having multiple test
targets in a sane way.
Part of bp:functional-tests-for-nova
Change-Id: Id42ba373c1bda6a312b673ab2b489ca56da8c628
Diffstat (limited to 'nova/tests/scheduler/filters/test_ram_filters.py')
-rw-r--r-- | nova/tests/scheduler/filters/test_ram_filters.py | 89 |
1 files changed, 0 insertions, 89 deletions
diff --git a/nova/tests/scheduler/filters/test_ram_filters.py b/nova/tests/scheduler/filters/test_ram_filters.py deleted file mode 100644 index 880cdac296..0000000000 --- a/nova/tests/scheduler/filters/test_ram_filters.py +++ /dev/null @@ -1,89 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock - -from nova.scheduler.filters import ram_filter -from nova import test -from nova.tests.scheduler import fakes - - -class TestRamFilter(test.NoDBTestCase): - - def setUp(self): - super(TestRamFilter, self).setUp() - self.filt_cls = ram_filter.RamFilter() - - def test_ram_filter_fails_on_memory(self): - ram_filter.RamFilter.ram_allocation_ratio = 1.0 - filter_properties = {'instance_type': {'memory_mb': 1024}} - host = fakes.FakeHostState('host1', 'node1', - {'free_ram_mb': 1023, 'total_usable_ram_mb': 1024}) - self.assertFalse(self.filt_cls.host_passes(host, filter_properties)) - - def test_ram_filter_passes(self): - ram_filter.RamFilter.ram_allocation_ratio = 1.0 - filter_properties = {'instance_type': {'memory_mb': 1024}} - host = fakes.FakeHostState('host1', 'node1', - {'free_ram_mb': 1024, 'total_usable_ram_mb': 1024}) - self.assertTrue(self.filt_cls.host_passes(host, filter_properties)) - - def test_ram_filter_oversubscribe(self): - ram_filter.RamFilter.ram_allocation_ratio = 2.0 - filter_properties = {'instance_type': {'memory_mb': 1024}} - host = fakes.FakeHostState('host1', 'node1', - {'free_ram_mb': -1024, 'total_usable_ram_mb': 2048}) - self.assertTrue(self.filt_cls.host_passes(host, filter_properties)) - self.assertEqual(2048 * 2.0, host.limits['memory_mb']) - - -@mock.patch('nova.scheduler.filters.utils.aggregate_values_from_db') -class TestAggregateRamFilter(test.NoDBTestCase): - - def setUp(self): - super(TestAggregateRamFilter, self).setUp() - self.filt_cls = ram_filter.AggregateRamFilter() - - def test_aggregate_ram_filter_value_error(self, agg_mock): - self.flags(ram_allocation_ratio=1.0) - filter_properties = {'context': mock.sentinel.ctx, - 'instance_type': {'memory_mb': 1024}} - host = fakes.FakeHostState('host1', 'node1', - {'free_ram_mb': 1024, 'total_usable_ram_mb': 1024}) - agg_mock.return_value = set(['XXX']) - self.assertTrue(self.filt_cls.host_passes(host, filter_properties)) - self.assertEqual(1024 * 1.0, host.limits['memory_mb']) - - def test_aggregate_ram_filter_default_value(self, agg_mock): - self.flags(ram_allocation_ratio=1.0) - filter_properties = {'context': mock.sentinel.ctx, - 'instance_type': {'memory_mb': 1024}} - host = fakes.FakeHostState('host1', 'node1', - {'free_ram_mb': 1023, 'total_usable_ram_mb': 1024}) - # False: fallback to default flag w/o aggregates - agg_mock.return_value = set() - self.assertFalse(self.filt_cls.host_passes(host, filter_properties)) - agg_mock.return_value = set(['2.0']) - # True: use ratio from aggregates - self.assertTrue(self.filt_cls.host_passes(host, filter_properties)) - self.assertEqual(1024 * 2.0, host.limits['memory_mb']) - - def test_aggregate_ram_filter_conflict_values(self, agg_mock): - self.flags(ram_allocation_ratio=1.0) - filter_properties = {'context': mock.sentinel.ctx, - 'instance_type': {'memory_mb': 1024}} - host = fakes.FakeHostState('host1', 'node1', - {'free_ram_mb': 1023, 'total_usable_ram_mb': 1024}) - agg_mock.return_value = set(['1.5', '2.0']) - # use the minimum ratio from aggregates - self.assertTrue(self.filt_cls.host_passes(host, filter_properties)) - self.assertEqual(1024 * 1.5, host.limits['memory_mb']) |