Add cinder scenario: create volume from volume(clone)

Change-Id: I8861a84d2bb607347162f5fb96516a025099f1b2
This commit is contained in:
Anton Arefiev 2015-01-15 12:30:46 +02:00
parent a1c8e313bc
commit 67ed016a73
5 changed files with 96 additions and 0 deletions

View File

@ -622,6 +622,24 @@
failure_rate:
max: 0
CinderVolumes.create_from_volume_and_delete_volume:
-
args:
size: 1
runner:
type: "constant"
times: 2
concurrency: 2
context:
users:
tenants: 1
users_per_tenant: 1
volumes:
size: 1
sla:
failure_rate:
max: 0
CinderVolumes.create_and_delete_snapshot:
-
args:

View File

@ -145,6 +145,32 @@ class CinderVolumes(utils.CinderScenario,
self.sleep_between(min_sleep, max_sleep)
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_from_volume_and_delete_volume(self, size, min_sleep=0,
max_sleep=0, **kwargs):
"""Create volume from volume and then delete it.
Scenario for testing volume clone.Optional 'min_sleep' and 'max_sleep'
parameters allow the scenario to simulate a pause between volume
creation and deletion (of random duration from [min_sleep, max_sleep]).
:param size: volume size (in GB). Should be equal or bigger
source volume size
:param min_sleep: minimum sleep time between volume creation and
deletion (in seconds)
:param max_sleep: maximum sleep time between volume creation and
deletion (in seconds)
:param kwargs: optional args to create a volume
"""
source_vol = random.choice(self.context["tenant"]["volumes"])
volume = self._create_volume(size, source_volid=source_vol["id"],
**kwargs)
self.sleep_between(min_sleep, max_sleep)
self._delete_volume(volume)
@validation.required_services(consts.Service.CINDER)
@validation.required_contexts("volumes")
@validation.required_openstack(users=True)

View File

@ -0,0 +1,23 @@
{
"CinderVolumes.create_from_volume_and_delete_volume": [
{
"args": {
"size": 1
},
"runner": {
"type": "constant",
"times": 2,
"concurrency": 2
},
"context": {
"users": {
"tenants": 1,
"users_per_tenant": 1
},
"volumes": {
"size": 1
}
}
}
]
}

View File

@ -0,0 +1,15 @@
---
CinderVolumes.create_from_volume_and_delete_volume:
-
args:
size: 1
runner:
type: "constant"
times: 2
concurrency: 2
context:
users:
tenants: 1
users_per_tenant: 1
volumes:
size: 1

View File

@ -112,6 +112,20 @@ class CinderServersTestCase(test.TestCase):
imageRef="fake_image")
scenario._list_volumes.assert_called_once_with(True)
def test_create_from_volume_and_delete_volume(self):
fake_volume = mock.MagicMock()
vol_size = 1
scenario = volumes.CinderVolumes(
context={"user": {"tenant_id": "fake"},
"tenant": {"id": "fake", "name": "fake",
"volumes": [{"id": "uuid"}]}})
scenario._create_volume = mock.MagicMock(return_value=fake_volume)
scenario._delete_volume = mock.MagicMock()
scenario.create_from_volume_and_delete_volume(vol_size)
scenario._create_volume.assert_called_once_with(1, source_volid="uuid")
scenario._delete_volume.assert_called_once_with(fake_volume)
def test_create_and_delete_snapshot(self):
fake_snapshot = mock.MagicMock()
scenario = volumes.CinderVolumes(