Deprecate resources_prefix and change rand_name()

Many projects are using rand_name() which is outside of tempest.lib.
The method specifies the prefix 'tempest', which is the default value
of tempest.conf, to tempest.lib's rand_name().
The prefix is useful to identify these resources are created by Tempest.
No projects change this configuration value, so this patch changes the
default value of rand_name() to 'tempest' and makes resources_prefix
option deprecated.

Change-Id: I624e2eb3954b6171fbbe00a4ed757bfac04b3eaf
This commit is contained in:
Ken'ichi Ohmichi 2017-02-28 14:50:44 -08:00
parent 1d0cc9c53f
commit 11cf2c595c
4 changed files with 27 additions and 8 deletions

View File

@ -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.

View File

@ -1021,7 +1021,12 @@ DefaultGroup = [
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 = [

View File

@ -43,7 +43,7 @@ def rand_uuid_hex():
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

View File

@ -37,16 +37,20 @@ class TestDataUtils(base.TestCase):
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')
self.assertTrue(actual.startswith('foo'))
actual2 = 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', prefix=None)
self.assertTrue(actual2.startswith('foo'))
self.assertNotEqual(actual, actual2)
def test_rand_name_with_prefix(self):