From 0534872abb78738993a35d24a6640c82b711deee Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Mon, 25 Sep 2017 14:57:43 -0400 Subject: [PATCH] Make TestRPC inherit from the base nova TestCase By not inheriting from the base nova test case, we lose things like timeouts. This makes the TestRPC test class inherit from the base test case and still avoid using the RPCFixture. Change-Id: Id65e15a57175bbdd9c84851b1b6716e6a1f2cfb8 Related-Bug: #1685333 --- nova/test.py | 7 ++++++- nova/tests/unit/test_rpc.py | 9 +++++---- 2 files changed, 11 insertions(+), 5 deletions(-) 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())