Use addCleanup to detach volume instead of explicit detach
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
diff --git a/barbican_tempest_plugin/tests/scenario/test_volume_encryption.py b/barbican_tempest_plugin/tests/scenario/test_volume_encryption.py
index 4e80948..61d53e4 100644
--- a/barbican_tempest_plugin/tests/scenario/test_volume_encryption.py
+++ b/barbican_tempest_plugin/tests/scenario/test_volume_encryption.py
@@ -91,7 +91,7 @@
def attach_detach_volume(self, server, volume, keypair):
# Attach volume
- attached_volume = self.nova_volume_attach(server, volume)
+ self.nova_volume_attach(server, volume)
# Write a timestamp to volume
server_ip = self.get_server_ip(server)
@@ -116,9 +116,6 @@
)
self.assertEqual(timestamp, timestamp2)
- # Detach volume
- self.nova_volume_detach(server, attached_volume)
-
@decorators.idempotent_id('89165fb4-5534-4b9d-8429-97ccffb8f86f')
@utils.services('compute', 'volume', 'image')
def test_encrypted_cinder_volumes_luks(self):