From 6f6d5bfccbf223c16dbbfc87d43e687fa9bb517c Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Fri, 11 Jan 2013 17:33:32 -0500 Subject: Add service_destroy to conductor. This patch adds a service_destroy method to the conductor API. It is used from nova.service for deleting the service record in kill(). If a service has been marked as not having db access, the conductor API will complete this operation via rpc. Part of bp no-db-compute. Change-Id: Ie2397a090290823c0a47aaea41f6900072d142b4 --- nova/tests/conductor/test_conductor.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/conductor/test_conductor.py b/nova/tests/conductor/test_conductor.py index a5d0f7fba..e3ef6072a 100644 --- a/nova/tests/conductor/test_conductor.py +++ b/nova/tests/conductor/test_conductor.py @@ -633,12 +633,19 @@ class ConductorAPITestCase(_BaseTestCase, test.TestCase): {'name': 'fake-inst'}, 'updated_at', 'asc') - def _test_stubbed(self, name, *args): + def _test_stubbed(self, name, *args, **kwargs): self.mox.StubOutWithMock(db, name) getattr(db, name)(self.context, *args).AndReturn('fake-result') + if name == 'service_destroy': + # TODO(russellb) This is a hack ... SetUp() starts the conductor() + # service. There is a cleanup step that runs after this test which + # also deletes the associated service record. This involves a call + # to db.service_destroy(), which we have stubbed out. + db.service_destroy(mox.IgnoreArg(), mox.IgnoreArg()) self.mox.ReplayAll() result = getattr(self.conductor, name)(self.context, *args) - self.assertEqual(result, 'fake-result') + self.assertEqual( + result, 'fake-result' if kwargs.get('returns', True) else None) def test_service_get_all(self): self._test_stubbed('service_get_all') @@ -658,6 +665,9 @@ class ConductorAPITestCase(_BaseTestCase, test.TestCase): def test_service_create(self): self._test_stubbed('service_create', {}) + def test_service_destroy(self): + self._test_stubbed('service_destroy', '', returns=False) + def test_ping(self): timeouts = [] calls = dict(count=0) -- cgit