diff options
author | Aija Jauntēva <aija.jaunteva@dell.com> | 2020-10-02 04:57:42 -0400 |
---|---|---|
committer | Dmitry Tantsur <dtantsur@protonmail.com> | 2021-01-12 10:51:39 +0100 |
commit | 27a4b468fa147cd5b8b66d80993ab103f60ee47b (patch) | |
tree | 0f72aa2fb250cb98f50562bde518931a60f761c6 /ironic/tests | |
parent | 0298ceac3ba391ae1cd7385d42b194247c80cbc4 (diff) | |
download | ironic-27a4b468fa147cd5b8b66d80993ab103f60ee47b.tar.gz |
Fix idrac-wsman RAID step async error handling
Instead of using process_event('fail') use error_handlers,
otherwise in case of failure node gets stuck and fails
because of timeout, instead of failing earlier due to
step failure.
Story: 2008307
Task: 41194
Change-Id: Ieec0173f57367587985d2baad77205bb83e8b69a
(cherry picked from commit 23951f4b44e64513da047c474f0a49408ddf9208)
Diffstat (limited to 'ironic/tests')
-rw-r--r-- | ironic/tests/unit/drivers/modules/drac/test_periodic_task.py | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/ironic/tests/unit/drivers/modules/drac/test_periodic_task.py b/ironic/tests/unit/drivers/modules/drac/test_periodic_task.py index ba5b7ae5e..ec7f4e27c 100644 --- a/ironic/tests/unit/drivers/modules/drac/test_periodic_task.py +++ b/ironic/tests/unit/drivers/modules/drac/test_periodic_task.py @@ -203,9 +203,11 @@ class DracPeriodicTaskTestCase(db_base.DbTestCase): self._test__check_node_raid_jobs_with_completed_job( mock_notify_conductor_resume) + @mock.patch.object(manager_utils, 'cleaning_error_handler', autospec=True) @mock.patch.object(drac_common, 'get_drac_client', spec_set=True, autospec=True) - def test__check_node_raid_jobs_with_failed_job(self, mock_get_drac_client): + def test__check_node_raid_jobs_with_failed_job( + self, mock_get_drac_client, mock_cleaning_error_handler): # mock node.driver_internal_info and node.clean_step driver_internal_info = {'raid_config_job_ids': ['42']} self.node.driver_internal_info = driver_internal_info @@ -232,15 +234,18 @@ class DracPeriodicTaskTestCase(db_base.DbTestCase): self.assertEqual([], self.node.driver_internal_info['raid_config_job_ids']) self.assertEqual({}, self.node.raid_config) - task.process_event.assert_called_once_with('fail') + mock_cleaning_error_handler.assert_called_once_with(task, mock.ANY) + @mock.patch.object(manager_utils, 'deploying_error_handler', autospec=True) + @mock.patch.object(manager_utils, 'cleaning_error_handler', autospec=True) @mock.patch.object(drac_common, 'get_drac_client', spec_set=True, autospec=True) @mock.patch.object(drac_raid.DracRAID, 'get_logical_disks', spec_set=True, autospec=True) def _test__check_node_raid_jobs_with_completed_job_already_failed( self, mock_notify_conductor_resume, - mock_get_logical_disks, mock_get_drac_client): + mock_get_logical_disks, mock_get_drac_client, + mock_cleaning_error_handler, mock_deploying_error_handler): expected_logical_disk = {'size_gb': 558, 'raid_level': '1', 'name': 'disk 0'} @@ -271,7 +276,12 @@ class DracPeriodicTaskTestCase(db_base.DbTestCase): self.assertNotIn('raid_config_job_failure', self.node.driver_internal_info) self.assertNotIn('logical_disks', self.node.raid_config) - task.process_event.assert_called_once_with('fail') + if self.node.clean_step: + mock_cleaning_error_handler.assert_called_once_with(task, mock.ANY) + else: + mock_deploying_error_handler.assert_called_once_with(task, + mock.ANY, + mock.ANY) self.assertFalse(mock_notify_conductor_resume.called) @mock.patch.object(manager_utils, 'notify_conductor_resume_clean', @@ -346,13 +356,16 @@ class DracPeriodicTaskTestCase(db_base.DbTestCase): self._test__check_node_raid_jobs_with_multiple_jobs_completed( mock_notify_conductor_resume) + @mock.patch.object(manager_utils, 'deploying_error_handler', autospec=True) + @mock.patch.object(manager_utils, 'cleaning_error_handler', autospec=True) @mock.patch.object(drac_common, 'get_drac_client', spec_set=True, autospec=True) @mock.patch.object(drac_raid.DracRAID, 'get_logical_disks', spec_set=True, autospec=True) def _test__check_node_raid_jobs_with_multiple_jobs_failed( self, mock_notify_conductor_resume, - mock_get_logical_disks, mock_get_drac_client): + mock_get_logical_disks, mock_get_drac_client, + mock_cleaning_error_handler, mock_deploying_error_handler): expected_logical_disk = {'size_gb': 558, 'raid_level': '1', 'name': 'disk 0'} @@ -387,7 +400,12 @@ class DracPeriodicTaskTestCase(db_base.DbTestCase): self.assertNotIn('raid_config_job_failure', self.node.driver_internal_info) self.assertNotIn('logical_disks', self.node.raid_config) - task.process_event.assert_called_once_with('fail') + if self.node.clean_step: + mock_cleaning_error_handler.assert_called_once_with(task, mock.ANY) + else: + mock_deploying_error_handler.assert_called_once_with(task, + mock.ANY, + mock.ANY) self.assertFalse(mock_notify_conductor_resume.called) @mock.patch.object(manager_utils, 'notify_conductor_resume_clean', |