Skip to content

Commit

Permalink
Support size range in Cinder create_volume and extend_volume
Browse files Browse the repository at this point in the history
It is useful for some test cases to set up volume size from some
range, not only specific value. This change add such possibility
to create_volume and extend_volume.

Change-Id: Ic7cc9270eb8d31dcbe3d30acf6f24cf9c41a6fd1
  • Loading branch information
Anton Arefiev committed Apr 29, 2015
1 parent e7f5d79 commit 1572137
Show file tree
Hide file tree
Showing 18 changed files with 439 additions and 14 deletions.
86 changes: 86 additions & 0 deletions rally-jobs/rally-neutron.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,22 @@
sla:
failure_rate:
max: 0
-
args:
size:
min: 1
max: 3
runner:
type: "constant"
times: 3
concurrency: 3
context:
users:
tenants: 2
users_per_tenant: 2
sla:
failure_rate:
max: 0

CinderVolumes.create_and_list_volume:
-
Expand All @@ -577,6 +593,23 @@
sla:
failure_rate:
max: 0
-
args:
size:
min: 1
max: 3
detailed: True
runner:
type: "constant"
times: 3
concurrency: 3
context:
users:
tenants: 1
users_per_tenant: 1
sla:
failure_rate:
max: 0
-
args:
size: 1
Expand Down Expand Up @@ -629,6 +662,22 @@
sla:
failure_rate:
max: 0
-
args:
size:
min: 1
max: 3
runner:
type: "constant"
times: 2
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 2
sla:
failure_rate:
max: 0
-
args:
size: 1
Expand Down Expand Up @@ -662,6 +711,25 @@
sla:
failure_rate:
max: 0
-
args:
size:
min: 1
max: 2
new_size:
min: 3
max: 4
runner:
type: "constant"
times: 2
concurrency: 2
context:
users:
tenants: 1
users_per_tenant: 1
sla:
failure_rate:
max: 0

CinderVolumes.create_from_volume_and_delete_volume:
-
Expand All @@ -680,6 +748,24 @@
sla:
failure_rate:
max: 0
-
args:
size:
min: 1
max: 2
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:
-
Expand Down
19 changes: 17 additions & 2 deletions rally/benchmark/scenarios/cinder/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,19 @@ def _create_volume(self, size, **kwargs):
Returns when the volume is actually created and is in the "Available"
state.
:param size: int be size of volume in GB
:param size: int be size of volume 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 kwargs: Other optional parameters to initialize the volume
:returns: Created volume object
"""
kwargs["display_name"] = kwargs.get("display_name",
self._generate_random_name())

if isinstance(size, dict):
size = random.randint(size["min"], size["max"])

volume = self.clients("cinder").volumes.create(size, **kwargs)
# NOTE(msdubov): It is reasonable to wait 5 secs before starting to
# check whether the volume is ready => less API calls.
Expand Down Expand Up @@ -114,8 +121,16 @@ def _extend_volume(self, volume, new_size):
Returns when the volume is actually extended.
:param volume: volume object
:param new_size: new volume size in GB
:param new_size: new volume size in GB, or
dictionary, must contain two values:
min - minimum size volumes will be created as;
max - maximum size volumes will be created as.
Notice: should be bigger volume size
"""

if isinstance(new_size, dict):
new_size = random.randint(new_size["min"], new_size["max"])

