diff options
author | jiapei <jiapei2@lenovo.com> | 2018-12-10 06:15:08 +0000 |
---|---|---|
committer | jiapei <jiapei2@lenovo.com> | 2018-12-14 01:43:52 +0000 |
commit | bb2942295a4f2b15f91e91b4b717bb39de228178 (patch) | |
tree | 9cf315e5b9725fbcab2d0df34ad4e02dedded812 /ironic/tests/unit/drivers/modules/xclarity | |
parent | de92b40588ed4d05f2460ad9e10e6ca6abe607ec (diff) | |
download | ironic-bb2942295a4f2b15f91e91b4b717bb39de228178.tar.gz |
Fix XClarity driver management defect
Although previous XClarity driver passes the unit test, we find that
getting boot order function test fails in the 3rd party CI, which will
throw an exception of "Unsupported boot device". After checking with
the code, we find that a boot device mapping from XClarity to Ironic
recoginzed format is needed.
This patch will fix this getting boot order defect. We have verified
this function in our 3rd CI environment. Also it will fix a minor
in power.py and enhance the unit test.
Change-Id: Ia7ccf986cb6b1c332691c811d32cb41850d4796c
Story: 2004576
Task: 28351
Diffstat (limited to 'ironic/tests/unit/drivers/modules/xclarity')
-rw-r--r-- | ironic/tests/unit/drivers/modules/xclarity/test_management.py | 37 | ||||
-rw-r--r-- | ironic/tests/unit/drivers/modules/xclarity/test_power.py | 5 |
2 files changed, 41 insertions, 1 deletions
diff --git a/ironic/tests/unit/drivers/modules/xclarity/test_management.py b/ironic/tests/unit/drivers/modules/xclarity/test_management.py index aa05d2b16..754e50a61 100644 --- a/ironic/tests/unit/drivers/modules/xclarity/test_management.py +++ b/ironic/tests/unit/drivers/modules/xclarity/test_management.py @@ -118,3 +118,40 @@ class XClarityManagementDriverTestCase(db_base.DbTestCase): exception.XClarityError, task.driver.management.get_boot_device, task) + + def test_get_boot_device_current_none(self, mock_xc_client): + with task_manager.acquire(self.context, self.node.uuid) as task: + reference = {'boot_device': None, 'persistent': None} + mock_xc_client.return_value.get_node_all_boot_info.return_value = \ + { + 'bootOrder': { + 'bootOrderList': [{ + 'fakeBootOrderDevices': [] + }] + } + } + expected_boot_device = task.driver.management.get_boot_device( + task=task) + self.assertEqual(reference, expected_boot_device) + + def test_get_boot_device_primary_none(self, mock_xc_client): + with task_manager.acquire(self.context, self.node.uuid) as task: + reference = {'boot_device': None, 'persistent': None} + mock_xc_client.return_value.get_node_all_boot_info.return_value = \ + { + 'bootOrder': { + 'bootOrderList': [ + { + 'bootType': 'SingleUse', + 'CurrentBootOrderDevices': [] + }, + { + 'bootType': 'Permanent', + 'CurrentBootOrderDevices': [] + }, + ] + } + } + expected_boot_device = task.driver.management.get_boot_device( + task=task) + self.assertEqual(reference, expected_boot_device) diff --git a/ironic/tests/unit/drivers/modules/xclarity/test_power.py b/ironic/tests/unit/drivers/modules/xclarity/test_power.py index fcda4e472..d259a6b28 100644 --- a/ironic/tests/unit/drivers/modules/xclarity/test_power.py +++ b/ironic/tests/unit/drivers/modules/xclarity/test_power.py @@ -72,7 +72,9 @@ class XClarityPowerDriverTestCase(db_base.DbTestCase): result = power.XClarityPower.get_power_state(task) self.assertEqual(STATE_POWER_ON, result) - def test_get_power_state_fail(self, mock_xc_client): + @mock.patch.object(common, 'translate_xclarity_power_state', + spec_set=True, autospec=True) + def test_get_power_state_fail(self, mock_translate_state, mock_xc_client): with task_manager.acquire(self.context, self.node.uuid) as task: xclarity_client_exceptions.XClarityError = Exception sys.modules['xclarity_client.exceptions'] = ( @@ -85,6 +87,7 @@ class XClarityPowerDriverTestCase(db_base.DbTestCase): self.assertRaises(exception.XClarityError, task.driver.power.get_power_state, task) + self.assertFalse(mock_translate_state.called) @mock.patch.object(power.LOG, 'warning') @mock.patch.object(power.XClarityPower, 'get_power_state', |