Merge "VMware: Improve reporting of path test failures"
This commit is contained in:
commit
5b8e156782
|
@ -1049,6 +1049,14 @@ def fake_get_network(*args, **kwargs):
|
|||
return {'type': 'fake'}
|
||||
|
||||
|
||||
def assertPathExists(test, path):
|
||||
test.assertIn(path, _db_content.get('files'))
|
||||
|
||||
|
||||
def assertPathNotExists(test, path):
|
||||
test.assertNotIn(path, _db_content.get('files'))
|
||||
|
||||
|
||||
def get_file(file_path):
|
||||
"""Check if file exists in the db."""
|
||||
return file_path in _db_content.get("files")
|
||||
|
|
|
@ -525,9 +525,9 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
|
|||
self.fake_image_uuid,
|
||||
'%s.vmdk' % self.fake_image_uuid)
|
||||
if exists:
|
||||
self.assertTrue(vmwareapi_fake.get_file(str(cache)))
|
||||
vmwareapi_fake.assertPathExists(self, str(cache))
|
||||
else:
|
||||
self.assertFalse(vmwareapi_fake.get_file(str(cache)))
|
||||
vmwareapi_fake.assertPathNotExists(self, str(cache))
|
||||
|
||||
@mock.patch.object(nova.virt.vmwareapi.images.VMwareImage,
|
||||
'from_image')
|
||||
|
@ -542,7 +542,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
|
|||
mock_from_image.return_value = img_props
|
||||
self._create_vm()
|
||||
path = ds_util.DatastorePath(self.ds, self.uuid, '%s.vmdk' % self.uuid)
|
||||
self.assertTrue(vmwareapi_fake.get_file(str(path)))
|
||||
vmwareapi_fake.assertPathExists(self, str(path))
|
||||
self._cached_files_exist()
|
||||
|
||||
@mock.patch.object(nova.virt.vmwareapi.images.VMwareImage,
|
||||
|
@ -565,8 +565,8 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
|
|||
root = ds_util.DatastorePath(self.ds, 'vmware_base',
|
||||
self.fake_image_uuid,
|
||||
'%s.80.vmdk' % self.fake_image_uuid)
|
||||
self.assertTrue(vmwareapi_fake.get_file(str(path)))
|
||||
self.assertTrue(vmwareapi_fake.get_file(str(root)))
|
||||
vmwareapi_fake.assertPathExists(self, str(path))
|
||||
vmwareapi_fake.assertPathExists(self, str(root))
|
||||
|
||||
def _iso_disk_type_created(self, instance_type='m1.large'):
|
||||
self.image['disk_format'] = 'iso'
|
||||
|
@ -574,17 +574,17 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
|
|||
path = ds_util.DatastorePath(self.ds, 'vmware_base',
|
||||
self.fake_image_uuid,
|
||||
'%s.iso' % self.fake_image_uuid)
|
||||
self.assertTrue(vmwareapi_fake.get_file(str(path)))
|
||||
vmwareapi_fake.assertPathExists(self, str(path))
|
||||
|
||||
def test_iso_disk_type_created(self):
|
||||
self._iso_disk_type_created()
|
||||
path = ds_util.DatastorePath(self.ds, self.uuid, '%s.vmdk' % self.uuid)
|
||||
self.assertTrue(vmwareapi_fake.get_file(str(path)))
|
||||
vmwareapi_fake.assertPathExists(self, str(path))
|
||||
|
||||
def test_iso_disk_type_created_with_root_gb_0(self):
|
||||
self._iso_disk_type_created(instance_type='m1.micro')
|
||||
path = ds_util.DatastorePath(self.ds, self.uuid, '%s.vmdk' % self.uuid)
|
||||
self.assertFalse(vmwareapi_fake.get_file(str(path)))
|
||||
vmwareapi_fake.assertPathNotExists(self, str(path))
|
||||
|
||||
def test_iso_disk_cdrom_attach(self):
|
||||
iso_path = ds_util.DatastorePath(self.ds, 'vmware_base',
|
||||
|
@ -642,7 +642,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
|
|||
self._create_vm(ephemeral=50)
|
||||
path = ds_util.DatastorePath(self.ds, self.uuid,
|
||||
'ephemeral_0.vmdk')
|
||||
self.assertTrue(vmwareapi_fake.get_file(str(path)))
|
||||
vmwareapi_fake.assertPathExists(self, str(path))
|
||||
|
||||
def test_ephemeral_disk_attach_from_bdi(self):
|
||||
ephemerals = [{'device_type': 'disk',
|
||||
|
@ -655,17 +655,17 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
|
|||
self._create_vm(bdi=bdi, ephemeral=50)
|
||||
path = ds_util.DatastorePath(self.ds, self.uuid,
|
||||
'ephemeral_0.vmdk')
|
||||
self.assertTrue(vmwareapi_fake.get_file(str(path)))
|
||||
vmwareapi_fake.assertPathExists(self, str(path))
|
||||
path = ds_util.DatastorePath(self.ds, self.uuid,
|
||||
'ephemeral_1.vmdk')
|
||||
self.assertTrue(vmwareapi_fake.get_file(str(path)))
|
||||
vmwareapi_fake.assertPathExists(self, str(path))
|
||||
|
||||
def test_ephemeral_disk_attach_from_bdii_with_no_ephs(self):
|
||||
bdi = {'ephemerals': []}
|
||||
self._create_vm(bdi=bdi, ephemeral=50)
|
||||
path = ds_util.DatastorePath(self.ds, self.uuid,
|
||||
'ephemeral_0.vmdk')
|
||||
self.assertTrue(vmwareapi_fake.get_file(str(path)))
|
||||
vmwareapi_fake.assertPathExists(self, str(path))
|
||||
|
||||
def test_cdrom_attach_with_config_drive(self):
|
||||
self.flags(force_config_drive=True)
|
||||
|
@ -738,8 +738,8 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
|
|||
(self.ds, self.fake_image_uuid, self.fake_image_uuid))
|
||||
gb_cache = ('[%s] vmware_base/%s/%s.0.vmdk' %
|
||||
(self.ds, self.fake_image_uuid, self.fake_image_uuid))
|
||||
self.assertTrue(vmwareapi_fake.get_file(cache))
|
||||
self.assertFalse(vmwareapi_fake.get_file(gb_cache))
|
||||
vmwareapi_fake.assertPathExists(self, cache)
|
||||
vmwareapi_fake.assertPathNotExists(self, gb_cache)
|
||||
|
||||
def _spawn_with_delete_exception(self, fault=None):
|
||||
|
||||
|
@ -803,7 +803,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
|
|||
self._create_vm()
|
||||
info = self._get_info()
|
||||
self._check_vm_info(info, power_state.RUNNING)
|
||||
self.assertTrue(vmwareapi_fake.get_file(str(root)))
|
||||
vmwareapi_fake.assertPathExists(self, str(root))
|
||||
|
||||
@mock.patch.object(nova.virt.vmwareapi.images.VMwareImage,
|
||||
'from_image')
|
||||
|
@ -876,7 +876,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
|
|||
def fake_wait_for_task(task_ref):
|
||||
if task_ref == self.task_ref:
|
||||
self.task_ref = None
|
||||
self.assertTrue(vmwareapi_fake.get_file(cached_image))
|
||||
vmwareapi_fake.assertPathExists(self, cached_image)
|
||||
# N.B. We don't test for -flat here because real
|
||||
# CopyVirtualDisk_Task doesn't actually create it
|
||||
raise CopyError('Copy failed!')
|
||||
|
@ -894,7 +894,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
|
|||
mock.patch.object(self.conn._session, '_wait_for_task',
|
||||
new=fake_wait_for_task)):
|
||||
self.assertRaises(CopyError, self._create_vm)
|
||||
self.assertFalse(vmwareapi_fake.get_file(cached_image))
|
||||
vmwareapi_fake.assertPathNotExists(self, cached_image)
|
||||
|
||||
def test_spawn_disk_extend_failed_partial_copy_failed_cleanup(self):
|
||||
# Spawn instance
|
||||
|
@ -915,7 +915,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
|
|||
def fake_wait_for_task(task_ref):
|
||||
if task_ref == self.task_ref:
|
||||
self.task_ref = None
|
||||
self.assertTrue(vmwareapi_fake.get_file(cached_image))
|
||||
vmwareapi_fake.assertPathExists(self, cached_image)
|
||||
# N.B. We don't test for -flat here because real
|
||||
# CopyVirtualDisk_Task doesn't actually create it
|
||||
raise CopyError('Copy failed!')
|
||||
|
@ -938,7 +938,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
|
|||
mock.patch.object(self.conn._session, '_call_method',
|
||||
new=fake_call_method)):
|
||||
self.assertRaises(DeleteError, self._create_vm)
|
||||
self.assertTrue(vmwareapi_fake.get_file(cached_image))
|
||||
vmwareapi_fake.assertPathExists(self, cached_image)
|
||||
|
||||
@mock.patch.object(nova.virt.vmwareapi.images.VMwareImage,
|
||||
'from_image')
|
||||
|
@ -995,8 +995,8 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
|
|||
fake_call_method)
|
||||
) as (mock_wait_for_task, mock_call_method):
|
||||
self.assertRaises(NoDiskSpace, self._create_vm)
|
||||
self.assertFalse(vmwareapi_fake.get_file(str(cached_image)))
|
||||
self.assertFalse(vmwareapi_fake.get_file(str(tmp_file)))
|
||||
vmwareapi_fake.assertPathNotExists(self, str(cached_image))
|
||||
vmwareapi_fake.assertPathNotExists(self, str(tmp_file))
|
||||
|
||||
def test_spawn_with_move_file_exists_exception(self):
|
||||
# The test will validate that the spawn completes
|
||||
|
@ -1907,9 +1907,9 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
|
|||
self.fake_image_uuid,
|
||||
self._get_timestamp_filename() + '/')
|
||||
if exists:
|
||||
self.assertTrue(vmwareapi_fake.get_file(str(timestamp)))
|
||||
vmwareapi_fake.assertPathExists(self, str(timestamp))
|
||||
else:
|
||||
self.assertFalse(vmwareapi_fake.get_file(str(timestamp)))
|
||||
vmwareapi_fake.assertPathNotExists(self, str(timestamp))
|
||||
|
||||
def _image_aging_image_marked_for_deletion(self):
|
||||
self._create_vm(uuid=uuidutils.generate_uuid())
|
||||
|
|
Loading…
Reference in New Issue