summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorRick Harris <rconradharris@gmail.com>2011-09-21 16:29:36 +0000
committerRick Harris <rconradharris@gmail.com>2011-09-21 16:29:36 +0000
commitec2a93ca94e3d8ce436858380fc2c46963c76e05 (patch)
tree7ef167c96c10ccb5c307b6cbc31930edc462693d /nova/tests
parent275f58c5649653632b8c28b66b59ff19d2cdf366 (diff)
Adding flavor filtering
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/test_instance_types.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/nova/tests/test_instance_types.py b/nova/tests/test_instance_types.py
index 09f532239..1ed34fba3 100644
--- a/nova/tests/test_instance_types.py
+++ b/nova/tests/test_instance_types.py
@@ -161,3 +161,40 @@ class InstanceTypeTestCase(test.TestCase):
self.assertRaises(exception.InstanceTypeNotFound,
instance_types.get_instance_type_by_name,
self._nonexistent_flavor_id())
+
+
+class InstanceTypeFilteringTest(test.TestCase):
+ """Test cases for the filter option available for instance_type_get_all"""
+ def setUp(self):
+ super(InstanceTypeFilteringTest, self).setUp()
+ self.context = context.get_admin_context()
+
+ def assertFilterResults(self, filters, expected):
+ inst_types = db.api.instance_type_get_all(
+ self.context, filters=filters)
+ inst_names = [i['name'] for i in inst_types]
+ self.assertEqual(inst_names, expected)
+
+ def test_no_filters(self):
+ filters = None
+ expected = ['m1.large', 'm1.medium', 'm1.small', 'm1.tiny',
+ 'm1.xlarge']
+ self.assertFilterResults(filters, expected)
+
+ def test_min_memory_mb_filter(self):
+ """Exclude tiny instance which is 512 MB"""
+ filters = dict(min_memory_mb=513)
+ expected = ['m1.large', 'm1.medium', 'm1.small', 'm1.xlarge']
+ self.assertFilterResults(filters, expected)
+
+ def test_min_local_gb_filter(self):
+ """Exclude everything but large and xlarge which have >= 80 GB"""
+ filters = dict(min_local_gb=80)
+ expected = ['m1.large', 'm1.xlarge']
+ self.assertFilterResults(filters, expected)
+
+ def test_min_memory_mb_AND_local_gb_filter(self):
+ """Exclude everything but large and xlarge which have >= 80 GB"""
+ filters = dict(min_memory_mb=16384, min_local_gb=80)
+ expected = ['m1.xlarge']
+ self.assertFilterResults(filters, expected)