Use random name in tempest tests

In the tempest tests, we use a fixed name for
security groups and containers. A better approach
is to use a random name.

Change-Id: Ia6334f508a5cefe3c7375d56179620088f7f89a2
Closes-Bug: #1748364
This commit is contained in:
deepak_mourya 2018-02-09 12:24:19 +05:30
parent 8189e128bc
commit 8cf5612220

View File

@ -11,6 +11,7 @@
# under the License. # under the License.
from oslo_utils import encodeutils from oslo_utils import encodeutils
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators from tempest.lib import decorators
from zun_tempest_plugin.tests.tempest.api import clients from zun_tempest_plugin.tests.tempest.api import clients
@ -205,7 +206,7 @@ class TestContainer(base.BaseZunTest):
@decorators.idempotent_id('f181eeda-a9d1-4b2e-9746-d6634ca81e2f') @decorators.idempotent_id('f181eeda-a9d1-4b2e-9746-d6634ca81e2f')
def test_run_container_with_security_groups(self): def test_run_container_with_security_groups(self):
sg_name = 'test_sg' sg_name = data_utils.rand_name('test_sg')
self.sgs_client.create_security_group(name=sg_name) self.sgs_client.create_security_group(name=sg_name)
_, model = self._run_container(security_groups=[sg_name]) _, model = self._run_container(security_groups=[sg_name])
sgs = self._get_all_security_groups(model) sgs = self._get_all_security_groups(model)
@ -367,13 +368,15 @@ class TestContainer(base.BaseZunTest):
@decorators.idempotent_id('b218bea7-f19b-499f-9819-c7021ffc59f4') @decorators.idempotent_id('b218bea7-f19b-499f-9819-c7021ffc59f4')
def test_rename_container(self): def test_rename_container(self):
_, model = self._run_container(name='container1') container1_name = data_utils.rand_name('container1')
self.assertEqual('container1', model.name) _, model = self._run_container(name=container1_name)
gen_model = datagen.container_rename_data(name='container2') self.assertEqual(container1_name, model.name)
container2_name = data_utils.rand_name('container2')
gen_model = datagen.container_rename_data(name=container2_name)
resp, model = self.container_client.rename_container(model.uuid, resp, model = self.container_client.rename_container(model.uuid,
gen_model) gen_model)
self.assertEqual(200, resp.status) self.assertEqual(200, resp.status)
self.assertEqual('container2', model.name) self.assertEqual(container2_name, model.name)
@decorators.idempotent_id('142b7716-0b21-41ed-b47d-a42fba75636b') @decorators.idempotent_id('142b7716-0b21-41ed-b47d-a42fba75636b')
def test_top_container(self): def test_top_container(self):
@ -402,8 +405,7 @@ class TestContainer(base.BaseZunTest):
sgs = self._get_all_security_groups(model) sgs = self._get_all_security_groups(model)
self.assertEqual(1, len(sgs)) self.assertEqual(1, len(sgs))
self.assertEqual('default', sgs[0]) self.assertEqual('default', sgs[0])
sg_name = data_utils.rand_name('test_add_sg')
sg_name = 'test_add_sg'
self.sgs_client.create_security_group(name=sg_name) self.sgs_client.create_security_group(name=sg_name)
gen_model = datagen.container_add_sg_data(name=sg_name) gen_model = datagen.container_add_sg_data(name=sg_name)
resp, body = self.container_client.add_security_group( resp, body = self.container_client.add_security_group(