From 2f8ffcc46db933ba27e14835c4448320bee5daa0 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Wed, 12 Dec 2012 13:14:56 -0800 Subject: Move agent_build_get_by_triple to conductor This patch moves the final method in Compute's VirtAPI to using the conductor. Related to blueprint no-db-compute-manager Change-Id: Icaf8990e117c8de7198de2f26f0d77e56c129430 --- nova/tests/compute/test_virtapi.py | 29 +++-------------------------- nova/tests/conductor/test_conductor.py | 11 +++++++++++ 2 files changed, 14 insertions(+), 26 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/compute/test_virtapi.py b/nova/tests/compute/test_virtapi.py index ceeacbc9d..568bf456d 100644 --- a/nova/tests/compute/test_virtapi.py +++ b/nova/tests/compute/test_virtapi.py @@ -129,33 +129,10 @@ class ComputeVirtAPITest(VirtAPIBaseTest): self.compute = FakeCompute() self.virtapi = compute_manager.ComputeVirtAPI(self.compute) - def setUp(self): - super(ComputeVirtAPITest, self).setUp() - # NOTE(danms): Eventually these should all be migrated to the - # conductor, but until then, dispatch appropriately. - self.conductor_methods = ['instance_update', 'instance_get_by_uuid', - 'instance_get_all_by_host', - 'aggregate_get_by_host', - 'aggregate_metadata_add', - 'aggregate_metadata_delete', - 'security_group_get_by_instance', - 'security_group_rule_get_by_security_group', - 'provider_fw_rule_get_all', - ] - self.db_methods = ['agent_build_get_by_triple', - ] - def assertExpected(self, method, *args, **kwargs): - if method in self.conductor_methods: - target = self.compute.conductor_api - elif method in self.db_methods: - target = self.compute.db - else: - raise Exception('Method "%s" not known to this test!') - - self.mox.StubOutWithMock(target, method) - getattr(target, method)(self.context, *args, **kwargs).AndReturn( - 'it worked') + self.mox.StubOutWithMock(self.compute.conductor_api, method) + getattr(self.compute.conductor_api, method)( + self.context, *args, **kwargs).AndReturn('it worked') self.mox.ReplayAll() result = getattr(self.virtapi, method)(self.context, *args, **kwargs) self.assertEqual(result, 'it worked') diff --git a/nova/tests/conductor/test_conductor.py b/nova/tests/conductor/test_conductor.py index 6acbe7ef6..734dba9ed 100644 --- a/nova/tests/conductor/test_conductor.py +++ b/nova/tests/conductor/test_conductor.py @@ -251,6 +251,17 @@ class _BaseTestCase(object): result = self.conductor.provider_fw_rule_get_all(self.context) self.assertEqual(result, fake_rules) + def test_agent_build_get_by_triple(self): + self.mox.StubOutWithMock(db, 'agent_build_get_by_triple') + db.agent_build_get_by_triple(self.context, 'fake-hv', 'fake-os', + 'fake-arch').AndReturn('it worked') + self.mox.ReplayAll() + result = self.conductor.agent_build_get_by_triple(self.context, + 'fake-hv', + 'fake-os', + 'fake-arch') + self.assertEqual(result, 'it worked') + class ConductorTestCase(_BaseTestCase, test.TestCase): """Conductor Manager Tests""" -- cgit