Merge "Add the scenario of list-flavors"

This commit is contained in:
Jenkins 2016-02-06 14:41:48 +00:00 committed by Gerrit Code Review
commit 4f7b42de67
7 changed files with 136 additions and 0 deletions

View File

@ -860,3 +860,19 @@
sla:
failure_rate:
max: 0
NovaFlavors.list_flavors:
-
args:
detailed: True
runner:
type: "constant"
times: 5
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 2
sla:
failure_rate:
max: 0

View File

@ -0,0 +1,38 @@
# Copyright 2015: 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.
from rally import consts
from rally.plugins.openstack import scenario
from rally.plugins.openstack.scenarios.nova import utils
from rally.task import validation
class NovaFlavors(utils.NovaScenario):
"""Benchmark scenarios for Nova flavors."""
@validation.required_services(consts.Service.NOVA)
@validation.required_openstack(users=True)
@scenario.configure(context={"cleanup": ["nova"]})
def list_flavors(self, detailed=True, **kwargs):
"""List all flavors.
Measure the "nova flavor-list" command performance.
:param detailed: True if the flavor listing
should contain detailed information
:param kwargs: Optional additional arguments for flavor listing
"""
self._list_flavors(detailed, **kwargs)

View File

@ -892,3 +892,14 @@ class NovaScenario(scenario.OpenStackScenario):
:param net_id: The nova-network ID to delete
"""
return self.admin_clients("nova").networks.delete(net_id)
@atomic.action_timer("nova.list_flavors")
def _list_flavors(self, detailed=True, **kwargs):
"""List all flavors.
:param kwargs: Optional additional arguments for flavor listing
:param detailed: True if the image listing
should contain detailed information
:returns: flavors list
"""
return self.clients("nova").flavors.list(detailed, **kwargs)

View File

@ -0,0 +1,20 @@
{
"NovaFlavors.list_flavors": [
{
"runner": {
"type": "constant",
"concurrency": 2,
"times": 10
},
"args": {
"detailed": true
},
"context": {
"users": {
"tenants": 3,
"users_per_tenant": 2
}
}
}
]
}

View File

@ -0,0 +1,13 @@
---
NovaFlavors.list_flavors:
-
args:
detailed: True
runner:
type: "constant"
times: 10
concurrency: 2
context:
users:
tenants: 3
users_per_tenant: 2

View File

@ -0,0 +1,28 @@
# Copyright: 2015.
# 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.plugins.openstack.scenarios.nova import flavors
from tests.unit import test
class NovaFlavorsTestCase(test.TestCase):
def test_list_flavors(self):
scenario = flavors.NovaFlavors()
scenario._list_flavors = mock.Mock()
scenario.list_flavors(detailed=True, fakearg="fakearg")
scenario._list_flavors.assert_called_once_with(True, fakearg="fakearg")

View File

@ -865,3 +865,13 @@ class NovaScenarioTestCase(test.ScenarioTestCase):
self.assertEqual(return_netlabel, fake_net)
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
"nova.create_network")
def test__list_flavors(self):
nova_scenario = utils.NovaScenario()
self.clients("nova").flavors.list.return_value = "flavors_list"
result = nova_scenario._list_flavors(detailed=True, fakearg="fakearg")
self.assertEqual("flavors_list", result)
self.clients("nova").flavors.list.assert_called_once_with(
True, fakearg="fakearg")
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
"nova.list_flavors")