Merge "Add neutron.CreateAndShowSubnet scenario"

This commit is contained in:
Jenkins 2017-04-06 09:51:07 +00:00 committed by Gerrit Code Review
commit cc7836fd59
7 changed files with 160 additions and 0 deletions

View File

@ -85,6 +85,30 @@
failure_rate:
max: 20
NeutronNetworks.create_and_show_subnets:
-
args:
network_create_args:
subnet_create_args:
subnet_cidr_start: "1.1.0.0/30"
subnets_per_network: 2
runner:
type: "constant"
times: {{smoke or 20 }}
concurrency: {{smoke or 10}}
context:
network: {}
users:
tenants: {{smoke or 3}}
users_per_tenant: {{smoke or 2}}
quotas:
neutron:
network: -1
subnet: -1
sla:
failure_rate:
max: 20
NeutronSecurityGroup.create_and_list_security_groups:
-
args:

View File

@ -154,6 +154,38 @@ class CreateAndUpdateSubnets(utils.NeutronScenario):
self._update_subnet(subnet, subnet_update_args)
@validation.number("subnets_per_network", minval=1, integer_only=True)
@validation.required_services(consts.Service.NEUTRON)
@validation.required_openstack(users=True)
@scenario.configure(context={"cleanup": ["neutron"]},
name="NeutronNetworks.create_and_show_subnets")
class CreateAndShowSubnets(utils.NeutronScenario):
def run(self, network_create_args=None,
subnet_create_args=None, subnet_cidr_start=None,
subnets_per_network=1):
"""Create and show a subnet details.
The scenario creates a network, a given number of subnets
and show the subnet details. This scenario measures the
"neutron subnet-show" command performance.
:param network_create_args: dict, POST /v2.0/networks request
options.
:param subnet_create_args: dict, POST /v2.0/subnets request options
:param subnet_cidr_start: str, start value for subnets CIDR
:param subnets_per_network: int, number of subnets for one network
"""
network = self._get_or_create_network(network_create_args)
subnets = self._create_subnets(network, subnet_create_args,
subnet_cidr_start, subnets_per_network)
with atomic.ActionTimer(self,
"neutron.show_%s_subnets" % len(subnets)):
for subnet in subnets:
self._show_subnet(subnet, atomic_action=False)
@validation.required_parameters("subnets_per_network")
@validation.required_services(consts.Service.NEUTRON)
@scenario.configure(context={"cleanup": ["neutron"]},

View File

@ -164,6 +164,17 @@ class NeutronScenario(scenario.OpenStackScenario):
"""Returns user subnetworks list."""
return self.clients("neutron").list_subnets()["subnets"]
@atomic.optional_action_timer("neutron.show_subnet")
def _show_subnet(self, subnet, **kwargs):
"""show subnet details.
:param: subnet: Subnet object
:param: kwargs: Optional additional arguments for subnet show
:returns: details of the subnet
"""
return self.clients("neutron").show_subnet(subnet["subnet"]["id"],
**kwargs)
@atomic.action_timer("neutron.update_subnet")
def _update_subnet(self, subnet, subnet_update_args):
"""Update the neutron subnet.

View File

@ -0,0 +1,35 @@
{
"NeutronNetworks.create_and_show_subnets": [
{
"args": {
"network_create_args": {},
"subnet_create_args": {},
"subnet_cidr_start": "1.1.0.0/30",
"subnets_per_network": 2
},
"runner": {
"type": "constant",
"times": 10,
"concurrency": 5
},
"context": {
"network": {},
"users": {
"tenants": 2,
"users_per_tenant": 3
},
"quotas": {
"neutron": {
"network": -1,
"subnet": -1
}
}
},
"sla": {
"failure_rate": {
"max": 0
}
}
}
]
}

View File

@ -0,0 +1,24 @@
---
NeutronNetworks.create_and_show_subnets:
-
args:
network_create_args: {}
subnet_create_args: {}
subnet_cidr_start: "1.1.0.0/30"
subnets_per_network: 2
runner:
type: "constant"
times: 10
concurrency: 5
context:
network: {}
users:
tenants: 2
users_per_tenant: 3
quotas:
neutron:
network: -1
subnet: -1
sla:
failure_rate:
max: 0

View File

@ -158,6 +158,31 @@ class NeutronNetworksTestCase(test.ScenarioTestCase):
scenario._list_subnets.assert_called_once_with()
def test_create_and_show_subnets(self):
network_create_args = {"router:external": True}
subnet_create_args = {"allocation_pools": []}
subnet_cidr_start = "1.1.0.0/30"
subnets_per_network = 5
net = mock.MagicMock()
scenario = network.CreateAndShowSubnets(self.context)
scenario._get_or_create_network = mock.Mock(return_value=net)
scenario._create_subnets = mock.MagicMock()
scenario._show_subnet = mock.Mock()
scenario.run(network_create_args=network_create_args,
subnet_create_args=subnet_create_args,
subnet_cidr_start=subnet_cidr_start,
subnets_per_network=subnets_per_network)
scenario._get_or_create_network.assert_called_once_with(
network_create_args)
scenario._create_subnets.assert_called_once_with(
net, subnet_create_args, subnet_cidr_start, subnets_per_network)
for subnet in scenario._create_subnets.return_value:
scenario._show_subnet.assert_called_with(subnet,
atomic_action=False)
def test_create_and_update_subnets(self):
network_create_args = {"router:external": True}
subnet_create_args = {"allocation_pools": []}

View File

@ -183,6 +183,15 @@ class NeutronScenarioTestCase(test.ScenarioTestCase):
self._test_atomic_action_timer(self.scenario.atomic_actions(),
"neutron.list_subnets")
def test_show_subnet(self):
subnet = {"subnet": {"name": "fake-name", "id": "fake-id"}}
result_subnet = self.scenario._show_subnet(subnet)
self.assertEqual(self.clients("neutron").show_subnet.return_value,
result_subnet)
self._test_atomic_action_timer(self.scenario.atomic_actions(),
"neutron.show_subnet")
def test_update_subnet(self):
expected_subnet = {
"subnet": {