Configure devstack gate to use UUID tokens
Using uuid tokens will result in faster test runs as there wouldn't
be a need for time.sleep in the rbac_utils.py.
For environments that use fernet tokens, continue to use the
time.sleep(1).
Change-Id: I82eda2e23bee412c3b7bb375649cae43b6f6c061
diff --git a/contrib/post_test_hook.sh b/contrib/post_test_hook.sh
index b864a9b..34555fb 100644
--- a/contrib/post_test_hook.sh
+++ b/contrib/post_test_hook.sh
@@ -35,6 +35,11 @@
# Import devstack function 'iniset'.
source $BASE/new/devstack/functions
+# Use uuid tokens for faster test runs
+KEYSTONE_CONF=/etc/keystone/keystone.conf
+iniset $KEYSTONE_CONF token provider uuid
+sudo service apache2 restart
+
# First argument is expected to contain value equal either to 'admin' or
# 'member' (both lower-case).
RBAC_ROLE=$1
diff --git a/patrole_tempest_plugin/rbac_utils.py b/patrole_tempest_plugin/rbac_utils.py
index 18f132e..db648df 100644
--- a/patrole_tempest_plugin/rbac_utils.py
+++ b/patrole_tempest_plugin/rbac_utils.py
@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+import oslo_utils.uuidutils as uuid_utils
import six
import time
@@ -96,8 +97,11 @@
test_obj.auth_provider.clear_auth()
# Fernet tokens are not subsecond aware and Keystone should only be
# precise to the second. Sleep to ensure we are passing the second
- # boundary before attempting to authenticate.
- time.sleep(1)
+ # boundary before attempting to authenticate. If token is of type
+ # uuid, then do not sleep.
+ if not uuid_utils.is_uuid_like(cls.creds_client.
+ identity_client.token):
+ time.sleep(1)
test_obj.auth_provider.set_auth()
def _clear_user_roles(cls, user_id, tenant_id):