Merge "Deprecate resources_prefix and change rand_name()"
diff --git a/releasenotes/notes/deprecate-resources-prefix-option-ad490c0a30a0266b.yaml b/releasenotes/notes/deprecate-resources-prefix-option-ad490c0a30a0266b.yaml
new file mode 100644
index 0000000..f679208
--- /dev/null
+++ b/releasenotes/notes/deprecate-resources-prefix-option-ad490c0a30a0266b.yaml
@@ -0,0 +1,10 @@
+---
+upgrade:
+ - The default value of rand_name()'s prefix argument is changed
+ to 'tempest' from None to identify resources are created by
+ Tempest.
+deprecations:
+ - The resources_prefix is marked as deprecated because it is
+ enough to set 'tempest' as the prefix on rand_name() to
+ ideintify resources which are created by Tempest and no
+ projects set this option on OpenStack dev community.
diff --git a/tempest/config.py b/tempest/config.py
index 7f45cf4..274cd21 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -1028,7 +1028,12 @@
help="Prefix to be added when generating the name for "
"test resources. It can be used to discover all "
"resources associated with a specific test run when "
- "running tempest on a real-life cloud"),
+ "running tempest on a real-life cloud",
+ deprecated_for_removal=True,
+ deprecated_reason="It is enough to add 'tempest' as this "
+ "prefix to ideintify resources which are "
+ "created by Tempest and no projects set "
+ "this option on OpenStack dev community."),
]
_opts = [
diff --git a/tempest/lib/common/utils/data_utils.py b/tempest/lib/common/utils/data_utils.py
index 642514b..a0941ef 100644
--- a/tempest/lib/common/utils/data_utils.py
+++ b/tempest/lib/common/utils/data_utils.py
@@ -43,7 +43,7 @@
return uuid.uuid4().hex
-def rand_name(name='', prefix=None):
+def rand_name(name='', prefix='tempest'):
"""Generate a random name that includes a random number
:param str name: The name that you want to include
diff --git a/tempest/tests/lib/common/utils/test_data_utils.py b/tempest/tests/lib/common/utils/test_data_utils.py
index 4446e5c..8bdf70e 100644
--- a/tempest/tests/lib/common/utils/test_data_utils.py
+++ b/tempest/tests/lib/common/utils/test_data_utils.py
@@ -37,16 +37,20 @@
actual2 = data_utils.rand_uuid_hex()
self.assertNotEqual(actual, actual2)
- def test_rand_name(self):
- actual = data_utils.rand_name()
+ def test_rand_name_with_default_prefix(self):
+ actual = data_utils.rand_name('foo')
self.assertIsInstance(actual, str)
- actual2 = data_utils.rand_name()
+ self.assertTrue(actual.startswith('tempest-foo'))
+ actual2 = data_utils.rand_name('foo')
+ self.assertTrue(actual2.startswith('tempest-foo'))
self.assertNotEqual(actual, actual2)
- actual = data_utils.rand_name('foo')
+ def test_rand_name_with_none_prefix(self):
+ actual = data_utils.rand_name('foo', prefix=None)
+ self.assertIsInstance(actual, str)
self.assertTrue(actual.startswith('foo'))
- actual2 = data_utils.rand_name('foo')
- self.assertTrue(actual.startswith('foo'))
+ actual2 = data_utils.rand_name('foo', prefix=None)
+ self.assertTrue(actual2.startswith('foo'))
self.assertNotEqual(actual, actual2)
def test_rand_name_with_prefix(self):