From f64154482f4a146a61e460f26cde7266a9051051 Mon Sep 17 00:00:00 2001 From: Javier Pena Date: Tue, 18 Apr 2017 14:10:22 +0200 Subject: [PATCH] Fix unit tests for oslo.config 4.0 oslo.config 4.0 will check overridden value type by default[1], which exposes a couple issues in Ironic: - default_storage_interface is defined as ListOpt, when it should be StrOpt. - test_get_client_with_endpoint_override sets an invalid url for config option url, which fails when checked by oslo.config. [1] https://review.openstack.org/#/c/328692 Change-Id: Id166da73a41c8c46d9f3e239579d0cafb93bf69f Closes-Bug: #1517839 --- etc/ironic/ironic.conf.sample | 16 +++++++++++++--- ironic/conf/default.py | 4 ++-- ironic/tests/unit/common/test_cinder.py | 4 ++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/etc/ironic/ironic.conf.sample b/etc/ironic/ironic.conf.sample index 55b72b26e6..46fa2e29d5 100644 --- a/etc/ironic/ironic.conf.sample +++ b/etc/ironic/ironic.conf.sample @@ -243,7 +243,7 @@ # have storage_interface field set. A complete list of storage # interfaces present on your system may be found by # enumerating the "ironic.hardware.interfaces.storage" -# entrypoint. (list value) +# entrypoint. (string value) #default_storage_interface = # Specify the list of vendor interfaces to load during service @@ -2564,10 +2564,20 @@ # value) #sasl_config_name = -# User name for message broker authentication (string value) +# DEPRECATED: User name for message broker authentication +# (string value) +# This option is deprecated for removal. +# Its value may be silently ignored in the future. +# Reason: Should use configuration option transport_url to +# provide the username. #username = -# Password for message broker authentication (string value) +# DEPRECATED: Password for message broker authentication +# (string value) +# This option is deprecated for removal. +# Its value may be silently ignored in the future. +# Reason: Should use configuration option transport_url to +# provide the password. #password = # Seconds to pause before attempting to re-connect. (integer diff --git a/ironic/conf/default.py b/ironic/conf/default.py index 476e7b8613..de45b7e11e 100644 --- a/ironic/conf/default.py +++ b/ironic/conf/default.py @@ -137,8 +137,8 @@ driver_opts = [ cfg.ListOpt('enabled_storage_interfaces', default=['noop'], help=_ENABLED_IFACE_HELP.format('storage')), - cfg.ListOpt('default_storage_interface', - help=_DEFAULT_IFACE_HELP.format('storage')), + cfg.StrOpt('default_storage_interface', + help=_DEFAULT_IFACE_HELP.format('storage')), cfg.ListOpt('enabled_vendor_interfaces', default=['no-vendor'], help=_ENABLED_IFACE_HELP.format('vendor')), diff --git a/ironic/tests/unit/common/test_cinder.py b/ironic/tests/unit/common/test_cinder.py index de1a723fb7..e5a1167b36 100644 --- a/ironic/tests/unit/common/test_cinder.py +++ b/ironic/tests/unit/common/test_cinder.py @@ -72,10 +72,10 @@ class TestCinderClient(base.TestCase): def test_get_client_with_endpoint_override( self, mock_client_init, mock_session): - self.config(url='test-url', group='cinder') + self.config(url='http://test-url', group='cinder') mock_session_obj = mock.Mock() expected = {'connect_retries': 2, - 'endpoint_override': 'test-url', + 'endpoint_override': 'http://test-url', 'session': mock_session_obj} mock_session.return_value = mock_session_obj mock_client_init.return_value = None