Decrease overall run time when identity auth is set to v3.
This patch avoids executing time.sleep(1) in rbac_utils, when
Keystone v3 auth is enabled, which greatly reduces run time
(approximately by 5 min or more). Thus, this patch also changes
post_test_hook to forcibly set Keystone v3 auth in the tempest
gates, so that tests run much faster.
Currently time.sleep(1) is used to avoid rounding issues with the
"created_at" field when creating a token. This field drops the
milliseconds from the time field. Attempting to use a token before
the time in the "created_at" field results in an error, meaning that
it is necessary to do time.sleep(1). However, with Keystone v3 this
is not the case, so this time.sleep(1) can be avoided with v3, resulting
in much faster overall test execution time.
Change-Id: I679f75b54bcc61f688f761a6e6f16d4cf0173cb7
diff --git a/contrib/post_test_hook.sh b/contrib/post_test_hook.sh
index 3961474..b864a9b 100644
--- a/contrib/post_test_hook.sh
+++ b/contrib/post_test_hook.sh
@@ -50,6 +50,7 @@
# Set additional, necessary CONF values
iniset $TEMPEST_CONFIG auth use_dynamic_credentials True
iniset $TEMPEST_CONFIG auth tempest_roles Member
+iniset $TEMPEST_CONFIG identity auth_version v3
# Give permissions back to Tempest.
sudo chown -R tempest:stack $BASE/new/tempest
diff --git a/patrole_tempest_plugin/rbac_utils.py b/patrole_tempest_plugin/rbac_utils.py
index ae018de..abbb435 100644
--- a/patrole_tempest_plugin/rbac_utils.py
+++ b/patrole_tempest_plugin/rbac_utils.py
@@ -87,11 +87,12 @@
raise
finally:
- test_obj.auth_provider.clear_auth()
- # Sleep to avoid 401 errors caused by rounding in timing of fernet
- # token creation.
- time.sleep(1)
- test_obj.auth_provider.set_auth()
+ if BaseTestCase.get_identity_version() != 'v3':
+ test_obj.auth_provider.clear_auth()
+ # Sleep to avoid 401 errors caused by rounding in timing of
+ # fernet token creation.
+ time.sleep(1)
+ test_obj.auth_provider.set_auth()
def _clear_user_roles(cls, user_id, tenant_id):
roles = cls.creds_client.roles_client.list_user_roles_on_project(