summaryrefslogtreecommitdiff
path: root/ironic_python_agent/tests/unit/extensions
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2021-06-02 12:36:57 +0000
committerGerrit Code Review <review@openstack.org>2021-06-02 12:36:57 +0000
commit7fdbcde3de2d7c81f84933ce6f81de1b3c3e05e2 (patch)
tree1ec4c8b4dab5eeedcafc3c408ea35849b6f73256 /ironic_python_agent/tests/unit/extensions
parent5c063c8224d3d3e69a1e10f2252e2eebdcceffb1 (diff)
parentf65752680700fc8df8877620b2354cb06ea54fd3 (diff)
downloadironic-python-agent-7fdbcde3de2d7c81f84933ce6f81de1b3c3e05e2.tar.gz
Merge "Stop accepting duplicated configdrive"
Diffstat (limited to 'ironic_python_agent/tests/unit/extensions')
-rw-r--r--ironic_python_agent/tests/unit/extensions/test_standby.py62
1 files changed, 38 insertions, 24 deletions
diff --git a/ironic_python_agent/tests/unit/extensions/test_standby.py b/ironic_python_agent/tests/unit/extensions/test_standby.py
index e7500027..f9f1d530 100644
--- a/ironic_python_agent/tests/unit/extensions/test_standby.py
+++ b/ironic_python_agent/tests/unit/extensions/test_standby.py
@@ -52,7 +52,6 @@ def _build_fake_partition_image_info():
'ephemeral_mb': '10',
'ephemeral_format': 'abc',
'preserve_ephemeral': 'False',
- 'configdrive': 'configdrive',
'image_type': 'partition',
'boot_option': 'netboot',
'disk_label': 'msdos',
@@ -234,7 +233,6 @@ class TestStandbyExtension(base.IronicAgentTest):
ephemeral_format = image_info['ephemeral_format']
node_uuid = image_info['node_uuid']
pr_ep = image_info['preserve_ephemeral']
- configdrive = image_info['configdrive']
boot_mode = image_info['deploy_boot_mode']
boot_option = image_info['boot_option']
disk_label = image_info['disk_label']
@@ -249,14 +247,14 @@ class TestStandbyExtension(base.IronicAgentTest):
work_on_disk_mock.side_effect = Exception_returned
self.assertRaises(exc, standby._write_image, image_info,
- device)
+ device, 'configdrive')
image_mb_mock.assert_called_once_with(image_path)
work_on_disk_mock.assert_called_once_with(device, root_mb, swap_mb,
ephemeral_mb,
ephemeral_format,
image_path,
node_uuid,
- configdrive=configdrive,
+ configdrive='configdrive',
preserve_ephemeral=pr_ep,
boot_mode=boot_mode,
boot_option=boot_option,
@@ -282,7 +280,6 @@ class TestStandbyExtension(base.IronicAgentTest):
ephemeral_format = image_info['ephemeral_format']
node_uuid = image_info['node_uuid']
pr_ep = image_info['preserve_ephemeral']
- configdrive = image_info['configdrive']
boot_mode = image_info['deploy_boot_mode']
boot_option = image_info['boot_option']
disk_label = image_info['disk_label']
@@ -297,14 +294,14 @@ class TestStandbyExtension(base.IronicAgentTest):
image_mb_mock.return_value = 1
work_on_disk_mock.return_value = uuids
- standby._write_image(image_info, device)
+ standby._write_image(image_info, device, 'configdrive')
image_mb_mock.assert_called_once_with(image_path)
work_on_disk_mock.assert_called_once_with(device, root_mb, swap_mb,
ephemeral_mb,
ephemeral_format,
image_path,
node_uuid,
- configdrive=configdrive,
+ configdrive='configdrive',
preserve_ephemeral=pr_ep,
boot_mode=boot_mode,
boot_option=boot_option,
@@ -355,7 +352,6 @@ class TestStandbyExtension(base.IronicAgentTest):
ephemeral_format = image_info['ephemeral_format']
node_uuid = image_info['node_uuid']
pr_ep = image_info['preserve_ephemeral']
- configdrive = image_info['configdrive']
boot_mode = image_info['deploy_boot_mode']
boot_option = image_info['boot_option']
disk_label = image_info['disk_label']
@@ -368,14 +364,14 @@ class TestStandbyExtension(base.IronicAgentTest):
dispatch_mock.return_value = self.fake_cpu
work_on_disk_mock.return_value = uuids
- standby._write_image(image_info, device)
+ standby._write_image(image_info, device, 'configdrive')
image_mb_mock.assert_called_once_with(image_path)
work_on_disk_mock.assert_called_once_with(device, root_mb, swap_mb,
ephemeral_mb,
ephemeral_format,
image_path,
node_uuid,
- configdrive=configdrive,
+ configdrive='configdrive',
preserve_ephemeral=pr_ep,
boot_mode=boot_mode,
boot_option=boot_option,
@@ -598,7 +594,7 @@ class TestStandbyExtension(base.IronicAgentTest):
async_result = self.agent_extension.cache_image(image_info=image_info)
async_result.join()
download_mock.assert_called_once_with(image_info)
- write_mock.assert_called_once_with(image_info, 'manager')
+ write_mock.assert_called_once_with(image_info, 'manager', None)
dispatch_mock.assert_called_once_with('get_os_install_device',
permit_refresh=True)
self.assertEqual(image_info['id'],
@@ -622,10 +618,12 @@ class TestStandbyExtension(base.IronicAgentTest):
download_mock.return_value = None
write_mock.return_value = {'root uuid': 'root_uuid'}
dispatch_mock.return_value = 'manager'
- async_result = self.agent_extension.cache_image(image_info=image_info)
+ async_result = self.agent_extension.cache_image(
+ image_info=image_info, configdrive='configdrive_data')
async_result.join()
download_mock.assert_called_once_with(image_info)
- write_mock.assert_called_once_with(image_info, 'manager')
+ write_mock.assert_called_once_with(image_info, 'manager',
+ 'configdrive_data')
dispatch_mock.assert_called_once_with('get_os_install_device',
permit_refresh=True)
self.assertEqual(image_info['id'],
@@ -657,7 +655,7 @@ class TestStandbyExtension(base.IronicAgentTest):
)
async_result.join()
download_mock.assert_called_once_with(image_info)
- write_mock.assert_called_once_with(image_info, 'manager')
+ write_mock.assert_called_once_with(image_info, 'manager', None)
dispatch_mock.assert_called_once_with('get_os_install_device',
permit_refresh=True)
self.assertEqual(image_info['id'],
@@ -732,7 +730,8 @@ class TestStandbyExtension(base.IronicAgentTest):
async_result.join()
download_mock.assert_called_once_with(image_info)
- write_mock.assert_called_once_with(image_info, 'manager')
+ write_mock.assert_called_once_with(image_info, 'manager',
+ 'configdrive_data')
dispatch_mock.assert_called_once_with('get_os_install_device',
permit_refresh=True)
configdrive_copy_mock.assert_called_once_with(image_info['node_uuid'],
@@ -783,7 +782,8 @@ class TestStandbyExtension(base.IronicAgentTest):
async_result.join()
download_mock.assert_called_once_with(image_info)
- write_mock.assert_called_once_with(image_info, 'manager')
+ write_mock.assert_called_once_with(image_info, 'manager',
+ 'configdrive_data')
dispatch_mock.assert_called_once_with('get_os_install_device',
permit_refresh=True)
self.assertFalse(configdrive_copy_mock.called)
@@ -856,7 +856,7 @@ class TestStandbyExtension(base.IronicAgentTest):
async_result.join()
download_mock.assert_called_once_with(image_info)
- write_mock.assert_called_once_with(image_info, 'manager')
+ write_mock.assert_called_once_with(image_info, 'manager', None)
dispatch_mock.assert_called_once_with('get_os_install_device',
permit_refresh=True)
@@ -907,7 +907,7 @@ class TestStandbyExtension(base.IronicAgentTest):
async_result.join()
download_mock.assert_called_once_with(image_info)
- write_mock.assert_called_once_with(image_info, 'manager')
+ write_mock.assert_called_once_with(image_info, 'manager', None)
dispatch_mock.assert_called_once_with('get_os_install_device',
permit_refresh=True)
@@ -950,7 +950,8 @@ class TestStandbyExtension(base.IronicAgentTest):
async_result.join()
download_mock.assert_called_once_with(image_info)
- write_mock.assert_called_once_with(image_info, 'manager')
+ write_mock.assert_called_once_with(image_info, 'manager',
+ 'configdrive_data')
dispatch_mock.assert_called_once_with('get_os_install_device',
permit_refresh=True)
configdrive_copy_mock.assert_called_once_with(image_info['node_uuid'],
@@ -1018,7 +1019,7 @@ class TestStandbyExtension(base.IronicAgentTest):
self.assertIs(partition, work_on_disk_mock.called)
else:
cache_write_mock.assert_called_once_with(mock.ANY, image_info,
- '/dev/foo')
+ '/dev/foo', None)
self.assertFalse(stream_mock.called)
def test_prepare_image_raw_stream_true(self):
@@ -1189,7 +1190,21 @@ class TestStandbyExtension(base.IronicAgentTest):
device = '/dev/foo'
self.agent_extension._cache_and_write_image(image_info, device)
download_mock.assert_called_once_with(image_info)
- write_mock.assert_called_once_with(image_info, device)
+ write_mock.assert_called_once_with(image_info, device, None)
+
+ @mock.patch('ironic_python_agent.extensions.standby._write_image',
+ autospec=True)
+ @mock.patch('ironic_python_agent.extensions.standby._download_image',
+ autospec=True)
+ def test_cache_and_write_image_configdirve(self, download_mock,
+ write_mock):
+ image_info = _build_fake_image_info()
+ device = '/dev/foo'
+ self.agent_extension._cache_and_write_image(image_info, device,
+ 'configdrive_data')
+ download_mock.assert_called_once_with(image_info)
+ write_mock.assert_called_once_with(image_info, device,
+ 'configdrive_data')
@mock.patch('ironic_lib.disk_utils.block_uuid', autospec=True)
@mock.patch('ironic_lib.disk_utils.fix_gpt_partition', autospec=True)
@@ -1415,7 +1430,6 @@ class TestStandbyExtension(base.IronicAgentTest):
ephemeral_format = image_info['ephemeral_format']
node_uuid = image_info['node_uuid']
pr_ep = image_info['preserve_ephemeral']
- configdrive = image_info['configdrive']
boot_option = image_info['boot_option']
cpu_arch = self.fake_cpu.architecture
@@ -1428,14 +1442,14 @@ class TestStandbyExtension(base.IronicAgentTest):
image_mb_mock.return_value = 1
work_on_disk_mock.return_value = uuids
- standby._write_image(image_info, device)
+ standby._write_image(image_info, device, 'configdrive')
image_mb_mock.assert_called_once_with(image_path)
work_on_disk_mock.assert_called_once_with(device, root_mb, swap_mb,
ephemeral_mb,
ephemeral_format,
image_path,
node_uuid,
- configdrive=configdrive,
+ configdrive='configdrive',
preserve_ephemeral=pr_ep,
boot_mode='uefi',
boot_option=boot_option,