summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorSandy Walsh <sandy.walsh@rackspace.com>2011-05-05 05:29:31 -0700
committerSandy Walsh <sandy.walsh@rackspace.com>2011-05-05 05:29:31 -0700
commit5a066cf5c2b952371eea753dcd0f95f917d08744 (patch)
tree6b8dc6cceac6350104b4b7726c9153ef3c552d3b /nova/tests
parent5f4fc98c9648fd3f124819e0f4a26cb1d2d7f0e8 (diff)
not =
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/test_query.py29
1 files changed, 21 insertions, 8 deletions
diff --git a/nova/tests/test_query.py b/nova/tests/test_query.py
index 90ae80dc0..9bfc83b75 100644
--- a/nova/tests/test_query.py
+++ b/nova/tests/test_query.py
@@ -33,7 +33,7 @@ class QueryTestCase(test.TestCase):
def _host_caps(self, multiplier):
# Returns host capabilities in the following way:
- # host0 = memory:free 10 (100max)
+ # host1 = memory:free 10 (100max)
# disk:available 100 (1000max)
# hostN = memory:free 10 + 10N
# disk:available 100 + 100N
@@ -69,7 +69,7 @@ class QueryTestCase(test.TestCase):
self.zone_manager = FakeZoneManager()
states = {}
for x in xrange(10):
- states['host%s' % x] = {'compute': self._host_caps(x)}
+ states['host%02d' % (x + 1)] = {'compute': self._host_caps(x)}
self.zone_manager.service_states = states
def tearDown(self):
@@ -106,8 +106,8 @@ class QueryTestCase(test.TestCase):
self.assertEquals(6, len(hosts))
just_hosts = [host for host, caps in hosts]
just_hosts.sort()
- self.assertEquals('host4', just_hosts[0])
- self.assertEquals('host9', just_hosts[5])
+ self.assertEquals('host05', just_hosts[0])
+ self.assertEquals('host10', just_hosts[5])
def test_json_driver(self):
driver = query.JsonQuery()
@@ -118,8 +118,8 @@ class QueryTestCase(test.TestCase):
self.assertEquals(6, len(hosts))
just_hosts = [host for host, caps in hosts]
just_hosts.sort()
- self.assertEquals('host4', just_hosts[0])
- self.assertEquals('host9', just_hosts[5])
+ self.assertEquals('host05', just_hosts[0])
+ self.assertEquals('host10', just_hosts[5])
# Try some custom queries
@@ -139,5 +139,18 @@ class QueryTestCase(test.TestCase):
self.assertEquals(5, len(hosts))
just_hosts = [host for host, caps in hosts]
just_hosts.sort()
- for index, host in zip([0, 1, 7, 8, 9], just_hosts):
- self.assertEquals('host%d' % index, host)
+ for index, host in zip([1, 2, 8, 9, 10], just_hosts):
+ self.assertEquals('host%02d' % index, host)
+
+ raw = ['not',
+ ['=', '$compute.host_memory.free', 30],
+ ]
+ cooked = json.dumps(raw)
+ hosts = driver.filter_hosts(self.zone_manager, cooked)
+
+ self.assertEquals(9, len(hosts))
+ just_hosts = [host for host, caps in hosts]
+ just_hosts.sort()
+ for index, host in zip([1, 2, 4, 5, 6, 7, 8, 9, 10], just_hosts):
+ self.assertEquals('host%02d' % index, host)
+