Merge "allow passing of specific volume type"
This commit is contained in:
commit
ed7561f01a
@ -26,6 +26,7 @@ from rally.task import atomic
|
||||
from rally.task import types
|
||||
from rally.task import validation
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
"""Scenarios for Cinder Volumes."""
|
||||
|
||||
@ -396,11 +397,7 @@ class CreateSnapshotAndAttachVolume(cinder_utils.CinderScenario,
|
||||
def run(self, volume_type=False, size=None, **kwargs):
|
||||
"""Create volume, snapshot and attach/detach volume.
|
||||
|
||||
This scenario is based on the standalone qaStressTest.py
|
||||
(https://github.com/WaltHP/cinder-stress).
|
||||
|
||||
:param volume_type: Whether or not to specify volume type when creating
|
||||
volumes.
|
||||
:param volume_type: Name of volume type to use
|
||||
:param size: Volume size - dictionary, contains two values:
|
||||
min - minimum size volumes will be created as;
|
||||
max - maximum size volumes will be created as.
|
||||
@ -410,16 +407,17 @@ class CreateSnapshotAndAttachVolume(cinder_utils.CinderScenario,
|
||||
"""
|
||||
if size is None:
|
||||
size = {"min": 1, "max": 5}
|
||||
selected_type = None
|
||||
volume_types = [None]
|
||||
|
||||
if volume_type:
|
||||
if isinstance(volume_type, bool):
|
||||
LOG.warning("Selecting a random volume type is deprecated"
|
||||
"as of Rally 0.7.0")
|
||||
volume_types = [None]
|
||||
volume_types_list = self.clients("cinder").volume_types.list()
|
||||
for s in volume_types_list:
|
||||
volume_types.append(s.name)
|
||||
selected_type = random.choice(volume_types)
|
||||
volume_type = random.choice(volume_types)
|
||||
|
||||
volume = self._create_volume(size, volume_type=selected_type)
|
||||
volume = self._create_volume(size, volume_type=volume_type)
|
||||
snapshot = self._create_snapshot(volume.id, False, **kwargs)
|
||||
|
||||
server = self.get_random_server()
|
||||
|
@ -282,7 +282,7 @@ class CinderServersTestCase(test.ScenarioTestCase):
|
||||
fake_attach)
|
||||
scenario._delete_volume.assert_called_once_with(fake_volume)
|
||||
|
||||
def test_create_snapshot_and_attach_volume_use_volume_type(self):
|
||||
def test_create_snapshot_and_attach_volume_use_volume_type_with_name(self):
|
||||
fake_volume = mock.MagicMock()
|
||||
fake_snapshot = mock.MagicMock()
|
||||
fake_server = mock.MagicMock()
|
||||
@ -305,13 +305,13 @@ class CinderServersTestCase(test.ScenarioTestCase):
|
||||
self.clients("nova").servers.get = mock.MagicMock(
|
||||
return_value=fake_server)
|
||||
|
||||
scenario.run(volume_type=True)
|
||||
scenario.run(volume_type="fake_volume_type")
|
||||
|
||||
# Make sure create volume's second arg was the correct volume type.
|
||||
# fake or none (randomly selected)
|
||||
self.assertTrue(scenario._create_volume.called)
|
||||
vol_type = scenario._create_volume.call_args_list[0][1]["volume_type"]
|
||||
self.assertTrue(vol_type is fake.name or vol_type is None)
|
||||
self.assertEqual(vol_type, "fake_volume_type")
|
||||
scenario._create_snapshot.assert_called_once_with(fake_volume.id,
|
||||
False)
|
||||
scenario._delete_snapshot.assert_called_once_with(fake_snapshot)
|
||||
|
Loading…
Reference in New Issue
Block a user