From 32d6f568aedeee25cb9c0b093ee847459c091f7e Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Wed, 6 Feb 2013 17:48:49 -0500 Subject: Move security_groups refreshes to conductor This moves the last bit of compute-initiated db accesses found during test runs to conductor. The quantum API was hitting the database directly while calling back to compute's API to trigger the refresh. This just makes the quantum API ask conductor to do that in a similar way to the usage notifications patch recently merged. Related to blueprint no-db-compute Change-Id: I44de7e1e12aec291b8319d45ec5975ad05b8e676 --- nova/tests/conductor/test_conductor.py | 43 ++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/conductor/test_conductor.py b/nova/tests/conductor/test_conductor.py index d9d6f2db5..773b65d43 100644 --- a/nova/tests/conductor/test_conductor.py +++ b/nova/tests/conductor/test_conductor.py @@ -495,12 +495,22 @@ class _BaseTestCase(object): system_metadata={}, extra_usage_info=dict(extra='info')) + def test_security_groups_trigger_members_refresh(self): + self.mox.StubOutWithMock(self.conductor_manager.security_group_api, + 'trigger_members_refresh') + self.conductor_manager.security_group_api.trigger_members_refresh( + self.context, [1, 2, 3]) + self.mox.ReplayAll() + self.conductor.security_groups_trigger_members_refresh(self.context, + [1, 2, 3]) + class ConductorTestCase(_BaseTestCase, test.TestCase): """Conductor Manager Tests.""" def setUp(self): super(ConductorTestCase, self).setUp() self.conductor = conductor_manager.ConductorManager() + self.conductor_manager = self.conductor self.stub_out_client_exceptions() def test_block_device_mapping_update_or_create(self): @@ -613,6 +623,16 @@ class ConductorTestCase(_BaseTestCase, test.TestCase): ('host', 'binary'), dict(host='host', binary='binary')) + def test_security_groups_trigger_handler(self): + self.mox.StubOutWithMock(self.conductor_manager.security_group_api, + 'trigger_handler') + self.conductor_manager.security_group_api.trigger_handler('event', + self.context, + 'args') + self.mox.ReplayAll() + self.conductor.security_groups_trigger_handler(self.context, + 'event', ['args']) + class ConductorRPCAPITestCase(_BaseTestCase, test.TestCase): """Conductor RPC API Tests.""" @@ -620,6 +640,7 @@ class ConductorRPCAPITestCase(_BaseTestCase, test.TestCase): super(ConductorRPCAPITestCase, self).setUp() self.conductor_service = self.start_service( 'conductor', manager='nova.conductor.manager.ConductorManager') + self.conductor_manager = self.conductor_service.manager self.conductor = conductor_rpcapi.ConductorAPI() def test_block_device_mapping_update_or_create(self): @@ -709,6 +730,16 @@ class ConductorRPCAPITestCase(_BaseTestCase, test.TestCase): dict(topic='compute', host='host'), db_result_listified=True) + def test_security_groups_trigger_handler(self): + self.mox.StubOutWithMock(self.conductor_manager.security_group_api, + 'trigger_handler') + self.conductor_manager.security_group_api.trigger_handler('event', + self.context, + 'arg') + self.mox.ReplayAll() + self.conductor.security_groups_trigger_handler(self.context, + 'event', ['arg']) + class ConductorAPITestCase(_BaseTestCase, test.TestCase): """Conductor API Tests.""" @@ -717,6 +748,7 @@ class ConductorAPITestCase(_BaseTestCase, test.TestCase): self.conductor_service = self.start_service( 'conductor', manager='nova.conductor.manager.ConductorManager') self.conductor = conductor_api.API() + self.conductor_manager = self.conductor_service.manager self.db = None def _do_update(self, instance_uuid, **updates): @@ -858,12 +890,23 @@ class ConductorAPITestCase(_BaseTestCase, test.TestCase): self.assertEqual(timeouts.count(10), 10) self.assertTrue(None in timeouts) + def test_security_groups_trigger_handler(self): + self.mox.StubOutWithMock(self.conductor_manager.security_group_api, + 'trigger_handler') + self.conductor_manager.security_group_api.trigger_handler('event', + self.context, + 'arg') + self.mox.ReplayAll() + self.conductor.security_groups_trigger_handler(self.context, + 'event', 'arg') + class ConductorLocalAPITestCase(ConductorAPITestCase): """Conductor LocalAPI Tests.""" def setUp(self): super(ConductorLocalAPITestCase, self).setUp() self.conductor = conductor_api.LocalAPI() + self.conductor_manager = self.conductor._manager._target self.db = db self.stub_out_client_exceptions() -- cgit