From 29c507f0e02ec70fc781e9de55219838d3f46b43 Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Wed, 23 Sep 2020 10:15:31 +1200 Subject: [PATCH] Use tempdirs for /tftpboot, /httpboot creation tests Otherwise these tests will fail in environments where these directories exist already Change-Id: Iad5f7500a915dd2d444963385136cd3a175b2dfc --- ironic/tests/unit/common/test_pxe_utils.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ironic/tests/unit/common/test_pxe_utils.py b/ironic/tests/unit/common/test_pxe_utils.py index 987afb928e..3e31ea715a 100644 --- a/ironic/tests/unit/common/test_pxe_utils.py +++ b/ironic/tests/unit/common/test_pxe_utils.py @@ -392,6 +392,7 @@ class TestPXEUtils(db_base.DbTestCase): @mock.patch('oslo_utils.fileutils.ensure_tree', autospec=True) def test_create_pxe_config(self, ensure_tree_mock, render_mock, write_mock, chmod_mock): + self.config(tftp_root=tempfile.mkdtemp(), group='pxe') with task_manager.acquire(self.context, self.node.uuid) as task: pxe_utils.create_pxe_config(task, self.pxe_options, CONF.pxe.pxe_config_template) @@ -420,6 +421,7 @@ class TestPXEUtils(db_base.DbTestCase): def test_create_pxe_config_set_dir_permission(self, ensure_tree_mock, render_mock, write_mock, chmod_mock): + self.config(tftp_root=tempfile.mkdtemp(), group='pxe') self.config(dir_permission=0o755, group='pxe') with task_manager.acquire(self.context, self.node.uuid) as task: pxe_utils.create_pxe_config(task, self.pxe_options, @@ -479,6 +481,7 @@ class TestPXEUtils(db_base.DbTestCase): def test_create_pxe_config_uefi_grub(self, ensure_tree_mock, render_mock, write_mock, link_ip_configs_mock, chmod_mock): + self.config(tftp_root=tempfile.mkdtemp(), group='pxe') grub_tmplte = "ironic/drivers/modules/pxe_grub_config.template" with task_manager.acquire(self.context, self.node.uuid) as task: task.node.properties['capabilities'] = 'boot_mode:uefi' @@ -518,6 +521,7 @@ class TestPXEUtils(db_base.DbTestCase): # enable mac address usage..... grub_tmplte = "ironic/drivers/modules/pxe_grub_config.template" self.config(dhcp_provider='none', group='dhcp') + self.config(tftp_root=tempfile.mkdtemp(), group='pxe') link_ip_configs_mock.side_effect = \ exception.FailedToGetIPAddressOnPort(port_id='blah') with task_manager.acquire(self.context, self.node.uuid) as task: @@ -552,6 +556,8 @@ class TestPXEUtils(db_base.DbTestCase): def test_create_pxe_config_uefi_ipxe(self, ensure_tree_mock, render_mock, write_mock, link_mac_pxe_mock, chmod_mock): + + self.config(http_root=tempfile.mkdtemp(), group='deploy') ipxe_template = "ironic/drivers/modules/ipxe_config.template" with task_manager.acquire(self.context, self.node.uuid) as task: task.node.properties['capabilities'] = 'boot_mode:uefi'