compute: Use wait_for_volume_attachment_remove when detaching multiattach volumes

This change replaces the attach_volume cleanup call to
wait_for_volume_resource_status with wait_for_volume_attachment_remove
for multiattach volumes. This newer waiter method being able to handle
cases where multiattached volumes remain attached and thus marked as
'in-use' after being detached from another instance.

Closes-Bug: #1858841
Change-Id: I4e9d253cad1b797940c2c1f922b66602ba592416
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index dd6d593..d7ee39c 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -555,11 +555,17 @@
 
         attachment = self.servers_client.attach_volume(
             server['id'], **attach_kwargs)['volumeAttachment']
-        # On teardown detach the volume and wait for it to be available. This
-        # is so we don't error out when trying to delete the volume during
-        # teardown.
-        self.addCleanup(waiters.wait_for_volume_resource_status,
-                        self.volumes_client, volume['id'], 'available')
+        # On teardown detach the volume and for multiattach volumes wait for
+        # the attachment to be removed. For non-multiattach volumes wait for
+        # the state of the volume to change to available. This is so we don't
+        # error out when trying to delete the volume during teardown.
+        if volume['multiattach']:
+            self.addCleanup(waiters.wait_for_volume_attachment_remove,
+                            self.volumes_client, volume['id'],
+                            attachment['id'])
+        else:
+            self.addCleanup(waiters.wait_for_volume_resource_status,
+                            self.volumes_client, volume['id'], 'available')
         # Ignore 404s on detach in case the server is deleted or the volume
         # is already detached.
         self.addCleanup(self._detach_volume, server, volume)