From 6efa86a8d55262349a797f1573fc364c439b7ffa Mon Sep 17 00:00:00 2001 From: Rajath Agasthya Date: Fri, 22 Sep 2017 17:10:29 -0700 Subject: [PATCH] Fix wrong transport warnings in functional tests Change-Id: Ie6726ecd566d965a94343bde7a518e986b434346 Closes-Bug: #1718691 --- .../tests/functional/test_functional.py | 8 +++--- oslo_messaging/tests/functional/utils.py | 28 ++++++++++++++++--- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/oslo_messaging/tests/functional/test_functional.py b/oslo_messaging/tests/functional/test_functional.py index 185534b6d..becf067fb 100644 --- a/oslo_messaging/tests/functional/test_functional.py +++ b/oslo_messaging/tests/functional/test_functional.py @@ -113,7 +113,7 @@ class CallTestCase(utils.SkipIfNoTransportURL): def test_timeout(self): transport = self.useFixture( - utils.TransportFixture(self.conf, self.url) + utils.RPCTransportFixture(self.conf, self.url) ) target = oslo_messaging.Target(topic="no_such_topic") c = utils.ClientStub(transport.transport, target, timeout=1) @@ -130,7 +130,7 @@ class CallTestCase(utils.SkipIfNoTransportURL): def test_timeout_with_concurrently_queues(self): transport = self.useFixture( - utils.TransportFixture(self.conf, self.url) + utils.RPCTransportFixture(self.conf, self.url) ) target = oslo_messaging.Target(topic="topic_" + str(uuid.uuid4()), server="server_" + str(uuid.uuid4())) @@ -167,7 +167,7 @@ class CallTestCase(utils.SkipIfNoTransportURL): return echo transport = self.useFixture( - utils.TransportFixture(self.conf, self.url) + utils.RPCTransportFixture(self.conf, self.url) ) self.useFixture( utils.RpcServerFixture(self.conf, self.url, target, @@ -209,7 +209,7 @@ class CallTestCase(utils.SkipIfNoTransportURL): target = oslo_messaging.Target(topic="topic_" + str(uuid.uuid4()), server="server_" + str(uuid.uuid4())) transport = self.useFixture( - utils.TransportFixture(self.conf, self.url) + utils.RPCTransportFixture(self.conf, self.url) ) self.assertRaises(TypeError, oslo_messaging.get_rpc_server, diff --git a/oslo_messaging/tests/functional/utils.py b/oslo_messaging/tests/functional/utils.py index 5cf3cb03d..c381ebd90 100644 --- a/oslo_messaging/tests/functional/utils.py +++ b/oslo_messaging/tests/functional/utils.py @@ -74,6 +74,24 @@ class TransportFixture(fixtures.Fixture): time.sleep(0.5) +class RPCTransportFixture(TransportFixture): + """Fixture defined to setup RPC transport.""" + + def setUp(self): + super(RPCTransportFixture, self).setUp() + self.transport = oslo_messaging.get_rpc_transport(self.conf, + url=self.url) + + +class NotificationTransportFixture(TransportFixture): + """Fixture defined to setup notification transport.""" + + def setUp(self): + super(NotificationTransportFixture, self).setUp() + self.transport = oslo_messaging.get_notification_transport( + self.conf, url=self.url) + + class RpcServerFixture(fixtures.Fixture): """Fixture to setup the TestServerEndpoint.""" @@ -91,7 +109,7 @@ class RpcServerFixture(fixtures.Fixture): def setUp(self): super(RpcServerFixture, self).setUp() endpoints = [self.endpoint, self] - transport = self.useFixture(TransportFixture(self.conf, self.url)) + transport = self.useFixture(RPCTransportFixture(self.conf, self.url)) self.server = oslo_messaging.get_rpc_server( transport=transport.transport, target=self.target, @@ -168,7 +186,7 @@ class RpcServerGroupFixture(fixtures.Fixture): else: raise ValueError("Invalid value for server: %r" % server) - transport = self.useFixture(TransportFixture(self.conf, self.url)) + transport = self.useFixture(RPCTransportFixture(self.conf, self.url)) client = ClientStub(transport.transport, target, cast=cast, timeout=5) transport.wait() @@ -345,7 +363,8 @@ class NotificationFixture(fixtures.Fixture): targets = [oslo_messaging.Target(topic=t) for t in self.topics] # add a special topic for internal notifications targets.append(oslo_messaging.Target(topic=self.name)) - transport = self.useFixture(TransportFixture(self.conf, self.url)) + transport = self.useFixture(NotificationTransportFixture(self.conf, + self.url)) self.server = self._get_server(transport, targets) self._ctrl = self.notifier('internal', topics=[self.name]) self._start() @@ -372,7 +391,8 @@ class NotificationFixture(fixtures.Fixture): raise Exception("Server did not shutdown properly") def notifier(self, publisher, topics=None): - transport = self.useFixture(TransportFixture(self.conf, self.url)) + transport = self.useFixture(NotificationTransportFixture(self.conf, + self.url)) n = notifier.Notifier(transport.transport, publisher, driver='messaging',