diff options
author | Zuul <zuul@review.opendev.org> | 2021-03-29 17:25:26 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2021-03-29 17:25:26 +0000 |
commit | d80a6b2651759fbff93c4341ea10db51dee46d7d (patch) | |
tree | 962704f24ebef7e8cbdf0c231897a5de730a8491 /ironic/tests/unit/drivers/modules/drac | |
parent | 851aac397effbf6690c68be58b3ce8765a61a88f (diff) | |
parent | 83ce7c4264a57658fb749c740e6b32e3eb6a906b (diff) | |
download | ironic-d80a6b2651759fbff93c4341ea10db51dee46d7d.tar.gz |
Merge "Fix idrac-wsman BIOS step async error handling"
Diffstat (limited to 'ironic/tests/unit/drivers/modules/drac')
-rw-r--r-- | ironic/tests/unit/drivers/modules/drac/test_bios.py | 82 |
1 files changed, 81 insertions, 1 deletions
diff --git a/ironic/tests/unit/drivers/modules/drac/test_bios.py b/ironic/tests/unit/drivers/modules/drac/test_bios.py index 6fdca0684..3903d979c 100644 --- a/ironic/tests/unit/drivers/modules/drac/test_bios.py +++ b/ironic/tests/unit/drivers/modules/drac/test_bios.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (c) 2015-2016 Dell Inc. or its subsidiaries. +# Copyright (c) 2015-2021 Dell Inc. or its subsidiaries. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -26,6 +26,7 @@ from dracclient import exceptions as drac_exceptions from ironic.common import exception from ironic.common import states from ironic.conductor import task_manager +from ironic.conductor import utils as manager_utils from ironic.drivers.modules import deploy_utils from ironic.drivers.modules.drac import bios as drac_bios from ironic.drivers.modules.drac import common as drac_common @@ -238,6 +239,85 @@ class DracWSManBIOSConfigurationTestCase(test_utils.BaseDracTest): self.assertRaises(exception.DracOperationError, task.driver.bios.factory_reset, task) + @mock.patch.object(manager_utils, 'notify_conductor_resume_clean', + autospec=True) + @mock.patch.object(drac_job, 'get_job', spec_set=True, + autospec=True) + def test__check_node_bios_jobs(self, mock_get_job, + mock_notify_conductor_resume_clean): + mock_job = mock.Mock() + mock_job.status = 'Completed' + mock_get_job.return_value = mock_job + + with task_manager.acquire(self.context, self.node.uuid) as task: + driver_internal_info = task.node.driver_internal_info + driver_internal_info['bios_config_job_ids'] = ['123', '789'] + task.node.driver_internal_info = driver_internal_info + task.node.clean_step = {'priority': 100, 'interface': 'bios', + 'step': 'factory_reset', 'argsinfo': {}} + task.node.save() + mock_cache = mock.Mock() + task.driver.bios.cache_bios_settings = mock_cache + + task.driver.bios._check_node_bios_jobs(task) + + self.assertEqual([], task.node.driver_internal_info.get( + 'bios_config_job_ids')) + mock_cache.assert_called_once_with(task) + mock_notify_conductor_resume_clean.assert_called_once_with(task) + + @mock.patch.object(drac_job, 'get_job', spec_set=True, + autospec=True) + def test__check_node_bios_jobs_still_running(self, mock_get_job): + mock_job = mock.Mock() + mock_job.status = 'Running' + mock_get_job.return_value = mock_job + + with task_manager.acquire(self.context, self.node.uuid) as task: + driver_internal_info = task.node.driver_internal_info + driver_internal_info['bios_config_job_ids'] = ['123'] + task.node.driver_internal_info = driver_internal_info + task.node.save() + mock_resume = mock.Mock() + task.driver.bios._resume_current_operation = mock_resume + mock_cache = mock.Mock() + task.driver.bios.cache_bios_settings = mock_cache + + task.driver.bios._check_node_bios_jobs(task) + + self.assertEqual(['123'], + task.node.driver_internal_info.get( + 'bios_config_job_ids')) + mock_cache.assert_not_called() + mock_resume.assert_not_called() + + @mock.patch.object(manager_utils, 'cleaning_error_handler', autospec=True) + @mock.patch.object(drac_job, 'get_job', spec_set=True, + autospec=True) + def test__check_node_bios_jobs_failed(self, mock_get_job, + mock_cleaning_error_handler): + mock_job = mock.Mock() + mock_job.status = 'Failed' + mock_job.id = '123' + mock_job.message = 'Invalid' + mock_get_job.return_value = mock_job + + with task_manager.acquire(self.context, self.node.uuid) as task: + driver_internal_info = task.node.driver_internal_info + driver_internal_info['bios_config_job_ids'] = ['123'] + task.node.driver_internal_info = driver_internal_info + task.node.clean_step = {'priority': 100, 'interface': 'bios', + 'step': 'factory_reset', 'argsinfo': {}} + task.node.save() + + task.driver.bios._check_node_bios_jobs(task) + + self.assertEqual([], + task.node.driver_internal_info.get( + 'bios_config_job_ids')) + mock_cleaning_error_handler.assert_called_once_with( + task, mock.ANY, "Failed config job: 123. Message: 'Invalid'.") + class DracBIOSConfigurationTestCase(test_utils.BaseDracTest): |