From 7acd2287252ae4996b0e690caf961c256e6af1a1 Mon Sep 17 00:00:00 2001 From: Roman Popelka Date: Thu, 14 Apr 2022 15:17:13 +0200 Subject: [PATCH] Remove create_volume & create_volume_type As tempest.scenario.manager was announced stable interface in Tempest 27.0.0[1] it can be now reused in plugins. Remove methods: * create_volume * create_volume_type - not used 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: Ie6ac628cf26579b6368447d3c86ecabe390167d3 --- .../tests/scenario/manager.py | 54 ------------------- .../scenario/test_execute_storage_balance.py | 2 +- .../tests/scenario/test_execute_strategies.py | 2 +- 3 files changed, 2 insertions(+), 56 deletions(-) diff --git a/watcher_tempest_plugin/tests/scenario/manager.py b/watcher_tempest_plugin/tests/scenario/manager.py index be298d1..4c5a906 100644 --- a/watcher_tempest_plugin/tests/scenario/manager.py +++ b/watcher_tempest_plugin/tests/scenario/manager.py @@ -14,10 +14,7 @@ # License for the specific language governing permissions and limitations # under the License. -from tempest.common import waiters from tempest import config -from tempest.lib.common.utils import data_utils -from tempest.lib.common.utils import test_utils import tempest.scenario.manager CONF = config.CONF @@ -64,54 +61,3 @@ class ScenarioTest(tempest.scenario.manager.ScenarioTest): cls.volumes_client = cls.os_primary.volumes_client_latest cls.snapshots_client = cls.os_primary.snapshots_client_latest - - # ## Test functions library - # - # The create_[resource] functions only return body and discard the - # resp part which is not used in scenario tests - - def create_volume(self, name=None, imageRef=None, size=1, - volume_type=None, clients=None): - - if clients is None: - clients = self.os_primary - - if imageRef: - image = self.image_client.show_image(imageRef) - min_disk = image.get('min_disk') - size = max(size, min_disk) - - if name is None: - name = data_utils.rand_name(self.__class__.__name__ + "-volume") - volumes_client = clients.volumes_client_latest - params = {'name': name, - 'imageRef': imageRef, - 'volume_type': volume_type, - 'size': size or CONF.volume.volume_size} - volume = volumes_client.create_volume(**params)['volume'] - self.addCleanup(volumes_client.wait_for_resource_deletion, - volume['id']) - self.addCleanup(test_utils.call_and_ignore_notfound_exc, - volumes_client.delete_volume, volume['id']) - self.assertEqual(name, volume['name']) - waiters.wait_for_volume_resource_status(volumes_client, - volume['id'], 'available') - volume = volumes_client.show_volume(volume['id'])['volume'] - return volume - - def create_volume_type(self, clients=None, name=None, backend_name=None): - if clients is None: - clients = self.os_admin - if name is None: - class_name = self.__class__.__name__ - name = data_utils.rand_name(class_name + '-volume-type') - - volumes_client = clients.volume_types_client_latest - extra_specs = {} - if backend_name: - extra_specs = {"volume_backend_name": backend_name} - - volume_type = volumes_client.create_volume_type( - name=name, extra_specs=extra_specs)['volume_type'] - self.addCleanup(volumes_client.delete_volume_type, volume_type['id']) - return volume_type diff --git a/watcher_tempest_plugin/tests/scenario/test_execute_storage_balance.py b/watcher_tempest_plugin/tests/scenario/test_execute_storage_balance.py index 3ec6baf..b0ad716 100644 --- a/watcher_tempest_plugin/tests/scenario/test_execute_storage_balance.py +++ b/watcher_tempest_plugin/tests/scenario/test_execute_storage_balance.py @@ -51,7 +51,7 @@ class TestExecuteStorageCapacityBalanceStrategy( self.create_volume(imageRef=CONF.compute.image_ref, size=3) self.create_volume(imageRef=CONF.compute.image_ref, size=3) self.create_volume(imageRef=CONF.compute.image_ref, size=3) - self.create_volume(imageRef=CONF.compute.image_ref) + self.create_volume(imageRef=CONF.compute.image_ref, size=1) audit_parameters = {"volume_threshold": 25} _, goal = self.client.show_goal(self.GOAL) diff --git a/watcher_tempest_plugin/tests/scenario/test_execute_strategies.py b/watcher_tempest_plugin/tests/scenario/test_execute_strategies.py index b0f7bd1..bc92816 100644 --- a/watcher_tempest_plugin/tests/scenario/test_execute_strategies.py +++ b/watcher_tempest_plugin/tests/scenario/test_execute_strategies.py @@ -91,7 +91,7 @@ class TestExecuteStrategies(base.BaseInfraOptimScenarioTest): self.create_volume(imageRef=CONF.compute.image_ref, size=3) self.create_volume(imageRef=CONF.compute.image_ref, size=3) self.create_volume(imageRef=CONF.compute.image_ref, size=3) - self.create_volume(imageRef=CONF.compute.image_ref) + self.create_volume(imageRef=CONF.compute.image_ref, size=1) audit_parameters = {"volume_threshold": 25} goal_name = "workload_balancing"