From ca6c34ac71a506026d3754584de7616ad2a7d8da Mon Sep 17 00:00:00 2001 From: Javeme Date: Thu, 7 Jan 2016 14:59:45 +0800 Subject: [PATCH] make enforce_type=True in CONF.set_override Each config option has limitation for type and value. If we use method CONF.set_override without parameter enforce_type=True, we may pass wrong type to config option. This commit makes sure calling method CONF.set_override with enforce_type=True. Change-Id: I1430c93777d6e5d98086a8700663ab9f58c1e5ab Closes-Bug: #1517839 --- oslo_messaging/conffixture.py | 5 +++-- oslo_messaging/tests/rpc/test_client.py | 2 +- oslo_messaging/tests/utils.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/oslo_messaging/conffixture.py b/oslo_messaging/conffixture.py index 0d05a5881..bb037b8db 100644 --- a/oslo_messaging/conffixture.py +++ b/oslo_messaging/conffixture.py @@ -128,7 +128,7 @@ class ConfFixture(fixtures.Fixture): @transport_driver.setter def transport_driver(self, value): - self.conf.set_override('rpc_backend', value) + self.conf.set_override('rpc_backend', value, enforce_type=True) @property def response_timeout(self): @@ -137,4 +137,5 @@ class ConfFixture(fixtures.Fixture): @response_timeout.setter def response_timeout(self, value): - self.conf.set_override('rpc_response_timeout', value) + self.conf.set_override('rpc_response_timeout', value, + enforce_type=True) diff --git a/oslo_messaging/tests/rpc/test_client.py b/oslo_messaging/tests/rpc/test_client.py index c5b7364d8..ebb72324b 100644 --- a/oslo_messaging/tests/rpc/test_client.py +++ b/oslo_messaging/tests/rpc/test_client.py @@ -221,7 +221,7 @@ class TestCallTimeout(test_utils.BaseTestCase): ('all_none', dict(confval=None, ctor=None, prepare=_notset, expect=None)), ('confval', - dict(confval=21.1, ctor=None, prepare=_notset, expect=21.1)), + dict(confval=21, ctor=None, prepare=_notset, expect=21)), ('ctor', dict(confval=None, ctor=21.1, prepare=_notset, expect=21.1)), ('ctor_zero', diff --git a/oslo_messaging/tests/utils.py b/oslo_messaging/tests/utils.py index eacfaedc8..aa2a56343 100644 --- a/oslo_messaging/tests/utils.py +++ b/oslo_messaging/tests/utils.py @@ -57,7 +57,7 @@ class BaseTestCase(base.BaseTestCase): """ group = kw.pop('group', None) for k, v in six.iteritems(kw): - self.conf.set_override(k, v, group) + self.conf.set_override(k, v, group, enforce_type=True) class ServerThreadHelper(threading.Thread):