summaryrefslogtreecommitdiff
path: root/ironic/tests/unit/drivers/modules
diff options
context:
space:
mode:
authorJacob Anders <janders@redhat.com>2022-06-21 13:18:12 +1000
committerJacob Anders <janders@redhat.com>2022-07-05 22:27:43 +1000
commit1dda97c783653aef638113cb1faa250836ed99e1 (patch)
treed3df7098d2eb1a5d4e5711701bcb2dccda9774d5 /ironic/tests/unit/drivers/modules
parent39a7f58002eac8ad10720c7347f001c8afd24a6f (diff)
downloadironic-1dda97c783653aef638113cb1faa250836ed99e1.tar.gz
Prevent clear_job_queue and reset_idrac failures on older iDRACs
Currently, clear_job_queue and reset_idrac steps are only supported on idrac-redfish driver on iDRAC9 hardware. However, Ironic still attempts to run these steps on iDRAC8 BMCs configured with idrac-redfish driver which results in verification failures. This change attempts to resolve it by catching the related exception, logging a warning and continuing verification. In case of cleaning, it still fails. Story: 2010091 Task: 45630 Change-Id: Icd8c5378469887962ff32eea2f38697c539f7e95
Diffstat (limited to 'ironic/tests/unit/drivers/modules')
-rw-r--r--ironic/tests/unit/drivers/modules/drac/test_management.py90
1 files changed, 90 insertions, 0 deletions
diff --git a/ironic/tests/unit/drivers/modules/drac/test_management.py b/ironic/tests/unit/drivers/modules/drac/test_management.py
index ba6857504..fa1ed6130 100644
--- a/ironic/tests/unit/drivers/modules/drac/test_management.py
+++ b/ironic/tests/unit/drivers/modules/drac/test_management.py
@@ -28,6 +28,7 @@ from oslo_utils import importutils
import ironic.common.boot_devices
from ironic.common import exception
from ironic.common import molds
+from ironic.common import states
from ironic.conductor import periodics
from ironic.conductor import task_manager
from ironic.conductor import utils as manager_utils
@@ -1438,6 +1439,48 @@ class DracRedfishManagementTestCase(test_utils.BaseDracTest):
mock_manager_oem.job_service.delete_jobs.assert_called_once_with(
job_ids=['JID_CLEARALL'])
+ @mock.patch.object(drac_mgmt, 'LOG', autospec=True)
+ @mock.patch.object(drac_utils, 'redfish_utils', autospec=True)
+ def test_clear_job_queue_missing_attr_verify_step(self,
+ mock_redfish_utils,
+ mock_log):
+ mock_system = mock_redfish_utils.get_system.return_value
+ mock_manager = mock.MagicMock()
+ mock_system.managers = [mock_manager]
+ mock_manager_oem = mock_manager.get_oem_extension.return_value
+ mock_manager_oem.job_service.delete_jobs.side_effect = (
+ exception.RedfishError("Oem/Dell/DellJobService is missing"))
+ with task_manager.acquire(self.context, self.node.uuid,
+ shared=False) as task:
+ task.node.provision_state = states.VERIFYING
+ task.driver.management.clear_job_queue(task)
+ mock_log.warning.assert_called_once_with(
+ 'iDRAC on node %(node)s does not support '
+ 'clearing Lifecycle Controller job queue '
+ 'using the idrac-redfish driver. '
+ 'If using iDRAC9, consider upgrading firmware. '
+ 'If using iDRAC8, consider switching to '
+ 'idrac-wsman for management interface if '
+ 'possible.',
+ {'node': task.node.uuid})
+
+ @mock.patch.object(drac_mgmt, 'LOG', autospec=True)
+ @mock.patch.object(drac_utils, 'redfish_utils', autospec=True)
+ def test_clear_job_queue_missing_attr_clean_step(self,
+ mock_redfish_utils,
+ mock_log):
+ mock_system = mock_redfish_utils.get_system.return_value
+ mock_manager = mock.MagicMock()
+ mock_system.managers = [mock_manager]
+ mock_manager_oem = mock_manager.get_oem_extension.return_value
+ mock_manager_oem.job_service.delete_jobs.side_effect = (
+ exception.RedfishError("Oem/Dell/DellJobService is missing"))
+ with task_manager.acquire(self.context, self.node.uuid,
+ shared=False) as task:
+ task.node.provision_state = states.CLEANING
+ self.assertRaises(ironic.common.exception.RedfishError,
+ task.driver.management.clear_job_queue, task)
+
@mock.patch.object(redfish_utils, 'wait_until_get_system_ready',
autospec=True)
@mock.patch.object(drac_utils, 'redfish_utils', autospec=True)
@@ -1454,6 +1497,53 @@ class DracRedfishManagementTestCase(test_utils.BaseDracTest):
@mock.patch.object(redfish_utils, 'wait_until_get_system_ready',
autospec=True)
+ @mock.patch.object(drac_mgmt, 'LOG', autospec=True)
+ @mock.patch.object(drac_utils, 'redfish_utils', autospec=True)
+ def test_reset_idrac_missing_attr_verify_step(self,
+ mock_redfish_utils,
+ mock_log,
+ mock_wait_system_ready):
+ mock_system = mock_redfish_utils.get_system.return_value
+ mock_manager = mock.MagicMock()
+ mock_system.managers = [mock_manager]
+ mock_manager_oem = mock_manager.get_oem_extension.return_value
+ mock_manager_oem.reset_idrac.side_effect = (
+ exception.RedfishError("Oem/Dell/DelliDRACCardService is missing"))
+ with task_manager.acquire(self.context, self.node.uuid,
+ shared=False) as task:
+ task.node.provision_state = states.VERIFYING
+ task.driver.management.reset_idrac(task)
+ mock_log.warning.assert_called_once_with(
+ 'iDRAC on node %(node)s does not support '
+ 'iDRAC reset using the idrac-redfish driver. '
+ 'If using iDRAC9, consider upgrading firmware. '
+ 'If using iDRAC8, consider switching to '
+ 'idrac-wsman for management interface if '
+ 'possible.',
+ {'node': task.node.uuid})
+
+ @mock.patch.object(redfish_utils, 'wait_until_get_system_ready',
+ autospec=True)
+ @mock.patch.object(drac_mgmt, 'LOG', autospec=True)
+ @mock.patch.object(drac_utils, 'redfish_utils', autospec=True)
+ def test_reset_idrac_missing_attr_clean_step(self,
+ mock_redfish_utils,
+ mock_log,
+ mock_wait_system_ready):
+ mock_system = mock_redfish_utils.get_system.return_value
+ mock_manager = mock.MagicMock()
+ mock_system.managers = [mock_manager]
+ mock_manager_oem = mock_manager.get_oem_extension.return_value
+ mock_manager_oem.reset_idrac.side_effect = (
+ exception.RedfishError("Oem/Dell/DelliDRACCardService is missing"))
+ with task_manager.acquire(self.context, self.node.uuid,
+ shared=False) as task:
+ task.node.provision_state = states.CLEANING
+ self.assertRaises(ironic.common.exception.RedfishError,
+ task.driver.management.reset_idrac, task)
+
+ @mock.patch.object(redfish_utils, 'wait_until_get_system_ready',
+ autospec=True)
@mock.patch.object(drac_utils, 'redfish_utils', autospec=True)
def test_known_good_state(self, mock_redfish_utils,
mock_wait_system_ready):