summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorTiago Mello <tmello@linux.vnet.ibm.com>2013-06-05 20:52:07 -0300
committerTiago Mello <tmello@linux.vnet.ibm.com>2013-06-06 01:16:19 -0300
commitcb49e5407cc1db0cd3533b57a12ec99a7179abd7 (patch)
tree9020a6970fb1c85a0fa2fc5607333277272d0e89 /nova/tests
parent86e12403ccb851199457bd0eaadc3f1d3c75679f (diff)
downloadnova-cb49e5407cc1db0cd3533b57a12ec99a7179abd7.tar.gz
nova-cb49e5407cc1db0cd3533b57a12ec99a7179abd7.tar.xz
nova-cb49e5407cc1db0cd3533b57a12ec99a7179abd7.zip
Refactors scheduler.chance.select_hosts to raise NoValidHost
This change is intended to refactor the method to be consistent with the filter_scheduler.select_hosts implementation. This method is called by scheduler.manager and it is exposed through the scheduler.rpcapi. Thus, both implementations should behave the same. This change is needed by others that will move cold migration to conductor. Partially implements bp cold-migrations-to-conductor Change-Id: I0f6fef43324cf829cdb26633874c537572423f77
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/scheduler/test_chance_scheduler.py9
-rw-r--r--nova/tests/scheduler/test_filter_scheduler.py9
-rw-r--r--nova/tests/scheduler/test_scheduler.py4
3 files changed, 22 insertions, 0 deletions
diff --git a/nova/tests/scheduler/test_chance_scheduler.py b/nova/tests/scheduler/test_chance_scheduler.py
index a589000cd..8a281073a 100644
--- a/nova/tests/scheduler/test_chance_scheduler.py
+++ b/nova/tests/scheduler/test_chance_scheduler.py
@@ -194,3 +194,12 @@ class ChanceSchedulerTestCase(test_scheduler.SchedulerTestCase):
self.mox.ReplayAll()
hosts = self.driver.select_hosts(ctxt, request_spec, {})
self.assertEquals(['host3', 'host1'], hosts)
+
+ def test_select_hosts_no_valid_host(self):
+
+ def _return_no_host(*args, **kwargs):
+ return []
+
+ self.stubs.Set(self.driver, '_schedule', _return_no_host)
+ self.assertRaises(exception.NoValidHost,
+ self.driver.select_hosts, self.context, {}, {})
diff --git a/nova/tests/scheduler/test_filter_scheduler.py b/nova/tests/scheduler/test_filter_scheduler.py
index 80680dda8..a4aba4207 100644
--- a/nova/tests/scheduler/test_filter_scheduler.py
+++ b/nova/tests/scheduler/test_filter_scheduler.py
@@ -707,3 +707,12 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
hosts = sched.select_hosts(fake_context, request_spec, {})
self.assertEquals(len(hosts), 10)
self.assertEquals(hosts, selected_hosts)
+
+ def test_select_hosts_no_valid_host(self):
+
+ def _return_no_host(*args, **kwargs):
+ return []
+
+ self.stubs.Set(self.driver, '_schedule', _return_no_host)
+ self.assertRaises(exception.NoValidHost,
+ self.driver.select_hosts, self.context, {}, {})
diff --git a/nova/tests/scheduler/test_scheduler.py b/nova/tests/scheduler/test_scheduler.py
index f4f607647..fc5c4787b 100644
--- a/nova/tests/scheduler/test_scheduler.py
+++ b/nova/tests/scheduler/test_scheduler.py
@@ -951,6 +951,10 @@ class SchedulerDriverBaseTestCase(SchedulerTestCase):
self.context, {},
fake_request_spec, {}, {}, {}, None)
+ def test_unimplemented_select_hosts(self):
+ self.assertRaises(NotImplementedError,
+ self.driver.select_hosts, self.context, {}, {})
+
class SchedulerDriverModuleTestCase(test.TestCase):
"""Test case for scheduler driver module methods."""