Merge "Use messaging_conf fixture configuration by default"

This commit is contained in:
Jenkins 2014-03-28 18:47:41 +00:00 committed by Gerrit Code Review
commit 19053b6e65
8 changed files with 13 additions and 59 deletions

View File

@ -52,6 +52,8 @@ class ConfFixture(fixtures.Fixture):
'oslo.messaging._drivers.amqp', 'amqp_opts') 'oslo.messaging._drivers.amqp', 'amqp_opts')
_import_opts(self.conf, 'oslo.messaging.rpc.client', '_client_opts') _import_opts(self.conf, 'oslo.messaging.rpc.client', '_client_opts')
_import_opts(self.conf, 'oslo.messaging.transport', '_transport_opts') _import_opts(self.conf, 'oslo.messaging.transport', '_transport_opts')
_import_opts(self.conf,
'oslo.messaging.notify.notifier', '_notifier_opts')
def setUp(self): def setUp(self):
super(ConfFixture, self).setUp() super(ConfFixture, self).setUp()

View File

@ -23,7 +23,6 @@ class PublishErrorsHandlerTestCase(test_utils.BaseTestCase):
"""Tests for log.PublishErrorsHandler""" """Tests for log.PublishErrorsHandler"""
def setUp(self): def setUp(self):
super(PublishErrorsHandlerTestCase, self).setUp() super(PublishErrorsHandlerTestCase, self).setUp()
self.conf.register_opts(messaging.notify.notifier._notifier_opts)
self.publisherrorshandler = (log_handler. self.publisherrorshandler = (log_handler.
PublishErrorsHandler(logging.ERROR)) PublishErrorsHandler(logging.ERROR))

View File

@ -135,8 +135,6 @@ class TestMessagingNotifier(test_utils.BaseTestCase):
def setUp(self): def setUp(self):
super(TestMessagingNotifier, self).setUp() super(TestMessagingNotifier, self).setUp()
self.conf.register_opts(msg_notifier._notifier_opts)
self.logger = self.useFixture(_ReRaiseLoggedExceptionsFixture()).logger self.logger = self.useFixture(_ReRaiseLoggedExceptionsFixture()).logger
self.stubs.Set(_impl_messaging, 'LOG', self.logger) self.stubs.Set(_impl_messaging, 'LOG', self.logger)
self.stubs.Set(msg_notifier, '_LOG', self.logger) self.stubs.Set(msg_notifier, '_LOG', self.logger)
@ -149,8 +147,8 @@ class TestMessagingNotifier(test_utils.BaseTestCase):
if self.v2: if self.v2:
drivers.append('messagingv2') drivers.append('messagingv2')
self.config(notification_driver=drivers) self.config(notification_driver=drivers,
self.config(notification_topics=self.topics) notification_topics=self.topics)
transport = _FakeTransport(self.conf) transport = _FakeTransport(self.conf)
@ -251,10 +249,6 @@ class TestSerializer(test_utils.BaseTestCase):
class TestLogNotifier(test_utils.BaseTestCase): class TestLogNotifier(test_utils.BaseTestCase):
def setUp(self):
super(TestLogNotifier, self).setUp()
self.conf.register_opts(msg_notifier._notifier_opts)
@mock.patch('oslo.messaging.openstack.common.timeutils.utcnow') @mock.patch('oslo.messaging.openstack.common.timeutils.utcnow')
def test_notifier(self, mock_utcnow): def test_notifier(self, mock_utcnow):
self.config(notification_driver=['log']) self.config(notification_driver=['log'])

View File

