Skip to content

Commit

Permalink
Merge "Add list_snapshots scenario for Cinder test"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Jan 21, 2015
2 parents 4635a21 + 49ae92d commit ecb4fba
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 0 deletions.
19 changes: 19 additions & 0 deletions rally-jobs/rally-neutron.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,25 @@
failure_rate:
max: 0

CinderVolumes.create_and_list_snapshots:
-
args:
force: False
detailed: True
runner:
type: "constant"
times: 2
concurrency: 2
context:
users:
tenants: 1
users_per_tenant: 1
volumes:
size: 1
sla:
failure_rate:
max: 0

VMTasks.boot_runcommand_delete:
-
args:
Expand Down
6 changes: 6 additions & 0 deletions rally/benchmark/scenarios/cinder/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ def _list_volumes(self, detailed=True):

return self.clients("cinder").volumes.list(detailed)

@base.atomic_action_timer('cinder.list_snapshots')
def _list_snapshots(self, detailed=True):
"""Returns user snapshots list."""

return self.clients("cinder").volume_snapshots.list(detailed)

@base.atomic_action_timer('cinder.create_volume')
def _create_volume(self, size, **kwargs):
"""Create one volume.
Expand Down
18 changes: 18 additions & 0 deletions rally/benchmark/scenarios/cinder/volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,3 +303,21 @@ def create_nested_snapshots_and_attach_volume(self,
self._detach_volume(server, volume)
self._delete_snapshot(snapshot)
self._delete_volume(volume)

@validation.required_services(consts.Service.CINDER)
@validation.required_contexts("volumes")
@validation.required_openstack(users=True)
@base.scenario(context={"cleanup": ["cinder"]})
def create_and_list_snapshots(self, force=False, detailed=True, **kwargs):
"""Create and then list a volume-snapshot.
:param force: when set to True, allows snapshot of a volume when
the volume is attached to an instance
:param detailed: True if detailed information about snapshots
should be listed
:param kwargs: optional args to create a snapshot
"""
volume = random.choice(self.context["tenant"]["volumes"])
self._create_snapshot(volume["id"], force=force, **kwargs)
self._list_snapshots(detailed)
24 changes: 24 additions & 0 deletions samples/tasks/scenarios/cinder/create-and-list-snapshots.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"CinderVolumes.create_and_list_snapshots": [
{
"args": {
"force": false,
"detailed": true
},
"runner": {
"type": "constant",
"times": 2,
"concurrency": 2
},
"context": {
"users": {
"tenants": 1,
"users_per_tenant": 1
},
"volumes": {
"size": 1
}
}
}
]
}
16 changes: 16 additions & 0 deletions samples/tasks/scenarios/cinder/create-and-list-snapshots.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
CinderVolumes.create_and_list_snapshots:
-
args:
force: False
detailed: True
runner:
type: "constant"
times: 2
concurrency: 2
context:
users:
tenants: 1
users_per_tenant: 1
volumes:
size: 1
9 changes: 9 additions & 0 deletions tests/unit/benchmark/scenarios/cinder/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ def test__list_volumes(self, mock_clients):
self._test_atomic_action_timer(self.scenario.atomic_actions(),
'cinder.list_volumes')

@mock.patch(CINDER_UTILS + '.CinderScenario.clients')
def test__list_snapshots(self, mock_clients):
snapsht_lst = mock.Mock()
mock_clients("cinder").volume_snapshots.list.return_value = snapsht_lst
return_snapshots_list = self.scenario._list_snapshots()
self.assertEqual(snapsht_lst, return_snapshots_list)
self._test_atomic_action_timer(self.scenario.atomic_actions(),
'cinder.list_snapshots')

@mock.patch(CINDER_UTILS + '.CinderScenario.clients')
def test__create_volume(self, mock_clients):
CONF = cfg.CONF
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/benchmark/scenarios/cinder/test_volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,20 @@ def test_create_and_delete_snapshot(self):
scenario.sleep_between.assert_called_once_with(10, 20)
scenario._delete_snapshot.assert_called_once_with(fake_snapshot)

def test_create_and_list_snapshots(self):
fake_snapshot = mock.MagicMock()
scenario = volumes.CinderVolumes(
context={"user": {"tenant_id": "fake"},
"tenant": {"id": "fake", "name": "fake",
"volumes": [{"id": "uuid"}]}})

scenario._create_snapshot = mock.MagicMock(return_value=fake_snapshot)
scenario._list_snapshots = mock.MagicMock()
scenario.create_and_list_snapshots(False, True, fakearg="f")
scenario._create_snapshot.assert_called_once_with("uuid", force=False,
fakearg="f")
scenario._list_snapshots.assert_called_once_with(True)

def test_create_and_attach_volume(self):
fake_volume = mock.MagicMock()
fake_server = mock.MagicMock()
Expand Down

0 comments on commit ecb4fba

Please sign in to comment.