From 94c16b1a5900a49edc9bcd407988879c633106c0 Mon Sep 17 00:00:00 2001 From: Roman Popelka Date: Tue, 22 Feb 2022 12:44:53 +0100 Subject: [PATCH] Remove _create_port and create_keypair methods As tempest.scenario.manager was announced stable interface in Tempest 27.0.0[1] it can be now reused in plugins. Replaced methods: * _create_port * create_keypair Etherpad concerning this effort: https://etherpad.opendev.org/p/tempest-scenario-manager-cleanup [1] https://docs.openstack.org/releasenotes/tempest/v27.0.0.html#release-notes-27-0-0 Change-Id: I800e55bb5a433961a96c57195fd806881caac4be --- .../tests/scenario/manager_freeze.py | 32 +++---------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/blazar_tempest_plugin/tests/scenario/manager_freeze.py b/blazar_tempest_plugin/tests/scenario/manager_freeze.py index 8695791..d1d678c 100644 --- a/blazar_tempest_plugin/tests/scenario/manager_freeze.py +++ b/blazar_tempest_plugin/tests/scenario/manager_freeze.py @@ -36,7 +36,7 @@ CONF = config.CONF LOG = log.getLogger(__name__) -class ScenarioTest(tempest.test.BaseTestCase): +class ScenarioTest(tempest.scenario.manager.ScenarioTest): """Base class for scenario tests. Uses tempest own clients. """ credentials = ['primary'] @@ -86,30 +86,6 @@ class ScenarioTest(tempest.test.BaseTestCase): # The create_[resource] functions only return body and discard the # resp part which is not used in scenario tests - def _create_port(self, network_id, client=None, namestart='port-quotatest', - **kwargs): - if not client: - client = self.ports_client - name = data_utils.rand_name(namestart) - result = client.create_port( - name=name, - network_id=network_id, - **kwargs) - self.assertIsNotNone(result, 'Unable to allocate port') - port = result['port'] - self.addCleanup(test_utils.call_and_ignore_notfound_exc, - client.delete_port, port['id']) - return port - - def create_keypair(self, client=None): - if not client: - client = self.keypairs_client - name = data_utils.rand_name(self.__class__.__name__) - # We don't need to create a keypair by pubkey in scenario - body = client.create_keypair(name=name) - self.addCleanup(client.delete_keypair, name) - return body['keypair'] - def create_server(self, name=None, image_id=None, flavor=None, validatable=False, wait_until='ACTIVE', clients=None, **kwargs): @@ -182,9 +158,9 @@ class ScenarioTest(tempest.test.BaseTestCase): for net in networks: net_id = net.get('uuid', net.get('id')) if 'port' not in net: - port = self._create_port(network_id=net_id, - client=clients.ports_client, - **create_port_body) + port = self.create_port(network_id=net_id, + client=clients.ports_client, + **create_port_body) ports.append({'port': port['id']}) else: ports.append({'port': net['port']})