add create_and_list_volume benchmark
Added create_and_list_volume benchmark. Config example is below. { "CinderVolumes.create_and_list_volume": [ { "args": { "size": 1, "detailed": True }, "runner": { "type": "continuous", "times": 3, "active_users": 1 }, "context": { "users": { "tenants": 1, "users_per_tenant": 1 } } } ] } Change-Id: I8b56a6e9e12cc2801332ba9760a2bc2892112d99
This commit is contained in:
21
doc/samples/tasks/cinder/create-and-list-volume.json
Normal file
21
doc/samples/tasks/cinder/create-and-list-volume.json
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"CinderVolumes.create_and_list_volume": [
|
||||||
|
{
|
||||||
|
"args": {
|
||||||
|
"size": 1,
|
||||||
|
"detailed": True
|
||||||
|
},
|
||||||
|
"runner": {
|
||||||
|
"type": "continuous",
|
||||||
|
"times": 3,
|
||||||
|
"active_users": 1
|
||||||
|
},
|
||||||
|
"context": {
|
||||||
|
"users": {
|
||||||
|
"tenants": 1,
|
||||||
|
"users_per_tenant": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
14
doc/samples/tasks/cinder/create-and-list-volume.yaml
Normal file
14
doc/samples/tasks/cinder/create-and-list-volume.yaml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
CinderVolumes.create_and_list_volume:
|
||||||
|
-
|
||||||
|
args:
|
||||||
|
size: 1
|
||||||
|
detailed: True
|
||||||
|
runner:
|
||||||
|
type: "continuous"
|
||||||
|
times: 3
|
||||||
|
active_users: 1
|
||||||
|
context:
|
||||||
|
users:
|
||||||
|
tenants: 1
|
||||||
|
users_per_tenant: 1
|
@@ -64,6 +64,12 @@ def generate_volume_name(length=10):
|
|||||||
|
|
||||||
class CinderScenario(base.Scenario):
|
class CinderScenario(base.Scenario):
|
||||||
|
|
||||||
|
@scenario_utils.atomic_action_timer('cinder.list_volumes')
|
||||||
|
def _list_volumes(self, detailed=True):
|
||||||
|
"""Returns user volumes list."""
|
||||||
|
|
||||||
|
return self.clients("cinder").volumes.list(detailed)
|
||||||
|
|
||||||
@scenario_utils.atomic_action_timer('cinder.create_volume')
|
@scenario_utils.atomic_action_timer('cinder.create_volume')
|
||||||
def _create_volume(self, size, **kwargs):
|
def _create_volume(self, size, **kwargs):
|
||||||
"""create one volume.
|
"""create one volume.
|
||||||
|
@@ -18,6 +18,22 @@ from rally.benchmark.scenarios.cinder import utils
|
|||||||
|
|
||||||
class CinderVolumes(utils.CinderScenario):
|
class CinderVolumes(utils.CinderScenario):
|
||||||
|
|
||||||
|
def create_and_list_volume(self, size, detailed=True, **kwargs):
|
||||||
|
"""Tests creating a volume and listing volumes.
|
||||||
|
|
||||||
|
This scenario is a very useful tool to measure
|
||||||
|
the "cinder volume-list" command performance.
|
||||||
|
|
||||||
|
If you have only 1 user in your context, you will
|
||||||
|
add 1 volume on every iteration. So you will have more
|
||||||
|
and more volumes and will be able to measure the
|
||||||
|
performance of the "cinder volume-list" command depending on
|
||||||
|
the number of images owned by users.
|
||||||
|
"""
|
||||||
|
|
||||||
|
self._create_volume(size, **kwargs)
|
||||||
|
self._list_volumes(detailed)
|
||||||
|
|
||||||
def create_and_delete_volume(self, size, min_sleep=0, max_sleep=0,
|
def create_and_delete_volume(self, size, min_sleep=0, max_sleep=0,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
"""Tests creating and then deleting a volume.
|
"""Tests creating and then deleting a volume.
|
||||||
|
41
tests/benchmark/scenarios/cinder/test_utils.py
Normal file
41
tests/benchmark/scenarios/cinder/test_utils.py
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
# Copyright 2013: Mirantis Inc.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
|
from rally.benchmark.scenarios.cinder import utils
|
||||||
|
from tests.benchmark.scenarios import test_utils
|
||||||
|
from tests import test
|
||||||
|
|
||||||
|
CINDER_UTILS = "rally.benchmark.scenarios.cinder.utils"
|
||||||
|
|
||||||
|
|
||||||
|
class CinderScenarioTestCase(test.TestCase):
|
||||||
|
|
||||||
|
def _test_atomic_action_timer(self, atomic_actions_time, name):
|
||||||
|
action_duration = test_utils.get_atomic_action_timer_value_by_name(
|
||||||
|
atomic_actions_time, name)
|
||||||
|
self.assertIsNotNone(action_duration)
|
||||||
|
self.assertIsInstance(action_duration, float)
|
||||||
|
|
||||||
|
@mock.patch(CINDER_UTILS + '.CinderScenario.clients')
|
||||||
|
def test__list_volumes(self, mock_clients):
|
||||||
|
volumes_list = mock.Mock()
|
||||||
|
mock_clients("cinder").volumes.list.return_value = volumes_list
|
||||||
|
scenario = utils.CinderScenario()
|
||||||
|
return_volumes_list = scenario._list_volumes()
|
||||||
|
self.assertEqual(volumes_list, return_volumes_list)
|
||||||
|
self._test_atomic_action_timer(scenario.atomic_actions_time(),
|
||||||
|
'cinder.list_volumes')
|
@@ -24,6 +24,14 @@ CINDER_VOLUMES = "rally.benchmark.scenarios.cinder.volumes.CinderVolumes"
|
|||||||
|
|
||||||
class CinderServersTestCase(test.TestCase):
|
class CinderServersTestCase(test.TestCase):
|
||||||
|
|
||||||
|
def test_create_and_list_volume(self):
|
||||||
|
scenario = volumes.CinderVolumes()
|
||||||
|
scenario._create_volume = mock.MagicMock()
|
||||||
|
scenario._list_volumes = mock.MagicMock()
|
||||||
|
scenario.create_and_list_volume(1, True, fakearg="f")
|
||||||
|
scenario._create_volume.assert_called_once_with(1, fakearg="f")
|
||||||
|
scenario._list_volumes.assert_called_once_with(True)
|
||||||
|
|
||||||
def test_create_and_delete_volume(self):
|
def test_create_and_delete_volume(self):
|
||||||
fake_volume = mock.MagicMock()
|
fake_volume = mock.MagicMock()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user