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