Fix compute create volume test race condition
Currently, create_volume test in test_volume_rbac in compute
module can fail [0] because of a race condition associated
with not waiting for the volume to reach 'active' status
following creation. Normally this is not an issue because
the class helper method "create_volume" is used which
does this in the background, but in this particular test,
create_volume is called via the volumes_extensions_client,
so no wait is currently being done.
This patch adds a wait for the volume to reach 'active'
status.
[0] http://logs.openstack.org/71/466871/4/check/gate-tempest-dsvm-patrole-admin-ubuntu-xenial/fbb5290/console.html
Change-Id: I8c16fab69502fe94e39a63afbb94eee72cc4cac1
diff --git a/patrole_tempest_plugin/tests/api/compute/test_volume_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_volume_rbac.py
index 505ec18..a2ae8e5 100644
--- a/patrole_tempest_plugin/tests/api/compute/test_volume_rbac.py
+++ b/patrole_tempest_plugin/tests/api/compute/test_volume_rbac.py
@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest.common import waiters
from tempest.lib import decorators
from patrole_tempest_plugin import rbac_rule_validation
@@ -40,8 +41,12 @@
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
volume = self.volumes_extensions_client.create_volume(
size=CONF.volume.volume_size)['volume']
- self.addCleanup(self.volumes_extensions_client.delete_volume,
- volume['id'])
+ # Use the admin volumes client to wait, because waiting involves
+ # calling show API action which enforces a different policy.
+ waiters.wait_for_volume_resource_status(self.os_admin.volumes_client,
+ volume['id'], 'available')
+ # Use non-deprecated volumes_client for deletion.
+ self.addCleanup(self.volumes_client.delete_volume, volume['id'])
@decorators.idempotent_id('69b3888c-dff2-47b0-9fa4-0672619c9054')
@rbac_rule_validation.action(