@ -128,11 +128,11 @@ class TestQpidInvalidTopologyVersion(_QpidBaseTestCase):
# 1. qpid driver raises Exception(msg) for invalid topology version # 1. qpid driver raises Exception(msg) for invalid topology version
# 2. flake8 - H202 assertRaises Exception too broad # 2. flake8 - H202 assertRaises Exception too broad
exception_msg = ("Invalid value for qpid_topology_version: %d" % exception_msg = ("Invalid value for qpid_topology_version: %d" %
self.messaging_conf.conf.qpid_topology_version) self.conf.qpid_topology_version)
recvd_exc_msg = '' recvd_exc_msg = ''
try: try:
self.consumer_cls(self.messaging_conf.conf, self.consumer_cls(self.conf,
self.session_receive, self.session_receive,
msgid_or_topic, msgid_or_topic,
consumer_callback) consumer_callback)
@ -143,7 +143,7 @@ class TestQpidInvalidTopologyVersion(_QpidBaseTestCase):
recvd_exc_msg = '' recvd_exc_msg = ''
try: try:
self.publisher_cls(self.messaging_conf.conf, self.publisher_cls(self.conf,
self.session_send, self.session_send,
msgid_or_topic) msgid_or_topic)
except Exception as e: except Exception as e:
@ -185,11 +185,11 @@ class TestQpidDirectConsumerPublisher(_QpidBaseTestCase):
self.msgid = str(random.randint(1, 100)) self.msgid = str(random.randint(1, 100))
# create a DirectConsumer and DirectPublisher class objects # create a DirectConsumer and DirectPublisher class objects
self.dir_cons = qpid_driver.DirectConsumer(self.messaging_conf.conf, self.dir_cons = qpid_driver.DirectConsumer(self.conf,
self.session_receive, self.session_receive,
self.msgid, self.msgid,
self.consumer_callback) self.consumer_callback)
self.dir_pub = qpid_driver.DirectPublisher(self.messaging_conf.conf, self.dir_pub = qpid_driver.DirectPublisher(self.conf,
self.session_send, self.session_send,
self.msgid) self.msgid)
@ -341,7 +341,7 @@ class TestQpidTopicAndFanout(_QpidBaseTestCase):
def test_qpid_topic_and_fanout(self): def test_qpid_topic_and_fanout(self):
for receiver_id in range(self.no_receivers): for receiver_id in range(self.no_receivers):
consumer = self.consumer_cls(self.messaging_conf.conf, consumer = self.consumer_cls(self.conf,
self.session_receive, self.session_receive,
self.receive_topic, self.receive_topic,
self.consumer_callback) self.consumer_callback)
@ -353,7 +353,7 @@ class TestQpidTopicAndFanout(_QpidBaseTestCase):
self._receiver_threads.append(thread) self._receiver_threads.append(thread)
for sender_id in range(self.no_senders): for sender_id in range(self.no_senders):
publisher = self.publisher_cls(self.messaging_conf.conf, publisher = self.publisher_cls(self.conf,
self.session_send, self.session_send,
self.topic) self.topic)
self._senders.append(publisher) self._senders.append(publisher)

View File

@ -17,7 +17,6 @@ from oslo.config import cfg
import testscenarios import testscenarios
from oslo import messaging from oslo import messaging
from oslo.messaging.rpc import client as rpc_client
from oslo.messaging import serializer as msg_serializer from oslo.messaging import serializer as msg_serializer
from tests import utils as test_utils from tests import utils as test_utils
@ -48,10 +47,6 @@ class TestCastCall(test_utils.BaseTestCase):
args=dict(bar='blaa', foobar=11.01))), args=dict(bar='blaa', foobar=11.01))),
] ]
def setUp(self):
super(TestCastCall, self).setUp(conf=cfg.ConfigOpts())
self.conf.register_opts(rpc_client._client_opts)
def test_cast_call(self): def test_cast_call(self):
self.config(rpc_response_timeout=None) self.config(rpc_response_timeout=None)
@ -238,10 +233,6 @@ class TestCallTimeout(test_utils.BaseTestCase):
dict(confval=None, ctor=None, prepare=0, expect=0)), dict(confval=None, ctor=None, prepare=0, expect=0)),
] ]
def setUp(self):
super(TestCallTimeout, self).setUp(conf=cfg.ConfigOpts())
self.conf.register_opts(rpc_client._client_opts)
def test_call_timeout(self): def test_call_timeout(self):
self.config(rpc_response_timeout=self.confval) self.config(rpc_response_timeout=self.confval)
@ -277,10 +268,6 @@ class TestSerializer(test_utils.BaseTestCase):
retval='d')), retval='d')),
] ]
def setUp(self):
super(TestSerializer, self).setUp(conf=cfg.ConfigOpts())
self.conf.register_opts(rpc_client._client_opts)
def test_call_serializer(self): def test_call_serializer(self):
self.config(rpc_response_timeout=None) self.config(rpc_response_timeout=None)
@ -361,10 +348,6 @@ class TestVersionCap(test_utils.BaseTestCase):
testscenarios.multiply_scenarios(cls._call_vs_cast, testscenarios.multiply_scenarios(cls._call_vs_cast,
cls._cap_scenarios)) cls._cap_scenarios))
def setUp(self):
super(TestVersionCap, self).setUp(conf=cfg.ConfigOpts())
self.conf.register_opts(rpc_client._client_opts)
def test_version_cap(self): def test_version_cap(self):
self.config(rpc_response_timeout=None) self.config(rpc_response_timeout=None)
@ -459,10 +442,6 @@ class TestCanSendVersion(test_utils.BaseTestCase):
can_send=False)), can_send=False)),
] ]
def setUp(self):
super(TestCanSendVersion, self).setUp(conf=cfg.ConfigOpts())
self.conf.register_opts(rpc_client._client_opts)
def test_version_cap(self): def test_version_cap(self):
self.config(rpc_response_timeout=None) self.config(rpc_response_timeout=None)

