Merge "Remove create_volume & create_volume_type"

This commit is contained in:
Zuul 2024-12-09 17:33:34 +00:00 committed by Gerrit Code Review
commit cfaba2898e
3 changed files with 2 additions and 56 deletions

View File

@ -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

View File

@ -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)

View File

@ -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"