Fix exception generation errors
This patch addresses some frequently failing tests with a few minor changes related around how the exceptions are tested and how the data is passed to the exceptions that are failing. I've been able to duplicate the failing tests in CI while streaming video on my desktop of all things. With these changes, I've been unable to reproduce the failures. This also fixes entries for DeployTemplate generation which were noticed as well, however the failures were not observed in CI. And a missing i18n tag was added into the pxe code, where it was previously missing. Change-Id: I719fa12340b51c55c0441df572ee7e3b33b1910c
This commit is contained in:
parent
2288990c7b
commit
7d0cd4c286
@ -494,7 +494,8 @@ def check_for_missing_params(info_dict, error_msg, param_prefix=''):
|
||||
if missing_info:
|
||||
exc_msg = _("%(error_msg)s. Missing are: %(missing_info)s")
|
||||
raise exception.MissingParameterValue(
|
||||
exc_msg % {'error_msg': error_msg, 'missing_info': missing_info})
|
||||
exc_msg % {'error_msg': error_msg,
|
||||
'missing_info': missing_info})
|
||||
|
||||
|
||||
def fetch_images(ctx, cache, images_info, force_raw=True):
|
||||
|
@ -316,9 +316,9 @@ class PXERamdiskDeploy(agent.AgentDeploy):
|
||||
def validate(self, task):
|
||||
if 'ramdisk_boot' not in task.driver.boot.capabilities:
|
||||
raise exception.InvalidParameterValue(
|
||||
err=('Invalid configuration: The boot interface '
|
||||
'must have the `ramdisk_boot` capability. '
|
||||
'You are using an incompatible boot interface.'))
|
||||
message=_('Invalid configuration: The boot interface '
|
||||
'must have the `ramdisk_boot` capability. '
|
||||
'You are using an incompatible boot interface.'))
|
||||
task.driver.boot.validate(task)
|
||||
|
||||
# Validate node capabilities
|
||||
|
@ -1972,10 +1972,13 @@ class ValidateImagePropertiesTestCase(db_base.DbTestCase):
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT,
|
||||
)
|
||||
inst_info = utils.get_image_instance_info(node)
|
||||
self.assertRaisesRegex(exception.InvalidParameterValue,
|
||||
'HTTPError',
|
||||
utils.validate_image_properties, self.context,
|
||||
inst_info, ['kernel', 'ramdisk'])
|
||||
expected_error = ('Validation of image href http://ubuntu '
|
||||
'failed, reason: HTTPError')
|
||||
error = self.assertRaises(exception.InvalidParameterValue,
|
||||
utils.validate_image_properties,
|
||||
self.context,
|
||||
inst_info, ['kernel', 'ramdisk'])
|
||||
self.assertEqual(expected_error, str(error))
|
||||
|
||||
|
||||
class ValidateParametersTestCase(db_base.DbTestCase):
|
||||
|
@ -36,6 +36,7 @@ from ironic.conductor import utils as manager_utils
|
||||
from ironic.drivers import base as drivers_base
|
||||
from ironic.drivers.modules import agent_base_vendor
|
||||
from ironic.drivers.modules import deploy_utils
|
||||
from ironic.drivers.modules import fake
|
||||
from ironic.drivers.modules import ipxe
|
||||
from ironic.drivers.modules import pxe
|
||||
from ironic.drivers.modules.storage import noop as noop_storage
|
||||
@ -1050,18 +1051,24 @@ class PXERamdiskDeployTestCase(db_base.DbTestCase):
|
||||
task.driver.deploy.validate(task)
|
||||
self.assertTrue(mock_validate_img.called)
|
||||
|
||||
@mock.patch.object(fake.FakeBoot, 'validate', autospec=True)
|
||||
@mock.patch.object(deploy_utils, 'validate_image_properties',
|
||||
autospec=True)
|
||||
def test_validate_interface_mismatch(self, mock_validate_image):
|
||||
def test_validate_interface_mismatch(self, mock_validate_image,
|
||||
mock_boot_validate):
|
||||
node = self.node
|
||||
node.boot_interface = 'fake'
|
||||
node.save()
|
||||
self.config(enabled_boot_interfaces=['fake'],
|
||||
default_boot_interface='fake')
|
||||
with task_manager.acquire(self.context, node.uuid) as task:
|
||||
self.assertRaisesRegex(exception.InvalidParameterValue,
|
||||
'must have the `ramdisk_boot` capability',
|
||||
task.driver.deploy.validate, task)
|
||||
error = self.assertRaises(exception.InvalidParameterValue,
|
||||
task.driver.deploy.validate, task)
|
||||
error_message = ('Invalid configuration: The boot interface must '
|
||||
'have the `ramdisk_boot` capability. You are '
|
||||
'using an incompatible boot interface.')
|
||||
self.assertEqual(error_message, str(error))
|
||||
self.assertFalse(mock_boot_validate.called)
|
||||
self.assertFalse(mock_validate_image.called)
|
||||
|
||||
@mock.patch.object(pxe.PXEBoot, 'validate', autospec=True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user