File 0001-Remove-redundant-cleanups-in-test_volume_backup.patch of Package python-cinder-tempest-plugin
From c96757b275a77a745c6c80947bdd0bcb2de7eefd Mon Sep 17 00:00:00 2001
From: melanie witt <melwittt@gmail.com>
Date: Thu, 31 May 2018 00:05:00 +0000
Subject: [PATCH] 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
---
diff --git a/cinder_tempest_plugin/api/volume/base.py b/cinder_tempest_plugin/api/volume/base.py
index b3765e0..50ee60a 100644
--- a/cinder_tempest_plugin/api/volume/base.py
+++ b/cinder_tempest_plugin/api/volume/base.py
@@ -143,7 +143,9 @@
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
diff --git a/cinder_tempest_plugin/api/volume/test_volume_backup.py b/cinder_tempest_plugin/api/volume/test_volume_backup.py
index 4eb7703..8c81543 100644
--- a/cinder_tempest_plugin/api/volume/test_volume_backup.py
+++ b/cinder_tempest_plugin/api/volume/test_volume_backup.py
@@ -41,35 +41,16 @@
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 @@
# 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 @@
# 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'])