From ba9cd2a545a0c198990f649b6a2985a22102930f Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Mon, 8 Apr 2013 16:13:30 -0700 Subject: Change DB API instance functions for selective metadata fetching This makes the DB API for instance_get_all() variants able to take a columns_to_join parameter like the base instance_get_all() function, which provides control over whether we go to the trouble of pulling the metadata out of the database before we return the instances. Related to bug 1164737 Change-Id: Ie7c012e2e12bb91ef4294cdc90d828af255b67c5 --- nova/tests/conductor/test_conductor.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/conductor/test_conductor.py b/nova/tests/conductor/test_conductor.py index f4c6dde61..e339ecf44 100644 --- a/nova/tests/conductor/test_conductor.py +++ b/nova/tests/conductor/test_conductor.py @@ -670,7 +670,8 @@ class ConductorTestCase(_BaseTestCase, test.TestCase): filters = {'foo': 'bar'} self.mox.StubOutWithMock(db, 'instance_get_all_by_filters') db.instance_get_all_by_filters(self.context, filters, - 'fake-key', 'fake-sort') + 'fake-key', 'fake-sort', + columns_to_join=None) self.mox.ReplayAll() self.conductor.instance_get_all_by_filters(self.context, filters, 'fake-key', 'fake-sort') @@ -679,7 +680,7 @@ class ConductorTestCase(_BaseTestCase, test.TestCase): self.mox.StubOutWithMock(db, 'instance_get_all_by_host') self.mox.StubOutWithMock(db, 'instance_get_all_by_host_and_node') db.instance_get_all_by_host(self.context.elevated(), - 'host').AndReturn('result') + 'host', None).AndReturn('result') db.instance_get_all_by_host_and_node(self.context.elevated(), 'host', 'node').AndReturn('result') self.mox.ReplayAll() @@ -826,7 +827,8 @@ class ConductorRPCAPITestCase(_BaseTestCase, test.TestCase): filters = {'foo': 'bar'} self.mox.StubOutWithMock(db, 'instance_get_all_by_filters') db.instance_get_all_by_filters(self.context, filters, - 'fake-key', 'fake-sort') + 'fake-key', 'fake-sort', + columns_to_join=None) self.mox.ReplayAll() self.conductor.instance_get_all_by_filters(self.context, filters, 'fake-key', 'fake-sort') @@ -973,7 +975,8 @@ class ConductorAPITestCase(_BaseTestCase, test.TestCase): self.mox.StubOutWithMock(db, 'instance_get_all_by_filters') db.instance_get_all(self.context) db.instance_get_all_by_filters(self.context, {'name': 'fake-inst'}, - 'updated_at', 'asc') + 'updated_at', 'asc', + columns_to_join=None) self.mox.ReplayAll() self.conductor.instance_get_all(self.context) self.conductor.instance_get_all_by_filters(self.context, @@ -1049,14 +1052,20 @@ class ConductorAPITestCase(_BaseTestCase, test.TestCase): result = self.conductor.service_update(self.context, {'id': ''}, {}) self.assertEqual(result, 'fake-result') - def test_instance_get_all_by_host(self): - self._test_stubbed('instance_get_all_by_host', - self.context.elevated(), 'host') - def test_instance_get_all_by_host_and_node(self): self._test_stubbed('instance_get_all_by_host_and_node', self.context.elevated(), 'host', 'node') + def test_instance_get_all_by_host(self): + self.mox.StubOutWithMock(db, 'instance_get_all_by_host') + self.mox.StubOutWithMock(db, 'instance_get_all_by_host_and_node') + db.instance_get_all_by_host(self.context.elevated(), 'host', + None).AndReturn('fake-result') + self.mox.ReplayAll() + result = self.conductor.instance_get_all_by_host(self.context, + 'host') + self.assertEqual(result, 'fake-result') + def test_ping(self): timeouts = [] calls = dict(count=0) -- cgit