diff --git a/tempest/api/compute/admin/test_keypairs_v210.py b/tempest/api/compute/admin/test_keypairs_v210.py index e24c7c1004..24ea8a1871 100644 --- a/tempest/api/compute/admin/test_keypairs_v210.py +++ b/tempest/api/compute/admin/test_keypairs_v210.py @@ -34,7 +34,8 @@ class KeyPairsV210TestJSON(base.BaseKeypairTest): k_name = data_utils.rand_name('keypair') keypair = self.create_keypair(k_name, keypair_type='ssh', - user_id=user_id) + user_id=user_id, + client=self.client) self.assertEqual(k_name, keypair['name'], "The created keypair name is not equal " "to the requested name!") @@ -56,7 +57,8 @@ class KeyPairsV210TestJSON(base.BaseKeypairTest): self.assertEqual(user_id, keypair_detail['user_id'], "The fetched keypair is not for requested user!") # Create a admin keypair - admin_keypair = self.create_keypair(keypair_type='ssh') + admin_keypair = self.create_keypair(keypair_type='ssh', + client=self.client) admin_keypair.pop('private_key', None) admin_keypair.pop('user_id') diff --git a/tempest/api/compute/keypairs/base.py b/tempest/api/compute/keypairs/base.py index 005181064f..44da88cfb3 100644 --- a/tempest/api/compute/keypairs/base.py +++ b/tempest/api/compute/keypairs/base.py @@ -20,17 +20,16 @@ from tempest.lib.common.utils import data_utils class BaseKeypairTest(base.BaseV2ComputeTest): """Base test case class for all keypair API tests.""" - @classmethod - def setup_clients(cls): - super(BaseKeypairTest, cls).setup_clients() - cls.client = cls.keypairs_client - - def _delete_keypair(self, keypair_name, **params): - self.client.delete_keypair(keypair_name, **params) + def _delete_keypair(self, keypair_name, client=None, **params): + if not client: + client = self.keypairs_client + client.delete_keypair(keypair_name, **params) def create_keypair(self, keypair_name=None, pub_key=None, keypair_type=None, - user_id=None): + user_id=None, client=None): + if not client: + client = self.keypairs_client if keypair_name is None: keypair_name = data_utils.rand_name( self.__class__.__name__ + '-keypair') @@ -43,6 +42,7 @@ class BaseKeypairTest(base.BaseV2ComputeTest): if user_id: kwargs.update({'user_id': user_id}) delete_params['user_id'] = user_id - body = self.client.create_keypair(**kwargs)['keypair'] - self.addCleanup(self._delete_keypair, keypair_name, **delete_params) + body = client.create_keypair(**kwargs)['keypair'] + self.addCleanup(self._delete_keypair, keypair_name, + client, **delete_params) return body diff --git a/tempest/api/compute/keypairs/test_keypairs.py b/tempest/api/compute/keypairs/test_keypairs.py index 3a54d51aec..66abb2168a 100644 --- a/tempest/api/compute/keypairs/test_keypairs.py +++ b/tempest/api/compute/keypairs/test_keypairs.py @@ -35,7 +35,7 @@ class KeyPairsV2TestJSON(base.BaseKeypairTest): key_list.append(keypair) # Fetch all keypairs and verify the list # has all created keypairs - fetched_list = self.client.list_keypairs()['keypairs'] + fetched_list = self.keypairs_client.list_keypairs()['keypairs'] new_list = list() for keypair in fetched_list: new_list.append(keypair['keypair']) @@ -61,7 +61,7 @@ class KeyPairsV2TestJSON(base.BaseKeypairTest): # Keypair should be created, Got details by name and deleted k_name = data_utils.rand_name('keypair') self.create_keypair(k_name) - keypair_detail = self.client.show_keypair(k_name)['keypair'] + keypair_detail = self.keypairs_client.show_keypair(k_name)['keypair'] self.assertEqual(keypair_detail['name'], k_name, "The created keypair name is not equal " "to requested name") diff --git a/tempest/api/compute/keypairs/test_keypairs_negative.py b/tempest/api/compute/keypairs/test_keypairs_negative.py index 205076c56d..f9050a87ea 100644 --- a/tempest/api/compute/keypairs/test_keypairs_negative.py +++ b/tempest/api/compute/keypairs/test_keypairs_negative.py @@ -34,7 +34,8 @@ class KeyPairsNegativeTestJSON(base.BaseKeypairTest): def test_keypair_delete_nonexistent_key(self): # Non-existent key deletion should throw a proper error k_name = data_utils.rand_name("keypair-non-existent") - self.assertRaises(lib_exc.NotFound, self.client.delete_keypair, + self.assertRaises(lib_exc.NotFound, + self.keypairs_client.delete_keypair, k_name) @decorators.attr(type=['negative']) @@ -58,11 +59,11 @@ class KeyPairsNegativeTestJSON(base.BaseKeypairTest): def test_create_keypair_with_duplicate_name(self): # Keypairs with duplicate names should not be created k_name = data_utils.rand_name('keypair') - self.client.create_keypair(name=k_name) + 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, k_name) - self.client.delete_keypair(k_name) + self.keypairs_client.delete_keypair(k_name) @decorators.attr(type=['negative']) @decorators.idempotent_id('1398abe1-4a84-45fb-9294-89f514daff00') diff --git a/tempest/api/compute/keypairs/test_keypairs_v22.py b/tempest/api/compute/keypairs/test_keypairs_v22.py index f39bb1212c..1aff262848 100644 --- a/tempest/api/compute/keypairs/test_keypairs_v22.py +++ b/tempest/api/compute/keypairs/test_keypairs_v22.py @@ -32,9 +32,9 @@ class KeyPairsV22TestJSON(test_keypairs.KeyPairsV2TestJSON): # Verify whether 'type' is present in keypair create response of # version 2.2 and it is with default value 'ssh'. self._check_keypair_type(keypair, keypair_type) - keypair_detail = self.client.show_keypair(k_name)['keypair'] + keypair_detail = self.keypairs_client.show_keypair(k_name)['keypair'] self._check_keypair_type(keypair_detail, keypair_type) - fetched_list = self.client.list_keypairs()['keypairs'] + fetched_list = self.keypairs_client.list_keypairs()['keypairs'] for keypair in fetched_list: # Verify whether 'type' is present in keypair list response of # version 2.2 and it is with default value 'ssh'. diff --git a/tempest/api/compute/servers/test_server_password.py b/tempest/api/compute/servers/test_server_password.py index e7591a5412..e6a668a514 100644 --- a/tempest/api/compute/servers/test_server_password.py +++ b/tempest/api/compute/servers/test_server_password.py @@ -20,11 +20,6 @@ from tempest.lib import decorators class ServerPasswordTestJSON(base.BaseV2ComputeTest): - @classmethod - def setup_clients(cls): - super(ServerPasswordTestJSON, cls).setup_clients() - cls.client = cls.servers_client - @classmethod def resource_setup(cls): super(ServerPasswordTestJSON, cls).resource_setup() @@ -32,8 +27,8 @@ class ServerPasswordTestJSON(base.BaseV2ComputeTest): @decorators.idempotent_id('f83b582f-62a8-4f22-85b0-0dee50ff783a') def test_get_server_password(self): - self.client.show_password(self.server['id']) + self.servers_client.show_password(self.server['id']) @decorators.idempotent_id('f8229e8b-b625-4493-800a-bde86ac611ea') def test_delete_server_password(self): - self.client.delete_password(self.server['id']) + self.servers_client.delete_password(self.server['id']) diff --git a/tempest/api/compute/servers/test_virtual_interfaces_negative.py b/tempest/api/compute/servers/test_virtual_interfaces_negative.py index 20923a819e..c4e2400c09 100644 --- a/tempest/api/compute/servers/test_virtual_interfaces_negative.py +++ b/tempest/api/compute/servers/test_virtual_interfaces_negative.py @@ -28,11 +28,6 @@ class VirtualInterfacesNegativeTestJSON(base.BaseV2ComputeTest): cls.set_network_resources() super(VirtualInterfacesNegativeTestJSON, cls).setup_credentials() - @classmethod - def setup_clients(cls): - super(VirtualInterfacesNegativeTestJSON, cls).setup_clients() - cls.client = cls.servers_client - @decorators.attr(type=['negative']) @decorators.idempotent_id('64ebd03c-1089-4306-93fa-60f5eb5c803c') @utils.services('network') @@ -41,5 +36,5 @@ class VirtualInterfacesNegativeTestJSON(base.BaseV2ComputeTest): # for an invalid server_id invalid_server_id = data_utils.rand_uuid() self.assertRaises(lib_exc.NotFound, - self.client.list_virtual_interfaces, + self.servers_client.list_virtual_interfaces, invalid_server_id)