summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryatin <ykarel@redhat.com>2018-03-27 14:49:36 +0530
committeryatin <ykarel@redhat.com>2018-03-27 17:06:44 +0530
commit5ddcc7eefaefb4ef178081ec4838e8f450c6c1dd (patch)
tree76316a8a04ea3b56672d331b9e175dc875f2efd4
parenta6d945d8e677dedf73ccb7b2f7271e8fc96836be (diff)
Use addCleanup to detach volume instead of explicit detachHEADmaster
Cinder volume delete [1] is executed during resource cleanup. So, if test fails due to some reason then it tries to delete a volume which is "in-use" state. Detach volume should be executed before trying to delete the volume. This patch adds nova_detach volume as a cleanup task. [1] https://github.com/openstack/barbican-tempest-plugin/blob/a6d945d8e677dedf73ccb7b2f7271e8fc96836be/barbican_tempest_plugin/tests/scenario/manager.py#L229 Change-Id: I3457bb6fc22a7bb6a32c8d6f4ea5879aeb8d43c5 Related-Bug: #1755485
Notes
Notes (review): Code-Review+2: Jeremy Liu <liujiong@gohighsec.com> Code-Review+2: Juan Antonio Osorio Robles <jaosorior@redhat.com> Workflow+1: Juan Antonio Osorio Robles <jaosorior@redhat.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Wed, 28 Mar 2018 04:39:07 +0000 Reviewed-on: https://review.openstack.org/556800 Project: openstack/barbican-tempest-plugin Branch: refs/heads/master
-rw-r--r--barbican_tempest_plugin/tests/scenario/manager.py1
-rw-r--r--barbican_tempest_plugin/tests/scenario/test_volume_encryption.py5
2 files changed, 2 insertions, 4 deletions
diff --git a/barbican_tempest_plugin/tests/scenario/manager.py b/barbican_tempest_plugin/tests/scenario/manager.py
index 1aa009e..66d28a5 100644
--- a/barbican_tempest_plugin/tests/scenario/manager.py
+++ b/barbican_tempest_plugin/tests/scenario/manager.py
@@ -333,6 +333,7 @@ class ScenarioTest(manager.NetworkScenarioTest):
333 waiters.wait_for_volume_resource_status(self.volumes_client, 333 waiters.wait_for_volume_resource_status(self.volumes_client,
334 volume['id'], 'in-use') 334 volume['id'], 'in-use')
335 335
336 self.addCleanup(self.nova_volume_detach, server, volume)
336 # Return the updated volume after the attachment 337 # Return the updated volume after the attachment
337 return self.volumes_client.show_volume(volume['id'])['volume'] 338 return self.volumes_client.show_volume(volume['id'])['volume']
338 339
diff --git a/barbican_tempest_plugin/tests/scenario/test_volume_encryption.py b/barbican_tempest_plugin/tests/scenario/test_volume_encryption.py
index 95ba5d5..c2033fb 100644
--- a/barbican_tempest_plugin/tests/scenario/test_volume_encryption.py
+++ b/barbican_tempest_plugin/tests/scenario/test_volume_encryption.py
@@ -56,7 +56,7 @@ class VolumeEncryptionTest(barbican_manager.BarbicanScenarioTest):
56 56
57 def attach_detach_volume(self, server, volume, keypair): 57 def attach_detach_volume(self, server, volume, keypair):
58 # Attach volume 58 # Attach volume
59 attached_volume = self.nova_volume_attach(server, volume) 59 self.nova_volume_attach(server, volume)
60 60
61 # Write a timestamp to volume 61 # Write a timestamp to volume
62 server_ip = self.get_server_ip(server) 62 server_ip = self.get_server_ip(server)
@@ -72,9 +72,6 @@ class VolumeEncryptionTest(barbican_manager.BarbicanScenarioTest):
72 ) 72 )
73 self.assertEqual(timestamp, timestamp2) 73 self.assertEqual(timestamp, timestamp2)
74 74
75 # Detach volume
76 self.nova_volume_detach(server, attached_volume)
77
78 @decorators.idempotent_id('89165fb4-5534-4b9d-8429-97ccffb8f86f') 75 @decorators.idempotent_id('89165fb4-5534-4b9d-8429-97ccffb8f86f')
79 @utils.services('compute', 'volume', 'image') 76 @utils.services('compute', 'volume', 'image')
80 def test_encrypted_cinder_volumes_luks(self): 77 def test_encrypted_cinder_volumes_luks(self):