summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorDan Smith <danms@us.ibm.com>2013-01-04 10:12:52 -0800
committerGerrit Code Review <review@openstack.org>2013-01-05 05:18:08 +0000
commitf47c997242f591ca45945f86c00b584217a9b75b (patch)
tree9677809e5b21c6dad5006f7e08e725fbdd98fc18 /nova/tests
parent8be47738aedb809b9d64559aeba821e17796a6a8 (diff)
Move service_get_all operations to conductor
This patch adds a single service_get_all_by() method to the conductor, which services the following database calls: - service_get_all() - service_get_all_by_topic() - service_get_all_by_host() - service_get_by_host_and_topic() - service_get_all_compute_by_host() It also makes compute/manager use conductor for this case. The special case for the service_get_all_compute_by_host() call is rather unfortunate, and I wonder if it might be okay to (later) make the generic function automatically joinedload in the compute case. Related to blueprint no-db-compute-manager Change-Id: Ib4aa10a3196a4b9aa779f57f4e5d6b136676f3bd
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/conductor/test_conductor.py82
1 files changed, 82 insertions, 0 deletions
diff --git a/nova/tests/conductor/test_conductor.py b/nova/tests/conductor/test_conductor.py
index b2342f5b4..f919b0465 100644
--- a/nova/tests/conductor/test_conductor.py
+++ b/nova/tests/conductor/test_conductor.py
@@ -402,6 +402,36 @@ class ConductorTestCase(_BaseTestCase, test.TestCase):
self.conductor.instance_get_all_by_filters(self.context, filters,
'fake-key', 'fake-sort')
+ def _test_stubbed(self, name, dbargs, condargs):
+ self.mox.StubOutWithMock(db, name)
+ getattr(db, name)(self.context, *dbargs).AndReturn('fake-result')
+ self.mox.ReplayAll()
+ result = self.conductor.service_get_all_by(self.context, **condargs)
+ self.assertEqual(result, 'fake-result')
+
+ def test_service_get_all(self):
+ self._test_stubbed('service_get_all', (), {})
+
+ def test_service_get_by_host_and_topic(self):
+ self._test_stubbed('service_get_by_host_and_topic',
+ ('host', 'topic'),
+ dict(topic='topic', host='host'))
+
+ def test_service_get_all_by_topic(self):
+ self._test_stubbed('service_get_all_by_topic',
+ ('topic',),
+ dict(topic='topic'))
+
+ def test_service_get_all_by_host(self):
+ self._test_stubbed('service_get_all_by_host',
+ ('host',),
+ dict(host='host'))
+
+ def test_service_get_all_compute_by_host(self):
+ self._test_stubbed('service_get_all_compute_by_host',
+ ('host',),
+ dict(topic='compute', host='host'))
+
class ConductorRPCAPITestCase(_BaseTestCase, test.TestCase):
"""Conductor RPC API Tests"""
@@ -463,6 +493,36 @@ class ConductorRPCAPITestCase(_BaseTestCase, test.TestCase):
self.conductor.instance_get_all_by_filters(self.context, filters,
'fake-key', 'fake-sort')
+ def _test_stubbed(self, name, dbargs, condargs):
+ self.mox.StubOutWithMock(db, name)
+ getattr(db, name)(self.context, *dbargs).AndReturn('fake-result')
+ self.mox.ReplayAll()
+ result = self.conductor.service_get_all_by(self.context, **condargs)
+ self.assertEqual(result, 'fake-result')
+
+ def test_service_get_all(self):
+ self._test_stubbed('service_get_all', (), {})
+
+ def test_service_get_by_host_and_topic(self):
+ self._test_stubbed('service_get_by_host_and_topic',
+ ('host', 'topic'),
+ dict(topic='topic', host='host'))
+
+ def test_service_get_all_by_topic(self):
+ self._test_stubbed('service_get_all_by_topic',
+ ('topic',),
+ dict(topic='topic'))
+
+ def test_service_get_all_by_host(self):
+ self._test_stubbed('service_get_all_by_host',
+ ('host',),
+ dict(host='host'))
+
+ def test_service_get_all_compute_by_host(self):
+ self._test_stubbed('service_get_all_compute_by_host',
+ ('host',),
+ dict(topic='compute', host='host'))
+
class ConductorAPITestCase(_BaseTestCase, test.TestCase):
"""Conductor API Tests"""
@@ -542,6 +602,28 @@ class ConductorAPITestCase(_BaseTestCase, test.TestCase):
{'name': 'fake-inst'},
'updated_at', 'asc')
+ def _test_stubbed(self, name, *args):
+ self.mox.StubOutWithMock(db, name)
+ getattr(db, name)(self.context, *args).AndReturn('fake-result')
+ self.mox.ReplayAll()
+ result = getattr(self.conductor, name)(self.context, *args)
+ self.assertEqual(result, 'fake-result')
+
+ def test_service_get_all(self):
+ self._test_stubbed('service_get_all')
+
+ def test_service_get_by_host_and_topic(self):
+ self._test_stubbed('service_get_by_host_and_topic', 'host', 'topic')
+
+ def test_service_get_all_by_topic(self):
+ self._test_stubbed('service_get_all_by_topic', 'topic')
+
+ def test_service_get_all_by_host(self):
+ self._test_stubbed('service_get_all_by_host', 'host')
+
+ def test_service_get_all_compute_by_host(self):
+ self._test_stubbed('service_get_all_compute_by_host', 'host')
+
class ConductorLocalAPITestCase(ConductorAPITestCase):
"""Conductor LocalAPI Tests"""