From 10db6128b8dc3ed2773acf262af529e0485cfe9f Mon Sep 17 00:00:00 2001 From: Hans Lindgren Date: Wed, 19 Jun 2013 21:52:51 +0200 Subject: Allow scheduler manager NoValidHost exception to pass over RPC Calls to scheduler.manager.select_hosts are expected to throw NoValidHost exceptions if no hosts match such requests. For the exception to be passed over RPC, the method must be decorated with: @rpc_common.client_exceptions(exception.NoValidHost) Resolves bug 1192693. Change-Id: If9d1f15ff1239e422067893f9d837c41e5f5474d --- nova/tests/scheduler/test_scheduler.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'nova/tests/scheduler') diff --git a/nova/tests/scheduler/test_scheduler.py b/nova/tests/scheduler/test_scheduler.py index 0574f6d2e..d627f2765 100644 --- a/nova/tests/scheduler/test_scheduler.py +++ b/nova/tests/scheduler/test_scheduler.py @@ -402,6 +402,17 @@ class SchedulerManagerTestCase(test.NoDBTestCase): self.manager._set_vm_state_and_notify('foo', {'vm_state': 'foo'}, self.context, None, request) + def test_select_hosts_throws_rpc_clientexception(self): + self.mox.StubOutWithMock(self.manager.driver, 'select_hosts') + + self.manager.driver.select_hosts(self.context, {}, {}).AndRaise( + exception.NoValidHost(reason="")) + + self.mox.ReplayAll() + self.assertRaises(rpc_common.ClientException, + self.manager.select_hosts, + self.context, {}, {}) + class SchedulerTestCase(test.NoDBTestCase): """Test case for base scheduler driver class.""" -- cgit