From 0419088f9d24ef95adbb5cc5a26c02c639521c5f Mon Sep 17 00:00:00 2001 From: zhufl Date: Tue, 23 May 2017 10:21:48 +0800 Subject: [PATCH] Replace the usage of 'os' with 'os_primary' Read-only property 'os' has moved to 'os_primary' in version 'Pike' and will be removed in version 'Queens', so this is to replace the usage of 'os' with 'os_primary'. Change-Id: I9f7c13da05a8c4a63529c11aa6213a7269abee6d --- doc/source/write_tests.rst | 22 +++++++++---------- .../admin/test_auto_allocate_network.py | 4 ++-- tempest/api/compute/base.py | 2 +- .../compute/servers/test_attach_interfaces.py | 3 ++- .../compute/servers/test_multiple_create.py | 2 +- tempest/api/volume/base.py | 2 +- .../test_security_groups_basic_ops.py | 2 +- 7 files changed, 19 insertions(+), 18 deletions(-) diff --git a/doc/source/write_tests.rst b/doc/source/write_tests.rst index 2363fa66f7..4e3bfa2ec7 100644 --- a/doc/source/write_tests.rst +++ b/doc/source/write_tests.rst @@ -178,16 +178,16 @@ requested credentials you can reference: +-------------------+---------------------+ | Credentials Entry | Manager Variable | +===================+=====================+ -| primary | cls.os | +| primary | cls.os_primary | +-------------------+---------------------+ -| admin | cls.os_adm | +| admin | cls.os_admin | +-------------------+---------------------+ | alt | cls.os_alt | +-------------------+---------------------+ | [$label, $role] | cls.os_roles_$label | +-------------------+---------------------+ -By default cls.os is available since it is allocated in the base tempest test +By default cls.os_primary is available since it is allocated in the base tempest test class (located in tempest/test.py). If your TestCase inherits from a different direct parent class (it'll still inherit from the BaseTestCase, just not directly) be sure to check if that class overrides allocated credentials. @@ -270,13 +270,13 @@ call to create a server in Nova:: class TestExampleCase(test.BaseTestCase): def test_example_create_server(self): - self.os.servers_client.create_server(...) + self.os_primary.servers_client.create_server(...) -is all you need to do. As described previously, in the above example the ``self.os`` -is created automatically because the base test class sets the ``credentials`` -attribute to allocate a primary credential set and initializes the client -manager as ``self.os``. This same access pattern can be used for all of the -clients in Tempest. +is all you need to do. As described previously, in the above example the +``self.os_primary`` is created automatically because the base test class sets the +``credentials`` attribute to allocate a primary credential set and initializes +the client manager as ``self.os_primary``. This same access pattern can be used +for all of the clients in Tempest. Credentials Objects ------------------- @@ -293,7 +293,7 @@ object via the manager's ``credentials`` attribute. For example:: class TestExampleCase(test.BaseTestCase): def test_example_create_server(self): - credentials = self.os.credentials + credentials = self.os_primary.credentials The credentials object provides access to all of the credential information you would need to make API requests. For example, building off the previous @@ -304,7 +304,7 @@ example:: class TestExampleCase(test.BaseTestCase): def test_example_create_server(self): - credentials = self.os.credentials + credentials = self.os_primary.credentials username = credentials.username user_id = credentials.user_id password = credentials.password diff --git a/tempest/api/compute/admin/test_auto_allocate_network.py b/tempest/api/compute/admin/test_auto_allocate_network.py index c4db5e3998..ba8a21448d 100644 --- a/tempest/api/compute/admin/test_auto_allocate_network.py +++ b/tempest/api/compute/admin/test_auto_allocate_network.py @@ -151,7 +151,7 @@ class AutoAllocateNetworkTest(base.BaseV2ComputeTest): """Tests that no networking is allocated for the server.""" # create the server with no networking server, _ = compute.create_test_server( - self.os, networks='none', wait_until='ACTIVE') + self.os_primary, networks='none', wait_until='ACTIVE') self.addCleanup(self.delete_server, server['id']) # get the server ips addresses = self.servers_client.list_addresses( @@ -176,7 +176,7 @@ class AutoAllocateNetworkTest(base.BaseV2ComputeTest): # - Third request sees net1 and net2 for the tenant and fails with a # NetworkAmbiguous 400 error. _, servers = compute.create_test_server( - self.os, networks='auto', wait_until='ACTIVE', + self.os_primary, networks='auto', wait_until='ACTIVE', min_count=3) server_nets = set() for server in servers: diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py index 141b9f37da..c9d6f02868 100644 --- a/tempest/api/compute/base.py +++ b/tempest/api/compute/base.py @@ -204,7 +204,7 @@ class BaseV2ComputeTest(api_version_utils.BaseMicroversionTest, kwargs['name'] = data_utils.rand_name(cls.__name__ + "-server") tenant_network = cls.get_tenant_network() body, servers = compute.create_test_server( - cls.os, + cls.os_primary, validatable, validation_resources=cls.validation_resources, tenant_network=tenant_network, diff --git a/tempest/api/compute/servers/test_attach_interfaces.py b/tempest/api/compute/servers/test_attach_interfaces.py index e50b29a3d2..6c5cc792e3 100644 --- a/tempest/api/compute/servers/test_attach_interfaces.py +++ b/tempest/api/compute/servers/test_attach_interfaces.py @@ -264,7 +264,8 @@ class AttachInterfacesTestJSON(base.BaseV2ComputeTest): # create two servers _, servers = compute.create_test_server( - self.os, tenant_network=network, wait_until='ACTIVE', min_count=2) + self.os_primary, tenant_network=network, + wait_until='ACTIVE', min_count=2) # add our cleanups for the servers since we bypassed the base class for server in servers: self.addCleanup(self.delete_server, server['id']) diff --git a/tempest/api/compute/servers/test_multiple_create.py b/tempest/api/compute/servers/test_multiple_create.py index 7cbb513bf6..059454dd02 100644 --- a/tempest/api/compute/servers/test_multiple_create.py +++ b/tempest/api/compute/servers/test_multiple_create.py @@ -24,7 +24,7 @@ class MultipleCreateTestJSON(base.BaseV2ComputeTest): def test_multiple_create(self): tenant_network = self.get_tenant_network() body, servers = compute.create_test_server( - self.os, + self.os_primary, wait_until='ACTIVE', min_count=2, tenant_network=tenant_network) diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py index 3f33c7b697..eace92d116 100644 --- a/tempest/api/volume/base.py +++ b/tempest/api/volume/base.py @@ -224,7 +224,7 @@ class BaseVolumeTest(api_version_utils.BaseMicroversionTest, tenant_network = self.get_tenant_network() body, _ = compute.create_test_server( - self.os, + self.os_primary, tenant_network=tenant_network, name=name, **kwargs) diff --git a/tempest/scenario/test_security_groups_basic_ops.py b/tempest/scenario/test_security_groups_basic_ops.py index 2116fe8465..c25ce4ccf1 100644 --- a/tempest/scenario/test_security_groups_basic_ops.py +++ b/tempest/scenario/test_security_groups_basic_ops.py @@ -168,7 +168,7 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest): cls.floating_ips = {} cls.tenants = {} - cls.primary_tenant = cls.TenantProperties(cls.os) + cls.primary_tenant = cls.TenantProperties(cls.os_primary) cls.alt_tenant = cls.TenantProperties(cls.os_alt) for tenant in [cls.primary_tenant, cls.alt_tenant]: cls.tenants[tenant.creds.tenant_id] = tenant