summaryrefslogtreecommitdiff
path: root/ironic
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-08-09 14:32:18 +0000
committerGerrit Code Review <review@openstack.org>2022-08-09 14:32:18 +0000
commit3058994fc017e46a4be8069dcfff1c460acc6d0f (patch)
tree7efe3ea4a00c3c7c408c1e84b1a0306d6b4b1a56 /ironic
parent1d9c10cfca030f607df511a1c6355ee5831c81dc (diff)
parent3b28d0984d5eb82320c632dd5840cebf6d0762ad (diff)
downloadironic-3058994fc017e46a4be8069dcfff1c460acc6d0f.tar.gz
Merge "Modify test code to avoid CONF modification affection"
Diffstat (limited to 'ironic')
-rw-r--r--ironic/tests/unit/api/test_audit.py7
-rw-r--r--ironic/tests/unit/api/test_ospmiddleware.py4
-rw-r--r--ironic/tests/unit/common/test_molds.py88
-rw-r--r--ironic/tests/unit/drivers/modules/ilo/test_boot.py18
-rw-r--r--ironic/tests/unit/drivers/modules/ilo/test_common.py42
-rw-r--r--ironic/tests/unit/drivers/modules/irmc/test_boot.py68
-rw-r--r--ironic/tests/unit/drivers/modules/redfish/test_firmware_utils.py26
-rw-r--r--ironic/tests/unit/drivers/modules/redfish/test_management.py10
-rw-r--r--ironic/tests/unit/drivers/modules/test_snmp.py2
9 files changed, 132 insertions, 133 deletions
diff --git a/ironic/tests/unit/api/test_audit.py b/ironic/tests/unit/api/test_audit.py
index d85ed3e85..cedeabf17 100644
--- a/ironic/tests/unit/api/test_audit.py
+++ b/ironic/tests/unit/api/test_audit.py
@@ -35,7 +35,7 @@ class TestAuditMiddleware(base.BaseApiTest):
@mock.patch.object(audit, 'AuditMiddleware', autospec=True)
def test_enable_audit_request(self, mock_audit):
- CONF.audit.enabled = True
+ CONF.set_override('enabled', True, 'audit')
self._make_app()
mock_audit.assert_called_once_with(
mock.ANY,
@@ -44,14 +44,13 @@ class TestAuditMiddleware(base.BaseApiTest):
@mock.patch.object(audit, 'AuditMiddleware', autospec=True)
def test_enable_audit_request_error(self, mock_audit):
- CONF.audit.enabled = True
+ CONF.set_override('enabled', True, 'audit')
mock_audit.side_effect = IOError("file access error")
-
self.assertRaises(exception.InputFileError,
self._make_app)
@mock.patch.object(audit, 'AuditMiddleware', autospec=True)
def test_disable_audit_request(self, mock_audit):
- CONF.audit.enabled = False
+ CONF.set_override('enabled', False, 'audit')
self._make_app()
self.assertFalse(mock_audit.called)
diff --git a/ironic/tests/unit/api/test_ospmiddleware.py b/ironic/tests/unit/api/test_ospmiddleware.py
index 555251dd7..f814d5688 100644
--- a/ironic/tests/unit/api/test_ospmiddleware.py
+++ b/ironic/tests/unit/api/test_ospmiddleware.py
@@ -32,12 +32,12 @@ class TestOsprofilerWsgiMiddleware(base.BaseApiTest):
@mock.patch.object(web, 'WsgiMiddleware', autospec=True)
def test_enable_osp_wsgi_request(self, mock_ospmiddleware):
- CONF.profiler.enabled = True
+ CONF.set_override('enabled', True, 'profiler')
self._make_app()
mock_ospmiddleware.assert_called_once_with(mock.ANY)
@mock.patch.object(web, 'WsgiMiddleware', autospec=True)
def test_disable_osp_wsgi_request(self, mock_ospmiddleware):
- CONF.profiler.enabled = False
+ CONF.set_override('enabled', False, 'profiler')
self._make_app()
self.assertFalse(mock_ospmiddleware.called)
diff --git a/ironic/tests/unit/common/test_molds.py b/ironic/tests/unit/common/test_molds.py
index bd2c37e47..810dd61bc 100644
--- a/ironic/tests/unit/common/test_molds.py
+++ b/ironic/tests/unit/common/test_molds.py
@@ -38,7 +38,7 @@ class ConfigurationMoldTestCase(db_base.DbTestCase):
mock_session = mock.Mock()
mock_session.get_token.return_value = 'token'
mock_swift.return_value = mock_session
- cfg.CONF.molds.storage = 'swift'
+ cfg.CONF.set_override('storage', 'swift', 'molds')
url = 'https://example.com/file1'
data = {'key': 'value'}
@@ -54,7 +54,7 @@ class ConfigurationMoldTestCase(db_base.DbTestCase):
mock_session = mock.Mock()
mock_session.get_token.return_value = None
mock_swift.return_value = mock_session
- cfg.CONF.molds.storage = 'swift'
+ cfg.CONF.set_override('storage', 'swift', 'molds')
url = 'https://example.com/file1'
data = {'key': 'value'}
@@ -66,9 +66,9 @@ class ConfigurationMoldTestCase(db_base.DbTestCase):
@mock.patch.object(requests, 'put', autospec=True)
def test_save_configuration_http(self, mock_put):
- cfg.CONF.molds.storage = 'http'
- cfg.CONF.molds.user = 'user'
- cfg.CONF.molds.password = 'password'
+ cfg.CONF.set_override('storage', 'http', 'molds')
+ cfg.CONF.set_override('user', 'user', 'molds')
+ cfg.CONF.set_override('password', 'password', 'molds')
url = 'https://example.com/file1'
data = {'key': 'value'}
@@ -81,9 +81,9 @@ class ConfigurationMoldTestCase(db_base.DbTestCase):
@mock.patch.object(requests, 'put', autospec=True)
def test_save_configuration_http_noauth(self, mock_put):
- cfg.CONF.molds.storage = 'http'
- cfg.CONF.molds.user = None
- cfg.CONF.molds.password = None
+ cfg.CONF.set_override('storage', 'http', 'molds')
+ cfg.CONF.set_override('user', None, 'molds')
+ cfg.CONF.set_override('password', None, 'molds')
url = 'https://example.com/file1'
data = {'key': 'value'}
@@ -95,9 +95,9 @@ class ConfigurationMoldTestCase(db_base.DbTestCase):
@mock.patch.object(requests, 'put', autospec=True)
def test_save_configuration_http_error(self, mock_put):
- cfg.CONF.molds.storage = 'http'
- cfg.CONF.molds.user = 'user'
- cfg.CONF.molds.password = 'password'
+ cfg.CONF.set_override('storage', 'http', 'molds')
+ cfg.CONF.set_override('user', 'user', 'molds')
+ cfg.CONF.set_override('password', 'password', 'molds')
response = mock.MagicMock()
response.status_code = 404
response.raise_for_status.side_effect = requests.exceptions.HTTPError
@@ -116,11 +116,11 @@ class ConfigurationMoldTestCase(db_base.DbTestCase):
@mock.patch.object(requests, 'put', autospec=True)
def test_save_configuration_connection_error(self, mock_put):
- cfg.CONF.molds.storage = 'http'
- cfg.CONF.molds.user = 'user'
- cfg.CONF.molds.password = 'password'
- cfg.CONF.molds.retry_interval = 0
- cfg.CONF.molds.retry_attempts = 3
+ cfg.CONF.set_override('storage', 'http', 'molds')
+ cfg.CONF.set_override('user', 'user', 'molds')
+ cfg.CONF.set_override('password', 'password', 'molds')
+ cfg.CONF.set_override('retry_interval', 0, 'molds')
+ cfg.CONF.set_override('retry_attempts', 3, 'molds')
response = mock.MagicMock()
mock_put.side_effect = [
requests.exceptions.ConnectTimeout,
@@ -137,11 +137,11 @@ class ConfigurationMoldTestCase(db_base.DbTestCase):
@mock.patch.object(requests, 'put', autospec=True)
def test_save_configuration_connection_error_exceeded(self, mock_put):
- cfg.CONF.molds.storage = 'http'
- cfg.CONF.molds.user = 'user'
- cfg.CONF.molds.password = 'password'
- cfg.CONF.molds.retry_interval = 0
- cfg.CONF.molds.retry_attempts = 2
+ cfg.CONF.set_override('storage', 'http', 'molds')
+ cfg.CONF.set_override('user', 'user', 'molds')
+ cfg.CONF.set_override('password', 'password', 'molds')
+ cfg.CONF.set_override('retry_interval', 0, 'molds')
+ cfg.CONF.set_override('retry_attempts', 2, 'molds')
mock_put.side_effect = [
requests.exceptions.ConnectTimeout,
requests.exceptions.ConnectionError]
@@ -164,7 +164,7 @@ class ConfigurationMoldTestCase(db_base.DbTestCase):
mock_session = mock.Mock()
mock_session.get_token.return_value = 'token'
mock_swift.return_value = mock_session
- cfg.CONF.molds.storage = 'swift'
+ cfg.CONF.set_override('storage', 'swift', 'molds')
response = mock.MagicMock()
response.status_code = 200
response.content = "{'key': 'value'}"
@@ -185,7 +185,7 @@ class ConfigurationMoldTestCase(db_base.DbTestCase):
mock_session = mock.Mock()
mock_session.get_token.return_value = None
mock_swift.return_value = mock_session
- cfg.CONF.molds.storage = 'swift'
+ cfg.CONF.set_override('storage', 'swift', 'molds')
url = 'https://example.com/file1'
with task_manager.acquire(self.context, self.node.uuid) as task:
@@ -196,9 +196,9 @@ class ConfigurationMoldTestCase(db_base.DbTestCase):
@mock.patch.object(requests, 'get', autospec=True)
def test_get_configuration_http(self, mock_get):
- cfg.CONF.molds.storage = 'http'
- cfg.CONF.molds.user = 'user'
- cfg.CONF.molds.password = 'password'
+ cfg.CONF.set_override('storage', 'http', 'molds')
+ cfg.CONF.set_override('user', 'user', 'molds')
+ cfg.CONF.set_override('password', 'password', 'molds')
response = mock.MagicMock()
response.status_code = 200
response.content = "{'key': 'value'}"
@@ -215,9 +215,9 @@ class ConfigurationMoldTestCase(db_base.DbTestCase):
@mock.patch.object(requests, 'get', autospec=True)
def test_get_configuration_http_noauth(self, mock_get):
- cfg.CONF.molds.storage = 'http'
- cfg.CONF.molds.user = None
- cfg.CONF.molds.password = None
+ cfg.CONF.set_override('storage', 'http', 'molds')
+ cfg.CONF.set_override('user', None, 'molds')
+ cfg.CONF.set_override('password', None, 'molds')
response = mock.MagicMock()
response.status_code = 200
response.content = "{'key': 'value'}"
@@ -233,9 +233,9 @@ class ConfigurationMoldTestCase(db_base.DbTestCase):
@mock.patch.object(requests, 'get', autospec=True)
def test_get_configuration_http_error(self, mock_get):
- cfg.CONF.molds.storage = 'http'
- cfg.CONF.molds.user = 'user'
- cfg.CONF.molds.password = 'password'
+ cfg.CONF.set_override('storage', 'http', 'molds')
+ cfg.CONF.set_override('user', 'user', 'molds')
+ cfg.CONF.set_override('password', 'password', 'molds')
response = mock.MagicMock()
response.status_code = 404
response.raise_for_status.side_effect = requests.exceptions.HTTPError
@@ -253,11 +253,11 @@ class ConfigurationMoldTestCase(db_base.DbTestCase):
@mock.patch.object(requests, 'get', autospec=True)
def test_get_configuration_connection_error(self, mock_get):
- cfg.CONF.molds.storage = 'http'
- cfg.CONF.molds.user = 'user'
- cfg.CONF.molds.password = 'password'
- cfg.CONF.molds.retry_interval = 0
- cfg.CONF.molds.retry_attempts = 3
+ cfg.CONF.set_override('storage', 'http', 'molds')
+ cfg.CONF.set_override('user', 'user', 'molds')
+ cfg.CONF.set_override('password', 'password', 'molds')
+ cfg.CONF.set_override('retry_interval', 0, 'molds')
+ cfg.CONF.set_override('retry_attempts', 3, 'molds')
response = mock.MagicMock()
mock_get.side_effect = [
requests.exceptions.ConnectTimeout,
@@ -274,11 +274,11 @@ class ConfigurationMoldTestCase(db_base.DbTestCase):
@mock.patch.object(requests, 'get', autospec=True)
def test_get_configuration_mold_connection_error_exceeded(self, mock_get):
- cfg.CONF.molds.storage = 'http'
- cfg.CONF.molds.user = 'user'
- cfg.CONF.molds.password = 'password'
- cfg.CONF.molds.retry_interval = 0
- cfg.CONF.molds.retry_attempts = 2
+ cfg.CONF.set_override('storage', 'http', 'molds')
+ cfg.CONF.set_override('user', 'user', 'molds')
+ cfg.CONF.set_override('password', 'password', 'molds')
+ cfg.CONF.set_override('retry_interval', 0, 'molds')
+ cfg.CONF.set_override('retry_attempts', 2, 'molds')
mock_get.side_effect = [
requests.exceptions.ConnectTimeout,
requests.exceptions.ConnectionError]
@@ -296,7 +296,7 @@ class ConfigurationMoldTestCase(db_base.DbTestCase):
@mock.patch.object(requests, 'get', autospec=True)
def test_get_configuration_empty(self, mock_get):
- cfg.CONF.molds.storage = 'http'
+ cfg.CONF.set_override('storage', 'http', 'molds')
response = mock.MagicMock()
response.status_code = 200
response.content = ''
@@ -309,7 +309,7 @@ class ConfigurationMoldTestCase(db_base.DbTestCase):
@mock.patch.object(requests, 'get', autospec=True)
def test_get_configuration_invalid_json(self, mock_get):
- cfg.CONF.molds.storage = 'http'
+ cfg.CONF.set_override('storage', 'http', 'molds')
response = mock.MagicMock()
response.status_code = 200
response.content = 'not json'
diff --git a/ironic/tests/unit/drivers/modules/ilo/test_boot.py b/ironic/tests/unit/drivers/modules/ilo/test_boot.py
index 5c4314082..8aa6f78da 100644
--- a/ironic/tests/unit/drivers/modules/ilo/test_boot.py
+++ b/ironic/tests/unit/drivers/modules/ilo/test_boot.py
@@ -116,9 +116,9 @@ class IloBootCommonMethodsTestCase(test_common.BaseIloTest):
self.assertEqual(expected_driver_info, actual_driver_info)
def test_parse_driver_info_deploy_config(self):
- CONF.conductor.deploy_kernel = 'kernel'
- CONF.conductor.deploy_ramdisk = 'ramdisk'
- CONF.conductor.bootloader = 'bootloader'
+ CONF.set_override('deploy_kernel', 'kernel', 'conductor')
+ CONF.set_override('deploy_ramdisk', 'ramdisk', 'conductor')
+ CONF.set_override('bootloader', 'bootloader', 'conductor')
expected_driver_info = {'deploy_kernel': 'kernel',
'deploy_ramdisk': 'ramdisk',
'bootloader': 'bootloader',
@@ -128,10 +128,9 @@ class IloBootCommonMethodsTestCase(test_common.BaseIloTest):
self.assertEqual(expected_driver_info, actual_driver_info)
def test_parse_driver_info_rescue_config(self):
- CONF.conductor.rescue_kernel = 'kernel'
- CONF.conductor.rescue_ramdisk = 'ramdisk'
- CONF.conductor.bootloader = 'bootloader'
-
+ CONF.set_override('rescue_kernel', 'kernel', 'conductor')
+ CONF.set_override('rescue_ramdisk', 'ramdisk', 'conductor')
+ CONF.set_override('bootloader', 'bootloader', 'conductor')
expected_driver_info = {'rescue_kernel': 'kernel',
'rescue_ramdisk': 'ramdisk',
'bootloader': 'bootloader',
@@ -141,9 +140,8 @@ class IloBootCommonMethodsTestCase(test_common.BaseIloTest):
self.assertEqual(expected_driver_info, actual_driver_info)
def test_parse_driver_info_bootloader_none(self):
- CONF.conductor.deploy_kernel = 'kernel'
- CONF.conductor.deploy_ramdisk = 'ramdisk'
-
+ CONF.set_override('deploy_kernel', 'kernel', 'conductor')
+ CONF.set_override('deploy_ramdisk', 'ramdisk', 'conductor')
self.assertRaisesRegex(exception.MissingParameterValue, 'bootloader',
ilo_boot.parse_driver_info, self.node)
diff --git a/ironic/tests/unit/drivers/modules/ilo/test_common.py b/ironic/tests/unit/drivers/modules/ilo/test_common.py
index 605124b69..352eb0837 100644
--- a/ironic/tests/unit/drivers/modules/ilo/test_common.py
+++ b/ironic/tests/unit/drivers/modules/ilo/test_common.py
@@ -434,8 +434,8 @@ class IloCommonMethodsTestCase(BaseIloTest):
tempfile_mock.return_value = mock_image_file_handle
self.config(use_web_server_for_images=True, group='ilo')
deploy_args = {'arg1': 'val1', 'arg2': 'val2'}
- CONF.deploy.http_url = "http://abc.com/httpboot"
- CONF.deploy.http_root = "/httpboot"
+ CONF.set_override('http_url', 'http://abc.com/httpboot', 'deploy')
+ CONF.set_override('http_root', '/httpboot', 'deploy')
with task_manager.acquire(self.context, self.node.uuid,
shared=False) as task:
@@ -676,8 +676,8 @@ class IloCommonMethodsTestCase(BaseIloTest):
swift_obj_mock = swift_api_mock.return_value
boot_iso = 'swift:object-name'
swift_obj_mock.get_temp_url.return_value = 'image_url'
- CONF.ilo.swift_ilo_container = 'ilo_cont'
- CONF.ilo.swift_object_expiry_timeout = 1
+ CONF.set_override('swift_ilo_container', 'ilo_cont', 'ilo')
+ CONF.set_override('swift_object_expiry_timeout', 1, 'ilo')
with task_manager.acquire(self.context, self.node.uuid,
shared=False) as task:
ilo_common.setup_vmedia_for_boot(task, boot_iso)
@@ -704,7 +704,7 @@ class IloCommonMethodsTestCase(BaseIloTest):
def test_cleanup_vmedia_boot(self, get_name_mock, swift_api_mock,
eject_mock):
swift_obj_mock = swift_api_mock.return_value
- CONF.ilo.swift_ilo_container = 'ilo_cont'
+ CONF.set_override('swift_ilo_container', 'ilo_cont', 'ilo')
get_name_mock.return_value = 'image-node-uuid'
@@ -727,7 +727,7 @@ class IloCommonMethodsTestCase(BaseIloTest):
exc = exception.SwiftOperationError('error')
swift_obj_mock = swift_api_mock.return_value
swift_obj_mock.delete_object.side_effect = exc
- CONF.ilo.swift_ilo_container = 'ilo_cont'
+ CONF.set_override('swift_ilo_container', 'ilo_cont', 'ilo')
get_name_mock.return_value = 'image-node-uuid'
@@ -752,7 +752,7 @@ class IloCommonMethodsTestCase(BaseIloTest):
exc = exception.SwiftObjectNotFoundError('error')
swift_obj_mock = swift_api_mock.return_value
swift_obj_mock.delete_object.side_effect = exc
- CONF.ilo.swift_ilo_container = 'ilo_cont'
+ CONF.set_override('swift_ilo_container', 'ilo_cont', 'ilo')
get_name_mock.return_value = 'image-node-uuid'
@@ -771,7 +771,7 @@ class IloCommonMethodsTestCase(BaseIloTest):
def test_cleanup_vmedia_boot_for_webserver(self,
destroy_image_mock,
eject_mock):
- CONF.ilo.use_web_server_for_images = True
+ CONF.set_override('use_web_server_for_images', True, 'ilo')
with task_manager.acquire(self.context, self.node.uuid,
shared=False) as task:
@@ -932,8 +932,8 @@ class IloCommonMethodsTestCase(BaseIloTest):
autospec=True)
def test_copy_image_to_web_server(self, copy_mock,
chmod_mock):
- CONF.deploy.http_url = "http://x.y.z.a/webserver/"
- CONF.deploy.http_root = "/webserver"
+ CONF.set_override('http_url', 'http://x.y.z.a/webserver/', 'deploy')
+ CONF.set_override('http_root', '/webserver', 'deploy')
expected_url = "http://x.y.z.a/webserver/image-UUID"
source = 'tmp_image_file'
destination = "image-UUID"
@@ -949,8 +949,8 @@ class IloCommonMethodsTestCase(BaseIloTest):
autospec=True)
def test_copy_image_to_web_server_fails(self, copy_mock,
chmod_mock):
- CONF.deploy.http_url = "http://x.y.z.a/webserver/"
- CONF.deploy.http_root = "/webserver"
+ CONF.set_override('http_url', 'http://x.y.z.a/webserver/', 'deploy')
+ CONF.set_override('http_root', '/webserver', 'deploy')
source = 'tmp_image_file'
destination = "image-UUID"
image_path = "/webserver/image-UUID"
@@ -965,8 +965,8 @@ class IloCommonMethodsTestCase(BaseIloTest):
@mock.patch.object(ilo_common, 'ironic_utils', autospec=True)
def test_remove_image_from_web_server(self, utils_mock):
# | GIVEN |
- CONF.deploy.http_url = "http://x.y.z.a/webserver/"
- CONF.deploy.http_root = "/webserver"
+ CONF.set_override('http_url', 'http://x.y.z.a/webserver/', 'deploy')
+ CONF.set_override('http_root', '/webserver', 'deploy')
object_name = 'tmp_image_file'
# | WHEN |
ilo_common.remove_image_from_web_server(object_name)
@@ -1076,7 +1076,7 @@ class IloCommonMethodsTestCase(BaseIloTest):
def test_destroy_floppy_image_from_web_server(self, get_floppy_name_mock,
utils_mock):
get_floppy_name_mock.return_value = 'image-uuid'
- CONF.deploy.http_root = "/webserver/"
+ CONF.set_override('http_root', '/webserver/', 'deploy')
with task_manager.acquire(self.context, self.node.uuid,
shared=False) as task:
ilo_common.destroy_floppy_image_from_web_server(task.node)
@@ -1220,7 +1220,7 @@ class IloCommonMethodsTestCase(BaseIloTest):
autospec=True)
def test__get_certificate_file_list_none(self, path_exists_mock):
cl = None
- CONF.webserver_verify_ca = '/file/path'
+ CONF.set_override('webserver_verify_ca', '/file/path')
path_exists_mock.return_value = True
expected = ['/file/path']
actual = ilo_common._get_certificate_file_list(cl)
@@ -1230,7 +1230,7 @@ class IloCommonMethodsTestCase(BaseIloTest):
autospec=True)
def test__get_certificate_file_list_empty(self, path_exists_mock):
cl = []
- CONF.webserver_verify_ca = '/file/path'
+ CONF.set_override('webserver_verify_ca', '/file/path')
path_exists_mock.return_value = True
expected = ['/file/path']
actual = ilo_common._get_certificate_file_list(cl)
@@ -1240,7 +1240,7 @@ class IloCommonMethodsTestCase(BaseIloTest):
autospec=True)
def test__get_certificate_file_list_empty_no_path(self, path_exists_mock):
cl = []
- CONF.webserver_verify_ca = '/file/path'
+ CONF.set_override('webserver_verify_ca', '/file/path')
path_exists_mock.return_value = False
expected = []
actual = ilo_common._get_certificate_file_list(cl)
@@ -1248,14 +1248,14 @@ class IloCommonMethodsTestCase(BaseIloTest):
def test__get_certificate_file_list(self):
cl = ['file/path/a', 'file/path/b']
- CONF.webserver_verify_ca = '/file/path/c'
+ CONF.set_override('webserver_verify_ca', '/file/path/c')
expected = cl
actual = ilo_common._get_certificate_file_list(cl)
self.assertEqual(expected, actual)
def test__get_certificate_file_list_string_type(self):
cl = 'file/path/a'
- CONF.webserver_verify_ca = '/file/path/c'
+ CONF.set_override('webserver_verify_ca', '/file/path/c')
self.assertRaisesRegex(exception.InvalidParameterValue,
"List of files is .* \"<class 'str'>\" .*",
ilo_common._get_certificate_file_list, cl)
@@ -1355,7 +1355,7 @@ class IloCommonMethodsTestCase(BaseIloTest):
autospec=True)
def test_add_certificates_raises_ilo_error(self, get_ilo_object_mock,
get_cl_mock):
- CONF.webserver_verify_ca = False
+ CONF.set_override('webserver_verify_ca', False)
ilo_mock_object = get_ilo_object_mock.return_value
c_l = ['/file/path/a', '/file/path/b']
get_cl_mock.return_value = c_l
diff --git a/ironic/tests/unit/drivers/modules/irmc/test_boot.py b/ironic/tests/unit/drivers/modules/irmc/test_boot.py
index 502fd3e7e..cd367cef0 100644
--- a/ironic/tests/unit/drivers/modules/irmc/test_boot.py
+++ b/ironic/tests/unit/drivers/modules/irmc/test_boot.py
@@ -74,13 +74,14 @@ class IRMCDeployPrivateMethodsTestCase(test_common.BaseIRMCTest):
def setUp(self):
super(IRMCDeployPrivateMethodsTestCase, self).setUp()
- CONF.irmc.remote_image_share_root = '/remote_image_share_root'
- CONF.irmc.remote_image_server = '10.20.30.40'
- CONF.irmc.remote_image_share_type = 'NFS'
- CONF.irmc.remote_image_share_name = 'share'
- CONF.irmc.remote_image_user_name = 'admin'
- CONF.irmc.remote_image_user_password = 'admin0'
- CONF.irmc.remote_image_user_domain = 'local'
+ CONF.set_override('remote_image_share_root',
+ '/remote_image_share_root', 'irmc')
+ CONF.set_override('remote_image_server', '10.20.30.40', 'irmc')
+ CONF.set_override('remote_image_share_type', 'NFS', 'irmc')
+ CONF.set_override('remote_image_share_name', 'share', 'irmc')
+ CONF.set_override('remote_image_user_name', 'admin', 'irmc')
+ CONF.set_override('remote_image_user_password', 'admin0', 'irmc')
+ CONF.set_override('remote_image_user_domain', 'local', 'irmc')
@mock.patch.object(os.path, 'isdir', spec_set=True, autospec=True)
def test__parse_config_option(self, isdir_mock,
@@ -95,7 +96,8 @@ class IRMCDeployPrivateMethodsTestCase(test_common.BaseIRMCTest):
@mock.patch.object(os.path, 'isdir', spec_set=True, autospec=True)
def test__parse_config_option_non_existed_root(
self, isdir_mock, check_share_fs_mounted_mock):
- CONF.irmc.remote_image_share_root = '/non_existed_root'
+ CONF.set_override('remote_image_share_root', '/non_existed_root',
+ 'irmc')
isdir_mock.return_value = False
self.assertRaises(exception.InvalidParameterValue,
@@ -248,7 +250,7 @@ class IRMCDeployPrivateMethodsTestCase(test_common.BaseIRMCTest):
def test__parse_instance_info_with_boot_iso_file_name_ok(
self, check_share_fs_mounted_mock):
"""With optional 'boot_iso' file name."""
- CONF.irmc.remote_image_share_root = '/etc'
+ CONF.set_override('remote_image_share_root', '/etc', 'irmc')
self.node.instance_info['boot_iso'] = 'hosts'
instance_info_expected = {'boot_iso': 'hosts'}
instance_info_actual = irmc_boot._parse_instance_info(self.node)
@@ -258,7 +260,7 @@ class IRMCDeployPrivateMethodsTestCase(test_common.BaseIRMCTest):
def test__parse_instance_info_with_boot_iso_deprecated(
self, check_share_fs_mounted_mock):
"""With optional 'irmc_boot_iso' file name."""
- CONF.irmc.remote_image_share_root = '/etc'
+ CONF.set_override('remote_image_share_root', '/etc', 'irmc')
self.node.instance_info['irmc_boot_iso'] = 'hosts'
instance_info_expected = {'boot_iso': 'hosts'}
instance_info_actual = irmc_boot._parse_instance_info(self.node)
@@ -268,7 +270,7 @@ class IRMCDeployPrivateMethodsTestCase(test_common.BaseIRMCTest):
def test__parse_instance_info_without_boot_iso_ok(
self, check_share_fs_mounted_mock):
"""With optional no 'boot_iso' file name."""
- CONF.irmc.remote_image_share_root = '/etc'
+ CONF.set_override('remote_image_share_root', '/etc', 'irmc')
self.node.instance_info['boot_iso'] = None
instance_info_expected = {}
@@ -335,7 +337,7 @@ class IRMCDeployPrivateMethodsTestCase(test_common.BaseIRMCTest):
@mock.patch.object(os.path, 'isfile', spec_set=True, autospec=True)
def test__parse_instance_info_with_boot_iso_invalid(
self, isfile_mock, check_share_fs_mounted_mock):
- CONF.irmc.remote_image_share_root = '/etc'
+ CONF.set_override('remote_image_share_root', '/etc', 'irmc')
isfile_mock.return_value = False
with task_manager.acquire(self.context, self.node.uuid) as task:
@@ -357,7 +359,7 @@ class IRMCDeployPrivateMethodsTestCase(test_common.BaseIRMCTest):
def test_parse_deploy_info_ok(self, mock_isfile,
get_image_instance_info_mock,
check_share_fs_mounted_mock):
- CONF.irmc.remote_image_share_root = '/etc'
+ CONF.set_override('remote_image_share_root', '/etc', 'irmc')
get_image_instance_info_mock.return_value = {'a': 'b'}
driver_info_expected = {
'a': 'b',
@@ -443,7 +445,7 @@ class IRMCDeployPrivateMethodsTestCase(test_common.BaseIRMCTest):
setup_vmedia_mock,
set_boot_device_mock,
check_share_fs_mounted_mock):
- CONF.irmc.remote_image_share_root = '/'
+ CONF.set_override('remote_image_share_root', '/', 'irmc')
with task_manager.acquire(self.context, self.node.uuid,
shared=False) as task:
@@ -476,7 +478,7 @@ class IRMCDeployPrivateMethodsTestCase(test_common.BaseIRMCTest):
setup_vmedia_mock,
set_boot_device_mock,
check_share_fs_mounted_mock):
- CONF.irmc.remote_image_share_root = '/'
+ CONF.set_override('remote_image_share_root', '/', 'irmc')
with task_manager.acquire(self.context, self.node.uuid,
shared=False) as task:
@@ -550,7 +552,7 @@ class IRMCDeployPrivateMethodsTestCase(test_common.BaseIRMCTest):
boot_mode_mock,
create_boot_iso_mock,
check_share_fs_mounted_mock):
- CONF.irmc.remote_image_share_root = '/'
+ CONF.set_override('remote_image_share_root', '/', 'irmc')
image = '733d1c44-a2ea-414b-aca7-69decf20d810'
is_image_href_ordinary_file_name_mock.return_value = False
deploy_info_mock.return_value = {'boot_iso': image}
@@ -828,7 +830,7 @@ class IRMCDeployPrivateMethodsTestCase(test_common.BaseIRMCTest):
autospec=True)
def test__remove_share_file(self, unlink_without_raise_mock,
check_share_fs_mounted_mock):
- CONF.irmc.remote_image_share_root = '/share'
+ CONF.set_override('remote_image_share_root', '/share', 'irmc')
irmc_boot._remove_share_file("boot.iso")
@@ -844,12 +846,12 @@ class IRMCDeployPrivateMethodsTestCase(test_common.BaseIRMCTest):
cd_set_params = (irmc_boot.scci
.get_virtual_cd_set_params_cmd.return_value)
- CONF.irmc.remote_image_server = '10.20.30.40'
- CONF.irmc.remote_image_user_domain = 'local'
- CONF.irmc.remote_image_share_type = 'NFS'
- CONF.irmc.remote_image_share_name = 'share'
- CONF.irmc.remote_image_user_name = 'admin'
- CONF.irmc.remote_image_user_password = 'admin0'
+ CONF.set_override('remote_image_server', '10.20.30.40', 'irmc')
+ CONF.set_override('remote_image_share_type', 'NFS', 'irmc')
+ CONF.set_override('remote_image_share_name', 'share', 'irmc')
+ CONF.set_override('remote_image_user_name', 'admin', 'irmc')
+ CONF.set_override('remote_image_user_password', 'admin0', 'irmc')
+ CONF.set_override('remote_image_user_domain', 'local', 'irmc')
irmc_boot.scci.get_share_type.return_value = 0
@@ -926,12 +928,12 @@ class IRMCDeployPrivateMethodsTestCase(test_common.BaseIRMCTest):
fd_set_params = (irmc_boot.scci
.get_virtual_fd_set_params_cmd.return_value)
- CONF.irmc.remote_image_server = '10.20.30.40'
- CONF.irmc.remote_image_user_domain = 'local'
- CONF.irmc.remote_image_share_type = 'NFS'
- CONF.irmc.remote_image_share_name = 'share'
- CONF.irmc.remote_image_user_name = 'admin'
- CONF.irmc.remote_image_user_password = 'admin0'
+ CONF.set_override('remote_image_server', '10.20.30.40', 'irmc')
+ CONF.set_override('remote_image_share_type', 'NFS', 'irmc')
+ CONF.set_override('remote_image_share_name', 'share', 'irmc')
+ CONF.set_override('remote_image_user_name', 'admin', 'irmc')
+ CONF.set_override('remote_image_user_password', 'admin0', 'irmc')
+ CONF.set_override('remote_image_user_domain', 'local', 'irmc')
irmc_boot.scci.get_share_type.return_value = 0
@@ -1009,8 +1011,8 @@ class IRMCDeployPrivateMethodsTestCase(test_common.BaseIRMCTest):
# irmc_boot.check_share_fs_mounted is mocked in
# third_party_driver_mocks.py.
# irmc_boot.check_share_fs_mounted_orig is the real function.
- CONF.irmc.remote_image_share_root = '/'
- CONF.irmc.remote_image_share_type = 'nfs'
+ CONF.set_override('remote_image_share_root', '/', 'irmc')
+ CONF.set_override('remote_image_share_type', 'nfs', 'irmc')
result = irmc_boot.check_share_fs_mounted_orig()
parse_conf_mock.assert_called_once_with()
@@ -1026,8 +1028,8 @@ class IRMCDeployPrivateMethodsTestCase(test_common.BaseIRMCTest):
# irmc_boot.check_share_fs_mounted is mocked in
# third_party_driver_mocks.py.
# irmc_boot.check_share_fs_mounted_orig is the real function.
- CONF.irmc.remote_image_share_root = '/etc'
- CONF.irmc.remote_image_share_type = 'cifs'
+ CONF.set_override('remote_image_share_root', '/etc', 'irmc')
+ CONF.set_override('remote_image_share_type', 'cifs', 'irmc')
self.assertRaises(exception.IRMCSharedFileSystemNotMounted,
irmc_boot.check_share_fs_mounted_orig)
diff --git a/ironic/tests/unit/drivers/modules/redfish/test_firmware_utils.py b/ironic/tests/unit/drivers/modules/redfish/test_firmware_utils.py
index e2c6e75b2..61bc23e48 100644
--- a/ironic/tests/unit/drivers/modules/redfish/test_firmware_utils.py
+++ b/ironic/tests/unit/drivers/modules/redfish/test_firmware_utils.py
@@ -262,9 +262,9 @@ class FirmwareUtilsTestCase(base.TestCase):
@mock.patch.object(os, 'chmod', autospec=True)
def test_stage_http(self, mock_chmod, mock_link, mock_copyfile,
mock_makedirs):
- CONF.deploy.http_url = 'http://10.0.0.2'
- CONF.deploy.external_http_url = None
- CONF.deploy.http_root = '/httproot'
+ CONF.set_override('http_url', 'http://10.0.0.2', 'deploy')
+ CONF.set_override('external_http_url', None, 'deploy')
+ CONF.set_override('http_root', '/httproot', 'deploy')
node = mock.Mock(uuid='55cdaba0-1123-4622-8b37-bb52dd6285d3')
staged_url, need_cleanup = firmware_utils.stage(
@@ -291,9 +291,9 @@ class FirmwareUtilsTestCase(base.TestCase):
@mock.patch.object(os, 'chmod', autospec=True)
def test_stage_http_copyfile(self, mock_chmod, mock_link, mock_copyfile,
mock_makedirs):
- CONF.deploy.http_url = 'http://10.0.0.2'
- CONF.deploy.external_http_url = None
- CONF.deploy.http_root = '/httproot'
+ CONF.set_override('http_url', 'http://10.0.0.2', 'deploy')
+ CONF.set_override('external_http_url', None, 'deploy')
+ CONF.set_override('http_root', '/httproot', 'deploy')
node = mock.Mock(uuid='55cdaba0-1123-4622-8b37-bb52dd6285d3')
mock_link.side_effect = OSError
@@ -323,9 +323,9 @@ class FirmwareUtilsTestCase(base.TestCase):
@mock.patch.object(os, 'chmod', autospec=True)
def test_stage_http_copyfile_fails(self, mock_chmod, mock_link,
mock_copyfile, mock_makedirs):
- CONF.deploy.http_url = 'http://10.0.0.2'
- CONF.deploy.external_http_url = None
- CONF.deploy.http_root = '/httproot'
+ CONF.set_override('http_url', 'http://10.0.0.2', 'deploy')
+ CONF.set_override('external_http_url', None, 'deploy')
+ CONF.set_override('http_root', '/httproot', 'deploy')
node = mock.Mock(uuid='55cdaba0-1123-4622-8b37-bb52dd6285d3')
mock_link.side_effect = OSError
mock_copyfile.side_effect = IOError
@@ -352,9 +352,9 @@ class FirmwareUtilsTestCase(base.TestCase):
@mock.patch.object(os, 'chmod', autospec=True)
def test_stage_local_external(self, mock_chmod, mock_link, mock_rmtree,
mock_copyfile, mock_makedirs):
- CONF.deploy.http_url = 'http://10.0.0.2'
- CONF.deploy.external_http_url = 'http://90.0.0.9'
- CONF.deploy.http_root = '/httproot'
+ CONF.set_override('http_url', 'http://10.0.0.2', 'deploy')
+ CONF.set_override('external_http_url', 'http://90.0.0.9', 'deploy')
+ CONF.set_override('http_root', '/httproot', 'deploy')
node = mock.Mock(uuid='55cdaba0-1123-4622-8b37-bb52dd6285d3')
staged_url, need_cleanup = firmware_utils.stage(
@@ -402,7 +402,7 @@ class FirmwareUtilsTestCase(base.TestCase):
@mock.patch.object(swift, 'SwiftAPI', autospec=True)
def test_cleanup(self, mock_swift_api, mock_gettempdir, mock_rmtree):
mock_gettempdir.return_value = '/tmp'
- CONF.deploy.http_root = '/httproot'
+ CONF.set_override('http_root', '/httproot', 'deploy')
node = mock.Mock(
uuid='55cdaba0-1123-4622-8b37-bb52dd6285d3',
driver_internal_info={'firmware_cleanup': ['http', 'swift']})
diff --git a/ironic/tests/unit/drivers/modules/redfish/test_management.py b/ironic/tests/unit/drivers/modules/redfish/test_management.py
index 93aae5de8..f8c82949a 100644
--- a/ironic/tests/unit/drivers/modules/redfish/test_management.py
+++ b/ironic/tests/unit/drivers/modules/redfish/test_management.py
@@ -836,7 +836,7 @@ class RedfishManagementTestCase(db_base.DbTestCase):
mock_update_service = mock.Mock()
mock_update_service.simple_update.return_value = mock_task_monitor
mock_get_update_service.return_value = mock_update_service
- CONF.redfish.firmware_source = 'http'
+ CONF.set_override('firmware_source', 'http', 'redfish')
with task_manager.acquire(self.context, self.node.uuid,
shared=False) as task:
task.node.save = mock.Mock()
@@ -1346,7 +1346,7 @@ class RedfishManagementTestCase(db_base.DbTestCase):
{'task_monitor': '/task/123', 'url': 'http://test1'},
{'url': 'http://test2'}]}
self.node.driver_internal_info = driver_internal_info
- CONF.redfish.firmware_source = 'http'
+ CONF.set_override('firmware_source', 'http', 'redfish')
management = redfish_mgmt.RedfishManagement()
with task_manager.acquire(self.context, self.node.uuid,
@@ -1375,7 +1375,7 @@ class RedfishManagementTestCase(db_base.DbTestCase):
@mock.patch.object(firmware_utils, 'stage', autospec=True)
def test__stage_firmware_file_https(self, mock_stage, mock_verify_checksum,
mock_download_to_temp):
- CONF.redfish.firmware_source = 'local'
+ CONF.set_override('firmware_source', 'local', 'redfish')
firmware_update = {'url': 'https://test1', 'checksum': 'abc'}
node = mock.Mock()
mock_download_to_temp.return_value = '/tmp/test1'
@@ -1399,7 +1399,7 @@ class RedfishManagementTestCase(db_base.DbTestCase):
def test__stage_firmware_file_swift(
self, mock_get_swift_temp_url, mock_stage, mock_verify_checksum,
mock_download_to_temp):
- CONF.redfish.firmware_source = 'swift'
+ CONF.set_override('firmware_source', 'swift', 'redfish')
firmware_update = {'url': 'swift://container/bios.exe'}
node = mock.Mock()
mock_get_swift_temp_url.return_value = 'http://temp'
@@ -1423,7 +1423,7 @@ class RedfishManagementTestCase(db_base.DbTestCase):
mock_download_to_temp, mock_cleanup):
node = mock.Mock()
firmware_update = {'url': 'https://test1'}
- CONF.redfish.firmware_source = 'local'
+ CONF.set_override('firmware_source', 'local', 'redfish')
firmware_update = {'url': 'https://test1'}
node = mock.Mock()
mock_download_to_temp.return_value = '/tmp/test1'
diff --git a/ironic/tests/unit/drivers/modules/test_snmp.py b/ironic/tests/unit/drivers/modules/test_snmp.py
index 36a59a396..6bdd2da5a 100644
--- a/ironic/tests/unit/drivers/modules/test_snmp.py
+++ b/ironic/tests/unit/drivers/modules/test_snmp.py
@@ -875,7 +875,7 @@ class SNMPDeviceDriverTestCase(db_base.DbTestCase):
def test_power_off_timeout(self, mock_sleep, mock_get_client):
# Ensure that a power off consistency poll timeout causes an error
mock_client = mock_get_client.return_value
- CONF.snmp.power_timeout = 5
+ CONF.set_override('power_timeout', 5, 'snmp')
driver = snmp._get_driver(self.node)
mock_client.get.return_value = driver.value_power_on
pstate = driver.power_off()