Files
rally/tests/benchmark/scenarios/cinder/test_utils.py
chen-li eacf26da3f 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
2014-03-26 09:36:02 +08:00

42 lines
1.6 KiB
Python

# 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')