From 168f6cc2bb72591012d54b15e1c2e4a0332fb5c9 Mon Sep 17 00:00:00 2001 From: Flavio Percoco Date: Tue, 7 Jul 2015 08:51:12 +0200 Subject: [PATCH] Make heartbeat the default When heartbeat was introduced, it couldn't be enabled by default because it depended on a minimum kombu version that we couldn't bump to at the end of the release. Now that Liberty is open and the minimum required version has been bumped, I'm enabling heartbeat by default. The threshold this patch uses is `60` which is the one gotten from tests and other deployments. Lets make sure this is a sande default before merging the patch. Change-Id: I21c29c328ef9936e76a215ab15962b46247dadd9 --- oslo_messaging/_drivers/impl_rabbit.py | 2 +- oslo_messaging/tests/drivers/test_impl_rabbit.py | 10 ++-------- oslo_messaging/tests/functional/test_functional.py | 8 ++++++++ oslo_messaging/tests/functional/utils.py | 9 ++++++--- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/oslo_messaging/_drivers/impl_rabbit.py b/oslo_messaging/_drivers/impl_rabbit.py index aa6dc3643..fa0591e78 100644 --- a/oslo_messaging/_drivers/impl_rabbit.py +++ b/oslo_messaging/_drivers/impl_rabbit.py @@ -136,7 +136,7 @@ rabbit_opts = [ 'If you change this option, you must wipe the ' 'RabbitMQ database.'), cfg.IntOpt('heartbeat_timeout_threshold', - default=0, + default=60, help="Number of seconds after which the Rabbit broker is " "considered down if heartbeat's keep-alive fails " "(0 disable the heartbeat). EXPERIMENTAL"), diff --git a/oslo_messaging/tests/drivers/test_impl_rabbit.py b/oslo_messaging/tests/drivers/test_impl_rabbit.py index a86ac599e..949968320 100644 --- a/oslo_messaging/tests/drivers/test_impl_rabbit.py +++ b/oslo_messaging/tests/drivers/test_impl_rabbit.py @@ -58,12 +58,6 @@ class TestDeprecatedRabbitDriverLoad(test_utils.BaseTestCase): class TestHeartbeat(test_utils.BaseTestCase): - def setUp(self): - super(TestHeartbeat, self).setUp( - conf=cfg.ConfigOpts()) - self.config(heartbeat_timeout_threshold=60, - group='oslo_messaging_rabbit') - @mock.patch('oslo_messaging._drivers.impl_rabbit.LOG') @mock.patch('kombu.connection.Connection.heartbeat_check') @mock.patch('oslo_messaging._drivers.impl_rabbit.Connection.' @@ -128,7 +122,7 @@ class TestRabbitDriverLoad(test_utils.BaseTestCase): @mock.patch('oslo_messaging._drivers.impl_rabbit.Connection.ensure') @mock.patch('oslo_messaging._drivers.impl_rabbit.Connection.reset') def test_driver_load(self, fake_ensure, fake_reset): - self.config(heartbeat_timeout_threshold=0, + self.config(heartbeat_timeout_threshold=60, group='oslo_messaging_rabbit') self.messaging_conf.transport_driver = self.transport_driver transport = oslo_messaging.get_transport(self.conf) @@ -173,7 +167,7 @@ class TestRabbitDriverLoadSSL(test_utils.BaseTestCase): 'on_blocked': mock.ANY, 'on_unblocked': mock.ANY}, ssl=self.expected, login_method='AMQPLAIN', - heartbeat=0, failover_strategy="shuffle") + heartbeat=60, failover_strategy="shuffle") class TestRabbitPublisher(test_utils.BaseTestCase): diff --git a/oslo_messaging/tests/functional/test_functional.py b/oslo_messaging/tests/functional/test_functional.py index 32cc0190c..c381e5bd9 100644 --- a/oslo_messaging/tests/functional/test_functional.py +++ b/oslo_messaging/tests/functional/test_functional.py @@ -15,6 +15,7 @@ import time import uuid import concurrent.futures +from oslo_config import cfg from testtools import matchers import oslo_messaging @@ -22,6 +23,13 @@ from oslo_messaging.tests.functional import utils class CallTestCase(utils.SkipIfNoTransportURL): + + def setUp(self): + super(CallTestCase, self).setUp(conf=cfg.ConfigOpts()) + + self.config(heartbeat_timeout_threshold=0, + group='oslo_messaging_rabbit') + def test_specific_server(self): group = self.useFixture(utils.RpcServerGroupFixture(self.url)) client = group.client(1) diff --git a/oslo_messaging/tests/functional/utils.py b/oslo_messaging/tests/functional/utils.py index 8ac087bc4..7c82939e8 100644 --- a/oslo_messaging/tests/functional/utils.py +++ b/oslo_messaging/tests/functional/utils.py @@ -61,7 +61,10 @@ class TransportFixture(fixtures.Fixture): self.transport = oslo_messaging.get_transport(cfg.CONF, url=self.url) def cleanUp(self): - self.transport.cleanup() + try: + self.transport.cleanup() + except fixtures.TimeoutException: + pass super(TransportFixture, self).cleanUp() def wait(self): @@ -271,8 +274,8 @@ class IsValidDistributionOf(object): class SkipIfNoTransportURL(test_utils.BaseTestCase): - def setUp(self): - super(SkipIfNoTransportURL, self).setUp() + def setUp(self, conf=cfg.CONF): + super(SkipIfNoTransportURL, self).setUp(conf=conf) self.url = os.environ.get('TRANSPORT_URL') if not self.url: self.skipTest("No transport url configured")