tighten up isolated creds create
we're spewing giant user and tenant names in logs, which make
actually getting to the bottom of things less useful, as we're
constantly doing left / right scrolling. Shorten this up.
this changes makes a number of fix ups here.
1) it shortens down the name to just classname + rand piece, no
need to add extra -tempest- -tenant, as it's pretty redundant. We
throw out any value which has a '.' in it, because that's not a
class name.
2) it fixes the scenario isolated creds call. __name__ is package
name, and cls.__name__ actually gives us the class name.
3) it stops using a variable in a different namespace as a
temporary variable for isolated creds create. This looks like it
was based on a find / replace refactor to remove importing modules.
It worked, but it was wrong.
4) it stops using the same random bits for user & tenant. There is
no reason these should match, and in the new scheme they would if
they shared random bits.
Change-Id: I216155d68cbdbf9bed10e2ab9b7a1ea714570358
diff --git a/tempest/common/isolated_creds.py b/tempest/common/isolated_creds.py
index 95d12c1..38834ff 100644
--- a/tempest/common/isolated_creds.py
+++ b/tempest/common/isolated_creds.py
@@ -146,18 +146,28 @@
else:
self.identity_admin_client.tenants.delete(tenant)
- def _create_creds(self, suffix=None, admin=False):
- data_utils.rand_name_root = data_utils.rand_name(self.name)
- if suffix:
- data_utils.rand_name_root += suffix
- tenant_name = data_utils.rand_name_root + "-tenant"
+ def _create_creds(self, suffix="", admin=False):
+ """Create random credentials under the following schema.
+
+ If the name contains a '.' is the full class path of something, and
+ we don't really care. If it isn't, it's probably a meaningful name,
+ so use it.
+
+ For logging purposes, -user and -tenant are long and redundant,
+ don't use them. The user# will be sufficient to figure it out.
+ """
+ if '.' in self.name:
+ root = ""
+ else:
+ root = self.name
+
+ tenant_name = data_utils.rand_name(root) + suffix
tenant_desc = tenant_name + "-desc"
tenant = self._create_tenant(name=tenant_name,
description=tenant_desc)
- if suffix:
- data_utils.rand_name_root += suffix
- username = data_utils.rand_name_root + "-user"
- email = data_utils.rand_name_root + "@example.com"
+
+ username = data_utils.rand_name(root) + suffix
+ email = data_utils.rand_name(root) + suffix + "@example.com"
user = self._create_user(username, self.password,
tenant, email)
if admin:
diff --git a/tempest/common/utils/data_utils.py b/tempest/common/utils/data_utils.py
index 2b2963c..cd32720 100644
--- a/tempest/common/utils/data_utils.py
+++ b/tempest/common/utils/data_utils.py
@@ -30,8 +30,12 @@
return uuid.uuid4().hex
-def rand_name(name='test'):
- return name + "-tempest-" + str(random.randint(1, 0x7fffffff))
+def rand_name(name=''):
+ randbits = str(random.randint(1, 0x7fffffff))
+ if name:
+ return name + '-' + randbits
+ else:
+ return randbits
def rand_int_id(start=0, end=0x7fffffff):
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 04882f3..ca3a2db 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -233,7 +233,7 @@
def setUpClass(cls):
super(OfficialClientTest, cls).setUpClass()
cls.isolated_creds = isolated_creds.IsolatedCreds(
- __name__, tempest_client=False,
+ cls.__name__, tempest_client=False,
network_resources=cls.network_resources)
username, password, tenant_name = cls.credentials()