Add cinder.ListAndGetVolume scenario

Create a volume and get the volume detailed information.
Measure the "cinder show" command performance.

Change-Id: I3d29c257c21cf4367c85e2739387201263ccd527
This commit is contained in:
zhangzhang 2016-10-18 02:08:08 -04:00
parent 3f24458c71
commit 945c697c5a
7 changed files with 183 additions and 0 deletions

View File

@ -217,6 +217,54 @@
failure_rate:
max: 0
CinderVolumes.create_and_get_volume:
-
args:
size: 1
runner:
type: "constant"
times: 5
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 2
sla:
failure_rate:
max: 0
-
args:
size:
min: 1
max: 3
runner:
type: "constant"
times: 5
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 2
sla:
failure_rate:
max: 0
-
args:
size: 1
image:
name: {{image_name}}
runner:
type: "constant"
times: 5
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 2
sla:
failure_rate:
max: 0
CinderVolumes.list_volumes:
-
args:

View File

@ -59,6 +59,15 @@ class CinderScenario(scenario.OpenStackScenario):
return self.clients("cinder").volumes.list(detailed)
@atomic.action_timer("cinder.get_volume")
def _get_volume(self, volume_id):
"""get volume detailed information.
:param volume_id: id of volume
:returns: class:`Volume`
"""
return self.clients("cinder").volumes.get(volume_id)
@atomic.action_timer("cinder.list_snapshots")
def _list_snapshots(self, detailed=True):
"""Returns user snapshots list."""

View File

@ -67,6 +67,35 @@ class CreateAndListVolume(cinder_utils.CinderScenario,
self._list_volumes(detailed)
@types.convert(image={"type": "glance_image"})
@validation.image_exists("image", nullable=True)
@validation.required_services(consts.Service.CINDER)
@validation.required_openstack(users=True)
@scenario.configure(context={"cleanup": ["cinder"]},
name="CinderVolumes.create_and_get_volume")
class CreateAndGetVolume(cinder_utils.CinderScenario,
nova_utils.NovaScenario,
glance_utils.GlanceScenario):
def run(self, size, image=None, **kwargs):
"""Create a volume and get the volume.
Measure the "cinder show" command performance.
:param size: volume size (integer, in GB) or
dictionary, must contain two values:
min - minimum size volumes will be created as;
max - maximum size volumes will be created as.
:param image: image to be used to create volume
:param kwargs: optional args to create a volume
"""
if image:
kwargs["imageRef"] = image
volume = self._create_volume(size, **kwargs)
self._get_volume(volume.id)
@validation.required_services(consts.Service.CINDER)
@validation.required_openstack(users=True)
@scenario.configure(context={"cleanup": ["cinder"]},

View File

@ -0,0 +1,49 @@
{
"CinderVolumes.create_and_get_volume": [
{
"args": {
"size": 1
},
"runner": {
"type": "constant",
"times": 5,
"concurrency": 2
},
"context": {
"users": {
"tenants": 2,
"users_per_tenant": 2
}
},
"sla": {
"failure_rate": {
"max": 0
}
}
},
{
"args": {
"size": {
"min": 1,
"max": 5
}
},
"runner": {
"type": "constant",
"times": 5,
"concurrency": 2
},
"context": {
"users": {
"tenants": 2,
"users_per_tenant": 2
}
},
"sla": {
"failure_rate": {
"max": 0
}
}
}
]
}

View File

@ -0,0 +1,32 @@
---
CinderVolumes.create_and_get_volume:
-
args:
size: 1
runner:
type: "constant"
times: 5
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 2
sla:
failure_rate:
max: 0
-
args:
size:
min: 1
max: 5
runner:
type: "constant"
times: 5
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 2
sla:
failure_rate:
max: 0

View File

@ -52,6 +52,13 @@ class CinderScenarioTestCase(test.ScenarioTestCase):
self._test_atomic_action_timer(self.scenario.atomic_actions(),
"cinder.list_types")
def test__get_volume(self):
volume = fakes.FakeVolume()
self.assertEqual(self.clients("cinder").volumes.get.return_value,
self.scenario._get_volume(volume.id))
self._test_atomic_action_timer(self.scenario.atomic_actions(),
"cinder.get_volume")
def test__list_snapshots(self):
return_snapshots_list = self.scenario._list_snapshots()
self.assertEqual(

View File

@ -48,6 +48,15 @@ class CinderServersTestCase(test.ScenarioTestCase):
scenario._create_volume.assert_called_once_with(1, fakearg="f")
scenario._list_volumes.assert_called_once_with(True)
def test_create_and_get_volume(self):
scenario = volumes.CreateAndGetVolume(self.context)
scenario._create_volume = mock.MagicMock()
scenario._get_volume = mock.MagicMock()
scenario.run(1, fakearg="f")
scenario._create_volume.assert_called_once_with(1, fakearg="f")
scenario._get_volume.assert_called_once_with(
scenario._create_volume.return_value.id)
def test_list_volumes(self):
scenario = volumes.ListVolumes(self.context)
scenario._list_volumes = mock.MagicMock()