Remove redundant cleanups in test_volume_backup

The BaseVolumeTest class contains some helper methods that do their
own cleanup steps within them. However, several of the tests in
VolumesBackupsTest were also doing identical cleanup.

Occasionally, this results in a failure to cleanup in the gate [1]
because a test that doesn't wait for resource deletion [2] after it
cleans up a resource can leave a resource in a mid-deletion state that
the base class cleanup will fail with a 400 when *it* tries to delete
the same resource.

This was noticed on the Ocata branch but it looks like the same issues
exist on master in the plugin, so I'm starting with the fix here.

Closes-Bug: #1774684

[1] http://logs.openstack.org/53/570653/1/check/legacy-tempest-dsvm-full-devstack-plugin-ceph/c5d03e7/job-output.txt.gz#_2018-05-30_04_41_10_689262
[2] https://github.com/openstack/cinder-tempest-plugin/blob/28456a1/cinder_tempest_plugin/api/volume/test_volume_backup.py#L64

Change-Id: I2a29daf56f8327fce405e7969767dc9993849f19
This commit is contained in:
melanie witt 2018-05-31 00:05:00 +00:00
parent 28456a1234
commit c96757b275
2 changed files with 7 additions and 38 deletions

View File

@ -143,7 +143,9 @@ class BaseVolumeTest(api_version_utils.BaseMicroversionTest,
backup = backup_client.create_backup(
volume_id=volume_id, **kwargs)['backup']
self.addCleanup(backup_client.delete_backup, backup['id'])
self.addCleanup(backup_client.wait_for_resource_deletion, backup['id'])
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
backup_client.delete_backup, backup['id'])
waiters.wait_for_volume_resource_status(backup_client, backup['id'],
'available')
return backup

View File

@ -41,35 +41,16 @@ class VolumesBackupsTest(base.BaseVolumeTest):
backup = self.create_backup(
volume_id=volume['id'],
snapshot_id=snapshot['id'])
# Get a given backup
backup = self.backups_client.show_backup(
backup['id'])['backup']
waiters.wait_for_volume_resource_status(
self.backups_client,
backup['id'], 'available')
self.assertEqual(volume['id'], backup['volume_id'])
self.assertEqual(snapshot['id'], backup['snapshot_id'])
self.snapshots_client.delete_snapshot(snapshot['id'])
self.snapshots_client.wait_for_resource_deletion(snapshot['id'])
self.volumes_client.delete_volume(volume['id'])
self.volumes_client.wait_for_resource_deletion(volume['id'])
@decorators.idempotent_id('b5d837b0-7066-455d-88fc-4a721a899306')
def test_backup_create_and_restore_to_an_existing_volume(self):
"""Test backup create and restore to an existing volume."""
# Create volume
src_vol = self.create_volume()
self.addCleanup(self.volumes_client.delete_volume,
src_vol['id'])
# Create backup
backup = self.backups_client.create_backup(
volume_id=src_vol['id'])['backup']
self.addCleanup(self.backups_client.delete_backup, backup['id'])
waiters.wait_for_volume_resource_status(
self.backups_client,
backup['id'], 'available')
backup = self.create_backup(volume_id=src_vol['id'])
# Restore to existing volume
restore = self.backups_client.restore_backup(
backup_id=backup['id'],
@ -89,14 +70,9 @@ class VolumesBackupsTest(base.BaseVolumeTest):
# Create volume from image
volume = self.create_volume(size=CONF.volume.volume_size,
imageRef=CONF.compute.image_ref)
self.addCleanup(self.volumes_client.delete_volume,
volume['id'])
# Create backup
backup = self.backups_client.create_backup(
volume_id=volume['id'])['backup']
waiters.wait_for_volume_resource_status(self.backups_client,
backup['id'], 'available')
self.create_backup(volume_id=volume['id'])
# Create a server
bd_map = [{'volume_id': volume['id'],
'delete_on_termination': '0'}]
@ -112,19 +88,10 @@ class VolumesBackupsTest(base.BaseVolumeTest):
# Create incremental backup
waiters.wait_for_volume_resource_status(self.volumes_client,
volume['id'], 'available')
backup_incr = self.backups_client.create_backup(
backup_incr = self.create_backup(
volume_id=volume['id'],
incremental=True)['backup']
waiters.wait_for_volume_resource_status(self.backups_client,
backup_incr['id'],
'available')
incremental=True)
is_incremental = self.backups_client.show_backup(
backup_incr['id'])['backup']['is_incremental']
self.assertTrue(is_incremental)
self.backups_client.delete_backup(backup_incr['id'])
self.backups_client.wait_for_resource_deletion(backup_incr['id'])
self.backups_client.delete_backup(backup['id'])
self.backups_client.wait_for_resource_deletion(backup['id'])