Add neutron.CreateAndShowSecurityGroup scenario

Create and show Neutron security-group

Measure the "neutron security-group-create" and "neutron
security-group-show" command performance.

Change-Id: I9ee650c691773fbe4b85e927a4b66c57e0dd659b
This commit is contained in:
zhangzhang 2016-11-17 22:52:25 -05:00
parent e332eb1aea
commit dbc7fc9946
7 changed files with 158 additions and 0 deletions

View File

@ -153,6 +153,25 @@
failure_rate:
max: 20
NeutronSecurityGroup.create_and_show_security_group:
-
args:
security_group_create_args: {}
runner:
type: "constant"
times: {{smoke or 20 }}
concurrency: {{smoke or 10}}
context:
users:
tenants: {{smoke or 3}}
users_per_tenant: {{smoke or 2}}
quotas:
neutron:
security_group: -1
sla:
failure_rate:
max: 20
NeutronSecurityGroup.create_and_delete_security_groups:
-
args:

View File

@ -40,6 +40,31 @@ class CreateAndListSecurityGroups(utils.NeutronScenario):
self._list_security_groups()
@validation.required_services(consts.Service.NEUTRON)
@validation.add("required_platform", platform="openstack", users=True)
@scenario.configure(context={"cleanup": ["neutron"]},
name=("NeutronSecurityGroup"
".create_and_show_security_group"))
class CreateAndShowSecurityGroup(utils.NeutronScenario):
def run(self, security_group_create_args=None):
"""Create and show Neutron security-group.
Measure the "neutron security-group-create" and "neutron
security-group-show" command performance.
:param security_group_create_args: dict, POST /v2.0/security-groups
request options
"""
security_group_create_args = security_group_create_args or {}
security_group = self._create_security_group(
**security_group_create_args)
msg = "security_group isn't created"
self.assertTrue(security_group, err_msg=msg)
self._show_security_group(security_group)
@validation.required_services(consts.Service.NEUTRON)
@validation.add("required_platform", platform="openstack", users=True)
@scenario.configure(context={"cleanup": ["neutron"]},

View File

@ -624,6 +624,17 @@ class NeutronScenario(scenario.OpenStackScenario):
"""Return list of Neutron security groups."""
return self.clients("neutron").list_security_groups(**kwargs)
@atomic.action_timer("neutron.show_security_group")
def _show_security_group(self, security_group, **kwargs):
"""Show security group details.
:param: security_group: dict, neutron security_group
:param: kwargs: Optional additional arguments for security_group show
:returns: security_group details
"""
return self.clients("neutron").show_security_group(
security_group["security_group"]["id"], **kwargs)
@atomic.action_timer("neutron.update_security_group")
def _update_security_group(self, security_group,
**security_group_update_args):

View File

@ -0,0 +1,30 @@
{
"NeutronSecurityGroup.create_and_show_security_group": [
{
"args": {
"security_group_create_args": {}
},
"runner": {
"type": "constant",
"times": 20,
"concurrency": 10
},
"context": {
"users": {
"tenants": 3,
"users_per_tenant": 3
},
"quotas": {
"neutron": {
"security_group": -1
}
}
},
"sla": {
"failure_rate": {
"max": 0
}
}
}
]
}

View File

@ -0,0 +1,19 @@
---
NeutronSecurityGroup.create_and_show_security_group:
-
args:
security_group_create_args: {}
runner:
type: "constant"
times: 20
concurrency: 10
context:
users:
tenants: 3
users_per_tenant: 3
quotas:
neutron:
security_group: -1
sla:
failure_rate:
max: 0

View File

@ -13,6 +13,7 @@
import ddt
import mock
from rally import exceptions as rally_exceptions
from rally.plugins.openstack.scenarios.neutron import security_groups
from tests.unit import test
@ -38,6 +39,48 @@ class NeutronSecurityGroup(test.TestCase):
**security_group_data)
scenario._list_security_groups.assert_called_once_with()
@ddt.data(
{},
{"security_group_create_args": {}},
{"security_group_create_args": {"description": "fake-description"}},
)
@ddt.unpack
def test_create_and_show_security_group(
self, security_group_create_args=None):
scenario = security_groups.CreateAndShowSecurityGroup()
security_group = mock.Mock()
security_group_data = security_group_create_args or {}
scenario._create_security_group = mock.Mock()
scenario._show_security_group = mock.Mock()
# Positive case
scenario._create_security_group.return_value = security_group
scenario.run(security_group_create_args=security_group_create_args)
scenario._create_security_group.assert_called_once_with(
**security_group_data)
scenario._show_security_group.assert_called_once_with(
scenario._create_security_group.return_value)
@ddt.data(
{},
{"security_group_create_args": {}},
{"security_group_create_args": {"description": "fake-description"}},
)
@ddt.unpack
def test_create_and_show_security_group_with_none_group(
self, security_group_create_args=None):
scenario = security_groups.CreateAndShowSecurityGroup()
security_group_data = security_group_create_args or {}
scenario._create_security_group = mock.Mock()
scenario._show_security_group = mock.Mock()
# Negative case: security_group isn't created
scenario._create_security_group.return_value = None
self.assertRaises(rally_exceptions.RallyAssertionError,
scenario.run, security_group_create_args)
scenario._create_security_group.assert_called_with(
**security_group_data)
@ddt.data(
{},
{"security_group_create_args": {}},

View File

@ -729,6 +729,17 @@ class NeutronScenarioTestCase(test.ScenarioTestCase):
self._test_atomic_action_timer(self.scenario.atomic_actions(),
"neutron.list_security_groups")
def test_show_security_group(self):
security_group = {"security_group": {"id": "fake-id"}}
result = self.scenario._show_security_group(security_group)
self.assertEqual(
result,
self.clients("neutron").show_security_group.return_value)
self.clients("neutron").show_security_group.assert_called_once_with(
security_group["security_group"]["id"])
self._test_atomic_action_timer(self.scenario.atomic_actions(),
"neutron.show_security_group")
def test_delete_security_group(self):
security_group = {"security_group": {"id": "fake-id"}}
self.scenario._delete_security_group(security_group)