diff --git a/tempest/api/compute/admin/test_agents.py b/tempest/api/compute/admin/test_agents.py index f54fb2245e..8fc155b02b 100644 --- a/tempest/api/compute/admin/test_agents.py +++ b/tempest/api/compute/admin/test_agents.py @@ -51,7 +51,9 @@ class AgentsAdminTestJSON(base.BaseV2ComputeAdminTest): # If you try to create an agent with the same hypervisor, # os and architecture as an existing agent, Nova will return # an HTTPConflict or HTTPServerError. - kwargs[rand_key] = data_utils.rand_name(kwargs[rand_key]) + kwargs[rand_key] = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=kwargs[rand_key]) return kwargs @decorators.idempotent_id('1fc6bdc8-0b6d-4cc7-9f30-9b04fabe5b90') diff --git a/tempest/api/compute/admin/test_aggregates_negative.py b/tempest/api/compute/admin/test_aggregates_negative.py index 7b115ceabc..c284370fcb 100644 --- a/tempest/api/compute/admin/test_aggregates_negative.py +++ b/tempest/api/compute/admin/test_aggregates_negative.py @@ -15,10 +15,13 @@ from tempest.api.compute import base from tempest.common import tempest_fixtures as fixtures +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators from tempest.lib import exceptions as lib_exc +CONF = config.CONF + class AggregatesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): """Tests Aggregates API that require admin privileges""" @@ -40,7 +43,9 @@ class AggregatesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): if v['status'] == 'enabled' and v['state'] == 'up'] def _create_test_aggregate(self): - aggregate_name = data_utils.rand_name(self.aggregate_name_prefix) + aggregate_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.aggregate_name_prefix) aggregate = (self.client.create_aggregate(name=aggregate_name) ['aggregate']) self.addCleanup(self.client.delete_aggregate, aggregate['id']) @@ -50,7 +55,9 @@ class AggregatesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): @decorators.idempotent_id('86a1cb14-da37-4a70-b056-903fd56dfe29') def test_aggregate_create_as_user(self): """Regular user is not allowed to create an aggregate""" - aggregate_name = data_utils.rand_name(self.aggregate_name_prefix) + aggregate_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.aggregate_name_prefix) self.assertRaises(lib_exc.Forbidden, self.aggregates_client.create_aggregate, name=aggregate_name) @@ -125,7 +132,9 @@ class AggregatesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): def test_aggregate_add_non_exist_host(self): """Adding a non-exist host to an aggregate should fail""" while True: - non_exist_host = data_utils.rand_name('nonexist_host') + non_exist_host = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name='nonexist_host') if non_exist_host not in self.hosts: break aggregate = self._create_test_aggregate() diff --git a/tempest/api/compute/admin/test_create_server.py b/tempest/api/compute/admin/test_create_server.py index ccdfbf3b83..293e2843ab 100644 --- a/tempest/api/compute/admin/test_create_server.py +++ b/tempest/api/compute/admin/test_create_server.py @@ -51,7 +51,8 @@ class ServersWithSpecificFlavorTestJSON(base.BaseV2ComputeAdminTest): def create_flavor_with_ephemeral(ephem_disk): name = 'flavor_with_ephemeral_%s' % ephem_disk - flavor_name = data_utils.rand_name(name) + flavor_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name=name) ram = flavor_base['ram'] vcpus = flavor_base['vcpus'] diff --git a/tempest/api/compute/admin/test_flavors.py b/tempest/api/compute/admin/test_flavors.py index 294b1ab4b1..cece9054cb 100644 --- a/tempest/api/compute/admin/test_flavors.py +++ b/tempest/api/compute/admin/test_flavors.py @@ -16,10 +16,13 @@ import uuid from tempest.api.compute import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators from tempest.lib import exceptions as lib_exc +CONF = config.CONF + class FlavorsAdminTestJSON(base.BaseV2ComputeAdminTest): """Tests Flavors API Create and Delete that require admin privileges""" @@ -76,7 +79,9 @@ class FlavorsAdminTestJSON(base.BaseV2ComputeAdminTest): This operation requires the user to have 'admin' role """ - flavor_name = data_utils.rand_name(self.flavor_name_prefix) + flavor_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.flavor_name_prefix) # Create the flavor self.create_flavor(name=flavor_name, @@ -107,7 +112,9 @@ class FlavorsAdminTestJSON(base.BaseV2ComputeAdminTest): self.assertEqual(flavor['OS-FLV-EXT-DATA:ephemeral'], 0) self.assertEqual(flavor['os-flavor-access:is_public'], True) - flavor_name = data_utils.rand_name(self.flavor_name_prefix) + flavor_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.flavor_name_prefix) new_flavor_id = data_utils.rand_int_id(start=1000) # Create the flavor @@ -143,7 +150,9 @@ class FlavorsAdminTestJSON(base.BaseV2ComputeAdminTest): tenant is not automatically added access list. This operation requires the user to have 'admin' role """ - flavor_name = data_utils.rand_name(self.flavor_name_prefix) + flavor_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.flavor_name_prefix) # Create the flavor self.create_flavor(name=flavor_name, @@ -178,7 +187,9 @@ class FlavorsAdminTestJSON(base.BaseV2ComputeAdminTest): Try to List/Get flavor with another user """ - flavor_name = data_utils.rand_name(self.flavor_name_prefix) + flavor_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.flavor_name_prefix) # Create the flavor self.create_flavor(name=flavor_name, @@ -192,8 +203,11 @@ class FlavorsAdminTestJSON(base.BaseV2ComputeAdminTest): @decorators.idempotent_id('fb9cbde6-3a0e-41f2-a983-bdb0a823c44e') def test_is_public_string_variations(self): """Test creating public and non public flavors""" - flavor_name_not_public = data_utils.rand_name(self.flavor_name_prefix) - flavor_name_public = data_utils.rand_name(self.flavor_name_prefix) + prefix = CONF.resource_name_prefix + flavor_name_not_public = data_utils.rand_name( + prefix=prefix, name=self.flavor_name_prefix) + flavor_name_public = data_utils.rand_name( + prefix=prefix, name=self.flavor_name_prefix) # Create a non public flavor self.create_flavor(name=flavor_name_not_public, diff --git a/tempest/api/compute/admin/test_flavors_extra_specs.py b/tempest/api/compute/admin/test_flavors_extra_specs.py index da95660a3f..5829269cbe 100644 --- a/tempest/api/compute/admin/test_flavors_extra_specs.py +++ b/tempest/api/compute/admin/test_flavors_extra_specs.py @@ -14,9 +14,12 @@ # under the License. from tempest.api.compute import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators +CONF = config.CONF + class FlavorsExtraSpecsTestJSON(base.BaseV2ComputeAdminTest): """Tests Flavor Extra Spec API extension. @@ -28,7 +31,8 @@ class FlavorsExtraSpecsTestJSON(base.BaseV2ComputeAdminTest): @classmethod def resource_setup(cls): super(FlavorsExtraSpecsTestJSON, cls).resource_setup() - flavor_name = data_utils.rand_name('test_flavor') + flavor_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='test_flavor') ram = 512 vcpus = 1 disk = 10 @@ -139,7 +143,9 @@ class FlavorMetadataValidation(base.BaseV2ComputeAdminTest): @decorators.idempotent_id('d3114f03-b0f2-4dc7-be11-70c0abc178b3') def test_flavor_update_with_custom_namespace(self): """Test flavor creation with a custom namespace, key and value""" - flavor_name = data_utils.rand_name(self.flavor_name_prefix) + flavor_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.flavor_name_prefix) flavor_id = self.create_flavor(ram=self.ram, vcpus=self.vcpus, disk=self.disk, diff --git a/tempest/api/compute/admin/test_flavors_extra_specs_negative.py b/tempest/api/compute/admin/test_flavors_extra_specs_negative.py index 68226144cb..7f518d2d4c 100644 --- a/tempest/api/compute/admin/test_flavors_extra_specs_negative.py +++ b/tempest/api/compute/admin/test_flavors_extra_specs_negative.py @@ -15,10 +15,13 @@ # under the License. from tempest.api.compute import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators from tempest.lib import exceptions as lib_exc +CONF = config.CONF + class FlavorsExtraSpecsNegativeTestJSON(base.BaseV2ComputeAdminTest): """Negative Tests Flavor Extra Spec API extension. @@ -30,7 +33,8 @@ class FlavorsExtraSpecsNegativeTestJSON(base.BaseV2ComputeAdminTest): def resource_setup(cls): super(FlavorsExtraSpecsNegativeTestJSON, cls).resource_setup() - flavor_name = data_utils.rand_name('test_flavor') + flavor_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='test_flavor') ram = 512 vcpus = 1 disk = 10 diff --git a/tempest/api/compute/admin/test_keypairs_v210.py b/tempest/api/compute/admin/test_keypairs_v210.py index 30681275f1..5c5031b932 100644 --- a/tempest/api/compute/admin/test_keypairs_v210.py +++ b/tempest/api/compute/admin/test_keypairs_v210.py @@ -14,9 +14,12 @@ # under the License. from tempest.api.compute.keypairs import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators +CONF = config.CONF + class KeyPairsV210TestJSON(base.BaseKeypairTest): """Tests KeyPairs API with microversion higher than 2.9""" @@ -33,7 +36,8 @@ class KeyPairsV210TestJSON(base.BaseKeypairTest): def _create_and_check_keypairs(self, user_id): key_list = list() for _ in range(2): - k_name = data_utils.rand_name('keypair') + k_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='keypair') keypair = self.create_keypair(k_name, keypair_type='ssh', user_id=user_id, diff --git a/tempest/api/compute/admin/test_live_migration.py b/tempest/api/compute/admin/test_live_migration.py index d68334fe87..429755aef4 100644 --- a/tempest/api/compute/admin/test_live_migration.py +++ b/tempest/api/compute/admin/test_live_migration.py @@ -214,7 +214,8 @@ class LiveMigrationTest(LiveMigrationTestBase): self.assertEqual(volume_id1, volume_id2) def _create_net_subnet(self, name, cidr): - net_name = data_utils.rand_name(name=name) + net_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name=name) net = self.networks_client.create_network(name=net_name)['network'] self.addClassResourceCleanup( self.networks_client.delete_network, net['id']) @@ -228,7 +229,8 @@ class LiveMigrationTest(LiveMigrationTestBase): return net def _create_port(self, network_id, name): - name = data_utils.rand_name(name=name) + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name=name) port = self.ports_client.create_port(name=name, network_id=network_id)['port'] self.addClassResourceCleanup(test_utils.call_and_ignore_notfound_exc, @@ -244,7 +246,8 @@ class LiveMigrationTest(LiveMigrationTestBase): subport = self._create_port(network_id=net['id'], name='subport') trunk = self.trunks_client.create_trunk( - name=data_utils.rand_name('trunk'), + name=data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='trunk'), port_id=parent['id'], sub_ports=[{"segmentation_id": 42, "port_id": subport['id'], "segmentation_type": "vlan"}] diff --git a/tempest/api/compute/admin/test_live_migration_negative.py b/tempest/api/compute/admin/test_live_migration_negative.py index 80c0525037..c956d998f2 100644 --- a/tempest/api/compute/admin/test_live_migration_negative.py +++ b/tempest/api/compute/admin/test_live_migration_negative.py @@ -43,7 +43,8 @@ class LiveMigrationNegativeTest(base.BaseV2ComputeAdminTest): @decorators.idempotent_id('7fb7856e-ae92-44c9-861a-af62d7830bcb') def test_invalid_host_for_migration(self): """Test migrating to an invalid host should not change the status""" - target_host = data_utils.rand_name('host') + target_host = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='host') server = self.create_test_server(wait_until="ACTIVE") self.assertRaises(lib_exc.BadRequest, self._migrate_server_to, diff --git a/tempest/api/compute/admin/test_migrations.py b/tempest/api/compute/admin/test_migrations.py index b3d283330f..fa8a7379c3 100644 --- a/tempest/api/compute/admin/test_migrations.py +++ b/tempest/api/compute/admin/test_migrations.py @@ -74,7 +74,9 @@ class MigrationsAdminTest(base.BaseV2ComputeAdminTest): flavor = self.admin_flavors_client.show_flavor( self.flavor_ref)['flavor'] flavor = self.admin_flavors_client.create_flavor( - name=data_utils.rand_name('test_resize_flavor_'), + name=data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name='test_resize_flavor_'), ram=flavor['ram'], disk=flavor['disk'], vcpus=flavor['vcpus'] diff --git a/tempest/api/compute/admin/test_quotas.py b/tempest/api/compute/admin/test_quotas.py index caf4fc1a08..70711f5580 100644 --- a/tempest/api/compute/admin/test_quotas.py +++ b/tempest/api/compute/admin/test_quotas.py @@ -43,7 +43,9 @@ class QuotasAdminTestBase(base.BaseV2ComputeAdminTest): def _get_updated_quotas(self): # Verify that GET shows the updated quota set of project - project_name = data_utils.rand_name('cpu_quota_project') + project_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name='cpu_quota_project') project_desc = project_name + '-desc' project = identity.identity_utils(self.os_admin).create_project( name=project_name, description=project_desc) @@ -59,7 +61,9 @@ class QuotasAdminTestBase(base.BaseV2ComputeAdminTest): self.assertEqual(5120, quota_set['ram']['limit']) # Verify that GET shows the updated quota set of user - user_name = data_utils.rand_name('cpu_quota_user') + user_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name='cpu_quota_user') password = data_utils.rand_password() email = user_name + '@testmail.tm' user = identity.identity_utils(self.os_admin).create_user( @@ -157,7 +161,9 @@ class QuotasAdminTestJSON(QuotasAdminTestBase): 'Legacy quota update not available with unified limits') def test_delete_quota(self): """Test admin can delete the compute quota set for a project""" - project_name = data_utils.rand_name('ram_quota_project') + project_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name='ram_quota_project') project_desc = project_name + '-desc' project = identity.identity_utils(self.os_admin).create_project( name=project_name, description=project_desc) diff --git a/tempest/api/compute/admin/test_quotas_negative.py b/tempest/api/compute/admin/test_quotas_negative.py index a4120bbda8..ef89cc1c2d 100644 --- a/tempest/api/compute/admin/test_quotas_negative.py +++ b/tempest/api/compute/admin/test_quotas_negative.py @@ -133,8 +133,9 @@ class QuotasSecurityGroupAdminNegativeTest(QuotasAdminNegativeTestBase): # when we reach limit maxSecurityGroupRules self._update_quota('security_group_rules', 0) - s_name = data_utils.rand_name('securitygroup') - s_description = data_utils.rand_name('description') + prefix = CONF.resource_name_prefix + s_name = data_utils.rand_name(prefix=prefix, name='securitygroup') + s_description = data_utils.rand_name(prefix=prefix, name='description') securitygroup = self.sg_client.create_security_group( name=s_name, description=s_description)['security_group'] self.addCleanup(self.sg_client.delete_security_group, diff --git a/tempest/api/compute/admin/test_security_groups.py b/tempest/api/compute/admin/test_security_groups.py index f0a6a84e1d..41acc9415f 100644 --- a/tempest/api/compute/admin/test_security_groups.py +++ b/tempest/api/compute/admin/test_security_groups.py @@ -15,9 +15,12 @@ from tempest.api.compute import base from tempest.common import utils +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators +CONF = config.CONF + class SecurityGroupsTestAdminJSON(base.BaseV2ComputeAdminTest): """Test security groups API that requires admin privilege @@ -57,9 +60,11 @@ class SecurityGroupsTestAdminJSON(base.BaseV2ComputeAdminTest): # List of all security groups created security_group_list = [] # Create two security groups for a non-admin tenant + prefix = CONF.resource_name_prefix for _ in range(2): - name = data_utils.rand_name('securitygroup') - description = data_utils.rand_name('description') + name = data_utils.rand_name(prefix=prefix, name='securitygroup') + description = data_utils.rand_name( + prefix=prefix, name='description') securitygroup = self.client.create_security_group( name=name, description=description)['security_group'] self.addCleanup(self._delete_security_group, @@ -69,8 +74,9 @@ class SecurityGroupsTestAdminJSON(base.BaseV2ComputeAdminTest): client_tenant_id = securitygroup['tenant_id'] # Create two security groups for admin tenant for _ in range(2): - name = data_utils.rand_name('securitygroup') - description = data_utils.rand_name('description') + name = data_utils.rand_name(prefix=prefix, name='securitygroup') + description = data_utils.rand_name( + prefix=prefix, name='description') adm_securitygroup = self.adm_client.create_security_group( name=name, description=description)['security_group'] self.addCleanup(self._delete_security_group, diff --git a/tempest/api/compute/admin/test_servers.py b/tempest/api/compute/admin/test_servers.py index 321078c5d6..be838fcbc0 100644 --- a/tempest/api/compute/admin/test_servers.py +++ b/tempest/api/compute/admin/test_servers.py @@ -37,11 +37,14 @@ class ServersAdminTestJSON(base.BaseV2ComputeAdminTest): def resource_setup(cls): super(ServersAdminTestJSON, cls).resource_setup() - cls.s1_name = data_utils.rand_name(cls.__name__ + '-server') + prefix = CONF.resource_name_prefix + cls.s1_name = data_utils.rand_name(prefix=prefix, + name=cls.__name__ + '-server') server = cls.create_test_server(name=cls.s1_name) cls.s1_id = server['id'] - cls.s2_name = data_utils.rand_name(cls.__name__ + '-server') + cls.s2_name = data_utils.rand_name(prefix=prefix, + name=cls.__name__ + '-server') server = cls.create_test_server(name=cls.s2_name, wait_until='ACTIVE') cls.s2_id = server['id'] diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py index d02532ddc6..2557e47847 100644 --- a/tempest/api/compute/base.py +++ b/tempest/api/compute/base.py @@ -223,7 +223,9 @@ class BaseV2ComputeTest(api_version_utils.BaseMicroversionTest, `compute.create_test_server` call. """ if 'name' not in kwargs: - kwargs['name'] = data_utils.rand_name(cls.__name__ + "-server") + kwargs['name'] = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=cls.__name__ + "-server") request_version = api_version_request.APIVersionRequest( cls.request_microversion) @@ -260,10 +262,13 @@ class BaseV2ComputeTest(api_version_utils.BaseMicroversionTest, @classmethod def create_security_group(cls, name=None, description=None): + prefix = CONF.resource_name_prefix if name is None: - name = data_utils.rand_name(cls.__name__ + "-securitygroup") + name = data_utils.rand_name( + prefix=prefix, name=cls.__name__ + "-securitygroup") if description is None: - description = data_utils.rand_name('description') + description = data_utils.rand_name( + prefix=prefix, name='description') body = cls.security_groups_client.create_security_group( name=name, description=description)['security_group'] cls.addClassResourceCleanup( @@ -276,7 +281,9 @@ class BaseV2ComputeTest(api_version_utils.BaseMicroversionTest, @classmethod def create_test_server_group(cls, name="", policy=None): if not name: - name = data_utils.rand_name(cls.__name__ + "-Server-Group") + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=cls.__name__ + "-Server-Group") if cls.is_requested_microversion_compatible('2.63'): policy = policy or ['affinity'] if not isinstance(policy, list): @@ -324,8 +331,11 @@ class BaseV2ComputeTest(api_version_utils.BaseMicroversionTest, If compute microversion >= 2.36, the returned image response will be from the image service API rather than the compute image proxy API. """ - name = kwargs.pop('name', - data_utils.rand_name(cls.__name__ + "-image")) + name = kwargs.pop( + 'name', + data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=cls.__name__ + "-image")) wait_until = kwargs.pop('wait_until', None) wait_for_server = kwargs.pop('wait_for_server', True) @@ -501,7 +511,9 @@ class BaseV2ComputeTest(api_version_utils.BaseMicroversionTest, if 'size' not in kwargs: kwargs['size'] = CONF.volume.volume_size if 'display_name' not in kwargs: - vol_name = data_utils.rand_name(cls.__name__ + '-volume') + vol_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=cls.__name__ + '-volume') kwargs['display_name'] = vol_name if image_ref is not None: kwargs['imageRef'] = image_ref @@ -595,7 +607,8 @@ class BaseV2ComputeTest(api_version_utils.BaseMicroversionTest, def create_volume_snapshot(self, volume_id, name=None, description=None, metadata=None, force=False): name = name or data_utils.rand_name( - self.__class__.__name__ + '-snapshot') + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-snapshot') snapshot = self.snapshots_client.create_snapshot( volume_id=volume_id, force=force, @@ -652,7 +665,9 @@ class BaseV2ComputeAdminTest(BaseV2ComputeTest): def create_flavor(self, ram, vcpus, disk, name=None, is_public='True', **kwargs): if name is None: - name = data_utils.rand_name(self.__class__.__name__ + "-flavor") + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + "-flavor") id = kwargs.pop('id', data_utils.rand_int_id(start=1000)) client = self.admin_flavors_client flavor = client.create_flavor( diff --git a/tempest/api/compute/flavors/test_flavors_negative.py b/tempest/api/compute/flavors/test_flavors_negative.py index 22b71fcdc6..09f54b5859 100644 --- a/tempest/api/compute/flavors/test_flavors_negative.py +++ b/tempest/api/compute/flavors/test_flavors_negative.py @@ -44,7 +44,8 @@ class FlavorsV2NegativeTest(base.BaseV2ComputeTest): size = random.randint(1024, 4096) image_file = io.BytesIO(data_utils.random_bytes(size)) params = { - 'name': data_utils.rand_name('image'), + 'name': data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='image'), 'container_format': CONF.image.container_formats[0], 'disk_format': CONF.image.disk_formats[0], 'min_ram': min_img_ram, diff --git a/tempest/api/compute/images/test_image_metadata.py b/tempest/api/compute/images/test_image_metadata.py index f630bc89ed..1c9f212492 100644 --- a/tempest/api/compute/images/test_image_metadata.py +++ b/tempest/api/compute/images/test_image_metadata.py @@ -52,9 +52,12 @@ class ImagesMetadataTestJSON(base.BaseV2ComputeTest): def resource_setup(cls): super(ImagesMetadataTestJSON, cls).resource_setup() cls.image_id = None - + image_name_kwargs = { + 'prefix': CONF.resource_name_prefix, + 'name': 'image' + } params = { - 'name': data_utils.rand_name('image'), + 'name': data_utils.rand_name(**image_name_kwargs), 'container_format': 'bare', 'disk_format': 'raw', 'visibility': 'private' diff --git a/tempest/api/compute/images/test_images.py b/tempest/api/compute/images/test_images.py index d47ffce504..87cedae60a 100644 --- a/tempest/api/compute/images/test_images.py +++ b/tempest/api/compute/images/test_images.py @@ -57,7 +57,8 @@ class ImagesTestJSON(base.BaseV2ComputeTest): # in task_state image_snapshot self.addCleanup(waiters.wait_for_server_status, self.servers_client, server['id'], 'ACTIVE') - snapshot_name = data_utils.rand_name('test-snap') + snapshot_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='test-snap') try: image = self.create_image_from_server(server['id'], name=snapshot_name, @@ -83,7 +84,8 @@ class ImagesTestJSON(base.BaseV2ComputeTest): waiters.wait_for_server_status(self.servers_client, server['id'], 'SHUTOFF') self.addCleanup(self.servers_client.delete_server, server['id']) - snapshot_name = data_utils.rand_name('test-snap') + snapshot_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='test-snap') image = self.create_image_from_server(server['id'], name=snapshot_name, wait_until='ACTIVE', @@ -102,7 +104,8 @@ class ImagesTestJSON(base.BaseV2ComputeTest): server['id'], 'PAUSED') self.addCleanup(self.servers_client.delete_server, server['id']) - snapshot_name = data_utils.rand_name('test-snap') + snapshot_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='test-snap') image = self.create_image_from_server(server['id'], name=snapshot_name, wait_until='ACTIVE', @@ -121,7 +124,8 @@ class ImagesTestJSON(base.BaseV2ComputeTest): server['id'], 'SUSPENDED') self.addCleanup(self.servers_client.delete_server, server['id']) - snapshot_name = data_utils.rand_name('test-snap') + snapshot_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='test-snap') image = self.create_image_from_server(server['id'], name=snapshot_name, wait_until='ACTIVE', @@ -136,7 +140,8 @@ class ImagesTestJSON(base.BaseV2ComputeTest): self.addCleanup(self.servers_client.delete_server, server['id']) # Snapshot it - snapshot_name = data_utils.rand_name('test-snap') + snapshot_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='test-snap') image = self.create_image_from_server(server['id'], name=snapshot_name, wait_until='ACTIVE', diff --git a/tempest/api/compute/images/test_images_negative.py b/tempest/api/compute/images/test_images_negative.py index 124651e83d..2375514b30 100644 --- a/tempest/api/compute/images/test_images_negative.py +++ b/tempest/api/compute/images/test_images_negative.py @@ -66,8 +66,12 @@ class ImagesNegativeTestJSON(ImagesNegativeTestBase): """Check server image should not be created with invalid server id""" # Create a new image with invalid server id meta = {'image_type': 'test'} - self.assertRaises(lib_exc.NotFound, self.create_image_from_server, - data_utils.rand_name('invalid'), metadata=meta) + self.assertRaises( + lib_exc.NotFound, + self.create_image_from_server, + data_utils.rand_name(prefix=CONF.resource_name_prefix, + name='invalid'), + metadata=meta) @decorators.attr(type=['negative']) @decorators.idempotent_id('ec176029-73dc-4037-8d72-2e4ff60cf538') @@ -76,7 +80,8 @@ class ImagesNegativeTestJSON(ImagesNegativeTestBase): Return an error if server id passed is 35 characters or less """ - snapshot_name = data_utils.rand_name('test-snap') + snapshot_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='test-snap') test_uuid = ('a' * 35) self.assertRaises(lib_exc.NotFound, self.client.create_image, test_uuid, name=snapshot_name) @@ -88,7 +93,8 @@ class ImagesNegativeTestJSON(ImagesNegativeTestBase): Return an error if sever id passed is 37 characters or more """ - snapshot_name = data_utils.rand_name('test-snap') + snapshot_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='test-snap') test_uuid = ('a' * 37) self.assertRaises(lib_exc.NotFound, self.client.create_image, test_uuid, name=snapshot_name) @@ -105,8 +111,10 @@ class ImagesDeleteNegativeTestJSON(ImagesNegativeTestBase): @decorators.idempotent_id('381acb65-785a-4942-94ce-d8f8c84f1f0f') def test_delete_image_with_invalid_image_id(self): """Check an image should not be deleted with invalid image id""" - self.assertRaises(lib_exc.NotFound, self.client.delete_image, - data_utils.rand_name('invalid')) + self.assertRaises( + lib_exc.NotFound, self.client.delete_image, + data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='invalid')) @decorators.attr(type=['negative']) @decorators.idempotent_id('137aef61-39f7-44a1-8ddf-0adf82511701') diff --git a/tempest/api/compute/images/test_images_oneserver.py b/tempest/api/compute/images/test_images_oneserver.py index 2b859da267..ed3bf66f20 100644 --- a/tempest/api/compute/images/test_images_oneserver.py +++ b/tempest/api/compute/images/test_images_oneserver.py @@ -66,7 +66,8 @@ class ImagesOneServerTestJSON(base.BaseV2ComputeTest): MIN_RAM = 'min_ram' # Create a new image - name = data_utils.rand_name('image') + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='image') meta = {'image_type': 'test'} image = self.create_image_from_server(self.server_id, name=name, metadata=meta, @@ -104,6 +105,8 @@ class ImagesOneServerTestJSON(base.BaseV2ComputeTest): # We use a string with 3 byte utf-8 character due to nova/glance which # will return 400(Bad Request) if we attempt to send a name which has # 4 byte utf-8 character. - utf8_name = data_utils.rand_name(b'\xe2\x82\xa1'.decode('utf-8')) + utf8_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=b'\xe2\x82\xa1'.decode('utf-8')) self.create_image_from_server(self.server_id, name=utf8_name, wait_until='ACTIVE') diff --git a/tempest/api/compute/images/test_list_image_filters.py b/tempest/api/compute/images/test_list_image_filters.py index c6eff9b1e5..78363ee8ad 100644 --- a/tempest/api/compute/images/test_list_image_filters.py +++ b/tempest/api/compute/images/test_list_image_filters.py @@ -56,8 +56,12 @@ class ListImageFiltersTestJSON(base.BaseV2ComputeTest): super(ListImageFiltersTestJSON, cls).resource_setup() def _create_image(): + image_name_kwargs = { + 'prefix': CONF.resource_name_prefix, + 'name': cls.__name__ + '-image' + } params = { - 'name': data_utils.rand_name(cls.__name__ + '-image'), + 'name': data_utils.rand_name(**image_name_kwargs), 'container_format': 'bare', 'disk_format': 'raw', 'visibility': 'private' diff --git a/tempest/api/compute/keypairs/base.py b/tempest/api/compute/keypairs/base.py index 44da88cfb3..5f8f95914c 100644 --- a/tempest/api/compute/keypairs/base.py +++ b/tempest/api/compute/keypairs/base.py @@ -14,8 +14,11 @@ # under the License. from tempest.api.compute import base +from tempest import config from tempest.lib.common.utils import data_utils +CONF = config.CONF + class BaseKeypairTest(base.BaseV2ComputeTest): """Base test case class for all keypair API tests.""" @@ -32,7 +35,8 @@ class BaseKeypairTest(base.BaseV2ComputeTest): client = self.keypairs_client if keypair_name is None: keypair_name = data_utils.rand_name( - self.__class__.__name__ + '-keypair') + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-keypair') kwargs = {'name': keypair_name} delete_params = {} if pub_key: diff --git a/tempest/api/compute/keypairs/test_keypairs.py b/tempest/api/compute/keypairs/test_keypairs.py index 8df2e842c3..2aab58da3d 100644 --- a/tempest/api/compute/keypairs/test_keypairs.py +++ b/tempest/api/compute/keypairs/test_keypairs.py @@ -14,9 +14,12 @@ # under the License. from tempest.api.compute.keypairs import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators +CONF = config.CONF + class KeyPairsV2TestJSON(base.BaseKeypairTest): """Test keypairs API with compute microversion less than 2.2""" @@ -54,7 +57,8 @@ class KeyPairsV2TestJSON(base.BaseKeypairTest): @decorators.idempotent_id('6c1d3123-4519-4742-9194-622cb1714b7d') def test_keypair_create_delete(self): """Test create/delete keypair""" - k_name = data_utils.rand_name('keypair') + k_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='keypair') keypair = self.create_keypair(k_name) key_name = keypair['name'] self.assertEqual(key_name, k_name, @@ -64,7 +68,8 @@ class KeyPairsV2TestJSON(base.BaseKeypairTest): @decorators.idempotent_id('a4233d5d-52d8-47cc-9a25-e1864527e3df') def test_get_keypair_detail(self): """Test getting keypair detail by keypair name""" - k_name = data_utils.rand_name('keypair') + k_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='keypair') self.create_keypair(k_name) keypair_detail = self.keypairs_client.show_keypair(k_name)['keypair'] self.assertEqual(keypair_detail['name'], k_name, @@ -74,7 +79,8 @@ class KeyPairsV2TestJSON(base.BaseKeypairTest): @decorators.idempotent_id('39c90c6a-304a-49dd-95ec-2366129def05') def test_keypair_create_with_pub_key(self): """Test creating keypair with a given public key""" - k_name = data_utils.rand_name('keypair') + k_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='keypair') pub_key = ("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCs" "Ne3/1ILNCqFyfYWDeTKLD6jEXC2OQHLmietMWW+/vd" "aZq7KZEwO0jhglaFjU1mpqq4Gz5RX156sCTNM9vRbw" diff --git a/tempest/api/compute/keypairs/test_keypairs_negative.py b/tempest/api/compute/keypairs/test_keypairs_negative.py index 40bea3f1eb..feef8648cd 100644 --- a/tempest/api/compute/keypairs/test_keypairs_negative.py +++ b/tempest/api/compute/keypairs/test_keypairs_negative.py @@ -15,10 +15,13 @@ # under the License. from tempest.api.compute.keypairs import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators from tempest.lib import exceptions as lib_exc +CONF = config.CONF + class KeyPairsNegativeTestJSON(base.BaseKeypairTest): """Negative tests of keypairs API""" @@ -35,7 +38,9 @@ class KeyPairsNegativeTestJSON(base.BaseKeypairTest): @decorators.idempotent_id('7cc32e47-4c42-489d-9623-c5e2cb5a2fa5') def test_keypair_delete_nonexistent_key(self): """Test non-existent key deletion should throw a proper error""" - k_name = data_utils.rand_name("keypair-non-existent") + k_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name="keypair-non-existent") self.assertRaises(lib_exc.NotFound, self.keypairs_client.delete_keypair, k_name) @@ -60,7 +65,8 @@ class KeyPairsNegativeTestJSON(base.BaseKeypairTest): @decorators.idempotent_id('0359a7f1-f002-4682-8073-0c91e4011b7c') def test_create_keypair_with_duplicate_name(self): """Test keypairs with duplicate names should not be created""" - k_name = data_utils.rand_name('keypair') + k_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='keypair') self.keypairs_client.create_keypair(name=k_name) # Now try the same keyname to create another key self.assertRaises(lib_exc.Conflict, self.create_keypair, diff --git a/tempest/api/compute/keypairs/test_keypairs_v22.py b/tempest/api/compute/keypairs/test_keypairs_v22.py index e229c374d5..06bbf575b9 100644 --- a/tempest/api/compute/keypairs/test_keypairs_v22.py +++ b/tempest/api/compute/keypairs/test_keypairs_v22.py @@ -13,9 +13,12 @@ # under the License. from tempest.api.compute.keypairs import test_keypairs +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators +CONF = config.CONF + class KeyPairsV22TestJSON(test_keypairs.KeyPairsV2TestJSON): """Test keypairs API with compute microversion greater than 2.1""" @@ -29,7 +32,8 @@ class KeyPairsV22TestJSON(test_keypairs.KeyPairsV2TestJSON): self.assertEqual(keypair_type, keypair['type']) def _test_keypairs_create_list_show(self, keypair_type=None): - k_name = data_utils.rand_name('keypair') + k_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='keypair') keypair = self.create_keypair(k_name, keypair_type=keypair_type) # Verify whether 'type' is present in keypair create response of # version 2.2 and it is with default value 'ssh'. diff --git a/tempest/api/compute/security_groups/test_security_group_rules_negative.py b/tempest/api/compute/security_groups/test_security_group_rules_negative.py index 3d000caade..c09be58757 100644 --- a/tempest/api/compute/security_groups/test_security_group_rules_negative.py +++ b/tempest/api/compute/security_groups/test_security_group_rules_negative.py @@ -14,10 +14,13 @@ # under the License. from tempest.api.compute.security_groups import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators from tempest.lib import exceptions as lib_exc +CONF = config.CONF + class SecurityGroupRulesNegativeTestJSON(base.BaseSecurityGroupsTest): """Negative tests of security group rules API @@ -59,7 +62,8 @@ class SecurityGroupRulesNegativeTestJSON(base.BaseSecurityGroupsTest): with parent group id which is not integer. """ # Adding rules to the non int Security Group id - parent_group_id = data_utils.rand_name('non_int_id') + parent_group_id = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='non_int_id') ip_protocol = 'tcp' from_port = 22 to_port = 22 @@ -105,7 +109,8 @@ class SecurityGroupRulesNegativeTestJSON(base.BaseSecurityGroupsTest): sg = self.create_security_group() # Adding rules to the created Security Group parent_group_id = sg['id'] - ip_protocol = data_utils.rand_name('999') + ip_protocol = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='999') from_port = 22 to_port = 22 diff --git a/tempest/api/compute/security_groups/test_security_groups.py b/tempest/api/compute/security_groups/test_security_groups.py index a1f35141ed..01a79864e3 100644 --- a/tempest/api/compute/security_groups/test_security_groups.py +++ b/tempest/api/compute/security_groups/test_security_groups.py @@ -15,10 +15,13 @@ from tempest.api.compute.security_groups import base from tempest.common import waiters +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators from tempest.lib import exceptions as lib_exc +CONF = config.CONF + class SecurityGroupsTestJSON(base.BaseSecurityGroupsTest): """Test security groups API with compute microversion less than 2.36""" @@ -69,7 +72,8 @@ class SecurityGroupsTestJSON(base.BaseSecurityGroupsTest): Security group should be created, fetched and deleted with char space between name along with leading and trailing spaces. """ - s_name = ' %s ' % data_utils.rand_name('securitygroup ') + s_name = ' %s ' % data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='securitygroup ') securitygroup = self.create_security_group(name=s_name) securitygroup_name = securitygroup['name'] self.assertEqual(securitygroup_name, s_name, @@ -133,8 +137,9 @@ class SecurityGroupsTestJSON(base.BaseSecurityGroupsTest): securitygroup = self.create_security_group() securitygroup_id = securitygroup['id'] # Update the name and description - s_new_name = data_utils.rand_name('sg-hth') - s_new_des = data_utils.rand_name('description-hth') + prefix = CONF.resource_name_prefix + s_new_name = data_utils.rand_name(prefix=prefix, name='sg-hth') + s_new_des = data_utils.rand_name(prefix=prefix, name='description-hth') self.client.update_security_group(securitygroup_id, name=s_new_name, description=s_new_des) diff --git a/tempest/api/compute/security_groups/test_security_groups_negative.py b/tempest/api/compute/security_groups/test_security_groups_negative.py index 4607112562..c7d873f42c 100644 --- a/tempest/api/compute/security_groups/test_security_groups_negative.py +++ b/tempest/api/compute/security_groups/test_security_groups_negative.py @@ -55,7 +55,8 @@ class SecurityGroupsNegativeTestJSON(base.BaseSecurityGroupsTest): as an empty string, or group name with white spaces, or group name with chars more than 255. """ - s_description = data_utils.rand_name('description') + s_description = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='description') # Create Security Group with empty string as group name self.assertRaises(lib_exc.BadRequest, self.client.create_security_group, @@ -81,7 +82,8 @@ class SecurityGroupsNegativeTestJSON(base.BaseSecurityGroupsTest): longer than 255 chars. Empty description is allowed by the API reference, however. """ - s_name = data_utils.rand_name('securitygroup') + s_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='securitygroup') # Create Security Group with group description longer than 255 chars s_description = 'description-'.ljust(260, '0') self.assertRaises(lib_exc.BadRequest, @@ -94,8 +96,10 @@ class SecurityGroupsNegativeTestJSON(base.BaseSecurityGroupsTest): @decorators.attr(type=['negative']) def test_security_group_create_with_duplicate_name(self): """Test creating security group with duplicate name should fail""" - s_name = data_utils.rand_name('securitygroup') - s_description = data_utils.rand_name('description') + s_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='securitygroup') + s_description = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='description') self.create_security_group(name=s_name, description=s_description) # Now try the Security Group with the same 'Name' self.assertRaises(lib_exc.BadRequest, @@ -138,10 +142,13 @@ class SecurityGroupsNegativeTestJSON(base.BaseSecurityGroupsTest): @decorators.attr(type=['negative']) def test_update_security_group_with_invalid_sg_id(self): """Test updating security group with invalid group id should fail""" - s_name = data_utils.rand_name('sg') - s_description = data_utils.rand_name('description') + s_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='sg') + s_description = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='description') # Create a non int sg_id - sg_id_invalid = data_utils.rand_name('sg') + sg_id_invalid = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='sg') self.assertRaises(lib_exc.BadRequest, self.client.update_security_group, sg_id_invalid, name=s_name, description=s_description) @@ -179,8 +186,10 @@ class SecurityGroupsNegativeTestJSON(base.BaseSecurityGroupsTest): def test_update_non_existent_security_group(self): """Test updating a non existent security group should fail""" non_exist_id = self.generate_random_security_group_id() - s_name = data_utils.rand_name('sg') - s_description = data_utils.rand_name('description') + s_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='sg') + s_description = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='description') self.assertRaises(lib_exc.NotFound, self.client.update_security_group, non_exist_id, name=s_name, diff --git a/tempest/api/compute/servers/test_attach_interfaces.py b/tempest/api/compute/servers/test_attach_interfaces.py index 9b6bf8453e..8984d1de78 100644 --- a/tempest/api/compute/servers/test_attach_interfaces.py +++ b/tempest/api/compute/servers/test_attach_interfaces.py @@ -161,7 +161,9 @@ class AttachInterfacesTestJSON(AttachInterfacesTestBase): network_id = ifs[0]['net_id'] port = self.ports_client.create_port( network_id=network_id, - name=data_utils.rand_name(self.__class__.__name__)) + name=data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__)) port_id = port['port']['id'] self.addCleanup(self.ports_client.delete_port, port_id) iface = self.interfaces_client.create_interface( @@ -324,7 +326,9 @@ class AttachInterfacesTestJSON(AttachInterfacesTestBase): port = self.ports_client.create_port( network_id=network_id, - name=data_utils.rand_name(self.__class__.__name__)) + name=data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__)) port_id = port['port']['id'] self.addCleanup(self.ports_client.delete_port, port_id) diff --git a/tempest/api/compute/servers/test_create_server.py b/tempest/api/compute/servers/test_create_server.py index c9aec62a76..6664e15737 100644 --- a/tempest/api/compute/servers/test_create_server.py +++ b/tempest/api/compute/servers/test_create_server.py @@ -53,7 +53,9 @@ class ServersTestJSON(base.BaseV2ComputeTest): cls.meta = {'hello': 'world'} cls.accessIPv4 = '1.1.1.1' cls.accessIPv6 = '0000:0000:0000:0000:0000:babe:220.12.22.2' - cls.name = data_utils.rand_name(cls.__name__ + '-server') + cls.name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=cls.__name__ + '-server') cls.password = data_utils.rand_password() disk_config = cls.disk_config server_initial = cls.create_test_server( diff --git a/tempest/api/compute/servers/test_create_server_multi_nic.py b/tempest/api/compute/servers/test_create_server_multi_nic.py index 6ec058dfed..1cbb976194 100644 --- a/tempest/api/compute/servers/test_create_server_multi_nic.py +++ b/tempest/api/compute/servers/test_create_server_multi_nic.py @@ -67,7 +67,9 @@ class ServersTestMultiNic(base.BaseV2ComputeTest): cls.subnets_client = cls.os_primary.subnets_client def _create_net_subnet_ret_net_from_cidr(self, cidr): - name_net = data_utils.rand_name(self.__class__.__name__) + name_net = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__) net = self.networks_client.create_network(name=name_net) self.addCleanup(self.networks_client.delete_network, net['network']['id']) diff --git a/tempest/api/compute/servers/test_device_tagging.py b/tempest/api/compute/servers/test_device_tagging.py index 7d29a4d104..26403111f7 100644 --- a/tempest/api/compute/servers/test_device_tagging.py +++ b/tempest/api/compute/servers/test_device_tagging.py @@ -172,11 +172,15 @@ class TaggedBootDevicesTest(DeviceTaggingBase): # Create networks net1 = self.networks_client.create_network( - name=data_utils.rand_name('device-tagging-net1'))['network'] + name=data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name='device-tagging-net1'))['network'] self.addCleanup(self.networks_client.delete_network, net1['id']) net2 = self.networks_client.create_network( - name=data_utils.rand_name('device-tagging-net2'))['network'] + name=data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name='device-tagging-net2'))['network'] self.addCleanup(self.networks_client.delete_network, net2['id']) # Create subnets @@ -195,13 +199,17 @@ class TaggedBootDevicesTest(DeviceTaggingBase): # Create ports self.port1 = self.ports_client.create_port( network_id=net1['id'], - name=data_utils.rand_name(self.__class__.__name__), + name=data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__), fixed_ips=[{'subnet_id': subnet1['id']}])['port'] self.addCleanup(self.ports_client.delete_port, self.port1['id']) self.port2 = self.ports_client.create_port( network_id=net1['id'], - name=data_utils.rand_name(self.__class__.__name__), + name=data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__), fixed_ips=[{'subnet_id': subnet1['id']}])['port'] self.addCleanup(self.ports_client.delete_port, self.port2['id']) @@ -215,7 +223,9 @@ class TaggedBootDevicesTest(DeviceTaggingBase): wait_until='SSHABLE', validation_resources=validation_resources, config_drive=config_drive_enabled, - name=data_utils.rand_name('device-tagging-server'), + name=data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name='device-tagging-server'), networks=[ # Validation network for ssh { @@ -378,7 +388,8 @@ class TaggedAttachmentsTest(DeviceTaggingBase): # Create network net = self.networks_client.create_network( name=data_utils.rand_name( - 'tagged-attachments-test-net'))['network'] + prefix=CONF.resource_name_prefix, + name='tagged-attachments-test-net'))['network'] self.addCleanup(self.networks_client.delete_network, net['id']) # Create subnet @@ -400,7 +411,9 @@ class TaggedAttachmentsTest(DeviceTaggingBase): validatable=True, validation_resources=validation_resources, config_drive=config_drive_enabled, - name=data_utils.rand_name('device-tagging-server'), + name=data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name='device-tagging-server'), networks=[{'uuid': self.get_tenant_network()['id']}], wait_until='SSHABLE') self.addCleanup(self.delete_server, server['id']) diff --git a/tempest/api/compute/servers/test_list_server_filters.py b/tempest/api/compute/servers/test_list_server_filters.py index 990dd525cf..78732963a5 100644 --- a/tempest/api/compute/servers/test_list_server_filters.py +++ b/tempest/api/compute/servers/test_list_server_filters.py @@ -48,17 +48,23 @@ class ListServerFiltersTestJSON(base.BaseV2ComputeTest): else: cls.fixed_network_name = None network_kwargs = fixed_network.set_networks_kwarg(network) - cls.s1_name = data_utils.rand_name(cls.__name__ + '-instance') + cls.s1_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=cls.__name__ + '-instance') cls.s1 = cls.create_test_server(name=cls.s1_name, **network_kwargs) - cls.s2_name = data_utils.rand_name(cls.__name__ + '-instance') + cls.s2_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=cls.__name__ + '-instance') # If image_ref_alt is "" or None then we still want to boot a server # but we rely on `testtools.skipUnless` decorator to actually skip # the irrelevant tests. cls.s2 = cls.create_test_server( name=cls.s2_name, image_id=cls.image_ref_alt or cls.image_ref) - cls.s3_name = data_utils.rand_name(cls.__name__ + '-instance') + cls.s3_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=cls.__name__ + '-instance') cls.s3 = cls.create_test_server(name=cls.s3_name, flavor=cls.flavor_ref_alt, wait_until='ACTIVE') diff --git a/tempest/api/compute/servers/test_server_actions.py b/tempest/api/compute/servers/test_server_actions.py index a181839c3a..21ed0cdc56 100644 --- a/tempest/api/compute/servers/test_server_actions.py +++ b/tempest/api/compute/servers/test_server_actions.py @@ -133,7 +133,9 @@ class ServerActionsBase(base.BaseV2ComputeTest): ['addresses']) # The server should be rebuilt using the provided image and data meta = {'rebuild': 'server'} - new_name = data_utils.rand_name(self.__class__.__name__ + '-server') + new_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-server') password = 'rebuildPassw0rd' rebuilt_server = self.client.rebuild_server( server_id, @@ -575,7 +577,8 @@ class ServerActionsTestOtherB(ServerActionsBase): raise lib_exc.InvalidConfiguration( 'api_v2 must be True in [image-feature-enabled].') - backup1 = data_utils.rand_name('backup-1') + backup1 = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='backup-1') resp = self.client.create_backup(self.server_id, backup_type='daily', rotation=2, @@ -603,7 +606,8 @@ class ServerActionsTestOtherB(ServerActionsBase): waiters.wait_for_image_status(glance_client, image1_id, 'active') - backup2 = data_utils.rand_name('backup-2') + backup2 = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='backup-2') waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE') resp = self.client.create_backup(self.server_id, backup_type='daily', @@ -639,7 +643,8 @@ class ServerActionsTestOtherB(ServerActionsBase): # create the third one, due to the rotation is 2, # the first one will be deleted - backup3 = data_utils.rand_name('backup-3') + backup3 = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='backup-3') waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE') resp = self.client.create_backup(self.server_id, backup_type='daily', @@ -796,7 +801,8 @@ class ServersAaction247Test(base.BaseV2ComputeTest): def test_create_backup(self): server = self.create_test_server(wait_until='ACTIVE') - backup1 = data_utils.rand_name('backup-1') + backup1 = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='backup-1') # Just check create_back to verify the schema with 2.47 self.servers_client.create_backup(server['id'], backup_type='daily', @@ -859,7 +865,9 @@ class ServerActionsV293TestJSON(base.BaseV2ComputeTest): # The server should be rebuilt using the provided image and data meta = {'rebuild': 'server'} - new_name = data_utils.rand_name(self.__class__.__name__ + '-server') + new_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-server') password = 'rebuildPassw0rd' rebuilt_server = self.servers_client.rebuild_server( server['id'], diff --git a/tempest/api/compute/servers/test_server_group.py b/tempest/api/compute/servers/test_server_group.py index 4b6d45a176..f92b5bad3f 100644 --- a/tempest/api/compute/servers/test_server_group.py +++ b/tempest/api/compute/servers/test_server_group.py @@ -17,9 +17,12 @@ import testtools from tempest.api.compute import base from tempest.common import compute +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators +CONF = config.CONF + class ServerGroupTestJSON(base.BaseV2ComputeTest): """These tests check for the server-group APIs. @@ -80,7 +83,8 @@ class ServerGroupTestJSON(base.BaseV2ComputeTest): def _create_delete_server_group(self, policy): # Create and Delete the server-group with given policy - name = data_utils.rand_name('server-group') + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='server-group') server_group = self._create_server_group(name, policy) self._delete_server_group(server_group) @@ -99,7 +103,8 @@ class ServerGroupTestJSON(base.BaseV2ComputeTest): def test_create_delete_multiple_server_groups_with_same_name_policy(self): """Test Create/Delete the server-groups with same name and policy""" server_groups = [] - server_group_name = data_utils.rand_name('server-group') + server_group_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='server-group') for _ in range(0, 2): server_groups.append(self._create_server_group(server_group_name, self.policy)) diff --git a/tempest/api/compute/servers/test_server_tags.py b/tempest/api/compute/servers/test_server_tags.py index cdeaae5ab1..0b5870a78b 100644 --- a/tempest/api/compute/servers/test_server_tags.py +++ b/tempest/api/compute/servers/test_server_tags.py @@ -14,9 +14,12 @@ # under the License. from tempest.api.compute import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators +CONF = config.CONF + class ServerTagsTestJSON(base.BaseV2ComputeTest): """Test server tags with compute microversion greater than 2.25""" @@ -51,7 +54,8 @@ class ServerTagsTestJSON(base.BaseV2ComputeTest): self.assertEmpty(fetched_tags) # Add server tag to the server. - assigned_tag = data_utils.rand_name('tag') + assigned_tag = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='tag') self._update_server_tags(self.server['id'], assigned_tag) # Check that added tag exists. @@ -67,11 +71,16 @@ class ServerTagsTestJSON(base.BaseV2ComputeTest): def test_update_all_tags(self): """Test updating all server tags""" # Add server tags to the server. - tags = [data_utils.rand_name('tag'), data_utils.rand_name('tag')] + kwargs = { + 'prefix': CONF.resource_name_prefix, + 'name': 'tag' + } + tags = [data_utils.rand_name(**kwargs), data_utils.rand_name(**kwargs)] self._update_server_tags(self.server['id'], tags) # Replace tags with new tags and check that they are present. - new_tags = [data_utils.rand_name('tag'), data_utils.rand_name('tag')] + new_tags = [data_utils.rand_name(**kwargs), + data_utils.rand_name(**kwargs)] replaced_tags = self.client.update_all_tags( self.server['id'], new_tags)['tags'] self.assertCountEqual(new_tags, replaced_tags) @@ -83,9 +92,13 @@ class ServerTagsTestJSON(base.BaseV2ComputeTest): @decorators.idempotent_id('a63b2a74-e918-4b7c-bcab-10c855f3a57e') def test_delete_all_tags(self): """Test deleting all server tags""" + kwargs = { + 'prefix': CONF.resource_name_prefix, + 'name': 'tag' + } # Add server tags to the server. - assigned_tags = [data_utils.rand_name('tag'), - data_utils.rand_name('tag')] + assigned_tags = [data_utils.rand_name(**kwargs), + data_utils.rand_name(**kwargs)] self._update_server_tags(self.server['id'], assigned_tags) # Delete tags from the server and check that they were deleted. @@ -97,7 +110,8 @@ class ServerTagsTestJSON(base.BaseV2ComputeTest): def test_check_tag_existence(self): """Test checking server tag existence""" # Add server tag to the server. - assigned_tag = data_utils.rand_name('tag') + assigned_tag = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='tag') self._update_server_tags(self.server['id'], assigned_tag) # Check that added tag exists. Throws a 404 if not found, else a 204, diff --git a/tempest/api/compute/servers/test_servers.py b/tempest/api/compute/servers/test_servers.py index 388b9b0e3a..c72b74e0e9 100644 --- a/tempest/api/compute/servers/test_servers.py +++ b/tempest/api/compute/servers/test_servers.py @@ -60,7 +60,8 @@ class ServersTestJSON(base.BaseV2ComputeTest): """Test creating a server with already existing name is allowed""" # TODO(sdague): clear out try, we do cleanup one layer up server_name = data_utils.rand_name( - self.__class__.__name__ + '-server') + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-server') server = self.create_test_server(name=server_name, wait_until='ACTIVE') id1 = server['id'] @@ -79,7 +80,8 @@ class ServersTestJSON(base.BaseV2ComputeTest): @decorators.idempotent_id('f9e15296-d7f9-4e62-b53f-a04e89160833') def test_create_specify_keypair(self): """Test creating server with keypair""" - key_name = data_utils.rand_name('key') + key_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='key') self.keypairs_client.create_keypair(name=key_name) self.addCleanup(self.keypairs_client.delete_keypair, key_name) self.keypairs_client.list_keypairs() @@ -91,7 +93,8 @@ class ServersTestJSON(base.BaseV2ComputeTest): def _update_server_name(self, server_id, status, prefix_name='server'): # The server name should be changed to the provided value - new_name = data_utils.rand_name(prefix_name) + new_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name=prefix_name) # Update the server with a new name self.client.update_server(server_id, @@ -159,7 +162,9 @@ class ServersTestJSON(base.BaseV2ComputeTest): will return 400(Bad Request) if we attempt to send a name which has 4 byte utf-8 character. """ - utf8_name = data_utils.rand_name(b'\xe2\x82\xa1'.decode('utf-8')) + utf8_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=b'\xe2\x82\xa1'.decode('utf-8')) self.create_test_server(name=utf8_name, wait_until='ACTIVE') diff --git a/tempest/api/compute/servers/test_servers_microversions.py b/tempest/api/compute/servers/test_servers_microversions.py index 566d04aa8e..346c6591c3 100644 --- a/tempest/api/compute/servers/test_servers_microversions.py +++ b/tempest/api/compute/servers/test_servers_microversions.py @@ -15,6 +15,7 @@ from tempest.api.compute import base from tempest.common import waiters +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators @@ -30,6 +31,8 @@ from tempest.lib import decorators # their integration tests, you can add tests to cover those schema # in this file. +CONF = config.CONF + class ServerShowV254Test(base.BaseV2ComputeTest): """Test servers API schema for compute microversion greater than 2.53""" @@ -41,7 +44,8 @@ class ServerShowV254Test(base.BaseV2ComputeTest): """Test rebuilding server with microversion greater than 2.53""" server = self.create_test_server(wait_until='ACTIVE') keypair_name = data_utils.rand_name( - self.__class__.__name__ + '-keypair') + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-keypair') kwargs = {'name': keypair_name} self.keypairs_client.create_keypair(**kwargs) self.addCleanup(self.keypairs_client.delete_keypair, diff --git a/tempest/api/compute/servers/test_servers_negative.py b/tempest/api/compute/servers/test_servers_negative.py index bd383d32ec..22fe54d2a9 100644 --- a/tempest/api/compute/servers/test_servers_negative.py +++ b/tempest/api/compute/servers/test_servers_negative.py @@ -267,7 +267,8 @@ class ServersNegativeTestJSON(base.BaseV2ComputeTest): def test_create_with_non_existent_keypair(self): """Creating a server with non-existent keypair should fail""" # Pass a non-existent keypair while creating a server - key_name = data_utils.rand_name('key') + key_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='key') self.assertRaises(lib_exc.BadRequest, self.create_test_server, key_name=key_name) @@ -288,7 +289,8 @@ class ServersNegativeTestJSON(base.BaseV2ComputeTest): """Updating name of a non-existent server should fail""" nonexistent_server = data_utils.rand_uuid() new_name = data_utils.rand_name( - self.__class__.__name__ + '-server') + '_updated' + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-server') + '_updated' self.assertRaises(lib_exc.NotFound, self.client.update_server, nonexistent_server, name=new_name) diff --git a/tempest/api/compute/volumes/test_volume_snapshots.py b/tempest/api/compute/volumes/test_volume_snapshots.py index 30bea604db..5b06a865ed 100644 --- a/tempest/api/compute/volumes/test_volume_snapshots.py +++ b/tempest/api/compute/volumes/test_volume_snapshots.py @@ -53,7 +53,9 @@ class VolumesSnapshotsTestJSON(base.BaseV2ComputeTest): volume = self.create_volume() self.addCleanup(self.delete_volume, volume['id']) - s_name = data_utils.rand_name(self.__class__.__name__ + '-Snapshot') + s_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-Snapshot') # Create snapshot snapshot = self.snapshots_client.create_snapshot( volume_id=volume['id'], diff --git a/tempest/api/compute/volumes/test_volumes_get.py b/tempest/api/compute/volumes/test_volumes_get.py index 554f418bb7..2a4189e75f 100644 --- a/tempest/api/compute/volumes/test_volumes_get.py +++ b/tempest/api/compute/volumes/test_volumes_get.py @@ -47,7 +47,9 @@ class VolumesGetTestJSON(base.BaseV2ComputeTest): @decorators.idempotent_id('f10f25eb-9775-4d9d-9cbe-1cf54dae9d5f') def test_volume_create_get_delete(self): """Test create/get/delete volume""" - v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume') + v_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-Volume') metadata = {'Type': 'work'} # Create volume volume = self.create_volume(size=CONF.volume.volume_size, diff --git a/tempest/api/compute/volumes/test_volumes_negative.py b/tempest/api/compute/volumes/test_volumes_negative.py index f553e32e04..c38649791c 100644 --- a/tempest/api/compute/volumes/test_volumes_negative.py +++ b/tempest/api/compute/volumes/test_volumes_negative.py @@ -64,7 +64,9 @@ class VolumesNegativeTest(base.BaseV2ComputeTest): @decorators.idempotent_id('5125ae14-152b-40a7-b3c5-eae15e9022ef') def test_create_volume_with_invalid_size(self): """Test creating volume with invalid size should fail""" - v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume') + v_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-Volume') metadata = {'Type': 'work'} self.assertRaises(lib_exc.BadRequest, self.client.create_volume, size='#$%', display_name=v_name, metadata=metadata) @@ -73,7 +75,9 @@ class VolumesNegativeTest(base.BaseV2ComputeTest): @decorators.idempotent_id('131cb3a1-75cc-4d40-b4c3-1317f64719b0') def test_create_volume_without_passing_size(self): """Test creating volume without specifying size should fail""" - v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume') + v_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-Volume') metadata = {'Type': 'work'} self.assertRaises(lib_exc.BadRequest, self.client.create_volume, size='', display_name=v_name, metadata=metadata) @@ -82,7 +86,9 @@ class VolumesNegativeTest(base.BaseV2ComputeTest): @decorators.idempotent_id('8cce995e-0a83-479a-b94d-e1e40b8a09d1') def test_create_volume_with_size_zero(self): """Test creating volume with size=0 should fail""" - v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume') + v_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-Volume') metadata = {'Type': 'work'} self.assertRaises(lib_exc.BadRequest, self.client.create_volume, size='0', display_name=v_name, metadata=metadata) @@ -97,9 +103,11 @@ class VolumesNegativeTest(base.BaseV2ComputeTest): @decorators.idempotent_id('62972737-124b-4513-b6cf-2f019f178494') def test_delete_invalid_volume_id(self): """Test deleting volume with an invalid volume id should fail""" - self.assertRaises(lib_exc.NotFound, - self.client.delete_volume, - data_utils.rand_name('invalid')) + self.assertRaises( + lib_exc.NotFound, + self.client.delete_volume, + data_utils.rand_name(prefix=CONF.resource_name_prefix, + name='invalid')) @decorators.attr(type=['negative']) @decorators.idempotent_id('0d1417c5-4ae8-4c2c-adc5-5f0b864253e5') diff --git a/tempest/api/identity/admin/v2/test_endpoints.py b/tempest/api/identity/admin/v2/test_endpoints.py index 236ce7cb9f..20d023b4b3 100644 --- a/tempest/api/identity/admin/v2/test_endpoints.py +++ b/tempest/api/identity/admin/v2/test_endpoints.py @@ -14,9 +14,12 @@ # under the License. from tempest.api.identity import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators +CONF = config.CONF + class EndPointsTestJSON(base.BaseIdentityV2AdminTest): """Test keystone v2 endpoints""" @@ -24,9 +27,12 @@ class EndPointsTestJSON(base.BaseIdentityV2AdminTest): @classmethod def resource_setup(cls): super(EndPointsTestJSON, cls).resource_setup() - s_name = data_utils.rand_name('service') - s_type = data_utils.rand_name('type') - s_description = data_utils.rand_name('description') + s_name = data_utils.rand_name( + name='service', prefix=CONF.resource_name_prefix) + s_type = data_utils.rand_name( + name='type', prefix=CONF.resource_name_prefix) + s_description = data_utils.rand_name( + name='description', prefix=CONF.resource_name_prefix) service_data = cls.services_client.create_service( name=s_name, type=s_type, description=s_description)['OS-KSADM:service'] @@ -36,7 +42,8 @@ class EndPointsTestJSON(base.BaseIdentityV2AdminTest): # Create endpoints so as to use for LIST and GET test cases cls.setup_endpoints = list() for _ in range(2): - region = data_utils.rand_name('region') + region = data_utils.rand_name( + name='region', prefix=CONF.resource_name_prefix) url = data_utils.rand_url() endpoint = cls.endpoints_client.create_endpoint( service_id=cls.service_id, @@ -65,7 +72,8 @@ class EndPointsTestJSON(base.BaseIdentityV2AdminTest): @decorators.idempotent_id('9974530a-aa28-4362-8403-f06db02b26c1') def test_create_list_delete_endpoint(self): """Test creating, listing and deleting a keystone endpoint""" - region = data_utils.rand_name('region') + region = data_utils.rand_name( + name='region', prefix=CONF.resource_name_prefix) url = data_utils.rand_url() endpoint = self.endpoints_client.create_endpoint( service_id=self.service_id, diff --git a/tempest/api/identity/admin/v2/test_roles.py b/tempest/api/identity/admin/v2/test_roles.py index 9736a76354..6d384ab5fa 100644 --- a/tempest/api/identity/admin/v2/test_roles.py +++ b/tempest/api/identity/admin/v2/test_roles.py @@ -14,10 +14,13 @@ # under the License. from tempest.api.identity import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib.common.utils import test_utils from tempest.lib import decorators +CONF = config.CONF + class RolesTestJSON(base.BaseIdentityV2AdminTest): @@ -26,7 +29,8 @@ class RolesTestJSON(base.BaseIdentityV2AdminTest): super(RolesTestJSON, cls).resource_setup() cls.roles = list() for _ in range(5): - role_name = data_utils.rand_name(name='role') + role_name = data_utils.rand_name( + name='role', prefix=CONF.resource_name_prefix) role = cls.roles_client.create_role(name=role_name)['role'] cls.addClassResourceCleanup( test_utils.call_and_ignore_notfound_exc, @@ -57,7 +61,8 @@ class RolesTestJSON(base.BaseIdentityV2AdminTest): @decorators.idempotent_id('c62d909d-6c21-48c0-ae40-0a0760e6db5e') def test_role_create_delete(self): """Role should be created, verified, and deleted.""" - role_name = data_utils.rand_name(name='role-test') + role_name = data_utils.rand_name( + name='role-test', prefix=CONF.resource_name_prefix) body = self.roles_client.create_role(name=role_name)['role'] self.addCleanup(test_utils.call_and_ignore_notfound_exc, self.roles_client.delete_role, body['id']) diff --git a/tempest/api/identity/admin/v2/test_roles_negative.py b/tempest/api/identity/admin/v2/test_roles_negative.py index 3c71ba9618..0f0466eece 100644 --- a/tempest/api/identity/admin/v2/test_roles_negative.py +++ b/tempest/api/identity/admin/v2/test_roles_negative.py @@ -14,10 +14,13 @@ # under the License. from tempest.api.identity import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators from tempest.lib import exceptions as lib_exc +CONF = config.CONF + class RolesNegativeTestJSON(base.BaseIdentityV2AdminTest): """Negative tests of keystone roles via v2 API""" @@ -55,7 +58,8 @@ class RolesNegativeTestJSON(base.BaseIdentityV2AdminTest): @decorators.idempotent_id('585c8998-a8a4-4641-a5dd-abef7a8ced00') def test_create_role_by_unauthorized_user(self): """Test non-admin user should not be able to create role via v2 API""" - role_name = data_utils.rand_name(name='role') + role_name = data_utils.rand_name( + name='role', prefix=CONF.resource_name_prefix) self.assertRaises(lib_exc.Forbidden, self.non_admin_roles_client.create_role, name=role_name) @@ -66,7 +70,8 @@ class RolesNegativeTestJSON(base.BaseIdentityV2AdminTest): """Test creating role without a valid token via v2 API should fail""" token = self.client.auth_provider.get_token() self.client.delete_token(token) - role_name = data_utils.rand_name(name='role') + role_name = data_utils.rand_name( + name='role', prefix=CONF.resource_name_prefix) self.assertRaises(lib_exc.Unauthorized, self.roles_client.create_role, name=role_name) self.client.auth_provider.clear_auth() @@ -75,7 +80,8 @@ class RolesNegativeTestJSON(base.BaseIdentityV2AdminTest): @decorators.idempotent_id('c0cde2c8-81c1-4bb0-8fe2-cf615a3547a8') def test_role_create_duplicate(self): """Test role names should be unique via v2 API""" - role_name = data_utils.rand_name(name='role-dup') + role_name = data_utils.rand_name( + name='role-dup', prefix=CONF.resource_name_prefix) body = self.roles_client.create_role(name=role_name)['role'] role1_id = body.get('id') self.addCleanup(self.roles_client.delete_role, role1_id) @@ -86,7 +92,8 @@ class RolesNegativeTestJSON(base.BaseIdentityV2AdminTest): @decorators.idempotent_id('15347635-b5b1-4a87-a280-deb2bd6d865e') def test_delete_role_by_unauthorized_user(self): """Test non-admin user should not be able to delete role via v2 API""" - role_name = data_utils.rand_name(name='role') + role_name = data_utils.rand_name( + name='role', prefix=CONF.resource_name_prefix) body = self.roles_client.create_role(name=role_name)['role'] self.addCleanup(self.roles_client.delete_role, body['id']) role_id = body.get('id') @@ -97,7 +104,8 @@ class RolesNegativeTestJSON(base.BaseIdentityV2AdminTest): @decorators.idempotent_id('44b60b20-70de-4dac-beaf-a3fc2650a16b') def test_delete_role_request_without_token(self): """Test deleting role without a valid token via v2 API should fail""" - role_name = data_utils.rand_name(name='role') + role_name = data_utils.rand_name( + name='role', prefix=CONF.resource_name_prefix) body = self.roles_client.create_role(name=role_name)['role'] self.addCleanup(self.roles_client.delete_role, body['id']) role_id = body.get('id') diff --git a/tempest/api/identity/admin/v2/test_services.py b/tempest/api/identity/admin/v2/test_services.py index 182b24cc72..0e5d3783fe 100644 --- a/tempest/api/identity/admin/v2/test_services.py +++ b/tempest/api/identity/admin/v2/test_services.py @@ -14,10 +14,13 @@ # under the License. from tempest.api.identity import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators from tempest.lib import exceptions as lib_exc +CONF = config.CONF + class ServicesTestJSON(base.BaseIdentityV2AdminTest): """Test identity services via v2 API""" @@ -34,9 +37,12 @@ class ServicesTestJSON(base.BaseIdentityV2AdminTest): """Test verifies the identity service create/get/delete via v2 API""" # GET Service # Creating a Service - name = data_utils.rand_name('service') - s_type = data_utils.rand_name('type') - description = data_utils.rand_name('description') + name = data_utils.rand_name( + name='service', prefix=CONF.resource_name_prefix) + s_type = data_utils.rand_name( + name='type', prefix=CONF.resource_name_prefix) + description = data_utils.rand_name( + name='description', prefix=CONF.resource_name_prefix) service_data = self.services_client.create_service( name=name, type=s_type, description=description)['OS-KSADM:service'] @@ -70,8 +76,10 @@ class ServicesTestJSON(base.BaseIdentityV2AdminTest): Create a service only with name and type. """ - name = data_utils.rand_name('service') - s_type = data_utils.rand_name('type') + name = data_utils.rand_name( + name='service', prefix=CONF.resource_name_prefix) + s_type = data_utils.rand_name( + name='type', prefix=CONF.resource_name_prefix) service = self.services_client.create_service( name=name, type=s_type)['OS-KSADM:service'] self.assertIn('id', service) @@ -87,9 +95,12 @@ class ServicesTestJSON(base.BaseIdentityV2AdminTest): """Test Create/List/Verify/Delete of identity service via v2 API""" services = [] for _ in range(3): - name = data_utils.rand_name('service') - s_type = data_utils.rand_name('type') - description = data_utils.rand_name('description') + name = data_utils.rand_name( + name='service', prefix=CONF.resource_name_prefix) + s_type = data_utils.rand_name( + name='type', prefix=CONF.resource_name_prefix) + description = data_utils.rand_name( + name='description', prefix=CONF.resource_name_prefix) service = self.services_client.create_service( name=name, type=s_type, diff --git a/tempest/api/identity/admin/v2/test_tenant_negative.py b/tempest/api/identity/admin/v2/test_tenant_negative.py index 792dad9646..4c7c44ccd9 100644 --- a/tempest/api/identity/admin/v2/test_tenant_negative.py +++ b/tempest/api/identity/admin/v2/test_tenant_negative.py @@ -14,10 +14,13 @@ # under the License. from tempest.api.identity import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators from tempest.lib import exceptions as lib_exc +CONF = config.CONF + class TenantsNegativeTestJSON(base.BaseIdentityV2AdminTest): """Negative tests of keystone tenants via v2 API""" @@ -77,7 +80,8 @@ class TenantsNegativeTestJSON(base.BaseIdentityV2AdminTest): @decorators.idempotent_id('af16f44b-a849-46cb-9f13-a751c388f739') def test_tenant_create_duplicate(self): """Test tenant names should be unique via v2 API""" - tenant_name = data_utils.rand_name(name='tenant') + tenant_name = data_utils.rand_name( + name='tenant', prefix=CONF.resource_name_prefix) self.setup_test_tenant(name=tenant_name) self.assertRaises(lib_exc.Conflict, self.tenants_client.create_tenant, name=tenant_name) @@ -89,7 +93,8 @@ class TenantsNegativeTestJSON(base.BaseIdentityV2AdminTest): Non-admin user should not be authorized to create a tenant via v2 API. """ - tenant_name = data_utils.rand_name(name='tenant') + tenant_name = data_utils.rand_name( + name='tenant', prefix=CONF.resource_name_prefix) self.assertRaises(lib_exc.Forbidden, self.non_admin_tenants_client.create_tenant, name=tenant_name) @@ -98,7 +103,8 @@ class TenantsNegativeTestJSON(base.BaseIdentityV2AdminTest): @decorators.idempotent_id('a3ee9d7e-6920-4dd5-9321-d4b2b7f0a638') def test_create_tenant_request_without_token(self): """Test creating tenant without a token via v2 API is not allowed""" - tenant_name = data_utils.rand_name(name='tenant') + tenant_name = data_utils.rand_name( + name='tenant', prefix=CONF.resource_name_prefix) token = self.client.auth_provider.get_token() self.client.delete_token(token) self.assertRaises(lib_exc.Unauthorized, diff --git a/tempest/api/identity/admin/v2/test_tenants.py b/tempest/api/identity/admin/v2/test_tenants.py index 5f73e1cd23..4f674a8498 100644 --- a/tempest/api/identity/admin/v2/test_tenants.py +++ b/tempest/api/identity/admin/v2/test_tenants.py @@ -14,9 +14,12 @@ # under the License. from tempest.api.identity import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators +CONF = config.CONF + class TenantsTestJSON(base.BaseIdentityV2AdminTest): """Test identity tenants via v2 API""" @@ -46,7 +49,8 @@ class TenantsTestJSON(base.BaseIdentityV2AdminTest): @decorators.idempotent_id('d25e9f24-1310-4d29-b61b-d91299c21d6d') def test_tenant_create_with_description(self): """Test creating tenant with a description via v2 API""" - tenant_desc = data_utils.rand_name(name='desc') + tenant_desc = data_utils.rand_name( + name='desc', prefix=CONF.resource_name_prefix) tenant = self.setup_test_tenant(description=tenant_desc) tenant_id = tenant['id'] desc1 = tenant['description'] @@ -83,12 +87,14 @@ class TenantsTestJSON(base.BaseIdentityV2AdminTest): @decorators.idempotent_id('781f2266-d128-47f3-8bdb-f70970add238') def test_tenant_update_name(self): """Test updating name attribute of a tenant via v2 API""" - t_name1 = data_utils.rand_name(name='tenant') + t_name1 = data_utils.rand_name( + name='tenant', prefix=CONF.resource_name_prefix) tenant = self.setup_test_tenant(name=t_name1) t_id = tenant['id'] resp1_name = tenant['name'] - t_name2 = data_utils.rand_name(name='tenant2') + t_name2 = data_utils.rand_name( + name='tenant2', prefix=CONF.resource_name_prefix) body = self.tenants_client.update_tenant(t_id, name=t_name2)['tenant'] resp2_name = body['name'] self.assertNotEqual(resp1_name, resp2_name) @@ -105,12 +111,14 @@ class TenantsTestJSON(base.BaseIdentityV2AdminTest): @decorators.idempotent_id('859fcfe1-3a03-41ef-86f9-b19a47d1cd87') def test_tenant_update_desc(self): """Test updating description attribute of a tenant via v2 API""" - t_desc = data_utils.rand_name(name='desc') + t_desc = data_utils.rand_name( + name='desc', prefix=CONF.resource_name_prefix) tenant = self.setup_test_tenant(description=t_desc) t_id = tenant['id'] resp1_desc = tenant['description'] - t_desc2 = data_utils.rand_name(name='desc2') + t_desc2 = data_utils.rand_name( + name='desc2', prefix=CONF.resource_name_prefix) body = self.tenants_client.update_tenant(t_id, description=t_desc2) updated_tenant = body['tenant'] resp2_desc = updated_tenant['description'] diff --git a/tempest/api/identity/admin/v2/test_tokens.py b/tempest/api/identity/admin/v2/test_tokens.py index 5d89f9dffe..78a2aada5c 100644 --- a/tempest/api/identity/admin/v2/test_tokens.py +++ b/tempest/api/identity/admin/v2/test_tokens.py @@ -29,7 +29,8 @@ class TokensTestJSON(base.BaseIdentityV2AdminTest): def test_create_check_get_delete_token(self): """Test getting create/check/get/delete token for user via v2 API""" # get a token by username and password - user_name = data_utils.rand_name(name='user') + user_name = data_utils.rand_name( + name='user', prefix=CONF.resource_name_prefix) user_password = data_utils.rand_password() # first:create a tenant tenant = self.setup_test_tenant() @@ -67,7 +68,8 @@ class TokensTestJSON(base.BaseIdentityV2AdminTest): """ # Create a user. - user_name = data_utils.rand_name(name='user') + user_name = data_utils.rand_name( + name='user', prefix=CONF.resource_name_prefix) user_password = data_utils.rand_password() tenant_id = None # No default tenant so will get unscoped token. user = self.create_test_user(name=user_name, @@ -76,10 +78,12 @@ class TokensTestJSON(base.BaseIdentityV2AdminTest): email='') # Create a couple tenants. - tenant1_name = data_utils.rand_name(name='tenant') + tenant1_name = data_utils.rand_name( + name='tenant', prefix=CONF.resource_name_prefix) tenant1 = self.setup_test_tenant(name=tenant1_name) - tenant2_name = data_utils.rand_name(name='tenant') + tenant2_name = data_utils.rand_name( + name='tenant', prefix=CONF.resource_name_prefix) tenant2 = self.setup_test_tenant(name=tenant2_name) # Create a role diff --git a/tempest/api/identity/admin/v2/test_users.py b/tempest/api/identity/admin/v2/test_users.py index 57a321a737..011419e3e7 100644 --- a/tempest/api/identity/admin/v2/test_users.py +++ b/tempest/api/identity/admin/v2/test_users.py @@ -18,9 +18,12 @@ import time from testtools import matchers from tempest.api.identity import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators +CONF = config.CONF + class UsersTestJSON(base.BaseIdentityV2AdminTest): """Test keystone users via v2 API""" @@ -28,7 +31,8 @@ class UsersTestJSON(base.BaseIdentityV2AdminTest): @classmethod def resource_setup(cls): super(UsersTestJSON, cls).resource_setup() - cls.alt_user = data_utils.rand_name('test_user') + cls.alt_user = data_utils.rand_name( + name='test_user', prefix=CONF.resource_name_prefix) cls.alt_email = cls.alt_user + '@testmail.tm' @decorators.attr(type='smoke') @@ -43,7 +47,8 @@ class UsersTestJSON(base.BaseIdentityV2AdminTest): def test_create_user_with_enabled(self): """Test creating a user with enabled : False via v2 API""" tenant = self.setup_test_tenant() - name = data_utils.rand_name('test_user') + name = data_utils.rand_name( + name='test_user', prefix=CONF.resource_name_prefix) user = self.create_test_user(name=name, tenantId=tenant['id'], email=self.alt_email, @@ -59,7 +64,8 @@ class UsersTestJSON(base.BaseIdentityV2AdminTest): user = self.create_test_user(tenantId=tenant['id']) # Updating user details with new values - u_name2 = data_utils.rand_name('user2') + u_name2 = data_utils.rand_name( + name='user2', prefix=CONF.resource_name_prefix) u_email2 = u_name2 + '@testmail.tm' update_user = self.users_client.update_user(user['id'], name=u_name2, email=u_email2, diff --git a/tempest/api/identity/admin/v2/test_users_negative.py b/tempest/api/identity/admin/v2/test_users_negative.py index eda1fdd4f1..7ccd75cb8e 100644 --- a/tempest/api/identity/admin/v2/test_users_negative.py +++ b/tempest/api/identity/admin/v2/test_users_negative.py @@ -14,10 +14,13 @@ # under the License. from tempest.api.identity import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators from tempest.lib import exceptions as lib_exc +CONF = config.CONF + class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest): """Negative tests of identity users via v2 API""" @@ -25,7 +28,8 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest): @classmethod def resource_setup(cls): super(UsersNegativeTestJSON, cls).resource_setup() - cls.alt_user = data_utils.rand_name('test_user') + cls.alt_user = data_utils.rand_name( + 'test_user', prefix=CONF.resource_name_prefix) cls.alt_password = data_utils.rand_password() cls.alt_email = cls.alt_user + '@testmail.tm' @@ -106,7 +110,8 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest): def test_create_user_with_enabled_non_bool(self): """Creating a user with invalid enabled para via v2 API should fail""" tenant = self.setup_test_tenant() - name = data_utils.rand_name('test_user') + name = data_utils.rand_name( + 'test_user', prefix=CONF.resource_name_prefix) self.assertRaises(lib_exc.BadRequest, self.users_client.create_user, name=name, password=self.alt_password, tenantId=tenant['id'], @@ -116,7 +121,8 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest): @decorators.idempotent_id('3d07e294-27a0-4144-b780-a2a1bf6fee19') def test_update_user_for_non_existent_user(self): """Updating a non-existent user via v2 API should fail""" - user_name = data_utils.rand_name('user') + user_name = data_utils.rand_name( + 'user', prefix=CONF.resource_name_prefix) non_existent_id = data_utils.rand_uuid() self.assertRaises(lib_exc.NotFound, self.users_client.update_user, non_existent_id, name=user_name) diff --git a/tempest/api/identity/admin/v3/test_credentials.py b/tempest/api/identity/admin/v3/test_credentials.py index 441f10f625..1213cfcf7a 100644 --- a/tempest/api/identity/admin/v3/test_credentials.py +++ b/tempest/api/identity/admin/v3/test_credentials.py @@ -15,9 +15,12 @@ from oslo_serialization import jsonutils as json from tempest.api.identity import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators +CONF = config.CONF + class CredentialsTestJSON(base.BaseIdentityV3AdminTest): """Test keystone credentials""" @@ -35,8 +38,11 @@ class CredentialsTestJSON(base.BaseIdentityV3AdminTest): ['access', 'secret']] for _ in range(2): project = cls.projects_client.create_project( - data_utils.rand_name('project'), - description=data_utils.rand_name('project-desc'))['project'] + data_utils.rand_name( + name='project', prefix=CONF.resource_name_prefix), + description=data_utils.rand_name( + name='project-desc', + prefix=CONF.resource_name_prefix))['project'] cls.addClassResourceCleanup( cls.projects_client.delete_project, project['id']) cls.projects.append(project['id']) @@ -50,8 +56,10 @@ class CredentialsTestJSON(base.BaseIdentityV3AdminTest): @decorators.idempotent_id('7cd59bf9-bda4-4c72-9467-d21cab278355') def test_credentials_create_get_update_delete(self): """Test creating, getting, updating, deleting of credentials""" + prefix = CONF.resource_name_prefix blob = '{"access": "%s", "secret": "%s"}' % ( - data_utils.rand_name('Access'), data_utils.rand_name('Secret')) + data_utils.rand_name(name='Access', prefix=prefix), + data_utils.rand_name(name='Secret', prefix=prefix)) cred = self.creds_client.create_credential( user_id=self.user_body['id'], project_id=self.projects[0], blob=blob, type='ec2')['credential'] @@ -61,8 +69,8 @@ class CredentialsTestJSON(base.BaseIdentityV3AdminTest): for value2 in self.creds_list[1]: self.assertIn(value2, cred['blob']) - new_keys = [data_utils.rand_name('NewAccess'), - data_utils.rand_name('NewSecret')] + new_keys = [data_utils.rand_name(name='NewAccess', prefix=prefix), + data_utils.rand_name(name='NewSecret', prefix=prefix)] blob = '{"access": "%s", "secret": "%s"}' % (new_keys[0], new_keys[1]) update_body = self.creds_client.update_credential( cred['id'], blob=blob, project_id=self.projects[1], @@ -88,10 +96,12 @@ class CredentialsTestJSON(base.BaseIdentityV3AdminTest): """Test listing credentials""" created_cred_ids = list() fetched_cred_ids = list() + prefix = CONF.resource_name_prefix for _ in range(2): blob = '{"access": "%s", "secret": "%s"}' % ( - data_utils.rand_name('Access'), data_utils.rand_name('Secret')) + data_utils.rand_name(name='Access', prefix=prefix), + data_utils.rand_name(name='Secret', prefix=prefix)) cred = self.creds_client.create_credential( user_id=self.user_body['id'], project_id=self.projects[0], blob=blob, type='ec2')['credential'] diff --git a/tempest/api/identity/admin/v3/test_default_project_id.py b/tempest/api/identity/admin/v3/test_default_project_id.py index 7c3a6ccb68..64550d159d 100644 --- a/tempest/api/identity/admin/v3/test_default_project_id.py +++ b/tempest/api/identity/admin/v3/test_default_project_id.py @@ -42,7 +42,8 @@ class TestDefaultProjectId(base.BaseIdentityV3AdminTest): def test_default_project_id(self): """Creating a token without project will default to user's project""" # create a domain - dom_name = data_utils.rand_name('dom') + dom_name = data_utils.rand_name( + name='dom', prefix=CONF.resource_name_prefix) domain_body = self.domains_client.create_domain( name=dom_name)['domain'] dom_id = domain_body['id'] @@ -57,7 +58,8 @@ class TestDefaultProjectId(base.BaseIdentityV3AdminTest): # create a user in the domain, with the previous project as his # default project - user_name = data_utils.rand_name('user') + user_name = data_utils.rand_name( + name='user', prefix=CONF.resource_name_prefix) user_pass = data_utils.rand_password() user_body = self.users_client.create_user( name=user_name, diff --git a/tempest/api/identity/admin/v3/test_domain_configuration.py b/tempest/api/identity/admin/v3/test_domain_configuration.py index a246a36d1c..e195dd914c 100644 --- a/tempest/api/identity/admin/v3/test_domain_configuration.py +++ b/tempest/api/identity/admin/v3/test_domain_configuration.py @@ -14,11 +14,14 @@ # under the License. from tempest.api.identity import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib.common.utils import test_utils from tempest.lib import decorators from tempest.lib import exceptions as lib_exc +CONF = config.CONF + class DomainConfigurationTestJSON(base.BaseIdentityV3AdminTest): """Test domain configuration""" @@ -150,7 +153,8 @@ class DomainConfigurationTestJSON(base.BaseIdentityV3AdminTest): domain, _ = self._create_domain_and_config(self.custom_config) # Check that updating configuration groups work. - new_driver = data_utils.rand_name('driver') + new_driver = data_utils.rand_name( + name='driver', prefix=CONF.resource_name_prefix) new_limit = data_utils.rand_int_id(0, 100) new_group_config = {'identity': {'driver': new_driver, 'list_limit': new_limit}} @@ -162,7 +166,8 @@ class DomainConfigurationTestJSON(base.BaseIdentityV3AdminTest): self.assertEqual(new_limit, updated_config['identity']['list_limit']) # Check that updating individual configuration group options work. - new_driver = data_utils.rand_name('driver') + new_driver = data_utils.rand_name( + name='driver', prefix=CONF.resource_name_prefix) updated_config = self.client.update_domain_group_option_config( domain['id'], 'identity', 'driver', driver=new_driver)['config'] diff --git a/tempest/api/identity/admin/v3/test_domains.py b/tempest/api/identity/admin/v3/test_domains.py index 419c6c782f..80c4d1c9a3 100644 --- a/tempest/api/identity/admin/v3/test_domains.py +++ b/tempest/api/identity/admin/v3/test_domains.py @@ -76,9 +76,10 @@ class DomainsTestJSON(base.BaseIdentityV3AdminTest): @decorators.idempotent_id('f2f5b44a-82e8-4dad-8084-0661ea3b18cf') def test_create_update_delete_domain(self): """Test creating, updating and deleting domain""" + prefix = CONF.resource_name_prefix # Create domain - d_name = data_utils.rand_name('domain') - d_desc = data_utils.rand_name('domain-desc') + d_name = data_utils.rand_name(name='domain', prefix=prefix) + d_desc = data_utils.rand_name(name='domain-desc', prefix=prefix) domain = self.domains_client.create_domain( name=d_name, description=d_desc)['domain'] self.addCleanup(test_utils.call_and_ignore_notfound_exc, @@ -92,8 +93,8 @@ class DomainsTestJSON(base.BaseIdentityV3AdminTest): self.assertEqual(d_desc, domain['description']) self.assertEqual(True, domain['enabled']) # Update domain - new_desc = data_utils.rand_name('new-desc') - new_name = data_utils.rand_name('new-name') + new_desc = data_utils.rand_name(name='new-desc', prefix=prefix) + new_name = data_utils.rand_name(name='new-name', prefix=prefix) updated_domain = self.domains_client.update_domain( domain['id'], name=new_name, description=new_desc, enabled=False)['domain'] @@ -139,8 +140,10 @@ class DomainsTestJSON(base.BaseIdentityV3AdminTest): def test_create_domain_with_disabled_status(self): """Test creating domain with disabled status""" # Create domain with enabled status as false - d_name = data_utils.rand_name('domain') - d_desc = data_utils.rand_name('domain-desc') + d_name = data_utils.rand_name( + name='domain', prefix=CONF.resource_name_prefix) + d_desc = data_utils.rand_name( + name='domain-desc', prefix=CONF.resource_name_prefix) domain = self.domains_client.create_domain( name=d_name, description=d_desc, enabled=False)['domain'] self.addCleanup(self.domains_client.delete_domain, domain['id']) @@ -152,7 +155,8 @@ class DomainsTestJSON(base.BaseIdentityV3AdminTest): def test_create_domain_without_description(self): """Test creating domain without description""" # Create domain only with name - d_name = data_utils.rand_name('domain') + d_name = data_utils.rand_name( + name='domain', prefix=CONF.resource_name_prefix) domain = self.domains_client.create_domain(name=d_name)['domain'] self.addCleanup(self.delete_domain, domain['id']) expected_data = {'name': d_name, 'enabled': True} diff --git a/tempest/api/identity/admin/v3/test_domains_negative.py b/tempest/api/identity/admin/v3/test_domains_negative.py index c90206d8fc..1087b63378 100644 --- a/tempest/api/identity/admin/v3/test_domains_negative.py +++ b/tempest/api/identity/admin/v3/test_domains_negative.py @@ -14,10 +14,13 @@ # under the License. from tempest.api.identity import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators from tempest.lib import exceptions as lib_exc +CONF = config.CONF + class DomainsNegativeTestJSON(base.BaseIdentityV3AdminTest): """Negative tests of identity domains""" @@ -73,7 +76,8 @@ class DomainsNegativeTestJSON(base.BaseIdentityV3AdminTest): @decorators.idempotent_id('e6f9e4a2-4f36-4be8-bdbc-4e199ae29427') def test_domain_create_duplicate(self): """Test creating domain with duplicate name should fail""" - domain_name = data_utils.rand_name('domain-dup') + domain_name = data_utils.rand_name( + name='domain-dup', prefix=CONF.resource_name_prefix) domain = self.domains_client.create_domain(name=domain_name)['domain'] domain_id = domain['id'] self.addCleanup(self.delete_domain, domain_id) diff --git a/tempest/api/identity/admin/v3/test_endpoint_groups.py b/tempest/api/identity/admin/v3/test_endpoint_groups.py index 2fa92e3c72..591a83bc80 100644 --- a/tempest/api/identity/admin/v3/test_endpoint_groups.py +++ b/tempest/api/identity/admin/v3/test_endpoint_groups.py @@ -14,10 +14,13 @@ # under the License. from tempest.api.identity import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib.common.utils import test_utils from tempest.lib import decorators +CONF = config.CONF + class EndPointGroupsTest(base.BaseIdentityV3AdminTest): """Test endpoint groups""" @@ -42,8 +45,10 @@ class EndPointGroupsTest(base.BaseIdentityV3AdminTest): cls.addClassResourceCleanup( cls.services_client.delete_service, service_id) - name = data_utils.rand_name('service_group') - description = data_utils.rand_name('description') + name = data_utils.rand_name( + name='service_group', prefix=CONF.resource_name_prefix) + description = data_utils.rand_name( + name='description', prefix=CONF.resource_name_prefix) filters = {'service_id': service_id} endpoint_group = cls.client.create_endpoint_group( @@ -57,9 +62,10 @@ class EndPointGroupsTest(base.BaseIdentityV3AdminTest): @classmethod def _create_service(cls): - s_name = data_utils.rand_name('service') - s_type = data_utils.rand_name('type') - s_description = data_utils.rand_name('description') + prefix = CONF.resource_name_prefix + s_name = data_utils.rand_name(name='service', prefix=prefix) + s_type = data_utils.rand_name(name='type', prefix=prefix) + s_description = data_utils.rand_name(name='description', prefix=prefix) service_data = ( cls.services_client.create_service(name=s_name, type=s_type, @@ -73,8 +79,10 @@ class EndPointGroupsTest(base.BaseIdentityV3AdminTest): """Test create/list/show/check/delete of endpoint group""" service_id = self._create_service() self.addCleanup(self.services_client.delete_service, service_id) - name = data_utils.rand_name('service_group') - description = data_utils.rand_name('description') + name = data_utils.rand_name( + name='service_group', prefix=CONF.resource_name_prefix) + description = data_utils.rand_name( + name='description', prefix=CONF.resource_name_prefix) filters = {'service_id': service_id} endpoint_group = self.client.create_endpoint_group( @@ -135,8 +143,10 @@ class EndPointGroupsTest(base.BaseIdentityV3AdminTest): # with new values service1_id = self._create_service() self.addCleanup(self.services_client.delete_service, service1_id) - name = data_utils.rand_name('service_group') - description = data_utils.rand_name('description') + name = data_utils.rand_name( + name='service_group', prefix=CONF.resource_name_prefix) + description = data_utils.rand_name( + name='description', prefix=CONF.resource_name_prefix) filters = {'service_id': service1_id} endpoint_group = self.client.create_endpoint_group( @@ -149,8 +159,10 @@ class EndPointGroupsTest(base.BaseIdentityV3AdminTest): # Creating new attr values to update endpoint group service2_id = self._create_service() self.addCleanup(self.services_client.delete_service, service2_id) - name2 = data_utils.rand_name('service_group2') - description2 = data_utils.rand_name('description2') + name2 = data_utils.rand_name( + name='service_group2', prefix=CONF.resource_name_prefix) + description2 = data_utils.rand_name( + name='description2', prefix=CONF.resource_name_prefix) filters = {'service_id': service2_id} # Updating endpoint group with new attr values diff --git a/tempest/api/identity/admin/v3/test_endpoints.py b/tempest/api/identity/admin/v3/test_endpoints.py index 0199d737c8..f9f3e7296d 100644 --- a/tempest/api/identity/admin/v3/test_endpoints.py +++ b/tempest/api/identity/admin/v3/test_endpoints.py @@ -14,10 +14,13 @@ # under the License. from tempest.api.identity import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib.common.utils import test_utils from tempest.lib import decorators +CONF = config.CONF + class EndPointsTestJSON(base.BaseIdentityV3AdminTest): """Test keystone endpoints""" @@ -46,7 +49,8 @@ class EndPointsTestJSON(base.BaseIdentityV3AdminTest): cls.addClassResourceCleanup( cls.services_client.delete_service, service['id']) - region_name = data_utils.rand_name('region') + region_name = data_utils.rand_name( + 'region', prefix=CONF.resource_name_prefix) url = data_utils.rand_url() endpoint = cls.client.create_endpoint( service_id=cls.service_ids[i], interface=interfaces[i], @@ -60,12 +64,14 @@ class EndPointsTestJSON(base.BaseIdentityV3AdminTest): @classmethod def _create_service(cls, s_name=None, s_type=None, s_description=None): + prefix = CONF.resource_name_prefix if s_name is None: - s_name = data_utils.rand_name('service') + s_name = data_utils.rand_name(name='service', prefix=prefix) if s_type is None: - s_type = data_utils.rand_name('type') + s_type = data_utils.rand_name(name='type', prefix=prefix) if s_description is None: - s_description = data_utils.rand_name('description') + s_description = data_utils.rand_name( + name='description', prefix=prefix) service_data = ( cls.services_client.create_service(name=s_name, type=s_type, description=s_description)) @@ -115,7 +121,8 @@ class EndPointsTestJSON(base.BaseIdentityV3AdminTest): @decorators.idempotent_id('0e2446d2-c1fd-461b-a729-b9e73e3e3b37') def test_create_list_show_delete_endpoint(self): """Test creating, listing, showing and deleting keystone endpoint""" - region_name = data_utils.rand_name('region') + region_name = data_utils.rand_name( + name='region', prefix=CONF.resource_name_prefix) url = data_utils.rand_url() interface = 'public' endpoint = self.client.create_endpoint(service_id=self.service_ids[0], @@ -162,16 +169,17 @@ class EndPointsTestJSON(base.BaseIdentityV3AdminTest): # endpoint_for_update is deleted, otherwise we will get a 404 error # when deleting endpoint_for_update if endpoint's service is deleted. + prefix = CONF.resource_name_prefix # Creating service for updating endpoint with new service ID - s_name = data_utils.rand_name('service') - s_type = data_utils.rand_name('type') - s_description = data_utils.rand_name('description') + s_name = data_utils.rand_name(name='service', prefix=prefix) + s_type = data_utils.rand_name(name='type', prefix=prefix) + s_description = data_utils.rand_name(name='description', prefix=prefix) service2 = self._create_service(s_name=s_name, s_type=s_type, s_description=s_description) self.addCleanup(self.services_client.delete_service, service2['id']) # Creating an endpoint so as to check update endpoint with new values - region1_name = data_utils.rand_name('region') + region1_name = data_utils.rand_name(name='region', prefix=prefix) url1 = data_utils.rand_url() interface1 = 'public' endpoint_for_update = ( @@ -183,7 +191,7 @@ class EndPointsTestJSON(base.BaseIdentityV3AdminTest): self.addCleanup(self.regions_client.delete_region, region1['id']) # Updating endpoint with new values - region2_name = data_utils.rand_name('region') + region2_name = data_utils.rand_name(name='region', prefix=prefix) url2 = data_utils.rand_url() interface2 = 'internal' endpoint = self.client.update_endpoint(endpoint_for_update['id'], diff --git a/tempest/api/identity/admin/v3/test_endpoints_negative.py b/tempest/api/identity/admin/v3/test_endpoints_negative.py index 9689d878f7..2d47eb8cc1 100644 --- a/tempest/api/identity/admin/v3/test_endpoints_negative.py +++ b/tempest/api/identity/admin/v3/test_endpoints_negative.py @@ -14,10 +14,13 @@ # under the License. from tempest.api.identity import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators from tempest.lib import exceptions as lib_exc +CONF = config.CONF + class EndpointsNegativeTestJSON(base.BaseIdentityV3AdminTest): """Negative tests of endpoint""" @@ -34,10 +37,11 @@ class EndpointsNegativeTestJSON(base.BaseIdentityV3AdminTest): @classmethod def resource_setup(cls): + prefix = CONF.resource_name_prefix super(EndpointsNegativeTestJSON, cls).resource_setup() - s_name = data_utils.rand_name('service') - s_type = data_utils.rand_name('type') - s_description = data_utils.rand_name('description') + s_name = data_utils.rand_name(name='service', prefix=prefix) + s_type = data_utils.rand_name(name='type', prefix=prefix) + s_description = data_utils.rand_name(name='description', prefix=prefix) service_data = ( cls.services_client.create_service(name=s_name, type=s_type, description=s_description) @@ -56,7 +60,8 @@ class EndpointsNegativeTestJSON(base.BaseIdentityV3AdminTest): """ interface = 'public' url = data_utils.rand_url() - region = data_utils.rand_name('region') + region = data_utils.rand_name( + name='region', prefix=CONF.resource_name_prefix) self.assertRaises(lib_exc.BadRequest, self.client.create_endpoint, service_id=self.service_id, interface=interface, url=url, region=region, enabled='False') @@ -70,7 +75,8 @@ class EndpointsNegativeTestJSON(base.BaseIdentityV3AdminTest): """ interface = 'public' url = data_utils.rand_url() - region = data_utils.rand_name('region') + region = data_utils.rand_name( + name='region', prefix=CONF.resource_name_prefix) self.assertRaises(lib_exc.BadRequest, self.client.create_endpoint, service_id=self.service_id, interface=interface, url=url, region=region, enabled='True') @@ -78,7 +84,8 @@ class EndpointsNegativeTestJSON(base.BaseIdentityV3AdminTest): def _assert_update_raises_bad_request(self, enabled): # Create an endpoint - region1_name = data_utils.rand_name('region') + region1_name = data_utils.rand_name( + name='region', prefix=CONF.resource_name_prefix) url1 = data_utils.rand_url() interface1 = 'public' endpoint_for_update = ( diff --git a/tempest/api/identity/admin/v3/test_groups.py b/tempest/api/identity/admin/v3/test_groups.py index b2e377533b..b5b3c5d036 100644 --- a/tempest/api/identity/admin/v3/test_groups.py +++ b/tempest/api/identity/admin/v3/test_groups.py @@ -38,9 +38,10 @@ class GroupsV3TestJSON(base.BaseIdentityV3AdminTest): @decorators.idempotent_id('2e80343b-6c81-4ac3-88c7-452f3e9d5129') def test_group_create_update_get(self): """Test creating, updating and getting keystone group""" + prefix = CONF.resource_name_prefix # Verify group creation works. - name = data_utils.rand_name('Group') - description = data_utils.rand_name('Description') + name = data_utils.rand_name(name='Group', prefix=prefix) + description = data_utils.rand_name(name='Description', prefix=prefix) group = self.setup_test_group(name=name, domain_id=self.domain['id'], description=description) self.assertEqual(group['name'], name) @@ -48,8 +49,10 @@ class GroupsV3TestJSON(base.BaseIdentityV3AdminTest): self.assertEqual(self.domain['id'], group['domain_id']) # Verify updating name and description works. - first_name_update = data_utils.rand_name('UpdateGroup') - first_desc_update = data_utils.rand_name('UpdateDescription') + first_name_update = data_utils.rand_name( + name='UpdateGroup', prefix=prefix) + first_desc_update = data_utils.rand_name( + name='UpdateDescription', prefix=prefix) updated_group = self.groups_client.update_group( group['id'], name=first_name_update, description=first_desc_update)['group'] @@ -65,7 +68,7 @@ class GroupsV3TestJSON(base.BaseIdentityV3AdminTest): # Verify that updating a single field for a group (name) leaves the # other fields (description, domain_id) unchanged. second_name_update = data_utils.rand_name( - self.__class__.__name__ + 'UpdateGroup') + self.__class__.__name__ + 'UpdateGroup', prefix=prefix) updated_group = self.groups_client.update_group( group['id'], name=second_name_update)['group'] self.assertEqual(second_name_update, updated_group['name']) diff --git a/tempest/api/identity/admin/v3/test_inherits.py b/tempest/api/identity/admin/v3/test_inherits.py index cababc6bd3..48bde2b4f4 100644 --- a/tempest/api/identity/admin/v3/test_inherits.py +++ b/tempest/api/identity/admin/v3/test_inherits.py @@ -37,20 +37,21 @@ class InheritsV3TestJSON(base.BaseIdentityV3AdminTest): @classmethod def resource_setup(cls): super(InheritsV3TestJSON, cls).resource_setup() - u_name = data_utils.rand_name('user-') + prefix = CONF.resource_name_prefix + u_name = data_utils.rand_name(name='user-', prefix=prefix) u_desc = '%s description' % u_name u_email = '%s@testmail.tm' % u_name u_password = data_utils.rand_password() cls.domain = cls.create_domain() cls.project = cls.projects_client.create_project( - data_utils.rand_name('project-'), - description=data_utils.rand_name('project-desc-'), + data_utils.rand_name(name='project-', prefix=prefix), + description=data_utils.rand_name('project-desc-', prefix=prefix), domain_id=cls.domain['id'])['project'] cls.addClassResourceCleanup(cls.projects_client.delete_project, cls.project['id']) cls.group = cls.groups_client.create_group( - name=data_utils.rand_name('group-'), project_id=cls.project['id'], - domain_id=cls.domain['id'])['group'] + name=data_utils.rand_name(name='group-', prefix=prefix), + project_id=cls.project['id'], domain_id=cls.domain['id'])['group'] cls.addClassResourceCleanup(cls.groups_client.delete_group, cls.group['id']) if not CONF.identity_feature_enabled.immutable_user_source: diff --git a/tempest/api/identity/admin/v3/test_list_projects.py b/tempest/api/identity/admin/v3/test_list_projects.py index b33d8bdb86..2135fccdd1 100644 --- a/tempest/api/identity/admin/v3/test_list_projects.py +++ b/tempest/api/identity/admin/v3/test_list_projects.py @@ -45,20 +45,21 @@ class ListProjectsTestJSON(BaseListProjectsTestJSON): @classmethod def resource_setup(cls): super(ListProjectsTestJSON, cls).resource_setup() + prefix = CONF.resource_name_prefix domain_id = cls.os_admin.credentials.domain_id # Create project with domain - p1_name = data_utils.rand_name(cls.__name__) + p1_name = data_utils.rand_name(cls.__name__, prefix=prefix) cls.p1 = cls.projects_client.create_project( p1_name, enabled=False, domain_id=domain_id)['project'] cls.addClassResourceCleanup(cls.projects_client.delete_project, cls.p1['id']) # Create default project - p2_name = data_utils.rand_name(cls.__name__) + p2_name = data_utils.rand_name(cls.__name__, prefix=prefix) cls.p2 = cls.projects_client.create_project(p2_name)['project'] cls.addClassResourceCleanup(cls.projects_client.delete_project, cls.p2['id']) # Create a new project (p3) using p2 as parent project - p3_name = data_utils.rand_name(cls.__name__) + p3_name = data_utils.rand_name(cls.__name__, prefix=prefix) cls.p3 = cls.projects_client.create_project( p3_name, parent_id=cls.p2['id'])['project'] cls.addClassResourceCleanup(cls.projects_client.delete_project, @@ -99,7 +100,8 @@ class ListProjectsStaticTestJSON(BaseListProjectsTestJSON): cls.p1 = cls.projects_client.show_project( cls.os_primary.credentials.project_id)['project'] # Create a test project - p2_name = data_utils.rand_name(cls.__name__) + p2_name = data_utils.rand_name( + cls.__name__, prefix=CONF.resource_name_prefix) p2_domain_id = CONF.identity.default_domain_id cls.p2 = cls.projects_client.create_project( p2_name, domain_id=p2_domain_id)['project'] diff --git a/tempest/api/identity/admin/v3/test_list_users.py b/tempest/api/identity/admin/v3/test_list_users.py index 7bd0bcfedd..3884989086 100644 --- a/tempest/api/identity/admin/v3/test_list_users.py +++ b/tempest/api/identity/admin/v3/test_list_users.py @@ -45,14 +45,15 @@ class UsersV3TestJSON(base.BaseIdentityV3AdminTest): @classmethod def resource_setup(cls): super(UsersV3TestJSON, cls).resource_setup() - alt_user = data_utils.rand_name('test_user') + prefix = CONF.resource_name_prefix + alt_user = data_utils.rand_name(name='test_user', prefix=prefix) alt_password = data_utils.rand_password() cls.alt_email = alt_user + '@testmail.tm' # Create a domain cls.domain = cls.create_domain() # Create user with Domain cls.users = list() - u1_name = data_utils.rand_name('test_user') + u1_name = data_utils.rand_name(name='test_user', prefix=prefix) cls.domain_enabled_user = cls.users_client.create_user( name=u1_name, password=alt_password, email=cls.alt_email, domain_id=cls.domain['id'])['user'] @@ -60,7 +61,7 @@ class UsersV3TestJSON(base.BaseIdentityV3AdminTest): cls.domain_enabled_user['id']) cls.users.append(cls.domain_enabled_user) # Create default not enabled user - u2_name = data_utils.rand_name('test_user') + u2_name = data_utils.rand_name(name='test_user', prefix=prefix) cls.non_domain_enabled_user = cls.users_client.create_user( name=u2_name, password=alt_password, email=cls.alt_email, enabled=False)['user'] diff --git a/tempest/api/identity/admin/v3/test_oauth_consumers.py b/tempest/api/identity/admin/v3/test_oauth_consumers.py index 7a85f8445b..0c474c029f 100644 --- a/tempest/api/identity/admin/v3/test_oauth_consumers.py +++ b/tempest/api/identity/admin/v3/test_oauth_consumers.py @@ -14,11 +14,14 @@ # under the License. from tempest.api.identity import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib.common.utils import test_utils from tempest.lib import decorators from tempest.lib import exceptions +CONF = config.CONF + class OAUTHConsumersV3Test(base.BaseIdentityV3AdminTest): # NOTE: force_tenant_isolation is true in the base class by default but @@ -28,7 +31,8 @@ class OAUTHConsumersV3Test(base.BaseIdentityV3AdminTest): def _create_consumer(self): """Creates a consumer with a random description.""" - description = data_utils.rand_name('test_create_consumer') + description = data_utils.rand_name( + name='test_create_consumer', prefix=CONF.resource_name_prefix) consumer = self.oauth_consumers_client.create_consumer( description)['consumer'] # cleans up created consumers after tests @@ -70,7 +74,8 @@ class OAUTHConsumersV3Test(base.BaseIdentityV3AdminTest): # create a new consumer to update consumer = self._create_consumer() # create new description - new_description = data_utils.rand_name('test_update_consumer') + new_description = data_utils.rand_name( + name='test_update_consumer', prefix=CONF.resource_name_prefix) # update consumer self.oauth_consumers_client.update_consumer(consumer['id'], new_description) diff --git a/tempest/api/identity/admin/v3/test_policies.py b/tempest/api/identity/admin/v3/test_policies.py index fb81d0a0b8..2d3775a48d 100644 --- a/tempest/api/identity/admin/v3/test_policies.py +++ b/tempest/api/identity/admin/v3/test_policies.py @@ -14,9 +14,12 @@ # under the License. from tempest.api.identity import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators +CONF = config.CONF + class PoliciesTestJSON(base.BaseIdentityV3AdminTest): """Test keystone policies""" @@ -30,8 +33,10 @@ class PoliciesTestJSON(base.BaseIdentityV3AdminTest): policy_ids = list() fetched_ids = list() for _ in range(3): - blob = data_utils.rand_name('BlobName') - policy_type = data_utils.rand_name('PolicyType') + blob = data_utils.rand_name( + name='BlobName', prefix=CONF.resource_name_prefix) + policy_type = data_utils.rand_name( + name='PolicyType', prefix=CONF.resource_name_prefix) policy = self.policies_client.create_policy( blob=blob, type=policy_type)['policy'] # Delete the Policy at the end of this method @@ -48,8 +53,9 @@ class PoliciesTestJSON(base.BaseIdentityV3AdminTest): @decorators.idempotent_id('e544703a-2f03-4cf2-9b0f-350782fdb0d3') def test_create_update_delete_policy(self): """Test to update keystone policy""" - blob = data_utils.rand_name('BlobName') - policy_type = data_utils.rand_name('PolicyType') + prefix = CONF.resource_name_prefix + blob = data_utils.rand_name(name='BlobName', prefix=prefix) + policy_type = data_utils.rand_name(name='PolicyType', prefix=prefix) policy = self.policies_client.create_policy(blob=blob, type=policy_type)['policy'] self.addCleanup(self._delete_policy, policy['id']) @@ -59,7 +65,7 @@ class PoliciesTestJSON(base.BaseIdentityV3AdminTest): self.assertEqual(blob, policy['blob']) self.assertEqual(policy_type, policy['type']) # Update policy - update_type = data_utils.rand_name('UpdatedPolicyType') + update_type = data_utils.rand_name('UpdatedPolicyType', prefix=prefix) data = self.policies_client.update_policy( policy['id'], type=update_type)['policy'] self.assertIn('type', data) diff --git a/tempest/api/identity/admin/v3/test_project_tags.py b/tempest/api/identity/admin/v3/test_project_tags.py index eed60af7e6..2cc725747d 100644 --- a/tempest/api/identity/admin/v3/test_project_tags.py +++ b/tempest/api/identity/admin/v3/test_project_tags.py @@ -40,7 +40,7 @@ class IdentityV3ProjectTagsTest(base.BaseIdentityV3AdminTest): project = self.setup_test_project() # Create a tag for testing. - tag = data_utils.rand_name('tag') + tag = data_utils.rand_name('tag', prefix=CONF.resource_name_prefix) # NOTE(felipemonteiro): The response body for create is empty. self.project_tags_client.update_project_tag(project['id'], tag) @@ -49,7 +49,8 @@ class IdentityV3ProjectTagsTest(base.BaseIdentityV3AdminTest): project['id'], tag) # Verify that updating the project tags works. - tags_to_update = [data_utils.rand_name('tag') for _ in range(3)] + tags_to_update = [data_utils.rand_name( + 'tag', prefix=CONF.resource_name_prefix) for _ in range(3)] updated_tags = self.project_tags_client.update_all_project_tags( project['id'], tags_to_update)['tags'] self.assertEqual(sorted(tags_to_update), sorted(updated_tags)) diff --git a/tempest/api/identity/admin/v3/test_projects.py b/tempest/api/identity/admin/v3/test_projects.py index be1216ab36..3b0052c8c4 100644 --- a/tempest/api/identity/admin/v3/test_projects.py +++ b/tempest/api/identity/admin/v3/test_projects.py @@ -33,7 +33,8 @@ class ProjectsTestJSON(base.BaseIdentityV3AdminTest): @decorators.idempotent_id('0ecf465c-0dc4-4532-ab53-91ffeb74d12d') def test_project_create_with_description(self): """Test creating project with a description""" - project_desc = data_utils.rand_name('desc') + project_desc = data_utils.rand_name( + name='desc', prefix=CONF.resource_name_prefix) project = self.setup_test_project(description=project_desc) project_id = project['id'] desc1 = project['description'] @@ -48,7 +49,8 @@ class ProjectsTestJSON(base.BaseIdentityV3AdminTest): def test_project_create_with_domain(self): """Test creating project with a domain""" domain = self.setup_test_domain() - project_name = data_utils.rand_name('project') + project_name = data_utils.rand_name( + name='project', prefix=CONF.resource_name_prefix) project = self.setup_test_project( name=project_name, domain_id=domain['id']) project_id = project['id'] @@ -64,7 +66,8 @@ class ProjectsTestJSON(base.BaseIdentityV3AdminTest): domain = self.setup_test_domain() domain_id = domain['id'] - root_project_name = data_utils.rand_name('root_project') + root_project_name = data_utils.rand_name( + name='root_project', prefix=CONF.resource_name_prefix) root_project = self.setup_test_project( name=root_project_name, domain_id=domain_id) @@ -76,7 +79,8 @@ class ProjectsTestJSON(base.BaseIdentityV3AdminTest): self.assertEqual(domain_id, parent_id) # Create a project using root_project_id as parent_id - project_name = data_utils.rand_name('project') + project_name = data_utils.rand_name( + name='project', prefix=CONF.resource_name_prefix) project = self.setup_test_project( name=project_name, domain_id=domain_id, parent_id=root_project_id) parent_id = project['parent_id'] @@ -127,12 +131,14 @@ class ProjectsTestJSON(base.BaseIdentityV3AdminTest): @decorators.idempotent_id('f608f368-048c-496b-ad63-d286c26dab6b') def test_project_update_name(self): """Test updating name attribute of a project""" - p_name1 = data_utils.rand_name('project') + p_name1 = data_utils.rand_name( + name='project', prefix=CONF.resource_name_prefix) project = self.setup_test_project(name=p_name1) resp1_name = project['name'] - p_name2 = data_utils.rand_name('project2') + p_name2 = data_utils.rand_name( + name='project2', prefix=CONF.resource_name_prefix) body = self.projects_client.update_project(project['id'], name=p_name2)['project'] resp2_name = body['name'] @@ -148,11 +154,13 @@ class ProjectsTestJSON(base.BaseIdentityV3AdminTest): @decorators.idempotent_id('f138b715-255e-4a7d-871d-351e1ef2e153') def test_project_update_desc(self): """Test updating description attribute of a project""" - p_desc = data_utils.rand_name('desc') + p_desc = data_utils.rand_name( + name='desc', prefix=CONF.resource_name_prefix) project = self.setup_test_project(description=p_desc) resp1_desc = project['description'] - p_desc2 = data_utils.rand_name('desc2') + p_desc2 = data_utils.rand_name( + name='desc2', prefix=CONF.resource_name_prefix) body = self.projects_client.update_project( project['id'], description=p_desc2)['project'] resp2_desc = body['description'] @@ -197,7 +205,8 @@ class ProjectsTestJSON(base.BaseIdentityV3AdminTest): project = self.setup_test_project() # Create a User - u_name = data_utils.rand_name('user') + u_name = data_utils.rand_name( + name='user', prefix=CONF.resource_name_prefix) u_desc = u_name + 'description' u_email = u_name + '@testmail.tm' u_password = data_utils.rand_password() diff --git a/tempest/api/identity/admin/v3/test_projects_negative.py b/tempest/api/identity/admin/v3/test_projects_negative.py index 79e3d29cae..68dd5cbfd7 100644 --- a/tempest/api/identity/admin/v3/test_projects_negative.py +++ b/tempest/api/identity/admin/v3/test_projects_negative.py @@ -14,10 +14,13 @@ # under the License. from tempest.api.identity import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators from tempest.lib import exceptions as lib_exc +CONF = config.CONF + class ProjectsNegativeTestJSON(base.BaseIdentityV3AdminTest): """Negative tests of projects""" @@ -54,7 +57,8 @@ class ProjectsNegativeStaticTestJSON(base.BaseIdentityV3AdminTest): @decorators.idempotent_id('874c3e84-d174-4348-a16b-8c01f599561b') def test_project_create_duplicate(self): """Project names should be unique""" - project_name = data_utils.rand_name('project-dup') + project_name = data_utils.rand_name( + name='project-dup', prefix=CONF.resource_name_prefix) self.setup_test_project(name=project_name) self.assertRaises(lib_exc.Conflict, @@ -64,7 +68,8 @@ class ProjectsNegativeStaticTestJSON(base.BaseIdentityV3AdminTest): @decorators.idempotent_id('8fba9de2-3e1f-4e77-812a-60cb68f8df13') def test_create_project_by_unauthorized_user(self): """Non-admin user should not be authorized to create a project""" - project_name = data_utils.rand_name('project') + project_name = data_utils.rand_name( + name='project', prefix=CONF.resource_name_prefix) self.assertRaises( lib_exc.Forbidden, self.non_admin_projects_client.create_project, project_name) diff --git a/tempest/api/identity/admin/v3/test_regions.py b/tempest/api/identity/admin/v3/test_regions.py index 63e456e283..870a406f0c 100644 --- a/tempest/api/identity/admin/v3/test_regions.py +++ b/tempest/api/identity/admin/v3/test_regions.py @@ -14,10 +14,13 @@ # under the License. from tempest.api.identity import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib.common.utils import test_utils from tempest.lib import decorators +CONF = config.CONF + class RegionsTestJSON(base.BaseIdentityV3AdminTest): """Test regions""" @@ -37,7 +40,8 @@ class RegionsTestJSON(base.BaseIdentityV3AdminTest): super(RegionsTestJSON, cls).resource_setup() cls.setup_regions = list() for _ in range(2): - r_description = data_utils.rand_name('description') + r_description = data_utils.rand_name( + name='description', prefix=CONF.resource_name_prefix) region = cls.client.create_region( description=r_description)['region'] cls.addClassResourceCleanup( @@ -48,7 +52,8 @@ class RegionsTestJSON(base.BaseIdentityV3AdminTest): def test_create_update_get_delete_region(self): """Test creating, updating, getting and updating region""" # Create region - r_description = data_utils.rand_name('description') + r_description = data_utils.rand_name( + name='description', prefix=CONF.resource_name_prefix) region = self.client.create_region( description=r_description, parent_region_id=self.setup_regions[0]['id'])['region'] @@ -62,7 +67,8 @@ class RegionsTestJSON(base.BaseIdentityV3AdminTest): self.assertEqual(self.setup_regions[0]['id'], region['parent_region_id']) # Update region with new description and parent ID - r_alt_description = data_utils.rand_name('description') + r_alt_description = data_utils.rand_name( + name='description', prefix=CONF.resource_name_prefix) region = self.client.update_region( region['id'], description=r_alt_description, @@ -86,7 +92,8 @@ class RegionsTestJSON(base.BaseIdentityV3AdminTest): def test_create_region_with_specific_id(self): """Test creating region with specific id""" r_region_id = data_utils.rand_uuid() - r_description = data_utils.rand_name('description') + r_description = data_utils.rand_name( + name='description', prefix=CONF.resource_name_prefix) region = self.client.create_region( region_id=r_region_id, description=r_description)['region'] self.addCleanup(self.client.delete_region, region['id']) @@ -109,7 +116,8 @@ class RegionsTestJSON(base.BaseIdentityV3AdminTest): def test_list_regions_filter_by_parent_region_id(self): """Test listing regions filtered by parent region id""" # Add a sub-region to one of the existing test regions - r_description = data_utils.rand_name('description') + r_description = data_utils.rand_name( + name='description', prefix=CONF.resource_name_prefix) region = self.client.create_region( description=r_description, parent_region_id=self.setup_regions[0]['id'])['region'] diff --git a/tempest/api/identity/admin/v3/test_roles.py b/tempest/api/identity/admin/v3/test_roles.py index e5137f4038..ab96027858 100644 --- a/tempest/api/identity/admin/v3/test_roles.py +++ b/tempest/api/identity/admin/v3/test_roles.py @@ -35,31 +35,34 @@ class RolesV3TestJSON(base.BaseIdentityV3AdminTest): @classmethod def resource_setup(cls): super(RolesV3TestJSON, cls).resource_setup() + prefix = CONF.resource_name_prefix cls.roles = list() for _ in range(3): - role_name = data_utils.rand_name(name='role') + role_name = data_utils.rand_name(name='role', prefix=prefix) role = cls.roles_client.create_role(name=role_name)['role'] cls.addClassResourceCleanup(cls.roles_client.delete_role, role['id']) cls.roles.append(role) - u_name = data_utils.rand_name('user') + u_name = data_utils.rand_name(name='user', prefix=prefix) u_desc = '%s description' % u_name u_email = '%s@testmail.tm' % u_name cls.u_password = data_utils.rand_password() cls.domain = cls.create_domain() cls.project = cls.projects_client.create_project( - data_utils.rand_name('project'), - description=data_utils.rand_name('project-desc'), + data_utils.rand_name(name='project', prefix=prefix), + description=data_utils.rand_name( + name='project-desc', prefix=prefix), domain_id=cls.domain['id'])['project'] cls.addClassResourceCleanup(cls.projects_client.delete_project, cls.project['id']) cls.group_body = cls.groups_client.create_group( - name=data_utils.rand_name('Group'), project_id=cls.project['id'], + name=data_utils.rand_name(name='Group', prefix=prefix), + project_id=cls.project['id'], domain_id=cls.domain['id'])['group'] cls.addClassResourceCleanup(cls.groups_client.delete_group, cls.group_body['id']) cls.role = cls.roles_client.create_role( - name=data_utils.rand_name('Role'))['role'] + name=data_utils.rand_name(name='Role', prefix=prefix))['role'] cls.addClassResourceCleanup(cls.roles_client.delete_role, cls.role['id']) if not CONF.identity_feature_enabled.immutable_user_source: @@ -78,13 +81,15 @@ class RolesV3TestJSON(base.BaseIdentityV3AdminTest): @decorators.idempotent_id('18afc6c0-46cf-4911-824e-9989cc056c3a') def test_role_create_update_show_list(self): """Test creating, updating, showing and listing a role""" - r_name = data_utils.rand_name('Role') + r_name = data_utils.rand_name( + name='Role', prefix=CONF.resource_name_prefix) role = self.roles_client.create_role(name=r_name)['role'] self.addCleanup(self.roles_client.delete_role, role['id']) self.assertIn('name', role) self.assertEqual(role['name'], r_name) - new_name = data_utils.rand_name('NewRole') + new_name = data_utils.rand_name( + name='NewRole', prefix=CONF.resource_name_prefix) updated_role = self.roles_client.update_role(role['id'], name=new_name)['role'] self.assertIn('name', updated_role) @@ -371,7 +376,8 @@ class RolesV3TestJSON(base.BaseIdentityV3AdminTest): def test_domain_roles_create_delete(self): """Test creating, listing and deleting domain roles""" domain_role = self.roles_client.create_role( - name=data_utils.rand_name('domain_role'), + name=data_utils.rand_name( + name='domain_role', prefix=CONF.resource_name_prefix), domain_id=self.domain['id'])['role'] self.addCleanup( test_utils.call_and_ignore_notfound_exc, diff --git a/tempest/api/identity/admin/v3/test_services.py b/tempest/api/identity/admin/v3/test_services.py index fb3b03ece1..b67e175256 100644 --- a/tempest/api/identity/admin/v3/test_services.py +++ b/tempest/api/identity/admin/v3/test_services.py @@ -14,10 +14,13 @@ # under the License. from tempest.api.identity import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators from tempest.lib import exceptions as lib_exc +CONF = config.CONF + class ServicesTestJSON(base.BaseIdentityV3AdminTest): """Test keystone services""" @@ -33,10 +36,11 @@ class ServicesTestJSON(base.BaseIdentityV3AdminTest): @decorators.idempotent_id('5193aad5-bcb7-411d-85b0-b3b61b96ef06') def test_create_update_get_service(self): """Test creating, updating and getting of keystone service""" + prefix = CONF.resource_name_prefix # Creating a Service - name = data_utils.rand_name('service') - serv_type = data_utils.rand_name('type') - desc = data_utils.rand_name('description') + name = data_utils.rand_name(name='service', prefix=prefix) + serv_type = data_utils.rand_name(name='type', prefix=prefix) + desc = data_utils.rand_name(name='description', prefix=prefix) create_service = self.services_client.create_service( type=serv_type, name=name, description=desc)['service'] self.addCleanup(self._del_service, create_service['id']) @@ -49,7 +53,7 @@ class ServicesTestJSON(base.BaseIdentityV3AdminTest): # Update description s_id = create_service['id'] resp1_desc = create_service['description'] - s_desc2 = data_utils.rand_name('desc2') + s_desc2 = data_utils.rand_name(name='desc2', prefix=prefix) update_service = self.services_client.update_service( s_id, description=s_desc2)['service'] resp2_desc = update_service['description'] @@ -66,8 +70,10 @@ class ServicesTestJSON(base.BaseIdentityV3AdminTest): @decorators.idempotent_id('d1dcb1a1-2b6b-4da8-bbb8-5532ef6e8269') def test_create_service_without_description(self): """Create a keystone service only with name and type""" - name = data_utils.rand_name('service') - serv_type = data_utils.rand_name('type') + name = data_utils.rand_name( + name='service', prefix=CONF.resource_name_prefix) + serv_type = data_utils.rand_name( + name='type', prefix=CONF.resource_name_prefix) service = self.services_client.create_service( type=serv_type, name=name)['service'] self.addCleanup(self.services_client.delete_service, service['id']) @@ -80,8 +86,12 @@ class ServicesTestJSON(base.BaseIdentityV3AdminTest): service_ids = list() service_types = list() for _ in range(3): - name = data_utils.rand_name(self.__class__.__name__ + '-Service') - serv_type = data_utils.rand_name(self.__class__.__name__ + '-Type') + name = data_utils.rand_name( + self.__class__.__name__ + '-Service', + prefix=CONF.resource_name_prefix) + serv_type = data_utils.rand_name( + self.__class__.__name__ + '-Type', + prefix=CONF.resource_name_prefix) create_service = self.services_client.create_service( type=serv_type, name=name)['service'] self.addCleanup(self.services_client.delete_service, diff --git a/tempest/api/identity/admin/v3/test_tokens.py b/tempest/api/identity/admin/v3/test_tokens.py index e191979240..d0a8748fd2 100644 --- a/tempest/api/identity/admin/v3/test_tokens.py +++ b/tempest/api/identity/admin/v3/test_tokens.py @@ -42,11 +42,13 @@ class TokensV3TestJSON(base.BaseIdentityV3AdminTest): domain_id=CONF.identity.default_domain_id) # Create a couple projects - project1_name = data_utils.rand_name(name=self.__class__.__name__) + project1_name = data_utils.rand_name( + name=self.__class__.__name__, prefix=CONF.resource_name_prefix) project1 = self.setup_test_project( name=project1_name, domain_id=CONF.identity.default_domain_id) - project2_name = data_utils.rand_name(name=self.__class__.__name__) + project2_name = data_utils.rand_name( + name=self.__class__.__name__, prefix=CONF.resource_name_prefix) project2 = self.setup_test_project( name=project2_name, domain_id=CONF.identity.default_domain_id) self.addCleanup(self.projects_client.delete_project, project2['id']) diff --git a/tempest/api/identity/admin/v3/test_trusts.py b/tempest/api/identity/admin/v3/test_trusts.py index 580e30412f..5bd6756713 100644 --- a/tempest/api/identity/admin/v3/test_trusts.py +++ b/tempest/api/identity/admin/v3/test_trusts.py @@ -53,9 +53,10 @@ class TrustsV3TestJSON(base.BaseIdentityV3AdminTest): super(TrustsV3TestJSON, self).tearDown() def create_trustor_and_roles(self): + prefix = CONF.resource_name_prefix # create a project that trusts will be granted on trustor_project_name = data_utils.rand_name( - name=self.__class__.__name__) + name=self.__class__.__name__, prefix=prefix) project = self.projects_client.create_project( trustor_project_name, domain_id=CONF.identity.default_domain_id)['project'] @@ -64,7 +65,7 @@ class TrustsV3TestJSON(base.BaseIdentityV3AdminTest): self.assertIsNotNone(self.trustor_project_id) # Create a trustor User - trustor_username = data_utils.rand_name('user') + trustor_username = data_utils.rand_name(name='user', prefix=prefix) u_desc = trustor_username + 'description' u_email = trustor_username + '@testmail.xx' trustor_password = data_utils.rand_password() @@ -79,8 +80,10 @@ class TrustsV3TestJSON(base.BaseIdentityV3AdminTest): self.trustor_user_id = user['id'] # And two roles, one we'll delegate and one we won't - self.delegated_role = data_utils.rand_name('DelegatedRole') - self.not_delegated_role = data_utils.rand_name('NotDelegatedRole') + self.delegated_role = data_utils.rand_name( + name='DelegatedRole', prefix=prefix) + self.not_delegated_role = data_utils.rand_name( + name='NotDelegatedRole', prefix=prefix) role = self.roles_client.create_role(name=self.delegated_role)['role'] self.addCleanup(self.roles_client.delete_role, role['id']) diff --git a/tempest/api/identity/admin/v3/test_users.py b/tempest/api/identity/admin/v3/test_users.py index 31cbbac9ef..9bcbba5858 100644 --- a/tempest/api/identity/admin/v3/test_users.py +++ b/tempest/api/identity/admin/v3/test_users.py @@ -40,8 +40,9 @@ class UsersV3TestJSON(base.BaseIdentityV3AdminTest): @decorators.idempotent_id('b537d090-afb9-4519-b95d-270b0708e87e') def test_user_update(self): """Test case to check if updating of user attributes is successful""" + prefix = CONF.resource_name_prefix # Creating first user - u_name = data_utils.rand_name('user') + u_name = data_utils.rand_name(name='user', prefix=prefix) u_desc = u_name + 'description' u_email = u_name + '@testmail.tm' u_password = data_utils.rand_password() @@ -55,7 +56,7 @@ class UsersV3TestJSON(base.BaseIdentityV3AdminTest): project = self.setup_test_project() # Updating user details with new values - update_kwargs = {'name': data_utils.rand_name('user2'), + update_kwargs = {'name': data_utils.rand_name('user2', prefix=prefix), 'description': data_utils.rand_name('desc2'), 'project_id': project['id'], 'email': 'user2@testmail.tm', @@ -75,7 +76,8 @@ class UsersV3TestJSON(base.BaseIdentityV3AdminTest): def test_update_user_password(self): """Test updating user password""" # Creating User to check password updation - u_name = data_utils.rand_name('user') + u_name = data_utils.rand_name( + name='user', prefix=CONF.resource_name_prefix) original_password = data_utils.rand_password() user = self.users_client.create_user( name=u_name, password=original_password)['user'] @@ -105,7 +107,8 @@ class UsersV3TestJSON(base.BaseIdentityV3AdminTest): fetched_project_ids = list() u_project = self.setup_test_project() # Create a user. - u_name = data_utils.rand_name('user') + u_name = data_utils.rand_name( + name='user', prefix=CONF.resource_name_prefix) u_desc = u_name + 'description' u_email = u_name + '@testmail.tm' u_password = data_utils.rand_password() diff --git a/tempest/api/identity/admin/v3/test_users_negative.py b/tempest/api/identity/admin/v3/test_users_negative.py index 1cba945b12..f55d2d49d7 100644 --- a/tempest/api/identity/admin/v3/test_users_negative.py +++ b/tempest/api/identity/admin/v3/test_users_negative.py @@ -29,7 +29,8 @@ class UsersNegativeTest(base.BaseIdentityV3AdminTest): @decorators.idempotent_id('e75f006c-89cc-477b-874d-588e4eab4b17') def test_create_user_for_non_existent_domain(self): """Attempt to create a user in a non-existent domain should fail""" - u_name = data_utils.rand_name('user') + u_name = data_utils.rand_name( + name='user', prefix=CONF.resource_name_prefix) u_email = u_name + '@testmail.tm' u_password = data_utils.rand_password() self.assertRaises(lib_exc.NotFound, self.users_client.create_user, diff --git a/tempest/api/identity/base.py b/tempest/api/identity/base.py index 5722f0e73e..c9e0e1c842 100644 --- a/tempest/api/identity/base.py +++ b/tempest/api/identity/base.py @@ -71,7 +71,8 @@ class BaseIdentityTest(tempest.test.BaseTestCase): if kwargs.get('password', None) is None: kwargs['password'] = data_utils.rand_password() if 'name' not in kwargs: - kwargs['name'] = data_utils.rand_name('test_user') + kwargs['name'] = data_utils.rand_name( + name='test_user', prefix=CONF.resource_name_prefix) if 'email' not in kwargs: kwargs['email'] = kwargs['name'] + '@testmail.tm' @@ -84,7 +85,8 @@ class BaseIdentityTest(tempest.test.BaseTestCase): def setup_test_role(self, name=None, domain_id=None): """Set up a test role.""" - params = {'name': name or data_utils.rand_name('test_role')} + params = {'name': name or data_utils.rand_name( + name='test_role', prefix=CONF.resource_name_prefix)} if domain_id: params['domain_id'] = domain_id @@ -161,9 +163,12 @@ class BaseIdentityV2AdminTest(BaseIdentityV2Test): def setup_test_tenant(self, **kwargs): """Set up a test tenant.""" if 'name' not in kwargs: - kwargs['name'] = data_utils.rand_name('test_tenant') + kwargs['name'] = data_utils.rand_name( + name='test_tenant', + prefix=CONF.resource_name_prefix) if 'description' not in kwargs: - kwargs['description'] = data_utils.rand_name('desc') + kwargs['description'] = data_utils.rand_name( + name='desc', prefix=CONF.resource_name_prefix) tenant = self.projects_client.create_tenant(**kwargs)['tenant'] # Delete the tenant at the end of the test self.addCleanup( @@ -249,9 +254,11 @@ class BaseIdentityV3AdminTest(BaseIdentityV3Test): def create_domain(cls, **kwargs): """Create a domain.""" if 'name' not in kwargs: - kwargs['name'] = data_utils.rand_name('test_domain') + kwargs['name'] = data_utils.rand_name( + name='test_domain', prefix=CONF.resource_name_prefix) if 'description' not in kwargs: - kwargs['description'] = data_utils.rand_name('desc') + kwargs['description'] = data_utils.rand_name( + name='desc', prefix=CONF.resource_name_prefix) domain = cls.domains_client.create_domain(**kwargs)['domain'] cls.addClassResourceCleanup(test_utils.call_and_ignore_notfound_exc, cls.delete_domain, domain['id']) @@ -274,9 +281,11 @@ class BaseIdentityV3AdminTest(BaseIdentityV3Test): def setup_test_project(self, **kwargs): """Set up a test project.""" if 'name' not in kwargs: - kwargs['name'] = data_utils.rand_name('test_project') + kwargs['name'] = data_utils.rand_name( + name='test_project', prefix=CONF.resource_name_prefix) if 'description' not in kwargs: - kwargs['description'] = data_utils.rand_name('test_description') + kwargs['description'] = data_utils.rand_name( + name='test_description', prefix=CONF.resource_name_prefix) project = self.projects_client.create_project(**kwargs)['project'] # Delete the project at the end of the test self.addCleanup( @@ -297,10 +306,12 @@ class BaseIdentityV3AdminTest(BaseIdentityV3Test): """Set up a test group.""" if 'name' not in kwargs: kwargs['name'] = data_utils.rand_name( - self.__class__.__name__ + '_test_project') + self.__class__.__name__ + '_test_project', + prefix=CONF.resource_name_prefix) if 'description' not in kwargs: kwargs['description'] = data_utils.rand_name( - self.__class__.__name__ + '_test_description') + self.__class__.__name__ + '_test_description', + prefix=CONF.resource_name_prefix) group = self.groups_client.create_group(**kwargs)['group'] self.addCleanup( test_utils.call_and_ignore_notfound_exc, @@ -324,7 +335,8 @@ class BaseApplicationCredentialsV3Test(BaseIdentityV3Test): cls.project_id = cls.os_primary.credentials.project_id def create_application_credential(self, name=None, **kwargs): - name = name or data_utils.rand_name('application_credential') + name = name or data_utils.rand_name( + name='application_credential', prefix=CONF.resource_name_prefix) application_credential = ( self.non_admin_app_creds_client.create_application_credential( self.user_id, name=name, **kwargs))['application_credential'] diff --git a/tempest/api/identity/v3/test_access_rules.py b/tempest/api/identity/v3/test_access_rules.py index 64a69593dc..f816a09d88 100644 --- a/tempest/api/identity/v3/test_access_rules.py +++ b/tempest/api/identity/v3/test_access_rules.py @@ -48,7 +48,9 @@ class AccessRulesV3Test(base.BaseIdentityV3Test): cls.ac = cls.non_admin_app_creds_client cls.app_cred = cls.ac.create_application_credential( cls.user_id, - name=data_utils.rand_name('application_credential'), + name=data_utils.rand_name( + name='application_credential', + prefix=CONF.resource_name_prefix), access_rules=access_rules )['application_credential'] cls.addClassResourceCleanup( @@ -77,7 +79,9 @@ class AccessRulesV3Test(base.BaseIdentityV3Test): ] app_cred = self.ac.create_application_credential( self.user_id, - name=data_utils.rand_name('application_credential'), + name=data_utils.rand_name( + name='application_credential', + prefix=CONF.resource_name_prefix), access_rules=access_rules )['application_credential'] self.addCleanup( diff --git a/tempest/api/image/base.py b/tempest/api/image/base.py index 7bae712b49..0544c319bb 100644 --- a/tempest/api/image/base.py +++ b/tempest/api/image/base.py @@ -51,7 +51,9 @@ class BaseImageTest(tempest.test.BaseTestCase): """Wrapper that returns a test image.""" if 'name' not in kwargs: - name = data_utils.rand_name(cls.__name__ + "-image") + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=cls.__name__ + "-image") kwargs['name'] = name image = cls.client.create_image(**kwargs) @@ -83,7 +85,8 @@ class BaseV2ImageTest(BaseImageTest): description='Tempest', protected=False, **kwargs): if not namespace_name: - namespace_name = data_utils.rand_name('test-ns') + namespace_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='test-ns') kwargs.setdefault('display_name', namespace_name) namespace = self.namespaces_client.create_namespace( namespace=namespace_name, visibility=visibility, @@ -200,7 +203,9 @@ class BaseV2MemberImageTest(BaseV2ImageTest): return image_ids def _create_image(self): - name = data_utils.rand_name(self.__class__.__name__ + '-image') + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-image') image = self.client.create_image(name=name, container_format='bare', disk_format='raw') diff --git a/tempest/api/image/v2/admin/test_image_caching.py b/tempest/api/image/v2/admin/test_image_caching.py index 11dcc80eec..75369c9e90 100644 --- a/tempest/api/image/v2/admin/test_image_caching.py +++ b/tempest/api/image/v2/admin/test_image_caching.py @@ -57,7 +57,9 @@ class ImageCachingTest(base.BaseV2ImageTest): def image_create_and_upload(self, upload=True, **kwargs): """Wrapper that returns a test image.""" if 'name' not in kwargs: - name = data_utils.rand_name(self.__name__ + "-image") + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__name__ + "-image") kwargs['name'] = name params = dict(kwargs) diff --git a/tempest/api/image/v2/admin/test_image_task.py b/tempest/api/image/v2/admin/test_image_task.py index 9439e91f21..6437a3c6c3 100644 --- a/tempest/api/image/v2/admin/test_image_task.py +++ b/tempest/api/image/v2/admin/test_image_task.py @@ -61,7 +61,8 @@ class ImageTaskCreate(base.BaseV2ImageAdminTest): i = 0 tasks = list() while i < len(disk_format): - image_name = data_utils.rand_name("task_image") + image_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name="task_image") image_property = {"container_format": "bare", "disk_format": disk_format[0], "visibility": "public", @@ -126,8 +127,12 @@ class ImageTaskCreate(base.BaseV2ImageAdminTest): @decorators.idempotent_id("ad6450c6-7060-4ee7-a2d1-41c2604b446c") @decorators.attr(type=['negative']) def test_task_create_fake_image_location(self): + kwargs = { + 'prefix': CONF.resource_name_prefix, + 'name': 'dummy-img-file' + } http_fake_url = ''.join( - ["http://", data_utils.rand_name('dummy-img-file'), ".qcow2"]) + ["http://", data_utils.rand_name(**kwargs), ".qcow2"]) task = self._prepare_image_tasks_param( image_from_format=['qcow2'], disk_format=['qcow2'], diff --git a/tempest/api/image/v2/admin/test_images.py b/tempest/api/image/v2/admin/test_images.py index ce50c5d5bc..27cdcd890d 100644 --- a/tempest/api/image/v2/admin/test_images.py +++ b/tempest/api/image/v2/admin/test_images.py @@ -63,7 +63,9 @@ class BasicOperationsImagesAdminTest(base.BaseV2ImageAdminTest): @decorators.idempotent_id('f6ab4aa0-035e-4664-9f2d-c57c6df50605') def test_list_public_image(self): """Test create image as admin and list public image as none admin""" - name = data_utils.rand_name(self.__class__.__name__ + '-Image') + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-Image') image = self.admin_client.create_image( name=name, container_format='bare', @@ -107,7 +109,8 @@ class ImportCopyImagesTest(base.BaseV2ImageAdminTest): raise self.skipException('Either copy-image import method or ' 'multistore is not available') uuid = data_utils.rand_uuid() - image_name = data_utils.rand_name('copy-image') + image_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='copy-image') container_format = CONF.image.container_formats[0] disk_format = CONF.image.disk_formats[0] image = self.create_image(name=image_name, diff --git a/tempest/api/image/v2/admin/test_images_metadefs_namespace_objects.py b/tempest/api/image/v2/admin/test_images_metadefs_namespace_objects.py index 9222920df7..f244ebc3d2 100644 --- a/tempest/api/image/v2/admin/test_images_metadefs_namespace_objects.py +++ b/tempest/api/image/v2/admin/test_images_metadefs_namespace_objects.py @@ -11,16 +11,21 @@ # under the License. from tempest.api.image import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib.common.utils import test_utils from tempest.lib import decorators +CONF = config.CONF + class MetadataNamespaceObjectsTest(base.BaseV2ImageAdminTest): """Test the Metadata definition namespace objects basic functionality""" def _create_namespace_object(self, namespace): - object_name = data_utils.rand_name(self.__class__.__name__ + '-object') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-object') namespace_object = self.namespace_objects_client.\ create_namespace_object(namespace['namespace'], name=object_name) self.addCleanup(test_utils.call_and_ignore_notfound_exc, @@ -36,7 +41,8 @@ class MetadataNamespaceObjectsTest(base.BaseV2ImageAdminTest): # Create a namespace object body = self._create_namespace_object(namespace) # Update a namespace object - up_object_name = data_utils.rand_name('update-object') + up_object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='update-object') body = self.namespace_objects_client.update_namespace_object( namespace['namespace'], body['name'], name=up_object_name) diff --git a/tempest/api/image/v2/admin/test_images_metadefs_namespace_properties.py b/tempest/api/image/v2/admin/test_images_metadefs_namespace_properties.py index 10dfba1ed5..5e0d28d44a 100644 --- a/tempest/api/image/v2/admin/test_images_metadefs_namespace_properties.py +++ b/tempest/api/image/v2/admin/test_images_metadefs_namespace_properties.py @@ -11,9 +11,12 @@ # under the License. from tempest.api.image import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators +CONF = config.CONF + class MetadataNamespacePropertiesTest(base.BaseV2ImageAdminTest): """Test the Metadata definition namespace property basic functionality""" @@ -31,7 +34,8 @@ class MetadataNamespacePropertiesTest(base.BaseV2ImageAdminTest): body = self.resource_types_client.create_resource_type_association( namespace['namespace'], name=resource_name) # Create a property - property_title = data_utils.rand_name('property') + property_title = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='property') body = self.namespace_properties_client.create_namespace_property( namespace=namespace['namespace'], title=property_title, name=resource_name, type="string", enum=enum) @@ -41,7 +45,9 @@ class MetadataNamespacePropertiesTest(base.BaseV2ImageAdminTest): namespace['namespace'], resource_name) self.assertEqual(resource_name, body['name']) # Update namespace property - update_property_title = data_utils.rand_name('update-property') + update_property_title = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name='update-property') body = self.namespace_properties_client.update_namespace_properties( namespace['namespace'], resource_name, title=update_property_title, type="string", diff --git a/tempest/api/image/v2/admin/test_images_metadefs_namespace_tags.py b/tempest/api/image/v2/admin/test_images_metadefs_namespace_tags.py index 9e88e032e0..361bb6076e 100644 --- a/tempest/api/image/v2/admin/test_images_metadefs_namespace_tags.py +++ b/tempest/api/image/v2/admin/test_images_metadefs_namespace_tags.py @@ -11,10 +11,13 @@ # under the License. from tempest.api.image import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib.common.utils import test_utils from tempest.lib import decorators +CONF = config.CONF + class MetadataNamespaceTagsTest(base.BaseV2ImageAdminTest): """Test the Metadata definition namespace tags basic functionality""" @@ -68,7 +71,8 @@ class MetadataNamespaceTagsTest(base.BaseV2ImageAdminTest): namespace = self.create_namespace() self._create_namespace_tags(namespace) # Create a tag - tag_name = data_utils.rand_name('tag_name') + tag_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='tag_name') self.namespace_tags_client.create_namespace_tag( namespace=namespace['namespace'], tag_name=tag_name) @@ -76,7 +80,8 @@ class MetadataNamespaceTagsTest(base.BaseV2ImageAdminTest): namespace['namespace'], tag_name) self.assertEqual(tag_name, body['name']) # Update tag definition - update_tag_definition = data_utils.rand_name('update-tag') + update_tag_definition = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='update-tag') body = self.namespace_tags_client.update_namespace_tag( namespace['namespace'], tag_name=tag_name, name=update_tag_definition) diff --git a/tempest/api/image/v2/admin/test_images_metadefs_namespaces.py b/tempest/api/image/v2/admin/test_images_metadefs_namespaces.py index c411aa973a..be6d01a080 100644 --- a/tempest/api/image/v2/admin/test_images_metadefs_namespaces.py +++ b/tempest/api/image/v2/admin/test_images_metadefs_namespaces.py @@ -14,11 +14,14 @@ # under the License. from tempest.api.image import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib.common.utils import test_utils from tempest.lib import decorators from tempest.lib import exceptions as lib_exc +CONF = config.CONF + class MetadataNamespacesTest(base.BaseV2ImageAdminTest): """Test the Metadata definition Namespaces basic functionality""" @@ -30,7 +33,8 @@ class MetadataNamespacesTest(base.BaseV2ImageAdminTest): body = self.resource_types_client.list_resource_types() resource_name = body['resource_types'][0]['name'] name = [{'name': resource_name}] - namespace_name = data_utils.rand_name('namespace') + namespace_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='namespace') # create the metadef namespace body = self.namespaces_client.create_namespace( namespace=namespace_name, diff --git a/tempest/api/image/v2/test_images.py b/tempest/api/image/v2/test_images.py index 977ad82d95..be7424f158 100644 --- a/tempest/api/image/v2/test_images.py +++ b/tempest/api/image/v2/test_images.py @@ -53,7 +53,8 @@ class ImportImagesTest(base.BaseV2ImageTest): def _create_image(self, disk_format=None, container_format=None): # Create image uuid = '00000000-1111-2222-3333-444455556666' - image_name = data_utils.rand_name('image') + image_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='image') container_format = container_format or CONF.image.container_formats[0] disk_format = disk_format or CONF.image.disk_formats[0] image = self.create_image(name=image_name, @@ -345,7 +346,8 @@ class MultiStoresImportImagesTest(base.BaseV2ImageTest): def _create_and_stage_image(self, all_stores=False): """Create Image & stage image file for glance-direct import method.""" - image_name = data_utils.rand_name('test-image') + image_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='test-image') container_format = CONF.image.container_formats[0] disk_format = CONF.image.disk_formats[0] image = self.create_image(name=image_name, @@ -416,7 +418,8 @@ class BasicOperationsImagesTest(base.BaseV2ImageTest): """ uuid = '00000000-1111-2222-3333-444455556666' - image_name = data_utils.rand_name('image') + image_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='image') container_format = CONF.image.container_formats[0] disk_format = CONF.image.disk_formats[0] image = self.create_image(name=image_name, @@ -464,7 +467,8 @@ class BasicOperationsImagesTest(base.BaseV2ImageTest): def test_delete_image(self): """Test deleting an image by image_id""" # Create image - image_name = data_utils.rand_name('image') + image_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='image') container_format = CONF.image.container_formats[0] disk_format = CONF.image.disk_formats[0] image = self.create_image(name=image_name, @@ -485,7 +489,8 @@ class BasicOperationsImagesTest(base.BaseV2ImageTest): def test_update_image(self): """Test updating an image by image_id""" # Create image - image_name = data_utils.rand_name('image') + image_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='image') container_format = CONF.image.container_formats[0] disk_format = CONF.image.disk_formats[0] image = self.create_image(name=image_name, @@ -495,7 +500,8 @@ class BasicOperationsImagesTest(base.BaseV2ImageTest): self.assertEqual('queued', image['status']) # Update Image - new_image_name = data_utils.rand_name('new-image') + new_image_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='new-image') self.client.update_image(image['id'], [ dict(replace='/name', value=new_image_name)]) @@ -509,7 +515,8 @@ class BasicOperationsImagesTest(base.BaseV2ImageTest): def test_deactivate_reactivate_image(self): """Test deactivating and reactivating an image""" # Create image - image_name = data_utils.rand_name('image') + image_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='image') image = self.create_image(name=image_name, container_format='bare', disk_format='raw', @@ -568,7 +575,9 @@ class ListUserImagesTest(base.BaseV2ImageTest): """ size = random.randint(1024, 4096) image_file = io.BytesIO(data_utils.random_bytes(size)) - tags = [data_utils.rand_name('tag'), data_utils.rand_name('tag')] + prefix = CONF.resource_name_prefix + tags = [data_utils.rand_name(prefix=prefix, name='tag'), + data_utils.rand_name(prefix=prefix, name='tag')] image = cls.create_image(container_format=container_format, disk_format=disk_format, visibility='private', diff --git a/tempest/api/image/v2/test_images_tags.py b/tempest/api/image/v2/test_images_tags.py index 163063c75f..12e6c8e474 100644 --- a/tempest/api/image/v2/test_images_tags.py +++ b/tempest/api/image/v2/test_images_tags.py @@ -13,9 +13,12 @@ # under the License. from tempest.api.image import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators +CONF = config.CONF + class ImagesTagsTest(base.BaseV2ImageTest): """Test image tags""" @@ -26,7 +29,8 @@ class ImagesTagsTest(base.BaseV2ImageTest): image = self.create_image(container_format='bare', disk_format='raw', visibility='private') - tag = data_utils.rand_name('tag') + tag = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='tag') self.addCleanup(self.client.delete_image, image['id']) # Creating image tag and verify it. diff --git a/tempest/api/image/v2/test_images_tags_negative.py b/tempest/api/image/v2/test_images_tags_negative.py index 2db4a74ecf..9d74aa45ef 100644 --- a/tempest/api/image/v2/test_images_tags_negative.py +++ b/tempest/api/image/v2/test_images_tags_negative.py @@ -13,10 +13,13 @@ # under the License. from tempest.api.image import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators from tempest.lib import exceptions as lib_exc +CONF = config.CONF + class ImagesTagsNegativeTest(base.BaseV2ImageTest): """Negative tests of image tags""" @@ -25,7 +28,8 @@ class ImagesTagsNegativeTest(base.BaseV2ImageTest): @decorators.idempotent_id('8cd30f82-6f9a-4c6e-8034-c1b51fba43d9') def test_update_tags_for_non_existing_image(self): """Update image tag with non existing image""" - tag = data_utils.rand_name('tag') + tag = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='tag') non_exist_image = data_utils.rand_uuid() self.assertRaises(lib_exc.NotFound, self.client.add_image_tag, non_exist_image, tag) @@ -38,7 +42,8 @@ class ImagesTagsNegativeTest(base.BaseV2ImageTest): disk_format='raw', visibility='private' ) - tag = data_utils.rand_name('non-exist-tag') + tag = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='non-exist-tag') self.addCleanup(self.client.delete_image, image['id']) self.assertRaises(lib_exc.NotFound, self.client.delete_image_tag, image['id'], tag) diff --git a/tempest/api/network/admin/test_external_network_extension.py b/tempest/api/network/admin/test_external_network_extension.py index 0cec316287..8d71a27a49 100644 --- a/tempest/api/network/admin/test_external_network_extension.py +++ b/tempest/api/network/admin/test_external_network_extension.py @@ -31,7 +31,8 @@ class ExternalNetworksTestJSON(base.BaseAdminNetworkTest): cls.network = cls.create_network() def _create_network(self, external=True): - post_body = {'name': data_utils.rand_name('network-')} + post_body = {'name': data_utils.rand_name( + name='network-', prefix=CONF.resource_name_prefix)} if external: post_body['router:external'] = external body = self.admin_networks_client.create_network(**post_body) diff --git a/tempest/api/network/admin/test_external_networks_negative.py b/tempest/api/network/admin/test_external_networks_negative.py index 92731f65f8..ef10ee03ba 100644 --- a/tempest/api/network/admin/test_external_networks_negative.py +++ b/tempest/api/network/admin/test_external_networks_negative.py @@ -54,6 +54,8 @@ class ExternalNetworksAdminNegativeTestJSON(base.BaseAdminNetworkTest): # create a port which will internally create an instance-ip self.assertRaises(lib_exc.Conflict, self.admin_ports_client.create_port, - name=data_utils.rand_name(self.__class__.__name__), + name=data_utils.rand_name( + self.__class__.__name__, + prefix=CONF.resource_name_prefix), network_id=CONF.network.public_network_id, fixed_ips=fixed_ips) diff --git a/tempest/api/network/admin/test_metering_extensions.py b/tempest/api/network/admin/test_metering_extensions.py index a60cd4858d..919aaf2808 100644 --- a/tempest/api/network/admin/test_metering_extensions.py +++ b/tempest/api/network/admin/test_metering_extensions.py @@ -14,10 +14,13 @@ from tempest.api.network import base from tempest.common import utils +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib.common.utils import test_utils from tempest.lib import decorators +CONF = config.CONF + class MeteringTestJSON(base.BaseAdminNetworkTest): """Tests the following operations in the Neutron API: @@ -37,7 +40,8 @@ class MeteringTestJSON(base.BaseAdminNetworkTest): def resource_setup(cls): super(MeteringTestJSON, cls).resource_setup() description = "metering label created by tempest" - name = data_utils.rand_name("metering-label") + name = data_utils.rand_name( + name="metering-label", prefix=CONF.resource_name_prefix) cls.metering_label = cls.create_metering_label(name, description) remote_ip_prefix = ("10.0.0.0/24" if cls._ip_version == 4 else "fd02::/64") @@ -101,7 +105,8 @@ class MeteringTestJSON(base.BaseAdminNetworkTest): def test_create_delete_metering_label_with_filters(self): """Verifies creating and deleting metering label with filters""" # Creates a label - name = data_utils.rand_name('metering-label-') + name = data_utils.rand_name( + name='metering-label-', prefix=CONF.resource_name_prefix) description = "label created by tempest" body = self.admin_metering_labels_client.create_metering_label( name=name, description=description) diff --git a/tempest/api/network/admin/test_ports.py b/tempest/api/network/admin/test_ports.py index 5f9f29f0db..3158749521 100644 --- a/tempest/api/network/admin/test_ports.py +++ b/tempest/api/network/admin/test_ports.py @@ -45,7 +45,9 @@ class PortsAdminExtendedAttrsTestJSON(base.BaseAdminNetworkTest): """Test creating port with extended attribute""" post_body = {"network_id": self.network['id'], "binding:host_id": self.host_id, - "name": data_utils.rand_name(self.__class__.__name__)} + "name": data_utils.rand_name( + self.__class__.__name__, + prefix=CONF.resource_name_prefix)} body = self.admin_ports_client.create_port(**post_body) port = body['port'] self.addCleanup(self.admin_ports_client.wait_for_resource_deletion, @@ -62,7 +64,9 @@ class PortsAdminExtendedAttrsTestJSON(base.BaseAdminNetworkTest): def test_update_port_binding_ext_attr(self): """Test updating port's extended attribute""" post_body = {"network_id": self.network['id'], - "name": data_utils.rand_name(self.__class__.__name__)} + "name": data_utils.rand_name( + self.__class__.__name__, + prefix=CONF.resource_name_prefix)} body = self.admin_ports_client.create_port(**post_body) port = body['port'] self.addCleanup(self.admin_ports_client.wait_for_resource_deletion, @@ -83,7 +87,9 @@ class PortsAdminExtendedAttrsTestJSON(base.BaseAdminNetworkTest): """Test updating and listing port's extended attribute""" # Create a new port post_body = {"network_id": self.network['id'], - "name": data_utils.rand_name(self.__class__.__name__)} + "name": data_utils.rand_name( + self.__class__.__name__, + prefix=CONF.resource_name_prefix)} body = self.admin_ports_client.create_port(**post_body) port = body['port'] self.addCleanup(self.admin_ports_client.wait_for_resource_deletion, @@ -113,7 +119,8 @@ class PortsAdminExtendedAttrsTestJSON(base.BaseAdminNetworkTest): def test_show_port_binding_ext_attr(self): """Test showing port's extended attribute""" body = self.admin_ports_client.create_port( - name=data_utils.rand_name(self.__class__.__name__), + name=data_utils.rand_name( + self.__class__.__name__, prefix=CONF.resource_name_prefix), network_id=self.network['id']) port = body['port'] self.addCleanup(self.admin_ports_client.wait_for_resource_deletion, diff --git a/tempest/api/network/admin/test_routers.py b/tempest/api/network/admin/test_routers.py index 90e0917f52..216b15dfe5 100644 --- a/tempest/api/network/admin/test_routers.py +++ b/tempest/api/network/admin/test_routers.py @@ -54,16 +54,17 @@ class RoutersAdminTest(base.BaseAdminNetworkTest): @decorators.idempotent_id('e54dd3a3-4352-4921-b09d-44369ae17397') def test_create_router_setting_project_id(self): + prefix = CONF.resource_name_prefix """Test creating router from admin user setting project_id.""" - project = data_utils.rand_name('test_tenant_') - description = data_utils.rand_name('desc_') + project = data_utils.rand_name(name='test_tenant_', prefix=prefix) + description = data_utils.rand_name(name='desc_', prefix=prefix) project = identity.identity_utils(self.os_admin).create_project( name=project, description=description) project_id = project['id'] self.addCleanup(identity.identity_utils(self.os_admin).delete_project, project_id) - name = data_utils.rand_name('router-') + name = data_utils.rand_name(name='router-', prefix=prefix) create_body = self.admin_routers_client.create_router( name=name, project_id=project_id) self.addCleanup(test_utils.call_and_ignore_notfound_exc, @@ -89,7 +90,8 @@ class RoutersAdminTest(base.BaseAdminNetworkTest): 'The public_network_id option must be specified.') def test_create_router_with_snat_explicit(self): """Test creating router with specified enable_snat value""" - name = data_utils.rand_name('snat-router') + name = data_utils.rand_name( + 'snat-router', prefix=CONF.resource_name_prefix) # Create a router enabling snat attributes enable_snat_states = [False, True] for enable_snat in enable_snat_states: @@ -226,7 +228,8 @@ class RoutersAdminTest(base.BaseAdminNetworkTest): """Test creating router setting gateway with fixed ip""" # At first create an external network and then use that # to create address and delete - network_name = data_utils.rand_name(self.__class__.__name__) + network_name = data_utils.rand_name( + self.__class__.__name__, prefix=CONF.resource_name_prefix) network_1 = self.admin_networks_client.create_network( name=network_name, **{'router:external': True})['network'] self.addCleanup(test_utils.call_and_ignore_notfound_exc, @@ -237,7 +240,8 @@ class RoutersAdminTest(base.BaseAdminNetworkTest): self.addCleanup(test_utils.call_and_ignore_notfound_exc, self.admin_subnets_client.delete_subnet, subnet['id']) port = self.admin_ports_client.create_port( - name=data_utils.rand_name(self.__class__.__name__), + name=data_utils.rand_name( + self.__class__.__name__, prefix=CONF.resource_name_prefix), network_id=network_1['id'])['port'] self.admin_ports_client.delete_port(port_id=port['id']) fixed_ip = { diff --git a/tempest/api/network/admin/test_routers_dvr.py b/tempest/api/network/admin/test_routers_dvr.py index 291581cd44..f19857db17 100644 --- a/tempest/api/network/admin/test_routers_dvr.py +++ b/tempest/api/network/admin/test_routers_dvr.py @@ -17,10 +17,13 @@ import testtools from tempest.api.network import base from tempest.common import utils +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib.common.utils import test_utils from tempest.lib import decorators +CONF = config.CONF + class RoutersTestDVR(base.BaseAdminNetworkTest): @@ -41,7 +44,8 @@ class RoutersTestDVR(base.BaseAdminNetworkTest): @classmethod def resource_setup(cls): super(RoutersTestDVR, cls).resource_setup() - name = data_utils.rand_name('pretest-check') + name = data_utils.rand_name( + name='pretest-check', prefix=CONF.resource_name_prefix) router = cls.admin_routers_client.create_router(name=name) cls.admin_routers_client.delete_router(router['router']['id']) if 'distributed' not in router['router']: @@ -60,7 +64,8 @@ class RoutersTestDVR(base.BaseAdminNetworkTest): The router is created and the "distributed" attribute is set to True """ - name = data_utils.rand_name('router') + name = data_utils.rand_name( + name='router', prefix=CONF.resource_name_prefix) router = self.admin_routers_client.create_router(name=name, distributed=True) self.addCleanup(test_utils.call_and_ignore_notfound_exc, @@ -81,7 +86,8 @@ class RoutersTestDVR(base.BaseAdminNetworkTest): set to False, thus making it a "Centralized Virtual Router" as opposed to a "Distributed Virtual Router" """ - name = data_utils.rand_name('router') + name = data_utils.rand_name( + name='router', prefix=CONF.resource_name_prefix) router = self.admin_routers_client.create_router(name=name, distributed=False) self.addCleanup(test_utils.call_and_ignore_notfound_exc, @@ -105,7 +111,8 @@ class RoutersTestDVR(base.BaseAdminNetworkTest): set to False. Once the router is updated, the distributed attribute will be set to True """ - name = data_utils.rand_name('router') + name = data_utils.rand_name( + name='router', prefix=CONF.resource_name_prefix) project_id = self.routers_client.project_id # router needs to be in admin state down in order to be upgraded to DVR # l3ha routers are not upgradable to dvr, make it explicitly non ha diff --git a/tempest/api/network/admin/test_routers_negative.py b/tempest/api/network/admin/test_routers_negative.py index 914c0467ce..2a07f168be 100644 --- a/tempest/api/network/admin/test_routers_negative.py +++ b/tempest/api/network/admin/test_routers_negative.py @@ -45,7 +45,8 @@ class RoutersAdminNegativeTest(base.BaseAdminNetworkTest): """Test creating router with gateway set to used ip should fail""" # At first create a address from public_network_id port = self.admin_ports_client.create_port( - name=data_utils.rand_name(self.__class__.__name__), + name=data_utils.rand_name( + self.__class__.__name__, prefix=CONF.resource_name_prefix), network_id=CONF.network.public_network_id)['port'] self.addCleanup(test_utils.call_and_ignore_notfound_exc, self.admin_ports_client.delete_port, diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py index 696d68dd65..99742ccd3d 100644 --- a/tempest/api/network/base.py +++ b/tempest/api/network/base.py @@ -104,7 +104,7 @@ class BaseNetworkTest(tempest.test.BaseTestCase): def create_network(cls, network_name=None, **kwargs): """Wrapper utility that returns a test network.""" network_name = network_name or data_utils.rand_name( - cls.__name__ + '-test-network') + cls.__name__ + '-test-network', prefix=CONF.resource_name_prefix) body = cls.networks_client.create_network(name=network_name, **kwargs) network = body['network'] @@ -161,7 +161,8 @@ class BaseNetworkTest(tempest.test.BaseTestCase): @classmethod def create_port(cls, network, **kwargs): if 'name' not in kwargs: - kwargs['name'] = data_utils.rand_name(cls.__name__) + kwargs['name'] = data_utils.rand_name( + cls.__name__, prefix=CONF.resource_name_prefix) """Wrapper utility that returns a test port.""" body = cls.ports_client.create_port(network_id=network['id'], **kwargs) @@ -182,7 +183,7 @@ class BaseNetworkTest(tempest.test.BaseTestCase): external_network_id=None, enable_snat=None, **kwargs): router_name = router_name or data_utils.rand_name( - cls.__name__ + "-router") + cls.__name__ + "-router", prefix=CONF.resource_name_prefix) ext_gw_info = {} if external_network_id: diff --git a/tempest/api/network/base_security_groups.py b/tempest/api/network/base_security_groups.py index 32f2cdd598..a1bb68d130 100644 --- a/tempest/api/network/base_security_groups.py +++ b/tempest/api/network/base_security_groups.py @@ -14,15 +14,19 @@ # under the License. from tempest.api.network import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib.common.utils import test_utils +CONF = config.CONF + class BaseSecGroupTest(base.BaseNetworkTest): def _create_security_group(self): # Create a security group - name = data_utils.rand_name('secgroup-') + name = data_utils.rand_name( + name='secgroup-', prefix=CONF.resource_name_prefix) group_create_body = ( self.security_groups_client.create_security_group(name=name)) self.addCleanup(test_utils.call_and_ignore_notfound_exc, diff --git a/tempest/api/network/test_allowed_address_pair.py b/tempest/api/network/test_allowed_address_pair.py index bf9eae64c5..5c28e96be3 100644 --- a/tempest/api/network/test_allowed_address_pair.py +++ b/tempest/api/network/test_allowed_address_pair.py @@ -15,10 +15,13 @@ from tempest.api.network import base from tempest.common import utils +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib.common.utils import test_utils from tempest.lib import decorators +CONF = config.CONF + class AllowedAddressPairTestJSON(base.BaseNetworkTest): """Tests the Neutron Allowed Address Pair API extension @@ -60,7 +63,8 @@ class AllowedAddressPairTestJSON(base.BaseNetworkTest): 'mac_address': self.mac_address}] body = self.ports_client.create_port( network_id=self.network['id'], - name=data_utils.rand_name(self.__class__.__name__), + name=data_utils.rand_name( + self.__class__.__name__, prefix=CONF.resource_name_prefix), allowed_address_pairs=allowed_address_pairs) port_id = body['port']['id'] self.addCleanup(self.ports_client.wait_for_resource_deletion, @@ -80,7 +84,8 @@ class AllowedAddressPairTestJSON(base.BaseNetworkTest): # Create a port without allowed address pair body = self.ports_client.create_port( network_id=self.network['id'], - name=data_utils.rand_name(self.__class__.__name__)) + name=data_utils.rand_name( + self.__class__.__name__, prefix=CONF.resource_name_prefix)) port_id = body['port']['id'] self.addCleanup(self.ports_client.wait_for_resource_deletion, port_id) @@ -126,7 +131,8 @@ class AllowedAddressPairTestJSON(base.BaseNetworkTest): """Update allowed address pair port with multiple ip and mac""" resp = self.ports_client.create_port( network_id=self.network['id'], - name=data_utils.rand_name(self.__class__.__name__)) + name=data_utils.rand_name( + self.__class__.__name__, prefix=CONF.resource_name_prefix)) newportid = resp['port']['id'] self.addCleanup(self.ports_client.wait_for_resource_deletion, newportid) diff --git a/tempest/api/network/test_extra_dhcp_options.py b/tempest/api/network/test_extra_dhcp_options.py index bc6418ac88..36578b1031 100644 --- a/tempest/api/network/test_extra_dhcp_options.py +++ b/tempest/api/network/test_extra_dhcp_options.py @@ -15,10 +15,13 @@ from tempest.api.network import base from tempest.common import utils +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib.common.utils import test_utils from tempest.lib import decorators +CONF = config.CONF + class ExtraDHCPOptionsTestJSON(base.BaseNetworkTest): """Tests the following operations with the Extra DHCP Options: @@ -61,7 +64,8 @@ class ExtraDHCPOptionsTestJSON(base.BaseNetworkTest): """Test creating a port with Extra DHCP Options and list those""" body = self.ports_client.create_port( network_id=self.network['id'], - name=data_utils.rand_name(self.__class__.__name__), + name=data_utils.rand_name( + self.__class__.__name__, prefix=CONF.resource_name_prefix), extra_dhcp_opts=self.extra_dhcp_opts) port_id = body['port']['id'] self.addCleanup(test_utils.call_and_ignore_notfound_exc, @@ -77,7 +81,8 @@ class ExtraDHCPOptionsTestJSON(base.BaseNetworkTest): @decorators.idempotent_id('9a6aebf4-86ee-4f47-b07a-7f7232c55607') def test_update_show_port_with_extra_dhcp_options(self): """Test updating port with extra DHCP options and show that port""" - name = data_utils.rand_name('new-port-name') + name = data_utils.rand_name( + name='new-port-name', prefix=CONF.resource_name_prefix) self.ports_client.update_port( self.port['id'], name=name, diff --git a/tempest/api/network/test_floating_ips.py b/tempest/api/network/test_floating_ips.py index 64f6e8035f..e39ad08f92 100644 --- a/tempest/api/network/test_floating_ips.py +++ b/tempest/api/network/test_floating_ips.py @@ -153,7 +153,8 @@ class FloatingIPTestJSON(base.BaseNetworkTest): # Create a port port = self.ports_client.create_port( network_id=self.network['id'], - name=data_utils.rand_name(self.__class__.__name__)) + name=data_utils.rand_name( + self.__class__.__name__, prefix=CONF.resource_name_prefix)) created_port = port['port'] floating_ip = self.floating_ips_client.update_floatingip( created_floating_ip['id'], @@ -183,7 +184,8 @@ class FloatingIPTestJSON(base.BaseNetworkTest): self.floating_ips_client.delete_floatingip, created_floating_ip['id']) self.assertEqual(created_floating_ip['router_id'], self.router['id']) - network_name = data_utils.rand_name(self.__class__.__name__) + network_name = data_utils.rand_name( + self.__class__.__name__, prefix=CONF.resource_name_prefix) network2 = self.networks_client.create_network( name=network_name)['network'] self.addCleanup( @@ -258,7 +260,8 @@ class FloatingIPTestJSON(base.BaseNetworkTest): # Create port body = self.ports_client.create_port( network_id=self.network['id'], - name=data_utils.rand_name(self.__class__.__name__), + name=data_utils.rand_name( + self.__class__.__name__, prefix=CONF.resource_name_prefix), fixed_ips=fixed_ips) port = body['port'] self.addCleanup(test_utils.call_and_ignore_notfound_exc, diff --git a/tempest/api/network/test_networks.py b/tempest/api/network/test_networks.py index caaf964f52..fd937796d7 100644 --- a/tempest/api/network/test_networks.py +++ b/tempest/api/network/test_networks.py @@ -468,8 +468,11 @@ class BulkNetworkOpsTest(base.BaseNetworkTest): def test_bulk_create_delete_network(self): """Verify creating and deleting multiple networks in one request""" # Creates 2 networks in one request - network_list = [{'name': data_utils.rand_name('network-')}, - {'name': data_utils.rand_name('network-')}] + network_list = [ + {'name': data_utils.rand_name( + 'network-', prefix=CONF.resource_name_prefix)}, + {'name': data_utils.rand_name( + 'network-', prefix=CONF.resource_name_prefix)}] body = self.networks_client.create_bulk_networks(networks=network_list) created_networks = body['networks'] self.addCleanup(self._delete_networks, created_networks) @@ -489,7 +492,9 @@ class BulkNetworkOpsTest(base.BaseNetworkTest): cidrs = [subnet_cidr for subnet_cidr in self.cidr.subnet(self.mask_bits)] - names = [data_utils.rand_name('subnet-') for i in range(len(networks))] + names = [data_utils.rand_name( + name='subnet-', prefix=CONF.resource_name_prefix) + for i in range(len(networks))] subnets_list = [] for i in range(len(names)): p1 = { @@ -516,7 +521,9 @@ class BulkNetworkOpsTest(base.BaseNetworkTest): """Verify creating and deleting multiple ports in one request""" networks = [self.create_network(), self.create_network()] # Creates 2 ports in one request - names = [data_utils.rand_name('port-') for i in range(len(networks))] + names = [data_utils.rand_name( + name='port-', prefix=CONF.resource_name_prefix) + for i in range(len(networks))] port_list = [] state = [True, False] for i in range(len(names)): diff --git a/tempest/api/network/test_networks_negative.py b/tempest/api/network/test_networks_negative.py index 05254842d7..6c91df0ae7 100644 --- a/tempest/api/network/test_networks_negative.py +++ b/tempest/api/network/test_networks_negative.py @@ -15,10 +15,13 @@ # under the License. from tempest.api.network import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators from tempest.lib import exceptions as lib_exc +CONF = config.CONF + class NetworksNegativeTestJSON(base.BaseNetworkTest): """Negative tests of network""" @@ -89,7 +92,9 @@ class NetworksNegativeTestJSON(base.BaseNetworkTest): self.assertRaises(lib_exc.NotFound, self.ports_client.create_port, network_id=non_exist_net_id, - name=data_utils.rand_name(self.__class__.__name__)) + name=data_utils.rand_name( + self.__class__.__name__, + prefix=CONF.resource_name_prefix)) @decorators.attr(type=['negative']) @decorators.idempotent_id('cf8eef21-4351-4f53-adcd-cc5cb1e76b92') diff --git a/tempest/api/network/test_ports.py b/tempest/api/network/test_ports.py index 190f7e0292..02faa59896 100644 --- a/tempest/api/network/test_ports.py +++ b/tempest/api/network/test_ports.py @@ -21,11 +21,14 @@ import testtools from tempest.api.network import base_security_groups as sec_base from tempest.common import custom_matchers from tempest.common import utils +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib.common.utils import test_utils from tempest.lib import decorators from tempest.lib import exceptions +CONF = config.CONF + class PortsTestJSON(sec_base.BaseSecGroupTest): """Test the following operations for ports: @@ -59,7 +62,7 @@ class PortsTestJSON(sec_base.BaseSecGroupTest): def _create_network(self, network_name=None, **kwargs): network_name = network_name or data_utils.rand_name( - self.__class__.__name__) + self.__class__.__name__, prefix=CONF.resource_name_prefix) network = self.networks_client.create_network( name=network_name, **kwargs)['network'] self.addCleanup(test_utils.call_and_ignore_notfound_exc, @@ -74,7 +77,8 @@ class PortsTestJSON(sec_base.BaseSecGroupTest): # Verify port creation body = self.ports_client.create_port( network_id=self.network['id'], - name=data_utils.rand_name(self.__class__.__name__)) + name=data_utils.rand_name( + self.__class__.__name__, prefix=CONF.resource_name_prefix)) port = body['port'] # Schedule port deletion with verification upon test completion self.addCleanup(self.ports_client.wait_for_resource_deletion, @@ -131,7 +135,8 @@ class PortsTestJSON(sec_base.BaseSecGroupTest): **allocation_pools) body = self.ports_client.create_port( network_id=net_id, - name=data_utils.rand_name(self.__class__.__name__)) + name=data_utils.rand_name( + self.__class__.__name__, prefix=CONF.resource_name_prefix)) self.addCleanup(self.ports_client.wait_for_resource_deletion, body['port']['id']) self.addCleanup(test_utils.call_and_ignore_notfound_exc, @@ -190,14 +195,16 @@ class PortsTestJSON(sec_base.BaseSecGroupTest): # Create two ports port_1 = self.ports_client.create_port( network_id=network['id'], - name=data_utils.rand_name(self.__class__.__name__)) + name=data_utils.rand_name( + self.__class__.__name__, prefix=CONF.resource_name_prefix)) self.addCleanup(self.ports_client.wait_for_resource_deletion, port_1['port']['id']) self.addCleanup(test_utils.call_and_ignore_notfound_exc, self.ports_client.delete_port, port_1['port']['id']) port_2 = self.ports_client.create_port( network_id=network['id'], - name=data_utils.rand_name(self.__class__.__name__)) + name=data_utils.rand_name( + self.__class__.__name__, prefix=CONF.resource_name_prefix)) self.addCleanup(self.ports_client.wait_for_resource_deletion, port_2['port']['id']) self.addCleanup(test_utils.call_and_ignore_notfound_exc, @@ -251,7 +258,8 @@ class PortsTestJSON(sec_base.BaseSecGroupTest): fixed_ips = [{'subnet_id': subnet['id'], 'ip_address': ip_address_1}] port_1 = self.ports_client.create_port( network_id=network['id'], - name=data_utils.rand_name(self.__class__.__name__), + name=data_utils.rand_name( + self.__class__.__name__, prefix=CONF.resource_name_prefix), fixed_ips=fixed_ips) self.addCleanup(self.ports_client.wait_for_resource_deletion, port_1['port']['id']) @@ -260,7 +268,8 @@ class PortsTestJSON(sec_base.BaseSecGroupTest): fixed_ips = [{'subnet_id': subnet['id'], 'ip_address': ip_address_2}] port_2 = self.ports_client.create_port( network_id=network['id'], - name=data_utils.rand_name(self.__class__.__name__), + name=data_utils.rand_name( + self.__class__.__name__, prefix=CONF.resource_name_prefix), fixed_ips=fixed_ips) self.addCleanup(self.ports_client.wait_for_resource_deletion, port_2['port']['id']) @@ -319,7 +328,8 @@ class PortsTestJSON(sec_base.BaseSecGroupTest): self.routers_client.delete_router, router['id']) port = self.ports_client.create_port( network_id=network['id'], - name=data_utils.rand_name(self.__class__.__name__)) + name=data_utils.rand_name( + self.__class__.__name__, prefix=CONF.resource_name_prefix)) # Add router interface to port created above self.routers_client.add_router_interface(router['id'], port_id=port['port']['id']) @@ -393,14 +403,16 @@ class PortsTestJSON(sec_base.BaseSecGroupTest): security_groups_list.append(group_create_body['security_group'] ['id']) # Create a port - sec_grp_name = data_utils.rand_name('secgroup') + sec_grp_name = data_utils.rand_name( + name='secgroup', prefix=CONF.resource_name_prefix) security_group = sec_grps_client.create_security_group( name=sec_grp_name) self.addCleanup(test_utils.call_and_ignore_notfound_exc, self.security_groups_client.delete_security_group, security_group['security_group']['id']) post_body = { - "name": data_utils.rand_name(self.__class__.__name__), + "name": data_utils.rand_name( + self.__class__.__name__, prefix=CONF.resource_name_prefix), "security_groups": [security_group['security_group']['id']], "network_id": self.network['id'], "admin_state_up": True, @@ -416,7 +428,8 @@ class PortsTestJSON(sec_base.BaseSecGroupTest): subnet_2 = self.create_subnet(self.network) fixed_ip_2 = [{'subnet_id': subnet_2['id']}] update_body = { - "name": data_utils.rand_name(self.__class__.__name__), + "name": data_utils.rand_name( + self.__class__.__name__, prefix=CONF.resource_name_prefix), "admin_state_up": False, "fixed_ips": fixed_ip_2, "security_groups": security_groups_list} @@ -446,7 +459,8 @@ class PortsTestJSON(sec_base.BaseSecGroupTest): the port's fixed ips. """ self._update_port_with_security_groups( - [data_utils.rand_name('secgroup')]) + [data_utils.rand_name('secgroup', + prefix=CONF.resource_name_prefix)]) @decorators.idempotent_id('edf6766d-3d40-4621-bc6e-2521a44c257d') @testtools.skipUnless( @@ -460,8 +474,10 @@ class PortsTestJSON(sec_base.BaseSecGroupTest): the port's fixed ips. """ self._update_port_with_security_groups( - [data_utils.rand_name('secgroup'), - data_utils.rand_name('secgroup')]) + [data_utils.rand_name('secgroup', + prefix=CONF.resource_name_prefix), + data_utils.rand_name('secgroup', + prefix=CONF.resource_name_prefix)]) @decorators.idempotent_id('13e95171-6cbd-489c-9d7c-3f9c58215c18') def test_create_show_delete_port_user_defined_mac(self): @@ -469,7 +485,8 @@ class PortsTestJSON(sec_base.BaseSecGroupTest): # Create a port for a legal mac body = self.ports_client.create_port( network_id=self.network['id'], - name=data_utils.rand_name(self.__class__.__name__)) + name=data_utils.rand_name( + self.__class__.__name__, prefix=CONF.resource_name_prefix)) old_port = body['port'] free_mac_address = old_port['mac_address'] self.ports_client.delete_port(old_port['id']) @@ -477,7 +494,8 @@ class PortsTestJSON(sec_base.BaseSecGroupTest): body = self.ports_client.create_port( network_id=self.network['id'], mac_address=free_mac_address, - name=data_utils.rand_name(self.__class__.__name__)) + name=data_utils.rand_name( + self.__class__.__name__, prefix=CONF.resource_name_prefix)) self.addCleanup(self.ports_client.wait_for_resource_deletion, body['port']['id']) self.addCleanup(test_utils.call_and_ignore_notfound_exc, diff --git a/tempest/api/network/test_routers.py b/tempest/api/network/test_routers.py index c03a8a27ba..0dd7c707c4 100644 --- a/tempest/api/network/test_routers.py +++ b/tempest/api/network/test_routers.py @@ -56,7 +56,9 @@ class RoutersTest(base.BaseNetworkTest): def test_create_show_list_update_delete_router(self): """Test create/show/list/update/delete of a router""" # Create a router - router_name = data_utils.rand_name(self.__class__.__name__ + '-router') + router_name = data_utils.rand_name( + self.__class__.__name__ + '-router', + prefix=CONF.resource_name_prefix) router = self.create_router( router_name, admin_state_up=False, @@ -90,7 +92,8 @@ class RoutersTest(base.BaseNetworkTest): @decorators.idempotent_id('b42e6e39-2e37-49cc-a6f4-8467e940900a') def test_add_remove_router_interface_with_subnet_id(self): """Test adding and removing router interface with subnet id""" - network_name = data_utils.rand_name(self.__class__.__name__) + network_name = data_utils.rand_name( + self.__class__.__name__, prefix=CONF.resource_name_prefix) network = self.networks_client.create_network( name=network_name)['network'] self.addCleanup(test_utils.call_and_ignore_notfound_exc, @@ -117,7 +120,8 @@ class RoutersTest(base.BaseNetworkTest): @decorators.idempotent_id('2b7d2f37-6748-4d78-92e5-1d590234f0d5') def test_add_remove_router_interface_with_port_id(self): """Test adding and removing router interface with port id""" - network_name = data_utils.rand_name(self.__class__.__name__) + network_name = data_utils.rand_name( + self.__class__.__name__, prefix=CONF.resource_name_prefix) network = self.networks_client.create_network( name=network_name)['network'] self.addCleanup(test_utils.call_and_ignore_notfound_exc, @@ -128,7 +132,8 @@ class RoutersTest(base.BaseNetworkTest): self.addCleanup(self.delete_router, router) port_body = self.ports_client.create_port( network_id=network['id'], - name=data_utils.rand_name(self.__class__.__name__)) + name=data_utils.rand_name( + self.__class__.__name__, prefix=CONF.resource_name_prefix)) # add router interface to port created above interface = self.routers_client.add_router_interface( router['id'], @@ -165,7 +170,8 @@ class RoutersTest(base.BaseNetworkTest): # Update router extra route, second ip of the range is # used as next hop for i in range(routes_num): - network_name = data_utils.rand_name(self.__class__.__name__) + network_name = data_utils.rand_name( + self.__class__.__name__, prefix=CONF.resource_name_prefix) network = self.networks_client.create_network( name=network_name)['network'] self.addCleanup(test_utils.call_and_ignore_notfound_exc, @@ -235,12 +241,14 @@ class RoutersTest(base.BaseNetworkTest): @decorators.idempotent_id('802c73c9-c937-4cef-824b-2191e24a6aab') def test_add_multiple_router_interfaces(self): """Test adding multiple router interfaces""" - network_name = data_utils.rand_name(self.__class__.__name__) + network_name = data_utils.rand_name( + self.__class__.__name__, prefix=CONF.resource_name_prefix) network01 = self.networks_client.create_network( name=network_name)['network'] self.addCleanup(test_utils.call_and_ignore_notfound_exc, self.networks_client.delete_network, network01['id']) - network_name = data_utils.rand_name(self.__class__.__name__) + network_name = data_utils.rand_name( + self.__class__.__name__, prefix=CONF.resource_name_prefix) network02 = self.networks_client.create_network( name=network_name)['network'] self.addCleanup(test_utils.call_and_ignore_notfound_exc, @@ -266,7 +274,8 @@ class RoutersTest(base.BaseNetworkTest): @decorators.idempotent_id('96522edf-b4b5-45d9-8443-fa11c26e6eff') def test_router_interface_port_update_with_fixed_ip(self): """Test updating router interface port's fixed ip""" - network_name = data_utils.rand_name(self.__class__.__name__) + network_name = data_utils.rand_name( + self.__class__.__name__, prefix=CONF.resource_name_prefix) network = self.networks_client.create_network( name=network_name)['network'] self.addCleanup(test_utils.call_and_ignore_notfound_exc, diff --git a/tempest/api/network/test_routers_negative.py b/tempest/api/network/test_routers_negative.py index 10a2706162..50ba9774a9 100644 --- a/tempest/api/network/test_routers_negative.py +++ b/tempest/api/network/test_routers_negative.py @@ -15,10 +15,13 @@ from tempest.api.network import base from tempest.common import utils +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators from tempest.lib import exceptions as lib_exc +CONF = config.CONF + class RoutersNegativeTest(base.BaseNetworkTest): """Negative tests of routers""" @@ -65,9 +68,11 @@ class RoutersNegativeTest(base.BaseNetworkTest): def test_add_router_interfaces_on_overlapping_subnets_returns_400(self): """Test adding router interface which is on overlapping subnets""" network01 = self.create_network( - network_name=data_utils.rand_name('router-network01-')) + network_name=data_utils.rand_name( + name='router-network01-', prefix=CONF.resource_name_prefix)) network02 = self.create_network( - network_name=data_utils.rand_name('router-network02-')) + network_name=data_utils.rand_name( + name='router-network02-', prefix=CONF.resource_name_prefix)) subnet01 = self.create_subnet(network01) subnet02 = self.create_subnet(network02) interface = self.routers_client.add_router_interface( @@ -96,7 +101,8 @@ class RoutersNegativeTest(base.BaseNetworkTest): @decorators.idempotent_id('c2a70d72-8826-43a7-8208-0209e6360c47') def test_show_non_existent_router_returns_404(self): """Test showing non existent router""" - router = data_utils.rand_name('non_exist_router') + router = data_utils.rand_name( + name='non_exist_router', prefix=CONF.resource_name_prefix) self.assertRaises(lib_exc.NotFound, self.routers_client.show_router, router) @@ -104,7 +110,8 @@ class RoutersNegativeTest(base.BaseNetworkTest): @decorators.idempotent_id('b23d1569-8b0c-4169-8d4b-6abd34fad5c7') def test_update_non_existent_router_returns_404(self): """Test updating non existent router""" - router = data_utils.rand_name('non_exist_router') + router = data_utils.rand_name( + name='non_exist_router', prefix=CONF.resource_name_prefix) self.assertRaises(lib_exc.NotFound, self.routers_client.update_router, router, name="new_name") @@ -112,7 +119,8 @@ class RoutersNegativeTest(base.BaseNetworkTest): @decorators.idempotent_id('c7edc5ad-d09d-41e6-a344-5c0c31e2e3e4') def test_delete_non_existent_router_returns_404(self): """Test deleting non existent router""" - router = data_utils.rand_name('non_exist_router') + router = data_utils.rand_name( + name='non_exist_router', prefix=CONF.resource_name_prefix) self.assertRaises(lib_exc.NotFound, self.routers_client.delete_router, router) diff --git a/tempest/api/network/test_security_groups.py b/tempest/api/network/test_security_groups.py index 532ef657e3..c7f6b8fa23 100644 --- a/tempest/api/network/test_security_groups.py +++ b/tempest/api/network/test_security_groups.py @@ -15,10 +15,13 @@ from tempest.api.network import base_security_groups as base from tempest.common import utils +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib.common.utils import test_utils from tempest.lib import decorators +CONF = config.CONF + class SecGroupTest(base.BaseSecGroupTest): """Test security groups""" @@ -91,7 +94,8 @@ class SecGroupTest(base.BaseSecGroupTest): secgroup_list.append(secgroup['id']) self.assertIn(group_create_body['security_group']['id'], secgroup_list) # Update the security group - new_name = data_utils.rand_name('security-') + new_name = data_utils.rand_name( + 'security-', prefix=CONF.resource_name_prefix) new_description = data_utils.rand_name('security-description') update_body = self.security_groups_client.update_security_group( group_create_body['security_group']['id'], diff --git a/tempest/api/network/test_subnetpools_extensions.py b/tempest/api/network/test_subnetpools_extensions.py index 48603ed570..689844bb75 100644 --- a/tempest/api/network/test_subnetpools_extensions.py +++ b/tempest/api/network/test_subnetpools_extensions.py @@ -50,7 +50,8 @@ class SubnetPoolsTestJSON(base.BaseNetworkTest): @decorators.idempotent_id('62595970-ab1c-4b7f-8fcc-fddfe55e9811') def test_create_list_show_update_delete_subnetpools(self): """Test create/list/show/update/delete of subnet pools""" - subnetpool_name = data_utils.rand_name('subnetpools') + subnetpool_name = data_utils.rand_name( + name='subnetpools', prefix=CONF.resource_name_prefix) # create subnet pool prefix = CONF.network.default_network body = self.subnetpools_client.create_subnetpool(name=subnetpool_name, @@ -64,7 +65,8 @@ class SubnetPoolsTestJSON(base.BaseNetworkTest): body = self.subnetpools_client.show_subnetpool(subnetpool_id) self.assertEqual(subnetpool_name, body["subnetpool"]["name"]) # update the subnet pool - subnetpool_name = data_utils.rand_name('subnetpools_update') + subnetpool_name = data_utils.rand_name( + name='subnetpools_update', prefix=CONF.resource_name_prefix) body = self.subnetpools_client.update_subnetpool(subnetpool_id, name=subnetpool_name) self.assertEqual(subnetpool_name, body["subnetpool"]["name"]) diff --git a/tempest/api/network/test_tags.py b/tempest/api/network/test_tags.py index 5219c34a14..bd3e360e5a 100644 --- a/tempest/api/network/test_tags.py +++ b/tempest/api/network/test_tags.py @@ -52,7 +52,8 @@ class TagsTest(base.BaseNetworkTest): @decorators.idempotent_id('ee76bfaf-ac94-4d74-9ecc-4bbd4c583cb1') def test_create_list_show_update_delete_tags(self): """Validate that creating a tag on a network resource works""" - tag_name = data_utils.rand_name(self.__class__.__name__ + '-Tag') + tag_name = data_utils.rand_name( + self.__class__.__name__ + '-Tag', prefix=CONF.resource_name_prefix) self.tags_client.create_tag('networks', self.network['id'], tag_name) self.addCleanup(self.tags_client.delete_all_tags, 'networks', self.network['id']) @@ -66,7 +67,8 @@ class TagsTest(base.BaseNetworkTest): # Generate 3 new tag names. replace_tags = [data_utils.rand_name( - self.__class__.__name__ + '-Tag') for _ in range(3)] + self.__class__.__name__ + '-Tag', + prefix=CONF.resource_name_prefix) for _ in range(3)] # Replace the current tag with the 3 new tags and validate that the # network resource has the 3 new tags. @@ -132,7 +134,8 @@ class TagsExtTest(base.BaseNetworkTest): cls.port = cls.create_port(cls.network) cls.router = cls.create_router() - subnetpool_name = data_utils.rand_name(cls.__name__ + '-Subnetpool') + subnetpool_name = data_utils.rand_name( + cls.__name__ + '-Subnetpool', prefix=CONF.resource_name_prefix) prefix = CONF.network.default_network cls.subnetpool = cls.subnetpools_client.create_subnetpool( name=subnetpool_name, prefixes=prefix)['subnetpool'] @@ -145,7 +148,9 @@ class TagsExtTest(base.BaseNetworkTest): tag_names = [] for resource in self.SUPPORTED_RESOURCES: - tag_name = data_utils.rand_name(self.__class__.__name__ + '-Tag') + tag_name = data_utils.rand_name( + self.__class__.__name__ + '-Tag', + prefix=CONF.resource_name_prefix) tag_names.append(tag_name) resource_object = getattr(self, resource[:-1]) @@ -188,7 +193,8 @@ class TagsExtTest(base.BaseNetworkTest): for resource in self.SUPPORTED_RESOURCES: # Generate 3 new tag names. replace_tags = [data_utils.rand_name( - self.__class__.__name__ + '-Tag') for _ in range(3)] + self.__class__.__name__ + '-Tag', + prefix=CONF.resource_name_prefix) for _ in range(3)] # Replace the current tag with the 3 new tags and validate that the # current resource has the 3 new tags. diff --git a/tempest/api/object_storage/base.py b/tempest/api/object_storage/base.py index 8adbe7d791..58e71a5ff6 100644 --- a/tempest/api/object_storage/base.py +++ b/tempest/api/object_storage/base.py @@ -78,7 +78,8 @@ class BaseObjectTest(tempest.test.BaseTestCase): @classmethod def create_container(cls): # wrapper that returns a test container - container_name = data_utils.rand_name(name='TestContainer') + container_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestContainer') cls.container_client.update_container(container_name) cls.containers.append(container_name) @@ -89,7 +90,8 @@ class BaseObjectTest(tempest.test.BaseTestCase): data=None, metadata=None): # wrapper that returns a test object if object_name is None: - object_name = data_utils.rand_name(name='TestObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') if data is None: data = data_utils.random_bytes() diff --git a/tempest/api/object_storage/test_account_quotas.py b/tempest/api/object_storage/test_account_quotas.py index 6854bbeb9e..0a40237c20 100644 --- a/tempest/api/object_storage/test_account_quotas.py +++ b/tempest/api/object_storage/test_account_quotas.py @@ -81,7 +81,8 @@ class AccountQuotasTest(base.BaseObjectTest): @utils.requires_ext(extension='account_quotas', service='object') def test_upload_valid_object(self): """Test uploading valid object""" - object_name = data_utils.rand_name(name="TestObject") + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name="TestObject") data = data_utils.arbitrary_string() resp, _ = self.object_client.create_object(self.container_name, object_name, data) diff --git a/tempest/api/object_storage/test_account_services.py b/tempest/api/object_storage/test_account_services.py index b7a413e178..75414c012b 100644 --- a/tempest/api/object_storage/test_account_services.py +++ b/tempest/api/object_storage/test_account_services.py @@ -42,7 +42,9 @@ class AccountTest(base.BaseObjectTest): def resource_setup(cls): super(AccountTest, cls).resource_setup() for i in range(ord('a'), ord('f') + 1): - name = data_utils.rand_name(name='%s-' % bytes((i,))) + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name='%s-' % bytes((i,))) cls.container_client.update_container(name) cls.addClassResourceCleanup(object_storage.delete_containers, [name], diff --git a/tempest/api/object_storage/test_container_acl.py b/tempest/api/object_storage/test_container_acl.py index 0259373d43..9dafbf0b64 100644 --- a/tempest/api/object_storage/test_container_acl.py +++ b/tempest/api/object_storage/test_container_acl.py @@ -50,7 +50,8 @@ class ObjectTestACLs(base.BaseObjectTest): create_update_metadata_prefix='')) self.assertHeaders(resp_meta, 'Container', 'POST') # create object - object_name = data_utils.rand_name(name='Object') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='Object') resp, _ = self.os_roles_operator.object_client.create_object( self.container_name, object_name, 'data') self.assertHeaders(resp, 'Object', 'PUT') @@ -84,7 +85,8 @@ class ObjectTestACLs(base.BaseObjectTest): auth_data=self.os_roles_operator_alt.object_client.auth_provider. auth_data) # Trying to write the object with rights - object_name = data_utils.rand_name(name='Object') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='Object') resp, _ = self.os_roles_operator.object_client.create_object( self.container_name, object_name, 'data', headers={}) diff --git a/tempest/api/object_storage/test_container_acl_negative.py b/tempest/api/object_storage/test_container_acl_negative.py index 347c79e072..49c2ed0b90 100644 --- a/tempest/api/object_storage/test_container_acl_negative.py +++ b/tempest/api/object_storage/test_container_acl_negative.py @@ -39,7 +39,8 @@ class ObjectACLsNegativeTest(base.BaseObjectTest): def setUp(self): super(ObjectACLsNegativeTest, self).setUp() - self.container_name = data_utils.rand_name(name='TestContainer') + self.container_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestContainer') self.container_client.update_container(self.container_name) self.containers.append(self.container_name) @@ -54,7 +55,8 @@ class ObjectACLsNegativeTest(base.BaseObjectTest): """Test writing object without using credentials""" # trying to create object with empty headers # X-Auth-Token is not provided - object_name = data_utils.rand_name(name='Object') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='Object') self.object_client.auth_provider.set_alt_auth_data( request_part='headers', auth_data=None @@ -68,7 +70,8 @@ class ObjectACLsNegativeTest(base.BaseObjectTest): def test_delete_object_without_using_creds(self): """Test deleting object without using credentials""" # create object - object_name = data_utils.rand_name(name='Object') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='Object') self.object_client.create_object(self.container_name, object_name, 'data') # trying to delete object with empty headers @@ -86,7 +89,8 @@ class ObjectACLsNegativeTest(base.BaseObjectTest): def test_write_object_with_non_authorized_user(self): """Test writing object with non-authorized user""" # User provided token is forbidden. ACL are not set - object_name = data_utils.rand_name(name='Object') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='Object') # trying to create object with non-authorized user self.object_client.auth_provider.set_alt_auth_data( request_part='headers', @@ -101,7 +105,8 @@ class ObjectACLsNegativeTest(base.BaseObjectTest): def test_read_object_with_non_authorized_user(self): """Test reading object with non-authorized user""" # User provided token is forbidden. ACL are not set - object_name = data_utils.rand_name(name='Object') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='Object') resp, _ = self.object_client.create_object( self.container_name, object_name, 'data') self.assertHeaders(resp, 'Object', 'PUT') @@ -119,7 +124,8 @@ class ObjectACLsNegativeTest(base.BaseObjectTest): def test_delete_object_with_non_authorized_user(self): """Test deleting object with non-authorized user""" # User provided token is forbidden. ACL are not set - object_name = data_utils.rand_name(name='Object') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='Object') resp, _ = self.object_client.create_object( self.container_name, object_name, 'data') self.assertHeaders(resp, 'Object', 'PUT') @@ -144,7 +150,8 @@ class ObjectACLsNegativeTest(base.BaseObjectTest): create_update_metadata_prefix='')) self.assertHeaders(resp_meta, 'Container', 'POST') # create object - object_name = data_utils.rand_name(name='Object') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='Object') resp, _ = self.object_client.create_object(self.container_name, object_name, 'data') self.assertHeaders(resp, 'Object', 'PUT') @@ -173,7 +180,8 @@ class ObjectACLsNegativeTest(base.BaseObjectTest): request_part='headers', auth_data=self.test_auth_data ) - object_name = data_utils.rand_name(name='Object') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='Object') self.assertRaises(lib_exc.Forbidden, self.object_client.create_object, self.container_name, @@ -199,7 +207,8 @@ class ObjectACLsNegativeTest(base.BaseObjectTest): request_part='headers', auth_data=self.test_auth_data ) - object_name = data_utils.rand_name(name='Object') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='Object') self.assertRaises(lib_exc.Forbidden, self.object_client.create_object, self.container_name, @@ -221,7 +230,8 @@ class ObjectACLsNegativeTest(base.BaseObjectTest): create_update_metadata_prefix='')) self.assertHeaders(resp_meta, 'Container', 'POST') # create object - object_name = data_utils.rand_name(name='Object') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='Object') resp, _ = self.object_client.create_object(self.container_name, object_name, 'data') self.assertHeaders(resp, 'Object', 'PUT') diff --git a/tempest/api/object_storage/test_container_quotas.py b/tempest/api/object_storage/test_container_quotas.py index fb67fb49b1..f055d19767 100644 --- a/tempest/api/object_storage/test_container_quotas.py +++ b/tempest/api/object_storage/test_container_quotas.py @@ -16,10 +16,12 @@ from tempest.api.object_storage import base from tempest.common import utils from tempest.common import waiters +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators from tempest.lib import exceptions as lib_exc +CONF = config.CONF QUOTA_BYTES = 10 QUOTA_COUNT = 3 @@ -55,7 +57,8 @@ class ContainerQuotasTest(base.BaseObjectTest): @decorators.attr(type="smoke") def test_upload_valid_object(self): """Attempts to uploads an object smaller than the bytes quota.""" - object_name = data_utils.rand_name(name="TestObject") + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name="TestObject") data = data_utils.arbitrary_string(QUOTA_BYTES) nbefore = self._get_bytes_used() @@ -72,7 +75,8 @@ class ContainerQuotasTest(base.BaseObjectTest): @decorators.attr(type="smoke") def test_upload_large_object(self): """Attempts to upload an object larger than the bytes quota.""" - object_name = data_utils.rand_name(name="TestObject") + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name="TestObject") data = data_utils.arbitrary_string(QUOTA_BYTES + 1) nbefore = self._get_bytes_used() @@ -90,7 +94,8 @@ class ContainerQuotasTest(base.BaseObjectTest): def test_upload_too_many_objects(self): """Attempts to upload many objects that exceeds the count limit.""" for _ in range(QUOTA_COUNT): - name = data_utils.rand_name(name="TestObject") + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name="TestObject") self.object_client.create_object(self.container_name, name, "") waiters.wait_for_object_create(self.object_client, self.container_name, diff --git a/tempest/api/object_storage/test_container_services.py b/tempest/api/object_storage/test_container_services.py index 085b8ab117..e2bbc267e9 100644 --- a/tempest/api/object_storage/test_container_services.py +++ b/tempest/api/object_storage/test_container_services.py @@ -14,9 +14,12 @@ # under the License. from tempest.api.object_storage import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators +CONF = config.CONF + class ContainerTest(base.BaseObjectTest): """Test containers""" @@ -30,7 +33,8 @@ class ContainerTest(base.BaseObjectTest): @decorators.idempotent_id('92139d73-7819-4db1-85f8-3f2f22a8d91f') def test_create_container(self): """Test creating container""" - container_name = data_utils.rand_name(name='TestContainer') + container_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestContainer') resp, _ = self.container_client.update_container(container_name) self.containers.append(container_name) self.assertHeaders(resp, 'Container', 'PUT') @@ -38,7 +42,8 @@ class ContainerTest(base.BaseObjectTest): @decorators.idempotent_id('49f866ed-d6af-4395-93e7-4187eb56d322') def test_create_container_overwrite(self): """Test overwriting container with the same name""" - container_name = data_utils.rand_name(name='TestContainer') + container_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestContainer') self.container_client.update_container(container_name) self.containers.append(container_name) @@ -48,7 +53,8 @@ class ContainerTest(base.BaseObjectTest): @decorators.idempotent_id('c2ac4d59-d0f5-40d5-ba19-0635056d48cd') def test_create_container_with_metadata_key(self): """Test creating container with the blank value of metadata""" - container_name = data_utils.rand_name(name='TestContainer') + container_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestContainer') headers = {'X-Container-Meta-test-container-meta': ''} resp, _ = self.container_client.update_container( container_name, @@ -65,7 +71,8 @@ class ContainerTest(base.BaseObjectTest): @decorators.idempotent_id('e1e8df32-7b22-44e1-aa08-ccfd8d446b58') def test_create_container_with_metadata_value(self): """Test creating container with metadata value""" - container_name = data_utils.rand_name(name='TestContainer') + container_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestContainer') # metadata name using underscores should be converted to hyphens headers = {'X-Container-Meta-test_container_meta': 'Meta1'} @@ -84,7 +91,8 @@ class ContainerTest(base.BaseObjectTest): @decorators.idempotent_id('24d16451-1c0c-4e4f-b59c-9840a3aba40e') def test_create_container_with_remove_metadata_key(self): """Test creating container with the blank value of remove metadata""" - container_name = data_utils.rand_name(name='TestContainer') + container_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestContainer') headers = {'X-Container-Meta-test-container-meta': 'Meta1'} self.container_client.update_container(container_name, **headers) self.containers.append(container_name) @@ -102,7 +110,8 @@ class ContainerTest(base.BaseObjectTest): @decorators.idempotent_id('8a21ebad-a5c7-4e29-b428-384edc8cd156') def test_create_container_with_remove_metadata_value(self): """Test creating container with remove metadata""" - container_name = data_utils.rand_name(name='TestContainer') + container_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestContainer') headers = {'X-Container-Meta-test-container-meta': 'Meta1'} self.container_client.update_container(container_name, **headers) self.containers.append(container_name) @@ -151,7 +160,8 @@ class ContainerTest(base.BaseObjectTest): def test_list_container_contents_with_delimiter(self): """Test getting container contents list using delimiter param""" container_name = self.create_container() - object_name = data_utils.rand_name(name='TestObject/') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject/') self.create_object(container_name, object_name) params = {'delimiter': '/'} @@ -247,7 +257,8 @@ class ContainerTest(base.BaseObjectTest): def test_list_container_contents_with_path(self): """Test getting container contents list using path param""" container_name = self.create_container() - object_name = data_utils.rand_name(name='TestObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') object_name = 'Swift/' + object_name self.create_object(container_name, object_name) @@ -305,7 +316,8 @@ class ContainerTest(base.BaseObjectTest): Send one request of adding and deleting metadata. """ - container_name = data_utils.rand_name(name='TestContainer') + container_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestContainer') metadata_1 = {'X-Container-Meta-test-container-meta1': 'Meta1'} self.container_client.update_container(container_name, **metadata_1) self.containers.append(container_name) @@ -346,7 +358,8 @@ class ContainerTest(base.BaseObjectTest): @decorators.idempotent_id('3a5ce7d4-6e4b-47d0-9d87-7cd42c325094') def test_update_container_metadata_with_delete_metadata(self): """Test updating container metadata using delete metadata""" - container_name = data_utils.rand_name(name='TestContainer') + container_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestContainer') metadata = {'X-Container-Meta-test-container-meta1': 'Meta1'} self.container_client.update_container(container_name, **metadata) self.containers.append(container_name) @@ -380,7 +393,8 @@ class ContainerTest(base.BaseObjectTest): @decorators.idempotent_id('a2e36378-6f1f-43f4-840a-ffd9cfd61914') def test_update_container_metadata_with_delete_metadata_key(self): """Test updating container metadata with a blank value of metadata""" - container_name = data_utils.rand_name(name='TestContainer') + container_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestContainer') headers = {'X-Container-Meta-test-container-meta1': 'Meta1'} self.container_client.update_container(container_name, **headers) self.containers.append(container_name) diff --git a/tempest/api/object_storage/test_container_services_negative.py b/tempest/api/object_storage/test_container_services_negative.py index 51c711f9ca..63d97a3b49 100644 --- a/tempest/api/object_storage/test_container_services_negative.py +++ b/tempest/api/object_storage/test_container_services_negative.py @@ -66,7 +66,8 @@ class ContainerNegativeTest(base.BaseObjectTest): def test_create_container_metadata_name_exceeds_max_length(self): """Test creating container with metadata name longer than max""" max_length = self.constraints['max_meta_name_length'] - container_name = data_utils.rand_name(name='TestContainer') + container_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestContainer') metadata_name = 'X-Container-Meta-' + data_utils.arbitrary_string( size=max_length + 1) metadata = {metadata_name: 'penguin'} @@ -84,7 +85,8 @@ class ContainerNegativeTest(base.BaseObjectTest): def test_create_container_metadata_value_exceeds_max_length(self): """Test creating container with metadata value longer than max""" max_length = self.constraints['max_meta_value_length'] - container_name = data_utils.rand_name(name='TestContainer') + container_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestContainer') metadata_value = data_utils.arbitrary_string(size=max_length + 1) metadata = {'X-Container-Meta-animal': metadata_value} ex = self.assertRaises( @@ -101,7 +103,8 @@ class ContainerNegativeTest(base.BaseObjectTest): def test_create_container_metadata_exceeds_overall_metadata_count(self): """Test creating container with metadata exceeding default count""" max_count = self.constraints['max_meta_count'] - container_name = data_utils.rand_name(name='TestContainer') + container_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestContainer') metadata = {} for i in range(max_count + 1): metadata['X-Container-Meta-animal-' + str(i)] = 'penguin' diff --git a/tempest/api/object_storage/test_container_sync.py b/tempest/api/object_storage/test_container_sync.py index 9b1d3c7600..e2c9d54de4 100644 --- a/tempest/api/object_storage/test_container_sync.py +++ b/tempest/api/object_storage/test_container_sync.py @@ -69,9 +69,13 @@ class ContainerSyncTest(base.BaseObjectTest): int(container_sync_timeout / cls.container_sync_interval) # define container and object clients - cls.clients[data_utils.rand_name(name='TestContainerSync')] = \ + cls.clients[data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name='TestContainerSync')] = \ (cls.container_client, cls.object_client) - cls.clients[data_utils.rand_name(name='TestContainerSync')] = \ + cls.clients[data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name='TestContainerSync')] = \ (cls.container_client_alt, cls.object_client_alt) for cont_name, client in cls.clients.items(): client[0].create_container(cont_name) @@ -92,7 +96,9 @@ class ContainerSyncTest(base.BaseObjectTest): headers = make_headers(cont[1], cont_client[1]) cont_client[0].put(str(cont[0]), body=None, headers=headers) # create object in container - object_name = data_utils.rand_name(name='TestSyncObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name='TestSyncObject') data = object_name[::-1].encode() # Raw data, we need bytes obj_client[0].create_object(cont[0], object_name, data) self.objects.append(object_name) diff --git a/tempest/api/object_storage/test_object_formpost.py b/tempest/api/object_storage/test_object_formpost.py index 39e895ea46..3231c0acce 100644 --- a/tempest/api/object_storage/test_object_formpost.py +++ b/tempest/api/object_storage/test_object_formpost.py @@ -19,9 +19,12 @@ from urllib import parse as urlparse from tempest.api.object_storage import base from tempest.common import utils +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators +CONF = config.CONF + class ObjectFormPostTest(base.BaseObjectTest): """Test object post with form""" @@ -33,7 +36,8 @@ class ObjectFormPostTest(base.BaseObjectTest): def resource_setup(cls): super(ObjectFormPostTest, cls).resource_setup() cls.container_name = cls.create_container() - cls.object_name = data_utils.rand_name(name='ObjectTemp') + cls.object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='ObjectTemp') cls.key = 'Meta' cls.metadata = {'Temp-URL-Key': cls.key} diff --git a/tempest/api/object_storage/test_object_formpost_negative.py b/tempest/api/object_storage/test_object_formpost_negative.py index 971a223221..c15ce1b6cc 100644 --- a/tempest/api/object_storage/test_object_formpost_negative.py +++ b/tempest/api/object_storage/test_object_formpost_negative.py @@ -19,10 +19,13 @@ from urllib import parse as urlparse from tempest.api.object_storage import base from tempest.common import utils +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators from tempest.lib import exceptions as lib_exc +CONF = config.CONF + class ObjectFormPostNegativeTest(base.BaseObjectTest): """Negative tests of object post with form""" @@ -34,7 +37,8 @@ class ObjectFormPostNegativeTest(base.BaseObjectTest): def resource_setup(cls): super(ObjectFormPostNegativeTest, cls).resource_setup() cls.container_name = cls.create_container() - cls.object_name = data_utils.rand_name(name='ObjectTemp') + cls.object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='ObjectTemp') cls.key = 'Meta' cls.metadata = {'Temp-URL-Key': cls.key} diff --git a/tempest/api/object_storage/test_object_services.py b/tempest/api/object_storage/test_object_services.py index 61b913663d..8110915517 100644 --- a/tempest/api/object_storage/test_object_services.py +++ b/tempest/api/object_storage/test_object_services.py @@ -43,7 +43,8 @@ class ObjectTest(base.BaseObjectTest): def _upload_segments(self): # create object - object_name = data_utils.rand_name(name='LObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='LObject') data = data_utils.arbitrary_string() segments = 10 data_segments = [data + str(i) for i in range(segments)] @@ -56,7 +57,8 @@ class ObjectTest(base.BaseObjectTest): return object_name, data_segments def _copy_object_2d(self, src_object_name, metadata=None): - dst_object_name = data_utils.rand_name(name='TestObject') + dst_object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') resp, _ = self.object_client.copy_object_2d_way(self.container_name, src_object_name, dst_object_name, @@ -81,12 +83,14 @@ class ObjectTest(base.BaseObjectTest): def test_create_object(self): """Test creating object and checking the object's uploaded content""" # create object - object_name = data_utils.rand_name(name='TestObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') data = data_utils.random_bytes() resp, _ = self.object_client.create_object(self.container_name, object_name, data) # create another object - object_name = data_utils.rand_name(name='TestObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') data = data_utils.random_bytes() resp, _ = self.object_client.create_object(self.container_name, object_name, data) @@ -100,7 +104,8 @@ class ObjectTest(base.BaseObjectTest): @decorators.idempotent_id('5daebb1d-f0d5-4dc9-b541-69672eff00b0') def test_create_object_with_content_disposition(self): """Test creating object with content-disposition""" - object_name = data_utils.rand_name(name='TestObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') data = data_utils.random_bytes() metadata = {} metadata['content-disposition'] = 'inline' @@ -122,7 +127,8 @@ class ObjectTest(base.BaseObjectTest): @decorators.idempotent_id('605f8317-f945-4bee-ae91-013f1da8f0a0') def test_create_object_with_content_encoding(self): """Test creating object with content-encoding""" - object_name = data_utils.rand_name(name='TestObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') # put compressed string data_before = b'x' * 2000 @@ -149,7 +155,8 @@ class ObjectTest(base.BaseObjectTest): @decorators.idempotent_id('73820093-0503-40b1-a478-edf0e69c7d1f') def test_create_object_with_etag(self): """Test creating object with Etag""" - object_name = data_utils.rand_name(name='TestObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') data = data_utils.random_bytes() create_md5 = md5(data, usedforsecurity=False).hexdigest() metadata = {'Etag': create_md5} @@ -168,7 +175,8 @@ class ObjectTest(base.BaseObjectTest): @decorators.idempotent_id('84dafe57-9666-4f6d-84c8-0814d37923b8') def test_create_object_with_expect_continue(self): """Test creating object with expect_continue""" - object_name = data_utils.rand_name(name='TestObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') data = data_utils.random_bytes() status, _ = self.object_client.create_object_continue( @@ -184,7 +192,8 @@ class ObjectTest(base.BaseObjectTest): @decorators.idempotent_id('4f84422a-e2f2-4403-b601-726a4220b54e') def test_create_object_with_transfer_encoding(self): """Test creating object with transfer_encoding""" - object_name = data_utils.rand_name(name='TestObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') data = data_utils.random_bytes(1024) resp, _ = self.object_client.create_object( self.container_name, @@ -205,14 +214,16 @@ class ObjectTest(base.BaseObjectTest): The previous added metadata will be cleared. """ - object_name_base = data_utils.rand_name(name='TestObject') + object_name_base = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') data = data_utils.random_bytes() metadata_1 = {'X-Object-Meta-test-meta': 'Meta'} self.object_client.create_object(self.container_name, object_name_base, data, metadata=metadata_1) - object_name = data_utils.rand_name(name='TestObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') metadata_2 = {'X-Copy-From': '%s/%s' % (self.container_name, object_name_base), 'X-Fresh-Metadata': 'true'} @@ -231,7 +242,8 @@ class ObjectTest(base.BaseObjectTest): @decorators.idempotent_id('1c7ed3e4-2099-406b-b843-5301d4811baf') def test_create_object_with_x_object_meta(self): """Test creating object with x-object-meta""" - object_name = data_utils.rand_name(name='TestObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') data = data_utils.random_bytes() metadata = {'X-Object-Meta-test-meta': 'Meta'} resp, _ = self.object_client.create_object( @@ -250,7 +262,8 @@ class ObjectTest(base.BaseObjectTest): @decorators.idempotent_id('e4183917-33db-4153-85cc-4dacbb938865') def test_create_object_with_x_object_metakey(self): """Test creating object with the blank value of metadata""" - object_name = data_utils.rand_name(name='TestObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') data = data_utils.random_bytes() metadata = {'X-Object-Meta-test-meta': ''} resp, _ = self.object_client.create_object( @@ -272,7 +285,8 @@ class ObjectTest(base.BaseObjectTest): The metadata will be removed from the object. """ - object_name = data_utils.rand_name(name='TestObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') data = data_utils.random_bytes() metadata_add = {'X-Object-Meta-test-meta': 'Meta'} self.object_client.create_object(self.container_name, @@ -299,7 +313,8 @@ class ObjectTest(base.BaseObjectTest): Creating object with blank metadata 'X-Remove-Object-Meta-test-meta', metadata 'x-object-meta-test-meta' will be removed from the object. """ - object_name = data_utils.rand_name(name='TestObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') data = data_utils.random_bytes() metadata_add = {'X-Object-Meta-test-meta': 'Meta'} self.object_client.create_object(self.container_name, @@ -322,7 +337,8 @@ class ObjectTest(base.BaseObjectTest): @decorators.idempotent_id('17738d45-03bd-4d45-9e0b-7b2f58f98687') def test_delete_object(self): """Test deleting object""" - object_name = data_utils.rand_name(name='TestObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') data = data_utils.random_bytes() resp, _ = self.object_client.create_object(self.container_name, object_name, data) @@ -353,7 +369,8 @@ class ObjectTest(base.BaseObjectTest): @decorators.idempotent_id('48650ed0-c189-4e1e-ad6b-1d4770c6e134') def test_update_object_metadata_with_remove_metadata(self): """Test updating object metadata with remove metadata""" - object_name = data_utils.rand_name(name='TestObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') data = data_utils.random_bytes() create_metadata = {'X-Object-Meta-test-meta1': 'Meta1'} self.object_client.create_object(self.container_name, @@ -381,7 +398,8 @@ class ObjectTest(base.BaseObjectTest): request, both operations will succeed. """ # creation and deletion of metadata with one request - object_name = data_utils.rand_name(name='TestObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') data = data_utils.random_bytes() create_metadata = {'X-Object-Meta-test-meta1': 'Meta1'} self.object_client.create_object(self.container_name, @@ -450,7 +468,8 @@ class ObjectTest(base.BaseObjectTest): @decorators.idempotent_id('9a88dca4-b684-425b-806f-306cd0e57e42') def test_update_object_metadata_with_x_remove_object_metakey(self): """Test updating object metadata with blank remove metadata value""" - object_name = data_utils.rand_name(name='TestObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') data = data_utils.arbitrary_string() create_metadata = {'X-Object-Meta-test-meta': 'Meta'} self.object_client.create_object(self.container_name, @@ -474,7 +493,8 @@ class ObjectTest(base.BaseObjectTest): @decorators.idempotent_id('9a447cf6-de06-48de-8226-a8c6ed31caf2') def test_list_object_metadata(self): """Test listing object metadata""" - object_name = data_utils.rand_name(name='TestObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') data = data_utils.random_bytes() metadata = {'X-Object-Meta-test-meta': 'Meta'} self.object_client.create_object(self.container_name, @@ -556,7 +576,8 @@ class ObjectTest(base.BaseObjectTest): @decorators.idempotent_id('005f9bf6-e06d-41ec-968e-96c78e0b1d82') def test_get_object_with_metadata(self): """Test getting object with metadata""" - object_name = data_utils.rand_name(name='TestObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') data = data_utils.random_bytes() metadata = {'X-Object-Meta-test-meta': 'Meta'} self.object_client.create_object(self.container_name, @@ -575,7 +596,8 @@ class ObjectTest(base.BaseObjectTest): @decorators.idempotent_id('05a1890e-7db9-4a6c-90a8-ce998a2bddfa') def test_get_object_with_range(self): """Test getting object with range""" - object_name = data_utils.rand_name(name='TestObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') data = data_utils.random_bytes(100) self.object_client.create_object(self.container_name, object_name, @@ -636,7 +658,8 @@ class ObjectTest(base.BaseObjectTest): @decorators.idempotent_id('c05b4013-e4de-47af-be84-e598062b16fc') def test_get_object_with_if_match(self): """Test getting object with if_match""" - object_name = data_utils.rand_name(name='TestObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') data = data_utils.random_bytes(10) create_md5 = md5(data, usedforsecurity=False).hexdigest() create_metadata = {'Etag': create_md5} @@ -656,7 +679,8 @@ class ObjectTest(base.BaseObjectTest): @decorators.idempotent_id('be133639-e5d2-4313-9b1f-2d59fc054a16') def test_get_object_with_if_modified_since(self): """Test getting object with if_modified_since""" - object_name = data_utils.rand_name(name='TestObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') data = data_utils.random_bytes() time_now = time.time() self.object_client.create_object(self.container_name, @@ -676,7 +700,8 @@ class ObjectTest(base.BaseObjectTest): @decorators.idempotent_id('641500d5-1612-4042-a04d-01fc4528bc30') def test_get_object_with_if_none_match(self): """Test getting object with if_none_match""" - object_name = data_utils.rand_name(name='TestObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') data = data_utils.random_bytes() create_md5 = md5(data, usedforsecurity=False).hexdigest() create_metadata = {'Etag': create_md5} @@ -727,13 +752,15 @@ class ObjectTest(base.BaseObjectTest): def test_copy_object_in_same_container(self): """Test copying object to another object in same container""" # create source object - src_object_name = data_utils.rand_name(name='SrcObject') + src_object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='SrcObject') src_data = data_utils.random_bytes(size=len(src_object_name) * 2) resp, _ = self.object_client.create_object(self.container_name, src_object_name, src_data) # create destination object - dst_object_name = data_utils.rand_name(name='DstObject') + dst_object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='DstObject') dst_data = data_utils.random_bytes(size=len(dst_object_name) * 3) resp, _ = self.object_client.create_object(self.container_name, dst_object_name, @@ -784,12 +811,14 @@ class ObjectTest(base.BaseObjectTest): def test_copy_object_2d_way(self): """Test copying object's data to the new object using COPY""" # create source object - src_object_name = data_utils.rand_name(name='SrcObject') + src_object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='SrcObject') src_data = data_utils.random_bytes(size=len(src_object_name) * 2) resp, _ = self.object_client.create_object(self.container_name, src_object_name, src_data) # create destination object - dst_object_name = data_utils.rand_name(name='DstObject') + dst_object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='DstObject') dst_data = data_utils.random_bytes(size=len(dst_object_name) * 3) resp, _ = self.object_client.create_object(self.container_name, dst_object_name, dst_data) @@ -809,22 +838,28 @@ class ObjectTest(base.BaseObjectTest): def test_copy_object_across_containers(self): """Test copying object to another container""" # create a container to use as a source container - src_container_name = data_utils.rand_name(name='TestSourceContainer') + src_container_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name='TestSourceContainer') self.container_client.update_container(src_container_name) self.containers.append(src_container_name) # create a container to use as a destination container dst_container_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestDestinationContainer') self.container_client.update_container(dst_container_name) self.containers.append(dst_container_name) # create object in source container - object_name = data_utils.rand_name(name='Object') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='Object') data = data_utils.random_bytes(size=len(object_name) * 2) resp, _ = self.object_client.create_object(src_container_name, object_name, data) # set object metadata - meta_key = data_utils.rand_name(name='test') - meta_value = data_utils.rand_name(name='MetaValue') + meta_key = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='test') + meta_value = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='MetaValue') orig_metadata = {'X-Object-Meta-' + meta_key: meta_value} resp, _ = self.object_client.create_or_update_object_metadata( src_container_name, @@ -924,7 +959,8 @@ class ObjectTest(base.BaseObjectTest): def test_object_upload_in_segments(self): """Test uploading object in segments""" # create object - object_name = data_utils.rand_name(name='LObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='LObject') data = data_utils.arbitrary_string() segments = 10 data_segments = [data + str(i) for i in range(segments)] @@ -1014,7 +1050,8 @@ class PublicObjectTest(base.BaseObjectTest): def setUp(self): super(PublicObjectTest, self).setUp() - self.container_name = data_utils.rand_name(name='TestContainer') + self.container_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestContainer') self.container_client.update_container(self.container_name) self.containers.append(self.container_name) @@ -1039,7 +1076,8 @@ class PublicObjectTest(base.BaseObjectTest): self.assertHeaders(resp_meta, 'Container', 'POST') # create object - object_name = data_utils.rand_name(name='Object') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='Object') data = data_utils.random_bytes(size=len(object_name)) resp, _ = self.object_client.create_object(self.container_name, object_name, data) @@ -1079,7 +1117,8 @@ class PublicObjectTest(base.BaseObjectTest): self.assertHeaders(resp_meta, 'Container', 'POST') # create object - object_name = data_utils.rand_name(name='Object') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='Object') data = data_utils.random_bytes(size=len(object_name)) resp, _ = self.object_client.create_object(self.container_name, object_name, data) diff --git a/tempest/api/object_storage/test_object_slo.py b/tempest/api/object_storage/test_object_slo.py index 22d12ceb6b..b8e0b55f67 100644 --- a/tempest/api/object_storage/test_object_slo.py +++ b/tempest/api/object_storage/test_object_slo.py @@ -17,9 +17,11 @@ from oslo_serialization import jsonutils as json from oslo_utils.secretutils import md5 from tempest.api.object_storage import base from tempest.common import utils +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators +CONF = config.CONF # Each segment, except for the final one, must be at least 1 megabyte MIN_SEGMENT_SIZE = 1024 * 1024 @@ -47,7 +49,8 @@ class ObjectSloTest(base.BaseObjectTest): def _create_manifest(self): # Create a manifest file for SLO uploading - object_name = data_utils.rand_name(name='TestObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') object_name_base_1 = object_name + '_01' object_name_base_2 = object_name + '_02' data_size = MIN_SEGMENT_SIZE @@ -80,7 +83,8 @@ class ObjectSloTest(base.BaseObjectTest): manifest = self._create_manifest() params = {'multipart-manifest': 'put'} - object_name = data_utils.rand_name(name='TestObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') self._create_object(self.container_name, object_name, manifest, @@ -109,7 +113,8 @@ class ObjectSloTest(base.BaseObjectTest): manifest = self._create_manifest() params = {'multipart-manifest': 'put'} - object_name = data_utils.rand_name(name='TestObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') resp = self._create_object(self.container_name, object_name, manifest, diff --git a/tempest/api/object_storage/test_object_temp_url_negative.py b/tempest/api/object_storage/test_object_temp_url_negative.py index 712697e364..d63a3cb994 100644 --- a/tempest/api/object_storage/test_object_temp_url_negative.py +++ b/tempest/api/object_storage/test_object_temp_url_negative.py @@ -67,7 +67,8 @@ class ObjectTempUrlNegativeTest(base.BaseObjectTest): self.key) # create object - self.object_name = data_utils.rand_name(name='ObjectTemp') + self.object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='ObjectTemp') content = data_utils.arbitrary_string(size=len(self.object_name), base_text=self.object_name) self.object_client.create_object(self.container_name, diff --git a/tempest/api/object_storage/test_object_version.py b/tempest/api/object_storage/test_object_version.py index 2a1f63e5bf..02b3be7f5d 100644 --- a/tempest/api/object_storage/test_object_version.py +++ b/tempest/api/object_storage/test_object_version.py @@ -52,7 +52,9 @@ class ContainerTest(base.BaseObjectTest): 6. delete object version 1 """ # create container - vers_container_name = data_utils.rand_name(name='TestVersionContainer') + vers_container_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name='TestVersionContainer') resp, _ = self.container_client.update_container(vers_container_name) self.addCleanup(object_storage.delete_containers, [vers_container_name], @@ -61,7 +63,9 @@ class ContainerTest(base.BaseObjectTest): self.assertHeaders(resp, 'Container', 'PUT') self.assertContainer(vers_container_name, '0', '0', 'Missing Header') - base_container_name = data_utils.rand_name(name='TestBaseContainer') + base_container_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name='TestBaseContainer') headers = {'X-versions-Location': vers_container_name} resp, _ = self.container_client.update_container( base_container_name, @@ -73,7 +77,8 @@ class ContainerTest(base.BaseObjectTest): self.assertHeaders(resp, 'Container', 'PUT') self.assertContainer(base_container_name, '0', '0', vers_container_name) - object_name = data_utils.rand_name(name='TestObject') + object_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='TestObject') # create object data_1 = data_utils.random_bytes() resp, _ = self.object_client.create_object(base_container_name, diff --git a/tempest/api/volume/admin/test_group_snapshots.py b/tempest/api/volume/admin/test_group_snapshots.py index 8af8435530..d059926312 100644 --- a/tempest/api/volume/admin/test_group_snapshots.py +++ b/tempest/api/volume/admin/test_group_snapshots.py @@ -35,7 +35,8 @@ class BaseGroupSnapshotsTest(base.BaseVolumeAdminTest): def _create_group_snapshot(self, **kwargs): if 'name' not in kwargs: kwargs['name'] = data_utils.rand_name( - self.__class__.__name__ + '-Group_Snapshot') + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-Group_Snapshot') group_snapshot = self.group_snapshots_client.create_group_snapshot( **kwargs)['group_snapshot'] @@ -93,7 +94,8 @@ class GroupSnapshotsTest(BaseGroupSnapshotsTest): # Create volume is instance level, can not be deleted before group. # Volume delete handled by delete_group method, cleanup method. - params = {'name': data_utils.rand_name("volume"), + prefix = CONF.resource_name_prefix + params = {'name': data_utils.rand_name(prefix=prefix, name="volume"), 'volume_type': volume_type['id'], 'group_id': grp['id'], 'size': CONF.volume.volume_size} @@ -102,7 +104,8 @@ class GroupSnapshotsTest(BaseGroupSnapshotsTest): self.volumes_client, vol['id'], 'available') # Create group snapshot - group_snapshot_name = data_utils.rand_name('group_snapshot') + group_snapshot_name = data_utils.rand_name(prefix=prefix, + name='group_snapshot') group_snapshot = self._create_group_snapshot( group_id=grp['id'], name=group_snapshot_name) snapshots = self.snapshots_client.list_snapshots( @@ -161,7 +164,8 @@ class GroupSnapshotsTest(BaseGroupSnapshotsTest): # Create volume is instance level, can not be deleted before group. # Volume delete handled by delete_group method, cleanup method. - params = {'name': data_utils.rand_name("volume"), + prefix = CONF.resource_name_prefix + params = {'name': data_utils.rand_name(prefix=prefix, name="volume"), 'volume_type': volume_type['id'], 'group_id': grp['id'], 'size': CONF.volume.volume_size} @@ -170,7 +174,8 @@ class GroupSnapshotsTest(BaseGroupSnapshotsTest): self.volumes_client, vol['id'], 'available') # Create group_snapshot - group_snapshot_name = data_utils.rand_name('group_snapshot') + group_snapshot_name = data_utils.rand_name(prefix=prefix, + name='group_snapshot') group_snapshot = self._create_group_snapshot( group_id=grp['id'], name=group_snapshot_name) self.assertEqual(group_snapshot_name, group_snapshot['name']) @@ -182,7 +187,7 @@ class GroupSnapshotsTest(BaseGroupSnapshotsTest): self.snapshots_client, snap['id'], 'available') # Create Group from Group snapshot - grp_name2 = data_utils.rand_name('Group_from_snap') + grp_name2 = data_utils.rand_name(prefix=prefix, name='Group_from_snap') grp2 = self.groups_client.create_group_from_source( group_snapshot_id=group_snapshot['id'], name=grp_name2)['group'] self.addCleanup(self.delete_group, grp2['id']) @@ -219,7 +224,7 @@ class GroupSnapshotsTest(BaseGroupSnapshotsTest): # Create a volume group grp = self.create_group(group_type=group_type['id'], volume_types=[volume_type['id']]) - + prefix = CONF.resource_name_prefix # Note: When dealing with consistency groups all volumes must # reside on the same backend. Adding volumes to the same consistency # group from multiple backends isn't supported. In order to ensure all @@ -229,7 +234,8 @@ class GroupSnapshotsTest(BaseGroupSnapshotsTest): for _ in range(2): # Create volume is instance level, can't be deleted before group. # Volume delete handled by delete_group method, cleanup method. - params = {'name': data_utils.rand_name("volume"), + params = {'name': data_utils.rand_name(prefix=prefix, + name="volume"), 'volume_type': volume_type['id'], 'group_id': grp['id'], 'size': CONF.volume.volume_size} @@ -287,9 +293,10 @@ class GroupSnapshotsV319Test(BaseGroupSnapshotsTest): group = self.create_group(group_type=group_type['id'], volume_types=[volume_type['id']]) + prefix = CONF.resource_name_prefix # Create volume is instance level, can not be deleted before group. # Volume delete handled by delete_group method, cleanup method. - params = {'name': data_utils.rand_name("volume"), + params = {'name': data_utils.rand_name(prefix=prefix, name="volume"), 'volume_type': volume_type['id'], 'group_id': group['id'], 'size': CONF.volume.volume_size} diff --git a/tempest/api/volume/admin/test_group_types.py b/tempest/api/volume/admin/test_group_types.py index 406af27354..03ff340ca4 100644 --- a/tempest/api/volume/admin/test_group_types.py +++ b/tempest/api/volume/admin/test_group_types.py @@ -14,9 +14,12 @@ # under the License. from tempest.api.volume import base +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators +CONF = config.CONF + class GroupTypesTest(base.BaseVolumeAdminTest): """Test group types""" @@ -27,8 +30,12 @@ class GroupTypesTest(base.BaseVolumeAdminTest): @decorators.idempotent_id('dd71e5f9-393e-4d4f-90e9-fa1b8d278864') def test_group_type_create_list_update_show_delete(self): """Test create/list/update/show/delete group type""" - name = data_utils.rand_name(self.__class__.__name__ + '-group-type') - description = data_utils.rand_name("group-type-description") + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-group-type') + description = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name="group-type-description") group_specs = {"consistent_group_snapshot_enabled": " False"} params = {'name': name, 'description': description, @@ -50,7 +57,8 @@ class GroupTypesTest(base.BaseVolumeAdminTest): update_params = { 'name': data_utils.rand_name( - self.__class__.__name__ + '-updated-group-type'), + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-updated-group-type'), 'description': 'updated-group-type-desc' } updated_group_type = self.admin_group_types_client.update_group_type( @@ -75,8 +83,10 @@ class GroupTypesTest(base.BaseVolumeAdminTest): @decorators.idempotent_id('3d5e5cec-72b4-4511-b135-7cc2b7a053ae') def test_group_type_list_by_optional_params(self): """Test list group type sort/public""" - type_a_name = "a_{}".format(data_utils.rand_name('group-type')) - type_b_name = "b_{}".format(data_utils.rand_name('group-type')) + type_a_name = "a_{}".format(data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='group-type')) + type_b_name = "b_{}".format(data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='group-type')) self.create_group_type(name=type_a_name, **{'is_public': True}) self.create_group_type(name=type_b_name, **{'is_public': False}) diff --git a/tempest/api/volume/admin/test_groups.py b/tempest/api/volume/admin/test_groups.py index 094f1424c5..8f74769d5e 100644 --- a/tempest/api/volume/admin/test_groups.py +++ b/tempest/api/volume/admin/test_groups.py @@ -38,20 +38,23 @@ class GroupsTest(base.BaseVolumeAdminTest): group_type = self.create_group_type() # Create group - grp1_name = data_utils.rand_name('Group1') + grp1_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='Group1') grp1 = self.create_group(group_type=group_type['id'], volume_types=[volume_type['id']], name=grp1_name) grp1_id = grp1['id'] - grp2_name = data_utils.rand_name('Group2') + grp2_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='Group2') grp2 = self.create_group(group_type=group_type['id'], volume_types=[volume_type['id']], name=grp2_name) grp2_id = grp2['id'] # Create volume - vol1_name = data_utils.rand_name("volume") + vol1_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name="volume") params = {'name': vol1_name, 'volume_type': volume_type['id'], 'group_id': grp1['id'], @@ -108,11 +111,13 @@ class GroupsTest(base.BaseVolumeAdminTest): grp = self.create_group(group_type=group_type['id'], volume_types=[volume_type['id']]) + prefix = CONF.resource_name_prefix # Create volume is instance level, can not be deleted before group. # Volume delete handled by delete_group method, cleanup method. grp_vols = [] for _ in range(2): - params = {'name': data_utils.rand_name("volume"), + params = {'name': data_utils.rand_name(prefix=prefix, + name="volume"), 'volume_type': volume_type['id'], 'group_id': grp['id'], 'size': CONF.volume.volume_size} @@ -177,9 +182,10 @@ class GroupsV314Test(base.BaseVolumeAdminTest): grp = self.create_group(group_type=group_type['id'], volume_types=[volume_type['id']]) + prefix = CONF.resource_name_prefix # Create volume is instance level, can not be deleted before group. # Volume delete handled by delete_group method, cleanup method. - params = {'name': data_utils.rand_name("volume"), + params = {'name': data_utils.rand_name(prefix=prefix, name="volume"), 'volume_type': volume_type['id'], 'group_id': grp['id'], 'size': CONF.volume.volume_size} @@ -188,7 +194,7 @@ class GroupsV314Test(base.BaseVolumeAdminTest): self.volumes_client, vol['id'], 'available') # Create Group from Group - grp_name2 = data_utils.rand_name('Group_from_grp') + grp_name2 = data_utils.rand_name(prefix=prefix, name='Group_from_grp') grp2 = self.groups_client.create_group_from_source( source_group_id=grp['id'], name=grp_name2)['group'] self.addCleanup(self.delete_group, grp2['id']) diff --git a/tempest/api/volume/admin/test_multi_backend.py b/tempest/api/volume/admin/test_multi_backend.py index 83733bda4b..028bf1a9c5 100644 --- a/tempest/api/volume/admin/test_multi_backend.py +++ b/tempest/api/volume/admin/test_multi_backend.py @@ -54,8 +54,12 @@ class VolumeMultiBackendTest(base.BaseVolumeAdminTest): @classmethod def _create_type_and_volume(cls, backend_name_key, with_prefix): # Volume/Type creation - type_name = data_utils.rand_name(cls.__name__ + '-Type') - vol_name = data_utils.rand_name(cls.__name__ + '-Volume') + type_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=cls.__name__ + '-Type') + vol_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=cls.__name__ + '-Volume') spec_key_with_prefix = "capabilities:volume_backend_name" spec_key_without_prefix = "volume_backend_name" if with_prefix: diff --git a/tempest/api/volume/admin/test_qos.py b/tempest/api/volume/admin/test_qos.py index e31c0ef291..83f7e21a62 100644 --- a/tempest/api/volume/admin/test_qos.py +++ b/tempest/api/volume/admin/test_qos.py @@ -14,9 +14,12 @@ from tempest.api.volume import base from tempest.common import waiters +from tempest import config from tempest.lib.common.utils import data_utils as utils from tempest.lib import decorators +CONF = config.CONF + class QosSpecsTestJSON(base.BaseVolumeAdminTest): """Test the Cinder QoS-specs. @@ -30,7 +33,8 @@ class QosSpecsTestJSON(base.BaseVolumeAdminTest): super(QosSpecsTestJSON, cls).resource_setup() # Create admin qos client # Create a test shared qos-specs for tests - cls.qos_name = utils.rand_name(cls.__name__ + '-QoS') + cls.qos_name = utils.rand_name( + cls.__name__ + '-QoS', prefix=CONF.resource_name_prefix) cls.qos_consumer = 'front-end' cls.created_qos = cls.create_test_qos_specs(cls.qos_name, @@ -38,7 +42,8 @@ class QosSpecsTestJSON(base.BaseVolumeAdminTest): read_iops_sec='2000') def _create_delete_test_qos_with_given_consumer(self, consumer): - name = utils.rand_name(self.__class__.__name__ + '-qos') + name = utils.rand_name( + self.__class__.__name__ + '-qos', prefix=CONF.resource_name_prefix) qos = {'name': name, 'consumer': consumer} body = self.create_test_qos_specs(name, consumer) for key in ['name', 'consumer']: diff --git a/tempest/api/volume/admin/test_snapshot_manage.py b/tempest/api/volume/admin/test_snapshot_manage.py index 478bd160c3..aed1010611 100644 --- a/tempest/api/volume/admin/test_snapshot_manage.py +++ b/tempest/api/volume/admin/test_snapshot_manage.py @@ -77,10 +77,12 @@ class SnapshotManageAdminTest(base.BaseVolumeAdminTest): self.assertNotIn(snapshot['id'], [v['id'] for v in all_snapshots]) # Manage the snapshot - name = data_utils.rand_name(self.__class__.__name__ + - '-Managed-Snapshot') - description = data_utils.rand_name(self.__class__.__name__ + - '-Managed-Snapshot-Description') + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-Managed-Snapshot') + description = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-Managed-Snapshot-Description') metadata = {"manage-snap-meta1": "value1", "manage-snap-meta2": "value2", "manage-snap-meta3": "value3"} diff --git a/tempest/api/volume/admin/test_user_messages.py b/tempest/api/volume/admin/test_user_messages.py index 00b7f3afa8..3443b870a6 100644 --- a/tempest/api/volume/admin/test_user_messages.py +++ b/tempest/api/volume/admin/test_user_messages.py @@ -29,12 +29,16 @@ class UserMessagesTest(base.BaseVolumeAdminTest): def _create_user_message(self): """Trigger a 'no valid host' situation to generate a message.""" - bad_protocol = data_utils.rand_name('storage_protocol') - bad_vendor = data_utils.rand_name('vendor_name') + bad_protocol = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name='storage_protocol') + bad_vendor = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='vendor_name') extra_specs = {'storage_protocol': bad_protocol, 'vendor_name': bad_vendor} vol_type_name = data_utils.rand_name( - self.__class__.__name__ + '-volume-type') + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-volume-type') bogus_type = self.create_volume_type( name=vol_type_name, extra_specs=extra_specs) params = {'volume_type': bogus_type['id'], diff --git a/tempest/api/volume/admin/test_volume_manage.py b/tempest/api/volume/admin/test_volume_manage.py index 1e4e7cb35c..609ec15f24 100644 --- a/tempest/api/volume/admin/test_volume_manage.py +++ b/tempest/api/volume/admin/test_volume_manage.py @@ -58,7 +58,8 @@ class VolumeManageAdminTest(base.BaseVolumeAdminTest): # Manage volume new_vol_name = data_utils.rand_name( - self.__class__.__name__ + '-volume') + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-volume') new_vol_ref = { 'name': new_vol_name, 'host': org_vol_info['os-vol-host-attr:host'], diff --git a/tempest/api/volume/admin/test_volume_quota_classes.py b/tempest/api/volume/admin/test_volume_quota_classes.py index f482788098..fb2adc7936 100644 --- a/tempest/api/volume/admin/test_volume_quota_classes.py +++ b/tempest/api/volume/admin/test_volume_quota_classes.py @@ -21,9 +21,11 @@ from testtools import matchers from tempest.api.volume import base from tempest.common import identity from tempest.common import tempest_fixtures as fixtures +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators +CONF = config.CONF LOG = logging.getLogger(__name__) QUOTA_KEYS = ['gigabytes', 'snapshots', 'volumes', 'backups', 'backup_gigabytes', 'per_volume_gigabytes'] @@ -96,8 +98,11 @@ class VolumeQuotaClassesTest(base.BaseVolumeAdminTest): matchers.ContainsAll(update_kwargs.items())) # Verify a new project's default quotas. - project_name = data_utils.rand_name('quota_class_tenant') - description = data_utils.rand_name('desc_') + project_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name='quota_class_tenant') + description = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='desc_') project_id = identity.identity_utils(self.os_admin).create_project( name=project_name, description=description)['id'] self.addCleanup(identity.identity_utils(self.os_admin).delete_project, diff --git a/tempest/api/volume/admin/test_volume_types.py b/tempest/api/volume/admin/test_volume_types.py index 98ae83b862..5b17afb59e 100644 --- a/tempest/api/volume/admin/test_volume_types.py +++ b/tempest/api/volume/admin/test_volume_types.py @@ -36,7 +36,9 @@ class VolumeTypesTest(base.BaseVolumeAdminTest): def test_volume_crud_with_volume_type_and_extra_specs(self): """Test create/update/get/delete volume with volume_type""" volume_types = list() - vol_name = data_utils.rand_name(self.__class__.__name__ + '-volume') + vol_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-volume') proto = CONF.volume.storage_protocol vendor = CONF.volume.vendor_name extra_specs = {"storage_protocol": proto, @@ -82,8 +84,12 @@ class VolumeTypesTest(base.BaseVolumeAdminTest): @decorators.idempotent_id('4e955c3b-49db-4515-9590-0c99f8e471ad') def test_volume_type_create_get_delete(self): """Test create/get/delete volume type""" - name = data_utils.rand_name(self.__class__.__name__ + '-volume-type') - description = data_utils.rand_name("volume-type-description") + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-volume-type') + description = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name="volume-type-description") proto = CONF.volume.storage_protocol vendor = CONF.volume.vendor_name extra_specs = {"storage_protocol": proto, @@ -183,8 +189,12 @@ class VolumeTypesTest(base.BaseVolumeAdminTest): volume_type = self.create_volume_type() # New volume type details - name = data_utils.rand_name("volume-type") - description = data_utils.rand_name("volume-type-description") + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name="volume-type") + description = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name="volume-type-description") is_public = not volume_type['is_public'] # Update volume type details diff --git a/tempest/api/volume/admin/test_volumes_backup.py b/tempest/api/volume/admin/test_volumes_backup.py index 835cc1d6d5..c1f753aafd 100644 --- a/tempest/api/volume/admin/test_volumes_backup.py +++ b/tempest/api/volume/admin/test_volumes_backup.py @@ -59,7 +59,9 @@ class VolumesBackupsAdminTest(base.BaseVolumeAdminTest): """ volume = self.create_volume() # Create backup - backup_name = data_utils.rand_name(self.__class__.__name__ + '-Backup') + backup_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-Backup') backup = self.create_backup(volume_id=volume['id'], name=backup_name) waiters.wait_for_volume_resource_status(self.volumes_client, volume['id'], 'available') @@ -124,7 +126,8 @@ class VolumesBackupsAdminTest(base.BaseVolumeAdminTest): volume = self.create_volume() # Create a backup backup_name = data_utils.rand_name( - self.__class__.__name__ + '-Backup') + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-Backup') backup = self.create_backup(volume_id=volume['id'], name=backup_name) waiters.wait_for_volume_resource_status(self.volumes_client, volume['id'], 'available') diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py index b9e1e58c37..53ffe7c444 100644 --- a/tempest/api/volume/base.py +++ b/tempest/api/volume/base.py @@ -120,7 +120,9 @@ class BaseVolumeTest(api_version_utils.BaseMicroversionTest, kwargs['size'] = max(kwargs['size'], min_disk) if 'name' not in kwargs: - name = data_utils.rand_name(self.__name__ + '-Volume') + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__name__ + '-Volume') kwargs['name'] = name if CONF.volume.volume_type and 'volume_type' not in kwargs: @@ -166,7 +168,9 @@ class BaseVolumeTest(api_version_utils.BaseMicroversionTest, def create_snapshot(self, volume_id=1, **kwargs): """Wrapper utility that returns a test snapshot.""" if 'name' not in kwargs: - name = data_utils.rand_name(self.__name__ + '-Snapshot') + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__name__ + '-Snapshot') kwargs['name'] = name snapshot = self.snapshots_client.create_snapshot( @@ -187,13 +191,17 @@ class BaseVolumeTest(api_version_utils.BaseMicroversionTest, if object_client is None: object_client = self.object_client if 'name' not in kwargs: - name = data_utils.rand_name(self.__class__.__name__ + '-Backup') + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-Backup') kwargs['name'] = name if CONF.volume.backup_driver == "swift": if 'container' not in kwargs: cont_name = self.__class__.__name__ + '-backup-container' - cont = data_utils.rand_name(cont_name) + cont = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=cont_name) kwargs['container'] = cont self.addCleanup(object_storage.delete_containers, @@ -246,7 +254,9 @@ class BaseVolumeTest(api_version_utils.BaseMicroversionTest, def create_server(self, wait_until='ACTIVE', **kwargs): name = kwargs.pop( 'name', - data_utils.rand_name(self.__class__.__name__ + '-instance')) + data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-instance')) if wait_until == 'SSHABLE' and not kwargs.get('validation_resources'): # If we were asked for SSHABLE but were not provided with the @@ -274,7 +284,8 @@ class BaseVolumeTest(api_version_utils.BaseMicroversionTest, def create_group(self, **kwargs): if 'name' not in kwargs: kwargs['name'] = data_utils.rand_name( - self.__class__.__name__ + '-Group') + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-Group') group = self.groups_client.create_group(**kwargs)['group'] self.addCleanup(test_utils.call_and_ignore_notfound_exc, @@ -337,7 +348,9 @@ class BaseVolumeAdminTest(BaseVolumeTest): @cleanup_order def create_test_qos_specs(self, name=None, consumer=None, **kwargs): """create a test Qos-Specs.""" - name = name or data_utils.rand_name(self.__name__ + '-QoS') + name = name or data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__name__ + '-QoS') consumer = consumer or 'front-end' qos_specs = self.admin_volume_qos_client.create_qos( name=name, consumer=consumer, **kwargs)['qos_specs'] @@ -347,7 +360,9 @@ class BaseVolumeAdminTest(BaseVolumeTest): @cleanup_order def create_volume_type(self, name=None, **kwargs): """Create a test volume-type""" - name = name or data_utils.rand_name(self.__name__ + '-volume-type') + name = name or data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__name__ + '-volume-type') volume_type = self.admin_volume_types_client.create_volume_type( name=name, **kwargs)['volume_type'] self.cleanup(self.clear_volume_type, volume_type['id']) @@ -377,7 +392,8 @@ class BaseVolumeAdminTest(BaseVolumeTest): def create_group_type(self, name=None, **kwargs): """Create a test group-type""" name = name or data_utils.rand_name( - self.__class__.__name__ + '-group-type') + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-group-type') group_type = self.admin_group_types_client.create_group_type( name=name, **kwargs)['group_type'] self.addCleanup(self.admin_group_types_client.delete_group_type, diff --git a/tempest/api/volume/test_volumes_actions.py b/tempest/api/volume/test_volumes_actions.py index 5b50bfa5ad..150677ddfa 100644 --- a/tempest/api/volume/test_volumes_actions.py +++ b/tempest/api/volume/test_volumes_actions.py @@ -109,7 +109,8 @@ class VolumesActionsTest(base.BaseVolumeTest): # it is shared with the other tests. After it is uploaded in Glance, # there is no way to delete it from Cinder, so we delete it from Glance # using the Glance images_client and from Cinder via tearDownClass. - image_name = data_utils.rand_name(self.__class__.__name__ + '-Image') + image_name = data_utils.rand_name(self.__class__.__name__ + '-Image', + prefix=CONF.resource_name_prefix) body = self.volumes_client.upload_volume( self.volume['id'], image_name=image_name, disk_format=CONF.volume.disk_format)['os-volume_upload_image'] diff --git a/tempest/api/volume/test_volumes_backup.py b/tempest/api/volume/test_volumes_backup.py index c775292ad7..2810440484 100644 --- a/tempest/api/volume/test_volumes_backup.py +++ b/tempest/api/volume/test_volumes_backup.py @@ -74,11 +74,15 @@ class VolumesBackupsTest(base.BaseVolumeTest): # Create a backup kwargs = {} kwargs["name"] = data_utils.rand_name( - self.__class__.__name__ + '-Backup') - kwargs["description"] = data_utils.rand_name("backup-description") + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-Backup') + kwargs["description"] = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name="backup-description") if CONF.volume.backup_driver == "swift": kwargs["container"] = data_utils.rand_name( - self.__class__.__name__ + '-Backup-container') + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-Backup-container') backup = self.create_backup(volume_id=volume['id'], **kwargs) self.assertEqual(kwargs["name"], backup['name']) waiters.wait_for_volume_resource_status(self.volumes_client, @@ -128,7 +132,8 @@ class VolumesBackupsTest(base.BaseVolumeTest): self.attach_volume(server['id'], volume['id']) # Create backup using force flag backup_name = data_utils.rand_name( - self.__class__.__name__ + '-Backup') + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-Backup') backup = self.create_backup(volume_id=volume['id'], name=backup_name, force=True) waiters.wait_for_volume_resource_status(self.volumes_client, @@ -191,8 +196,12 @@ class VolumesBackupsV39Test(base.BaseVolumeTest): # Update backup and assert response body for update_backup method update_kwargs = { - 'name': data_utils.rand_name(self.__class__.__name__ + '-Backup'), - 'description': data_utils.rand_name("volume-backup-description") + 'name': data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-Backup'), + 'description': data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name="volume-backup-description") } update_backup = self.backups_client.update_backup( backup['id'], **update_kwargs)['backup'] diff --git a/tempest/api/volume/test_volumes_get.py b/tempest/api/volume/test_volumes_get.py index 2009970344..9b79f381c4 100644 --- a/tempest/api/volume/test_volumes_get.py +++ b/tempest/api/volume/test_volumes_get.py @@ -31,7 +31,9 @@ class VolumesGetTest(base.BaseVolumeTest): def _volume_create_get_update_delete(self, **kwargs): # Create a volume, Get it's details and Delete the volume - v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume') + v_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-Volume') metadata = {'Type': 'Test'} # Create a volume kwargs['name'] = v_name @@ -71,7 +73,8 @@ class VolumesGetTest(base.BaseVolumeTest): self.volumes_client.update_volume(volume['id'], **params) # Test volume update when display_name is new new_v_name = data_utils.rand_name( - self.__class__.__name__ + '-new-Volume') + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-new-Volume') new_desc = 'This is the new description of volume' params = {'name': new_v_name, 'description': new_desc} @@ -94,7 +97,9 @@ class VolumesGetTest(base.BaseVolumeTest): # Test volume create when display_name is none and display_description # contains specific characters, # then test volume update if display_name is duplicated - new_v_desc = data_utils.rand_name('@#$%^* description') + new_v_desc = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name='@#$%^* description') params = {'description': new_v_desc, 'availability_zone': volume['availability_zone'], 'size': CONF.volume.volume_size} diff --git a/tempest/api/volume/test_volumes_negative.py b/tempest/api/volume/test_volumes_negative.py index d9b8430a22..d8480df16d 100644 --- a/tempest/api/volume/test_volumes_negative.py +++ b/tempest/api/volume/test_volumes_negative.py @@ -39,7 +39,9 @@ class VolumesNegativeTest(base.BaseVolumeTest): def create_image(self): # Create image - image_name = data_utils.rand_name(self.__class__.__name__ + "-image") + image_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + "-image") image = self.images_client.create_image( name=image_name, container_format=CONF.image.container_formats[0], @@ -133,8 +135,11 @@ class VolumesNegativeTest(base.BaseVolumeTest): @decorators.idempotent_id('e66e40d6-65e6-4e75-bdc7-636792fa152d') def test_update_volume_with_invalid_volume_id(self): """Test updating volume with invalid volume id should fail""" - self.assertRaises(lib_exc.NotFound, self.volumes_client.update_volume, - volume_id=data_utils.rand_name('invalid'), name="n") + self.assertRaises( + lib_exc.NotFound, self.volumes_client.update_volume, + volume_id=data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name='invalid'), name="n") @decorators.attr(type=['negative']) @decorators.idempotent_id('72aeca85-57a5-4c1f-9057-f320f9ea575b') @@ -147,8 +152,10 @@ class VolumesNegativeTest(base.BaseVolumeTest): @decorators.idempotent_id('30799cfd-7ee4-446c-b66c-45b383ed211b') def test_get_invalid_volume_id(self): """Test getting volume with invalid volume id should fail""" - self.assertRaises(lib_exc.NotFound, self.volumes_client.show_volume, - data_utils.rand_name('invalid')) + self.assertRaises( + lib_exc.NotFound, self.volumes_client.show_volume, + data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='invalid')) @decorators.attr(type=['negative']) @decorators.idempotent_id('c6c3db06-29ad-4e91-beb0-2ab195fe49e3') @@ -161,8 +168,10 @@ class VolumesNegativeTest(base.BaseVolumeTest): @decorators.idempotent_id('1f035827-7c32-4019-9240-b4ec2dbd9dfd') def test_delete_invalid_volume_id(self): """Test deleting volume with invalid volume id should fail""" - self.assertRaises(lib_exc.NotFound, self.volumes_client.delete_volume, - data_utils.rand_name('invalid')) + self.assertRaises( + lib_exc.NotFound, self.volumes_client.delete_volume, + data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='invalid')) @decorators.attr(type=['negative']) @decorators.idempotent_id('441a1550-5d44-4b30-af0f-a6d402f52026') @@ -268,7 +277,9 @@ class VolumesNegativeTest(base.BaseVolumeTest): @decorators.idempotent_id('0f4aa809-8c7b-418f-8fb3-84c7a5dfc52f') def test_list_volumes_with_nonexistent_name(self): """Test listing volumes with non existent name should get nothing""" - v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume') + v_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-Volume') params = {'name': v_name} fetched_volume = self.volumes_client.list_volumes( params=params)['volumes'] @@ -281,7 +292,9 @@ class VolumesNegativeTest(base.BaseVolumeTest): Listing volume details with non existent name should get nothing. """ - v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume') + v_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-Volume') params = {'name': v_name} fetched_volume = \ self.volumes_client.list_volumes( diff --git a/tempest/api/volume/test_volumes_snapshots.py b/tempest/api/volume/test_volumes_snapshots.py index 95521e7e06..35afffd2c2 100644 --- a/tempest/api/volume/test_volumes_snapshots.py +++ b/tempest/api/volume/test_volumes_snapshots.py @@ -132,7 +132,8 @@ class VolumesSnapshotTestJSON(base.BaseVolumeTest): # Updates snapshot with new values new_s_name = data_utils.rand_name( - self.__class__.__name__ + '-new-snap') + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-new-snap') new_desc = 'This is the new description of snapshot.' params = {'name': new_s_name, 'description': new_desc} diff --git a/tempest/api/volume/test_volumes_snapshots_negative.py b/tempest/api/volume/test_volumes_snapshots_negative.py index 9c36dc64de..364c5a890f 100644 --- a/tempest/api/volume/test_volumes_snapshots_negative.py +++ b/tempest/api/volume/test_volumes_snapshots_negative.py @@ -32,7 +32,9 @@ class VolumesSnapshotNegativeTestJSON(base.BaseVolumeTest): @decorators.idempotent_id('e3e466af-70ab-4f4b-a967-ab04e3532ea7') def test_create_snapshot_with_nonexistent_volume_id(self): """Test creating snapshot from non existent volume should fail""" - s_name = data_utils.rand_name(self.__class__.__name__ + '-snap') + s_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-snap') self.assertRaises(lib_exc.NotFound, self.snapshots_client.create_snapshot, volume_id=data_utils.rand_uuid(), @@ -43,7 +45,9 @@ class VolumesSnapshotNegativeTestJSON(base.BaseVolumeTest): def test_create_snapshot_without_passing_volume_id(self): """Test creating snapshot without passing volume_id should fail""" # Create a snapshot without passing volume id - s_name = data_utils.rand_name(self.__class__.__name__ + '-snap') + s_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-snap') self.assertRaises(lib_exc.NotFound, self.snapshots_client.create_snapshot, volume_id=None, display_name=s_name) diff --git a/tempest/common/compute.py b/tempest/common/compute.py index 1c0110f9f1..a8aafe93ae 100644 --- a/tempest/common/compute.py +++ b/tempest/common/compute.py @@ -196,7 +196,8 @@ def create_test_server(clients, validatable=False, validation_resources=None, """ if name is None: - name = data_utils.rand_name(__name__ + "-instance") + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name=__name__ + "-instance") if flavor is None: flavor = CONF.compute.flavor_ref if image_id is None: @@ -245,7 +246,8 @@ def create_test_server(clients, validatable=False, validation_resources=None, kwargs['user_data'] = script_b64 if volume_backed: - volume_name = data_utils.rand_name(__name__ + '-volume') + volume_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name=__name__ + '-volume') volumes_client = clients.volumes_client_latest params = {'name': volume_name, 'imageRef': image_id, diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py index 0450d9427b..5cf695401a 100644 --- a/tempest/scenario/manager.py +++ b/tempest/scenario/manager.py @@ -155,7 +155,8 @@ class ScenarioTest(tempest.test.BaseTestCase): if not client: client = self.ports_client name = data_utils.rand_name( - kwargs.pop('namestart', self.__class__.__name__)) + prefix=CONF.resource_name_prefix, + name=kwargs.pop('namestart', self.__class__.__name__)) if CONF.network.port_vnic_type and 'binding:vnic_type' not in kwargs: kwargs['binding:vnic_type'] = CONF.network.port_vnic_type if CONF.network.port_profile and 'binding:profile' not in kwargs: @@ -183,7 +184,9 @@ class ScenarioTest(tempest.test.BaseTestCase): if not client: client = self.keypairs_client if not kwargs.get('name'): - kwargs['name'] = data_utils.rand_name(self.__class__.__name__) + kwargs['name'] = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__) # We don't need to create a keypair by pubkey in scenario body = client.create_keypair(**kwargs) self.addCleanup(client.delete_keypair, kwargs['name']) @@ -246,7 +249,9 @@ class ScenarioTest(tempest.test.BaseTestCase): clients = self.os_primary if name is None: - name = data_utils.rand_name(self.__class__.__name__ + "-server") + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + "-server") vnic_type = kwargs.pop('vnic_type', CONF.network.port_vnic_type) profile = kwargs.pop('port_profile', CONF.network.port_profile) @@ -370,7 +375,9 @@ class ScenarioTest(tempest.test.BaseTestCase): min_disk = image.get('min_disk') size = max(size, min_disk) if name is None: - name = data_utils.rand_name(self.__class__.__name__ + "-volume") + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + "-volume") kwargs.update({'name': name, 'snapshot_id': snapshot_id, 'imageRef': imageRef, @@ -420,7 +427,8 @@ class ScenarioTest(tempest.test.BaseTestCase): """ name = name or data_utils.rand_name( - self.__class__.__name__ + "-backup") + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + "-backup") args = {'name': name, 'description': description, 'force': force, @@ -496,7 +504,8 @@ class ScenarioTest(tempest.test.BaseTestCase): """ name = name or data_utils.rand_name( - self.__class__.__name__ + '-snapshot') + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-snapshot') snapshot = self.snapshots_client.create_snapshot( volume_id=volume_id, force=force, @@ -557,8 +566,11 @@ class ScenarioTest(tempest.test.BaseTestCase): client = self.os_admin.volume_types_client_latest if not name: class_name = self.__class__.__name__ - name = data_utils.rand_name(class_name + '-volume-type') - randomized_name = data_utils.rand_name('scenario-type-' + name) + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=class_name + '-volume-type') + randomized_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='scenario-type-' + name) LOG.debug("Creating a volume type: %s on backend %s", randomized_name, backend_name) @@ -613,7 +625,8 @@ class ScenarioTest(tempest.test.BaseTestCase): client = self.security_groups_client if not project_id: project_id = client.project_id - sg_name = data_utils.rand_name(namestart) + sg_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name=namestart) sg_desc = sg_name + " description" sg_dict = dict(name=sg_name, description=sg_desc) @@ -782,7 +795,8 @@ class ScenarioTest(tempest.test.BaseTestCase): img_properties) if img_properties is None: img_properties = {} - name = data_utils.rand_name('%s-' % name) + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='%s-' % name) params = { 'name': name, 'container_format': img_container_format, @@ -833,7 +847,9 @@ class ScenarioTest(tempest.test.BaseTestCase): # Compute client _images_client = self.compute_images_client if name is None: - name = data_utils.rand_name(self.__class__.__name__ + 'snapshot') + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + 'snapshot') LOG.debug("Creating a snapshot image for server: %s", server['name']) image = _images_client.create_image(server['id'], name=name, **kwargs) # microversion 2.45 and above returns image_id @@ -1264,7 +1280,8 @@ class ScenarioTest(tempest.test.BaseTestCase): name = kwargs.pop('name', None) if not name: namestart = self.__class__.__name__ + '-volume-origin' - name = data_utils.rand_name(namestart) + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name=namestart) return self.create_volume(name=name, imageRef=image_id, **kwargs) @@ -1294,7 +1311,8 @@ class NetworkScenarioTest(ScenarioTest): networks_client = self.networks_client if not project_id: project_id = networks_client.project_id - name = data_utils.rand_name(namestart) + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name=namestart) network_kwargs = dict(name=name, project_id=project_id) if net_dict: network_kwargs.update(net_dict) @@ -1352,7 +1370,8 @@ class NetworkScenarioTest(ScenarioTest): ip_version, subnets_client, **kwargs): subnet = dict( - name=data_utils.rand_name(namestart), + name=data_utils.rand_name( + prefix=CONF.resource_name_prefix, name=namestart), network_id=network['id'], project_id=network['project_id'], ip_version=ip_version, @@ -1540,7 +1559,8 @@ class NetworkScenarioTest(ScenarioTest): name = kwargs.pop('name', None) if not name: namestart = self.__class__.__name__ + '-router' - name = data_utils.rand_name(namestart) + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name=namestart) ext_gw_info = kwargs.pop('external_gateway_info', None) if not ext_gw_info: @@ -1698,7 +1718,7 @@ class ObjectStorageScenarioTest(ScenarioTest): def create_container(self, container_name=None): """Creates container""" name = container_name or data_utils.rand_name( - 'swift-scenario-container') + prefix=CONF.resource_name_prefix, name='swift-scenario-container') self.container_client.update_container(name) # look for the container to assure it is created self.list_and_check_container_objects(name) @@ -1715,7 +1735,8 @@ class ObjectStorageScenarioTest(ScenarioTest): def upload_object_to_container(self, container_name, obj_name=None): """Uploads object to container""" - obj_name = obj_name or data_utils.rand_name('swift-scenario-object') + obj_name = obj_name or data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='swift-scenario-object') obj_data = data_utils.random_bytes() self.object_client.create_object(container_name, obj_name, obj_data) self.addCleanup(test_utils.call_and_ignore_notfound_exc, diff --git a/tempest/scenario/test_network_qos_placement.py b/tempest/scenario/test_network_qos_placement.py index 0b2cfcb6bd..dbbc314882 100644 --- a/tempest/scenario/test_network_qos_placement.py +++ b/tempest/scenario/test_network_qos_placement.py @@ -113,7 +113,8 @@ class MinBwAllocationPlacementTest(NetworkQoSPlacementTestBase): self, name_prefix, min_kbps, direction="ingress" ): policy = self.qos_client.create_qos_policy( - name=data_utils.rand_name(name_prefix), + name=data_utils.rand_name( + prefix=CONF.resource_name_prefix, name=name_prefix), shared=True)['policy'] self.addCleanup(test_utils.call_and_ignore_notfound_exc, self.qos_client.delete_qos_policy, policy['id']) @@ -600,7 +601,7 @@ class QoSBandwidthAndPacketRateTests(NetworkQoSPlacementTestBase): def _create_qos_policy_with_bw_and_pps_rules(self, min_kbps, min_kpps): policy = self.qos_client.create_qos_policy( - name=data_utils.rand_name(), + name=data_utils.rand_name(prefix=CONF.resource_name_prefix), shared=True )['policy'] self.addCleanup( @@ -660,10 +661,11 @@ class QoSBandwidthAndPacketRateTests(NetworkQoSPlacementTestBase): def _create_port_with_qos_policy(self, policy): port = self.ports_client.create_port( - name=data_utils.rand_name(self.__class__.__name__), + name=data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__), network_id=self.network['id'], - qos_policy_id=policy['id'] if policy else None, - )['port'] + qos_policy_id=policy['id'] if policy else None)['port'] self.addCleanup( test_utils.call_and_ignore_notfound_exc, self.ports_client.delete_port, port['id'] diff --git a/tempest/scenario/test_security_groups_basic_ops.py b/tempest/scenario/test_security_groups_basic_ops.py index 2fc5f328f2..752b854793 100644 --- a/tempest/scenario/test_security_groups_basic_ops.py +++ b/tempest/scenario/test_security_groups_basic_ops.py @@ -300,7 +300,8 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest): tenant=tenant.creds.tenant_name, num=i ) - name = data_utils.rand_name(name) + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name=name) server = self._create_server(name, tenant, [tenant.security_groups['default']]) tenant.servers.append(server) @@ -312,7 +313,8 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest): secgroups = tenant.security_groups.values() name = 'server-{tenant}-access_point'.format( tenant=tenant.creds.tenant_name) - name = data_utils.rand_name(name) + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name=name) server = self._create_server(name, tenant, security_groups=secgroups) tenant.access_point = server @@ -555,7 +557,8 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest): name = 'server-{tenant}-gen-1'.format( tenant=new_tenant.creds.tenant_name ) - name = data_utils.rand_name(name) + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name=name) server = self._create_server(name, new_tenant, [new_tenant.security_groups['default']]) @@ -624,7 +627,8 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest): name = 'server-{tenant}-gen-1'.format( tenant=new_tenant.creds.tenant_name ) - name = data_utils.rand_name(name) + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name=name) server = self._create_server(name, new_tenant, [new_tenant.security_groups['default']]) @@ -668,7 +672,8 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest): tenant = self.primary_tenant self._create_tenant_network(tenant, port_security_enabled=False) self.assertFalse(tenant.network['port_security_enabled']) - name = data_utils.rand_name('server-smoke') + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='server-smoke') sec_groups = [] server = self._create_server(name, tenant, sec_groups) server_id = server['id'] diff --git a/tempest/scenario/test_unified_limits.py b/tempest/scenario/test_unified_limits.py index 22256b409c..6e194f9550 100644 --- a/tempest/scenario/test_unified_limits.py +++ b/tempest/scenario/test_unified_limits.py @@ -71,7 +71,9 @@ class ImageQuotaTest(manager.ScenarioTest): """Wrapper that returns a test image.""" if 'name' not in kwargs: - name = data_utils.rand_name(self.__name__ + "-image") + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__name__ + "-image") kwargs['name'] = name params = dict(kwargs) diff --git a/tempest/scenario/test_volume_boot_pattern.py b/tempest/scenario/test_volume_boot_pattern.py index 6ebee48ffc..5e28ecd319 100644 --- a/tempest/scenario/test_volume_boot_pattern.py +++ b/tempest/scenario/test_volume_boot_pattern.py @@ -187,8 +187,9 @@ class TestVolumeBootPattern(manager.EncryptionScenarioTest): def test_image_defined_boot_from_volume(self): # create an instance from image-backed volume volume_origin = self.create_volume_from_image() - name = data_utils.rand_name(self.__class__.__name__ + - '-volume-backed-server') + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-volume-backed-server') instance1 = self.boot_instance_from_resource( source_id=volume_origin['id'], source_type='volume', @@ -205,8 +206,9 @@ class TestVolumeBootPattern(manager.EncryptionScenarioTest): # about the volume snapshot. The compute service will use this to # create a volume from the volume snapshot and use that as the root # disk for the server. - name = data_utils.rand_name(self.__class__.__name__ + - '-image-snapshot-server') + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__ + '-image-snapshot-server') instance2 = self.create_server(image_id=image['id'], name=name, wait_until='SSHABLE') diff --git a/tempest/serial_tests/api/admin/test_aggregates.py b/tempest/serial_tests/api/admin/test_aggregates.py index 2ca91aacec..cedeec0635 100644 --- a/tempest/serial_tests/api/admin/test_aggregates.py +++ b/tempest/serial_tests/api/admin/test_aggregates.py @@ -63,7 +63,9 @@ class AggregatesAdminTestBase(base.BaseV2ComputeAdminTest): def _create_test_aggregate(self, **kwargs): if 'name' not in kwargs: - kwargs['name'] = data_utils.rand_name(self.aggregate_name_prefix) + kwargs['name'] = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.aggregate_name_prefix) aggregate = self.client.create_aggregate(**kwargs)['aggregate'] self.addCleanup(test_utils.call_and_ignore_notfound_exc, self.client.delete_aggregate, aggregate['id']) @@ -87,7 +89,8 @@ class AggregatesAdminTestJSON(AggregatesAdminTestBase): @decorators.idempotent_id('5873a6f8-671a-43ff-8838-7ce430bb6d0b') def test_aggregate_create_delete_with_az(self): """Test create/delete aggregate with availability_zone""" - az_name = data_utils.rand_name(self.az_name_prefix) + az_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name=self.az_name_prefix) aggregate = self._create_test_aggregate(availability_zone=az_name) self.assertEqual(az_name, aggregate['availability_zone']) @@ -125,8 +128,10 @@ class AggregatesAdminTestJSON(AggregatesAdminTestBase): @decorators.idempotent_id('4d2b2004-40fa-40a1-aab2-66f4dab81beb') def test_aggregate_create_update_with_az(self): """Test create/update aggregate with availability_zone""" - aggregate_name = data_utils.rand_name(self.aggregate_name_prefix) - az_name = data_utils.rand_name(self.az_name_prefix) + aggregate_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name=self.aggregate_name_prefix) + az_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name=self.az_name_prefix) aggregate = self._create_test_aggregate( name=aggregate_name, availability_zone=az_name) @@ -153,7 +158,8 @@ class AggregatesAdminTestJSON(AggregatesAdminTestBase): def test_aggregate_add_remove_host(self): """Test adding host to and removing host from aggregate""" self.useFixture(fixtures.LockFixture('availability_zone')) - aggregate_name = data_utils.rand_name(self.aggregate_name_prefix) + aggregate_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name=self.aggregate_name_prefix) aggregate = self._create_test_aggregate(name=aggregate_name) body = (self.client.add_host(aggregate['id'], host=self.host) @@ -177,7 +183,8 @@ class AggregatesAdminTestJSON(AggregatesAdminTestBase): Add a host to the given aggregate and list. """ self.useFixture(fixtures.LockFixture('availability_zone')) - aggregate_name = data_utils.rand_name(self.aggregate_name_prefix) + aggregate_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name=self.aggregate_name_prefix) aggregate = self._create_test_aggregate(name=aggregate_name) self.client.add_host(aggregate['id'], host=self.host) @@ -199,7 +206,8 @@ class AggregatesAdminTestJSON(AggregatesAdminTestBase): Add a host to the given aggregate and get details. """ self.useFixture(fixtures.LockFixture('availability_zone')) - aggregate_name = data_utils.rand_name(self.aggregate_name_prefix) + aggregate_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name=self.aggregate_name_prefix) aggregate = self._create_test_aggregate(name=aggregate_name) self.client.add_host(aggregate['id'], host=self.host) @@ -215,7 +223,8 @@ class AggregatesAdminTestJSON(AggregatesAdminTestBase): def test_aggregate_add_host_create_server_with_az(self): """Test adding a host to the given aggregate and creating a server""" self.useFixture(fixtures.LockFixture('availability_zone')) - az_name = data_utils.rand_name(self.az_name_prefix) + az_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name=self.az_name_prefix) aggregate = self._create_test_aggregate(availability_zone=az_name) # Find a host that has not been added to other availability zone, @@ -269,7 +278,8 @@ class AggregatesAdminTestV241(AggregatesAdminTestBase): # Checking create aggregate API response schema aggregate = self._create_test_aggregate() - new_aggregate_name = data_utils.rand_name(self.aggregate_name_prefix) + new_aggregate_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name=self.aggregate_name_prefix) # Checking update aggregate API response schema self.client.update_aggregate(aggregate['id'], name=new_aggregate_name) # Checking show aggregate API response schema diff --git a/tempest/serial_tests/scenario/test_aggregates_basic_ops.py b/tempest/serial_tests/scenario/test_aggregates_basic_ops.py index ba31d846e5..a831fe5706 100644 --- a/tempest/serial_tests/scenario/test_aggregates_basic_ops.py +++ b/tempest/serial_tests/scenario/test_aggregates_basic_ops.py @@ -15,10 +15,13 @@ from tempest.common import tempest_fixtures as fixtures from tempest.common import utils +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators from tempest.scenario import manager +CONF = config.CONF + @decorators.serial class TestAggregatesBasicOps(manager.ScenarioTest): @@ -119,7 +122,8 @@ class TestAggregatesBasicOps(manager.ScenarioTest): def test_aggregate_basic_ops(self): self.useFixture(fixtures.LockFixture('availability_zone')) az = 'foo_zone' - aggregate_name = data_utils.rand_name('aggregate-scenario') + aggregate_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, name='aggregate-scenario') aggregate = self._create_aggregate(name=aggregate_name, availability_zone=az) @@ -131,7 +135,9 @@ class TestAggregatesBasicOps(manager.ScenarioTest): self._check_aggregate_details(aggregate, aggregate_name, az, [host], metadata) - aggregate_name = data_utils.rand_name('renamed-aggregate-scenario') + aggregate_name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name='renamed-aggregate-scenario') # Updating the name alone. The az must be specified again otherwise # the tempest client would send None in the put body aggregate = self._update_aggregate(aggregate, aggregate_name, az)