diff --git a/nova/test.py b/nova/test.py index f0e6953b965c..2c9028a4510e 100644 --- a/nova/test.py +++ b/nova/test.py @@ -209,6 +209,9 @@ class TestCase(testtools.TestCase): USES_DB_SELF = False REQUIRES_LOCKING = False + # Setting to True makes the test use the RPCFixture. + STUB_RPC = True + # The number of non-cell0 cells to create. This is only used in the # base class when USES_DB is True. NUMBER_OF_CELLS = 1 @@ -250,7 +253,9 @@ class TestCase(testtools.TestCase): group='oslo_concurrency') self.useFixture(conf_fixture.ConfFixture(CONF)) - self.useFixture(nova_fixtures.RPCFixture('nova.test')) + + if self.STUB_RPC: + self.useFixture(nova_fixtures.RPCFixture('nova.test')) # we cannot set this in the ConfFixture as oslo only registers the # notification opts at the first instantiation of a Notifier that diff --git a/nova/tests/unit/test_rpc.py b/nova/tests/unit/test_rpc.py index 3fd8d383a48e..0d8d3842ae76 100644 --- a/nova/tests/unit/test_rpc.py +++ b/nova/tests/unit/test_rpc.py @@ -18,7 +18,6 @@ import mock import oslo_messaging as messaging from oslo_messaging.rpc import dispatcher from oslo_serialization import jsonutils -import testtools from nova import context from nova import rpc @@ -45,9 +44,11 @@ class RPCResetFixture(fixtures.Fixture): rpc.CONF = self.conf -# We can't import nova.test.TestCase because that sets up an RPCFixture -# that pretty much nullifies all of this testing -class TestRPC(testtools.TestCase): +class TestRPC(test.NoDBTestCase): + + # We're testing the rpc code so we can't use the RPCFixture. + STUB_RPC = False + def setUp(self): super(TestRPC, self).setUp() self.useFixture(RPCResetFixture())