summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorSandy Walsh <sandy.walsh@rackspace.com>2011-05-05 04:57:25 -0700
committerSandy Walsh <sandy.walsh@rackspace.com>2011-05-05 04:57:25 -0700
commitcc18ff47ff41ddefd7a31db5b772d55b2e312e8c (patch)
tree6fa831f28e4630e1dbd50f363674ccecb706224c /nova/tests
parent772fc58644871f7ee0bb880074c89d79871e197a (diff)
and or test
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/test_query.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/nova/tests/test_query.py b/nova/tests/test_query.py
index 7a036a4d8..896b2364d 100644
--- a/nova/tests/test_query.py
+++ b/nova/tests/test_query.py
@@ -16,6 +16,8 @@
Tests For Scheduler Query Drivers
"""
+import json
+
from nova import exception
from nova import flags
from nova import test
@@ -118,3 +120,27 @@ class QueryTestCase(test.TestCase):
just_hosts.sort()
self.assertEquals('host4', just_hosts[0])
self.assertEquals('host9', just_hosts[5])
+
+ # Try some custom queries
+
+ raw = ['or',
+ ['and',
+ ['<', '$compute.host_memory.free', 30],
+ ['<', '$compute.disk.available', 300]
+ ],
+ ['and',
+ ['>', '$compute.host_memory.free', 70],
+ ['>', '$compute.disk.available', 700]
+ ]
+ ]
+ cooked = json.dumps(raw)
+ hosts = driver.filter_hosts(self.zone_manager, cooked)
+
+ self.assertEquals(5, len(hosts))
+ just_hosts = [host for host, caps in hosts]
+ just_hosts.sort()
+ self.assertEquals('host0', just_hosts[0])
+ self.assertEquals('host1', just_hosts[1])
+ self.assertEquals('host7', just_hosts[2])
+ self.assertEquals('host8', just_hosts[3])
+ self.assertEquals('host9', just_hosts[4])