"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "ironic/tests/unit/drivers/modules/test_pxe.py" between
ironic-17.0.2.tar.gz and ironic-17.0.3.tar.gz

About: OpenStack Ironic (Optional Service: Bare-Metal Provisioning) aims to provision bare metal machines instead of virtual machines, forked from the Nova baremetal driver.
The "Wallaby" series (latest release).

test_pxe.py  (ironic-17.0.2):test_pxe.py  (ironic-17.0.3)
skipping to change at line 23 skipping to change at line 23
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
"""Test class for PXE driver.""" """Test class for PXE driver."""
import os import os
import tempfile import tempfile
from unittest import mock from unittest import mock
from oslo_config import cfg from oslo_config import cfg
from oslo_serialization import jsonutils as json
from oslo_utils import timeutils from oslo_utils import timeutils
from oslo_utils import uuidutils from oslo_utils import uuidutils
from ironic.common import boot_devices from ironic.common import boot_devices
from ironic.common import boot_modes from ironic.common import boot_modes
from ironic.common import dhcp_factory from ironic.common import dhcp_factory
from ironic.common import exception from ironic.common import exception
from ironic.common.glance_service import image_service from ironic.common.glance_service import image_service
from ironic.common import pxe_utils from ironic.common import pxe_utils
from ironic.common import states from ironic.common import states
skipping to change at line 143 skipping to change at line 142
self.assertRaises(exception.MissingParameterValue, self.assertRaises(exception.MissingParameterValue,
task.driver.boot.validate, task) task.driver.boot.validate, task)
def test_validate_fail_missing_deploy_ramdisk(self): def test_validate_fail_missing_deploy_ramdisk(self):
with task_manager.acquire(self.context, self.node.uuid, with task_manager.acquire(self.context, self.node.uuid,
shared=True) as task: shared=True) as task:
del task.node.driver_info['deploy_ramdisk'] del task.node.driver_info['deploy_ramdisk']
self.assertRaises(exception.MissingParameterValue, self.assertRaises(exception.MissingParameterValue,
task.driver.boot.validate, task) task.driver.boot.validate, task)
def test_validate_no_image_source_for_local_boot(self):
with task_manager.acquire(self.context, self.node.uuid,
shared=True) as task:
del task.node['instance_info']['image_source']
task.driver.boot.validate(task)
def test_validate_fail_missing_image_source(self): def test_validate_fail_missing_image_source(self):
info = dict(INST_INFO_DICT)
del info['image_source']
self.node.instance_info = json.dumps(info)
with task_manager.acquire(self.context, self.node.uuid, with task_manager.acquire(self.context, self.node.uuid,
shared=True) as task: shared=True) as task:
task.node['instance_info'] = json.dumps(info) task.node['instance_info']['capabilities'] = {
'boot_option': 'netboot'}
del task.node['instance_info']['image_source']
self.assertRaises(exception.MissingParameterValue, self.assertRaises(exception.MissingParameterValue,
task.driver.boot.validate, task) task.driver.boot.validate, task)
def test_validate_fail_no_port(self): def test_validate_fail_no_port(self):
new_node = obj_utils.create_test_node( new_node = obj_utils.create_test_node(
self.context, self.context,
uuid='aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee', uuid='aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
driver=self.driver, boot_interface=self.boot_interface, driver=self.driver, boot_interface=self.boot_interface,
instance_info=INST_INFO_DICT, driver_info=DRV_INFO_DICT) instance_info=INST_INFO_DICT, driver_info=DRV_INFO_DICT)
with task_manager.acquire(self.context, new_node.uuid, with task_manager.acquire(self.context, new_node.uuid,
skipping to change at line 203 skipping to change at line 207
task.node.instance_info['capabilities'] = instance_info task.node.instance_info['capabilities'] = instance_info
self.assertRaises(exception.MissingParameterValue, self.assertRaises(exception.MissingParameterValue,
task.driver.boot.validate, task.driver.boot.validate,
task) task)
@mock.patch.object(image_service.GlanceImageService, 'show', autospec=True) @mock.patch.object(image_service.GlanceImageService, 'show', autospec=True)
def test_validate_fail_glance_image_doesnt_exists(self, mock_glance): def test_validate_fail_glance_image_doesnt_exists(self, mock_glance):
mock_glance.side_effect = exception.ImageNotFound('not found') mock_glance.side_effect = exception.ImageNotFound('not found')
with task_manager.acquire(self.context, self.node.uuid, with task_manager.acquire(self.context, self.node.uuid,
shared=True) as task: shared=True) as task:
task.node.instance_info['capabilities'] = {
'boot_option': 'netboot'}
self.assertRaises(exception.InvalidParameterValue, self.assertRaises(exception.InvalidParameterValue,
task.driver.boot.validate, task) task.driver.boot.validate, task)
@mock.patch.object(image_service.GlanceImageService, 'show', autospec=True) @mock.patch.object(image_service.GlanceImageService, 'show', autospec=True)
def test_validate_fail_glance_conn_problem(self, mock_glance): def test_validate_fail_glance_conn_problem(self, mock_glance):
exceptions = (exception.GlanceConnectionFailed('connection fail'), exceptions = (exception.GlanceConnectionFailed('connection fail'),
exception.ImageNotAuthorized('not authorized'), exception.ImageNotAuthorized('not authorized'),
exception.Invalid('invalid')) exception.Invalid('invalid'))
mock_glance.side_effect = exceptions mock_glance.side_effect = exceptions
for exc in exceptions: for exc in exceptions:
with task_manager.acquire(self.context, self.node.uuid, with task_manager.acquire(self.context, self.node.uuid,
shared=True) as task: shared=True) as task:
task.node.instance_info['capabilities'] = {
'boot_option': 'netboot'}
self.assertRaises(exception.InvalidParameterValue, self.assertRaises(exception.InvalidParameterValue,
task.driver.boot.validate, task) task.driver.boot.validate, task)
def test_validate_inspection(self): def test_validate_inspection(self):
with task_manager.acquire(self.context, self.node.uuid) as task: with task_manager.acquire(self.context, self.node.uuid) as task:
task.driver.boot.validate_inspection(task) task.driver.boot.validate_inspection(task)
def test_validate_inspection_no_inspection_ramdisk(self): def test_validate_inspection_no_inspection_ramdisk(self):
driver_info = self.node.driver_info driver_info = self.node.driver_info
del driver_info['deploy_ramdisk'] del driver_info['deploy_ramdisk']
skipping to change at line 975 skipping to change at line 983
with task_manager.acquire(self.context, node.uuid) as task: with task_manager.acquire(self.context, node.uuid) as task:
task.driver.deploy.prepare(task) task.driver.deploy.prepare(task)
self.assertFalse(mock_prepare_instance.called) self.assertFalse(mock_prepare_instance.called)
self.assertEqual({'boot_option': 'ramdisk'}, self.assertEqual({'boot_option': 'ramdisk'},
task.node.instance_info['capabilities']) task.node.instance_info['capabilities'])
self.assertTrue(mock_warning.called) self.assertTrue(mock_warning.called)
@mock.patch.object(deploy_utils, 'validate_image_properties', @mock.patch.object(deploy_utils, 'validate_image_properties',
autospec=True) autospec=True)
def test_validate(self, mock_validate_img): def test_validate(self, mock_validate_img):
node = self.node with task_manager.acquire(self.context, self.node.uuid) as task:
node.properties['capabilities'] = 'boot_option:netboot' task.node.instance_info['capabilities'] = {
node.save() 'boot_option': 'netboot'}
with task_manager.acquire(self.context, node.uuid) as task:
task.driver.deploy.validate(task) task.driver.deploy.validate(task)
self.assertTrue(mock_validate_img.called) self.assertTrue(mock_validate_img.called)
@mock.patch.object(fake.FakeBoot, 'validate', autospec=True) @mock.patch.object(fake.FakeBoot, 'validate', autospec=True)
@mock.patch.object(deploy_utils, 'validate_image_properties', @mock.patch.object(deploy_utils, 'validate_image_properties',
autospec=True) autospec=True)
def test_validate_interface_mismatch(self, mock_validate_image, def test_validate_interface_mismatch(self, mock_validate_image,
mock_boot_validate): mock_boot_validate):
node = self.node node = self.node
node.boot_interface = 'fake' node.boot_interface = 'fake'
 End of changes. 7 change blocks. 
9 lines changed or deleted 16 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)