View File

@ -112,10 +112,6 @@ class GetTransportTestCase(test_utils.BaseTestCase):
allowed=[]))), allowed=[]))),
] ]
def setUp(self):
super(GetTransportTestCase, self).setUp(conf=cfg.ConfigOpts())
self.conf.register_opts(transport._transport_opts)
def test_get_transport(self): def test_get_transport(self):
self.config(rpc_backend=self.rpc_backend, self.config(rpc_backend=self.rpc_backend,
control_exchange=self.control_exchange, control_exchange=self.control_exchange,
@ -171,10 +167,6 @@ class GetTransportSadPathTestCase(test_utils.BaseTestCase):
driver='testbackend'))), driver='testbackend'))),
] ]
def setUp(self):
super(GetTransportSadPathTestCase, self).setUp(conf=cfg.ConfigOpts())
self.conf.register_opts(transport._transport_opts)
def test_get_transport_sad(self): def test_get_transport_sad(self):
self.config(rpc_backend=self.rpc_backend, self.config(rpc_backend=self.rpc_backend,
transport_url=self.transport_url) transport_url=self.transport_url)

View File

@ -13,11 +13,9 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo.config import cfg
import testscenarios import testscenarios
from oslo import messaging from oslo import messaging
from oslo.messaging import transport
from tests import utils as test_utils from tests import utils as test_utils
load_tests = testscenarios.load_tests_apply_scenarios load_tests = testscenarios.load_tests_apply_scenarios
@ -120,10 +118,6 @@ class TestParseURL(test_utils.BaseTestCase):
]))), ]))),
] ]
def setUp(self):
super(TestParseURL, self).setUp(conf=cfg.ConfigOpts())
self.conf.register_opts(transport._transport_opts)
def test_parse_url(self): def test_parse_url(self):
self.config(rpc_backend=None) self.config(rpc_backend=None)
@ -223,10 +217,6 @@ class TestFormatURL(test_utils.BaseTestCase):
expected='testtransport://b%24:s%26@host:10//%24')), expected='testtransport://b%24:s%26@host:10//%24')),
] ]
def setUp(self):
super(TestFormatURL, self).setUp(conf=cfg.ConfigOpts())
self.conf.register_opts(transport._transport_opts)
def test_parse_url(self): def test_parse_url(self):
self.config(rpc_backend=self.rpc_backend) self.config(rpc_backend=self.rpc_backend)

View File

@ -32,12 +32,10 @@ class BaseTestCase(base.BaseTestCase):
def setUp(self, conf=cfg.CONF): def setUp(self, conf=cfg.CONF):
super(BaseTestCase, self).setUp() super(BaseTestCase, self).setUp()
self.conf = conf
self.addCleanup(self.conf.reset)
from oslo.messaging import conffixture from oslo.messaging import conffixture
self.messaging_conf = self.useFixture( self.messaging_conf = self.useFixture(conffixture.ConfFixture(conf))
conffixture.ConfFixture(self.conf)) self.conf = self.messaging_conf.conf
moxfixture = self.useFixture(moxstubout.MoxStubout()) moxfixture = self.useFixture(moxstubout.MoxStubout())
self.mox = moxfixture.mox self.mox = moxfixture.mox