summaryrefslogtreecommitdiff
path: root/ironic_python_agent/tests
diff options
context:
space:
mode:
authorDmitry Tantsur <dtantsur@protonmail.com>2020-07-29 10:10:18 +0200
committerDmitry Tantsur <dtantsur@protonmail.com>2020-07-29 10:10:18 +0200
commitf03d72019a9e1bd51d52fb7cb4b5d77a29e44658 (patch)
treeff7cc1cf9313cd24ba019f2d6eb6480c759e6219 /ironic_python_agent/tests
parentdc395c58377d7793ea691d21fef7bb9665c604e4 (diff)
downloadironic-python-agent-f03d72019a9e1bd51d52fb7cb4b5d77a29e44658.tar.gz
Return the final RAID configuration from apply_configuration
AgentRAID expects it and fails with TypeError if it's not provided. Change-Id: Id84ac129bba97540338e25f0027aa0a0f51bde52 Story: #2006963
Diffstat (limited to 'ironic_python_agent/tests')
-rw-r--r--ironic_python_agent/tests/unit/test_hardware.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/ironic_python_agent/tests/unit/test_hardware.py b/ironic_python_agent/tests/unit/test_hardware.py
index 63ccb1d0..3555310f 100644
--- a/ironic_python_agent/tests/unit/test_hardware.py
+++ b/ironic_python_agent/tests/unit/test_hardware.py
@@ -2791,6 +2791,69 @@ class TestGenericHardwareManager(base.IronicAgentTest):
self.hardware.validate_configuration,
self.node, [])
+ @mock.patch.object(hardware.GenericHardwareManager,
+ '_do_create_configuration', autospec=True)
+ @mock.patch.object(hardware.GenericHardwareManager,
+ 'delete_configuration', autospec=True)
+ @mock.patch.object(hardware.GenericHardwareManager,
+ 'validate_configuration', autospec=True)
+ def test_apply_configuration(self, mocked_validate, mocked_delete,
+ mocked_create):
+ raid_config = {
+ "logical_disks": [
+ {
+ "size_gb": "10",
+ "raid_level": "1",
+ "controller": "software",
+ },
+ {
+ "size_gb": "MAX",
+ "raid_level": "0",
+ "controller": "software",
+ },
+ ]
+ }
+
+ result = self.hardware.apply_configuration(self.node, [], raid_config)
+ self.assertIs(result, mocked_create.return_value)
+ mocked_validate.assert_called_once_with(self.hardware, raid_config,
+ self.node)
+ mocked_delete.assert_called_once_with(self.hardware, self.node, [])
+ mocked_create.assert_called_once_with(self.hardware, self.node, [],
+ raid_config)
+
+ @mock.patch.object(hardware.GenericHardwareManager,
+ '_do_create_configuration', autospec=True)
+ @mock.patch.object(hardware.GenericHardwareManager,
+ 'delete_configuration', autospec=True)
+ @mock.patch.object(hardware.GenericHardwareManager,
+ 'validate_configuration', autospec=True)
+ def test_apply_configuration_no_delete(self, mocked_validate,
+ mocked_delete, mocked_create):
+ raid_config = {
+ "logical_disks": [
+ {
+ "size_gb": "10",
+ "raid_level": "1",
+ "controller": "software",
+ },
+ {
+ "size_gb": "MAX",
+ "raid_level": "0",
+ "controller": "software",
+ },
+ ]
+ }
+
+ result = self.hardware.apply_configuration(self.node, [], raid_config,
+ delete_existing=False)
+ self.assertIs(result, mocked_create.return_value)
+ mocked_validate.assert_called_once_with(self.hardware, raid_config,
+ self.node)
+ self.assertFalse(mocked_delete.called)
+ mocked_create.assert_called_once_with(self.hardware, self.node, [],
+ raid_config)
+
@mock.patch.object(disk_utils, 'list_partitions', autospec=True)
@mock.patch.object(utils, 'execute', autospec=True)
@mock.patch.object(os.path, 'isdir', autospec=True, return_value=False)