Merge "Remove fake_imagebackend.Raw and cleanup dependent tests"

This commit is contained in:
Jenkins 2016-05-14 01:07:16 +00:00 committed by Gerrit Code Review
commit 17367af1cf
2 changed files with 25 additions and 49 deletions

View File

@ -61,21 +61,3 @@ class Backend(object):
return imagebackend.Backend(True).snapshot(instance,
disk_path,
image_type=image_type)
class Raw(imagebackend.Image):
# NOTE(spandhe) Added for test_rescue and test_rescue_config_drive
def __init__(self, instance=None, disk_name=None, path=None):
pass
def _get_driver_format(self):
pass
def correct_format(self):
pass
def create_image(self, prepare_template, base, size, *args, **kwargs):
pass
def resize_image(self, size):
pass

View File

@ -77,7 +77,6 @@ import nova.tests.unit.image.fake
from nova.tests.unit import matchers
from nova.tests.unit.objects import test_pci_device
from nova.tests.unit.objects import test_vcpu_model
from nova.tests.unit.virt.libvirt import fake_imagebackend
from nova.tests.unit.virt.libvirt import fake_libvirt_utils
from nova.tests.unit.virt.libvirt import fakelibvirt
from nova import utils
@ -15209,22 +15208,14 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
libvirt_utils.write_to_file(mox.IgnoreArg(), mox.IgnoreArg())
libvirt_utils.write_to_file(mox.IgnoreArg(), mox.IgnoreArg(),
mox.IgnoreArg())
imagebackend.Backend.image(instance, 'kernel.rescue', 'raw'
).AndReturn(fake_imagebackend.Raw())
imagebackend.Backend.image(instance, 'ramdisk.rescue', 'raw'
).AndReturn(fake_imagebackend.Raw())
imagebackend.Backend.image(instance, 'disk.rescue', 'default'
).AndReturn(fake_imagebackend.Raw())
imagebackend.Image.cache(context=mox.IgnoreArg(),
fetch_func=mox.IgnoreArg(),
filename=mox.IgnoreArg(),
image_id=mox.IgnoreArg()).MultipleTimes()
imagebackend.Image.cache(context=mox.IgnoreArg(),
fetch_func=mox.IgnoreArg(),
filename=mox.IgnoreArg(),
image_id=mox.IgnoreArg(),
size=None)
mock_backend = mock.MagicMock()
imagebackend.Backend.image(instance, 'kernel.rescue', 'raw'
).AndReturn(mock_backend.kernel)
imagebackend.Backend.image(instance, 'ramdisk.rescue', 'raw'
).AndReturn(mock_backend.ramdisk)
imagebackend.Backend.image(instance, 'disk.rescue', 'default'
).AndReturn(mock_backend.root)
image_meta = objects.ImageMeta.from_dict(
{'id': 'fake', 'name': 'fake'})
@ -15246,6 +15237,11 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
network_info, image_meta, rescue_password)
self.mox.VerifyAll()
# cache() should have been called on the 3 disk backends
for backend in (mock_backend.kernel, mock_backend.ramdisk,
mock_backend.root):
backend.cache.assert_called()
@mock.patch.object(libvirt_utils, 'get_instance_path')
@mock.patch.object(libvirt_utils, 'load_file')
@mock.patch.object(host.Host, "get_domain")
@ -15325,25 +15321,15 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
libvirt_utils.write_to_file(mox.IgnoreArg(), mox.IgnoreArg(),
mox.IgnoreArg())
mock_backend = mock.MagicMock()
imagebackend.Backend.image(instance, 'kernel.rescue', 'raw'
).AndReturn(fake_imagebackend.Raw())
).AndReturn(mock_backend.kernel)
imagebackend.Backend.image(instance, 'ramdisk.rescue', 'raw'
).AndReturn(fake_imagebackend.Raw())
).AndReturn(mock_backend.ramdisk)
imagebackend.Backend.image(instance, 'disk.rescue', 'default'
).AndReturn(fake_imagebackend.Raw())
).AndReturn(mock_backend.root)
imagebackend.Backend.image(instance, 'disk.config.rescue', 'raw'
).AndReturn(fake_imagebackend.Raw())
imagebackend.Image.cache(context=mox.IgnoreArg(),
fetch_func=mox.IgnoreArg(),
filename=mox.IgnoreArg(),
image_id=mox.IgnoreArg()).MultipleTimes()
imagebackend.Image.cache(context=mox.IgnoreArg(),
fetch_func=mox.IgnoreArg(),
filename=mox.IgnoreArg(),
image_id=mox.IgnoreArg(),
size=None)
).AndReturn(mock_backend.config)
instance_metadata.InstanceMetadata.__init__(mox.IgnoreArg(),
content=mox.IgnoreArg(),
@ -15373,6 +15359,14 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
configdrive_path))]
mock_make.assert_has_calls(expected_call)
# cache() should habe been called on the 3 non-config disk backends
for backend in (mock_backend.kernel, mock_backend.ramdisk,
mock_backend.root):
backend.cache.assert_called()
# import_file() should have been called for the config disk
mock_backend.config.import_file.assert_called()
@mock.patch('shutil.rmtree')
@mock.patch('nova.utils.execute')
@mock.patch('os.path.exists')