volume.extend(volume, new_size)
volume = bench_utils.wait_for(
volume,
Expand Down
48 changes: 36 additions & 12 deletions rally/benchmark/scenarios/cinder/volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ def create_and_list_volume(self, size, detailed=True,
performance of the "cinder volume-list" command depending on
the number of images owned by users.
:param size: volume size (in GB)
: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 detailed: determines whether the volume listing should contain
detailed information about all of them
:param image: image to be used to create volume
Expand Down Expand Up @@ -91,7 +94,10 @@ def create_and_delete_volume(self, size, image=None,
between volume creation and deletion (of random duration from
[min_sleep, max_sleep]).
:param size: volume size (in GB)
: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 min_sleep: minimum sleep time between volume creation and
deletion (in seconds)
Expand All @@ -117,7 +123,10 @@ def create_volume(self, size, image=None, **kwargs):
Good test to check how influence amount of active volumes on
performance of creating new.
:param size: volume size (in GB)
: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
"""
Expand All @@ -134,8 +143,16 @@ def create_and_extend_volume(self, size, new_size, min_sleep=0,
"""Create and extend a volume and then delete it.
:param size: volume size (in GB)
:param new_size: volume new size (in GB) to extend
:param size: volume size (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 new_size: volume new size (in GB) or
dictionary, must contain two values:
min - minimum size volumes will be created as;
max - maximum size volumes will be created as.
to extend.
Notice: should be bigger volume size
:param min_sleep: minimum sleep time between volume extension and
deletion (in seconds)
:param max_sleep: maximum sleep time between volume extension and
Expand All @@ -159,8 +176,12 @@ def create_from_volume_and_delete_volume(self, size, min_sleep=0,
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 size: volume size (in GB), or
dictionary, must contain two values:
min - minimum size volumes will be created as;
max - maximum size volumes will be created as.
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
Expand Down Expand Up @@ -210,7 +231,10 @@ def create_and_attach_volume(self, size, image, flavor, **kwargs):
Simple test to create a VM and attach a volume, then
detach the volume and delete volume/VM.
:param size: volume size (in GB)
: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: Glance image name to use for the VM
:param flavor: VM flavor name
:param kwargs: optional arguments for VM creation
Expand Down Expand Up @@ -268,8 +292,6 @@ def create_snapshot_and_attach_volume(self, volume_type=False,
volume_types.append(s.name)
selected_type = random.choice(volume_types)

size = random.randint(size["min"], size["max"])

volume = self._create_volume(size, volume_type=selected_type)
snapshot = self._create_snapshot(volume.id, False, **kwargs)

Expand Down Expand Up @@ -320,7 +342,6 @@ def create_nested_snapshots_and_attach_volume(self,
if nested_level is None:
nested_level = {"min": 5, "max": 10}

size = random.randint(size["min"], size["max"])
nested_level = random.randint(nested_level["min"], nested_level["max"])

source_vol = self._create_volume(size)
Expand Down Expand Up @@ -373,7 +394,10 @@ def create_and_upload_volume_to_image(self, size, force=False,
**kwargs):
"""Create and upload a volume to image.
:param size: volume size (integers, in GB)
:param size: volume size (integers, 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 force: when set to True volume that is attached to an instance
could be uploaded to image
:param container_format: image container format
Expand Down
22 changes: 22 additions & 0 deletions samples/tasks/scenarios/cinder/create-and-attach-volume.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,28 @@
"users_per_tenant": 2
}
}
},
{
"args": {
"size": {
"min": 1,
"max": 5
},
"flavor": {
"name": "m1.nano"
}
},
"runner": {
"type": "constant",
"times": 5,
"concurrency": 1
},
"context": {
"users": {
"tenants": 2,
"users_per_tenant": 2
}
}
}
]
}
15 changes: 15 additions & 0 deletions samples/tasks/scenarios/cinder/create-and-attach-volume.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,18 @@
users:
tenants: 2
users_per_tenant: 2
-
args:
size:
min: 1
max: 5
flavor:
name: "m1.nano"
runner:
type: "constant"
times: 5
concurrency: 1
context:
users:
tenants: 2
users_per_tenant: 2
19 changes: 19 additions & 0 deletions samples/tasks/scenarios/cinder/create-and-delete-volume.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,25 @@
"users_per_tenant": 2
}
}
},
{
"args": {
"size": {
"min": 1,
"max": 5
}
},
"runner": {
"type": "constant",
"times": 3,
"concurrency": 2
},
"context": {
"users": {
"tenants": 2,
"users_per_tenant": 2
}
}
}
]
}
13 changes: 13 additions & 0 deletions samples/tasks/scenarios/cinder/create-and-delete-volume.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,16 @@
users:
tenants: 2
users_per_tenant: 2
-
args:
size:
min: 1
max: 5
runner:
type: "constant"
times: 3
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 2
23 changes: 23 additions & 0 deletions samples/tasks/scenarios/cinder/create-and-extend-volume.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,29 @@
"users_per_tenant": 1
}
}
},
{
"args": {
"size": {
"min": 1,
"max": 5
},
"new_size": {
"min": 6,
"max": 10
}
},
"runner": {
"type": "constant",
"times": 2,
"concurrency": 2
},
"context": {
"users": {
"tenants": 1,
"users_per_tenant": 1
}
}
}
]
}
Loading

0 comments on commit 1572137

Please sign in to comment.