Adds deleting scenarios for Neutron:
- NeutronNetwork.create_and_delete_networks - NeutronNetwork.create_and_delete_subnets - NeutronNetwork.create_and_delete_ports blueprint benchmark-scenarios-for-neutron Change-Id: I585b76935644712c019a9d5502637fbad6d4d2f0
This commit is contained in:
parent
39c580767c
commit
c2453d294b
@ -0,0 +1,25 @@
|
||||
{
|
||||
"NeutronNetworks.create_and_delete_networks": [
|
||||
{
|
||||
"args": {
|
||||
"network_create_args": {}
|
||||
},
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"times": 100,
|
||||
"concurrency": 10
|
||||
},
|
||||
"context": {
|
||||
"users": {
|
||||
"tenants": 1,
|
||||
"users_per_tenant": 1
|
||||
},
|
||||
"quotas": {
|
||||
"neutron": {
|
||||
"network": -1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
---
|
||||
NeutronNetworks.create_and_delete_networks:
|
||||
-
|
||||
args:
|
||||
network_create_args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 100
|
||||
concurrency: 10
|
||||
context:
|
||||
users:
|
||||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
quotas:
|
||||
neutron:
|
||||
network: -1
|
@ -0,0 +1,28 @@
|
||||
{
|
||||
"NeutronNetworks.create_and_delete_ports": [
|
||||
{
|
||||
"args": {
|
||||
"network_create_args": {},
|
||||
"port_create_args": {},
|
||||
"ports_per_network": 10
|
||||
},
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"times": 100,
|
||||
"concurrency": 10
|
||||
},
|
||||
"context": {
|
||||
"users": {
|
||||
"tenants": 1,
|
||||
"users_per_tenant": 1
|
||||
},
|
||||
"quotas": {
|
||||
"neutron": {
|
||||
"network": -1,
|
||||
"port": -1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
---
|
||||
NeutronNetworks.create_and_delete_ports:
|
||||
-
|
||||
args:
|
||||
network_create_args: {}
|
||||
port_create_args: {}
|
||||
ports_per_network: 10
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 100
|
||||
concurrency: 10
|
||||
context:
|
||||
users:
|
||||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
quotas:
|
||||
neutron:
|
||||
network: -1
|
||||
port: -1
|
@ -0,0 +1,29 @@
|
||||
{
|
||||
"NeutronNetworks.create_and_delete_subnets": [
|
||||
{
|
||||
"args": {
|
||||
"network_create_args": {},
|
||||
"subnet_create_args": {},
|
||||
"subnet_cidr_start": "1.1.0.0/30",
|
||||
"subnets_per_network": 2
|
||||
},
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"times": 100,
|
||||
"concurrency": 10
|
||||
},
|
||||
"context": {
|
||||
"users": {
|
||||
"tenants": 1,
|
||||
"users_per_tenant": 1
|
||||
},
|
||||
"quotas": {
|
||||
"neutron": {
|
||||
"network": -1,
|
||||
"subnet": -1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
---
|
||||
NeutronNetworks.create_and_delete_subnets:
|
||||
-
|
||||
args:
|
||||
network_create_args: {}
|
||||
subnet_create_args: {}
|
||||
subnet_cidr_start: "1.1.0.0/30"
|
||||
subnets_per_network: 2
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 100
|
||||
concurrency: 10
|
||||
context:
|
||||
users:
|
||||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
quotas:
|
||||
neutron:
|
||||
network: -1
|
||||
subnet: -1
|
@ -123,6 +123,68 @@
|
||||
sla:
|
||||
max_failure_percent: 0
|
||||
|
||||
NeutronNetworks.create_and_delete_networks:
|
||||
-
|
||||
args:
|
||||
network_create_args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 30
|
||||
concurrency: 10
|
||||
context:
|
||||
users:
|
||||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
quotas:
|
||||
neutron:
|
||||
network: -1
|
||||
subnet: -1
|
||||
sla:
|
||||
max_failure_percent: 0
|
||||
|
||||
NeutronNetworks.create_and_delete_subnets:
|
||||
-
|
||||
args:
|
||||
network_create_args: {}
|
||||
subnet_create_args: {}
|
||||
subnet_cidr_start: "1.1.0.0/30"
|
||||
subnets_per_network: 2
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 30
|
||||
concurrency: 10
|
||||
context:
|
||||
users:
|
||||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
quotas:
|
||||
neutron:
|
||||
network: -1
|
||||
subnet: -1
|
||||
sla:
|
||||
max_failure_percent: 0
|
||||
|
||||
NeutronNetworks.create_and_delete_ports:
|
||||
-
|
||||
args:
|
||||
network_create_args: {}
|
||||
port_create_args: {}
|
||||
ports_per_network: 10
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 30
|
||||
concurrency: 10
|
||||
context:
|
||||
users:
|
||||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
quotas:
|
||||
neutron:
|
||||
network: -1
|
||||
port: -1
|
||||
sla:
|
||||
max_failure_percent: 0
|
||||
|
||||
VMTasks.boot_runcommand_delete:
|
||||
-
|
||||
args:
|
||||
|
@ -40,6 +40,19 @@ class NeutronNetworks(utils.NeutronScenario):
|
||||
self._create_network(network_create_args or {})
|
||||
self._list_networks()
|
||||
|
||||
@base.scenario(context={"cleanup": ["neutron"]})
|
||||
@validation.required_services(consts.Service.NEUTRON)
|
||||
def create_and_delete_networks(self, network_create_args=None):
|
||||
"""Create a network and then deleting it.
|
||||
|
||||
This scenario is a very useful tool to measure
|
||||
the "neutron net-create" and "net-delete" command performance.
|
||||
|
||||
:param network_create_agrs: dict, POST /v2.0/networks request options
|
||||
"""
|
||||
network = self._create_network(network_create_args or {})
|
||||
self._delete_network(network['network'])
|
||||
|
||||
@base.scenario(context={"cleanup": ["neutron"]})
|
||||
@validation.add(validation.required_parameters(['subnets_per_network']))
|
||||
@validation.required_services(consts.Service.NEUTRON)
|
||||
@ -66,6 +79,32 @@ class NeutronNetworks(utils.NeutronScenario):
|
||||
|
||||
self._list_subnets()
|
||||
|
||||
@base.scenario(context={"cleanup": ["neutron"]})
|
||||
@validation.add(validation.required_parameters(['subnets_per_network']))
|
||||
@validation.required_services(consts.Service.NEUTRON)
|
||||
def create_and_delete_subnets(self,
|
||||
network_create_args=None,
|
||||
subnet_create_args=None,
|
||||
subnet_cidr_start=None,
|
||||
subnets_per_network=None):
|
||||
"""Test creating and deleting a given number of subnets.
|
||||
|
||||
The scenario creates a network, a given number of subnets and then
|
||||
deletes subnets.
|
||||
|
||||
: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
|
||||
"""
|
||||
|
||||
if subnet_cidr_start:
|
||||
NeutronNetworks.SUBNET_CIDR_START = subnet_cidr_start
|
||||
network = self._create_network(network_create_args or {})
|
||||
for i in range(subnets_per_network):
|
||||
subnet = self._create_subnet(network, subnet_create_args or {})
|
||||
self._delete_subnet(subnet)
|
||||
|
||||
@base.scenario(context={"cleanup": ["neutron"]})
|
||||
@validation.add(validation.required_parameters(['subnets_per_network']))
|
||||
@validation.required_services(consts.Service.NEUTRON)
|
||||
@ -116,3 +155,25 @@ class NeutronNetworks(utils.NeutronScenario):
|
||||
self._create_port(network, port_create_args or {})
|
||||
|
||||
self._list_ports()
|
||||
|
||||
@base.scenario(context={"cleanup": ["neutron"]})
|
||||
@validation.add(validation.required_parameters(["ports_per_network"]))
|
||||
@validation.required_services(consts.Service.NEUTRON)
|
||||
def create_and_delete_ports(self,
|
||||
network_create_args=None,
|
||||
port_create_args=None,
|
||||
ports_per_network=None):
|
||||
"""Create a port and then deleting it.
|
||||
|
||||
This scenario is a very useful tool to measure
|
||||
the "neutron port-create" and
|
||||
"neutron port-delete" command performance.
|
||||
|
||||
:param network_create_args: dict, POST /v2.0/networks request options
|
||||
:param port_create_args: dict, POST /v2.0/ports request options
|
||||
:param ports_per_network: int, number of ports for one network
|
||||
"""
|
||||
network = self._create_network(network_create_args or {})
|
||||
for i in range(ports_per_network):
|
||||
port = self._create_port(network, port_create_args or {})
|
||||
self._delete_port(port)
|
||||
|
@ -62,6 +62,14 @@ class NeutronScenario(base.Scenario):
|
||||
"""Return user networks list."""
|
||||
return self.clients("neutron").list_networks()['networks']
|
||||
|
||||
@scenario_utils.atomic_action_timer('neutron.delete_network')
|
||||
def _delete_network(self, network):
|
||||
"""Delete neutron network.
|
||||
|
||||
:param network: Network object
|
||||
"""
|
||||
self.clients("neutron").delete_network(network['id'])
|
||||
|
||||
@scenario_utils.atomic_action_timer('neutron.create_subnet')
|
||||
def _create_subnet(self, network, subnet_create_args):
|
||||
"""Create neutron subnet.
|
||||
@ -87,6 +95,14 @@ class NeutronScenario(base.Scenario):
|
||||
"""Returns user subnetworks list."""
|
||||
return self.clients("neutron").list_subnets()["subnets"]
|
||||
|
||||
@scenario_utils.atomic_action_timer('neutron.delete_subnet')
|
||||
def _delete_subnet(self, subnet):
|
||||
"""Delete neutron subnet
|
||||
|
||||
:param subnet: Subnet object
|
||||
"""
|
||||
self.clients("neutron").delete_subnet(subnet['subnet']['id'])
|
||||
|
||||
@scenario_utils.atomic_action_timer('neutron.create_router')
|
||||
def _create_router(self, router_create_args):
|
||||
"""Create neutron router.
|
||||
@ -121,3 +137,11 @@ class NeutronScenario(base.Scenario):
|
||||
def _list_ports(self):
|
||||
"""Return user ports list."""
|
||||
return self.clients("neutron").list_ports()["ports"]
|
||||
|
||||
@scenario_utils.atomic_action_timer('neutron.delete_port')
|
||||
def _delete_port(self, port):
|
||||
"""Delete neutron port.
|
||||
|
||||
:param port: Port object
|
||||
"""
|
||||
self.clients("neutron").delete_port(port['port']['id'])
|
||||
|
@ -45,6 +45,27 @@ class NeutronNetworksTestCase(test.TestCase):
|
||||
mock_create.assert_called_once_with(network_create_args)
|
||||
mock_list.assert_called_once_with()
|
||||
|
||||
@mock.patch(NEUTRON_NETWORKS + "._delete_network")
|
||||
@mock.patch(NEUTRON_NETWORKS + "._create_network")
|
||||
def test_create_and_delete_networks(self, mock_create, mock_delete):
|
||||
neutron_scenario = network.NeutronNetworks()
|
||||
|
||||
# Default options
|
||||
network_create_args = {}
|
||||
neutron_scenario.create_and_delete_networks()
|
||||
mock_create.assert_called_once_with(network_create_args)
|
||||
mock_delete.assert_called_once()
|
||||
|
||||
mock_create.reset_mock()
|
||||
mock_delete.reset_mock()
|
||||
|
||||
# Explict network name is specified
|
||||
network_create_args = {"name": "given-name"}
|
||||
neutron_scenario.create_and_delete_networks(
|
||||
network_create_args=network_create_args)
|
||||
mock_create.assert_called_once_with(network_create_args)
|
||||
mock_delete.assert_called_once()
|
||||
|
||||
@mock.patch(NEUTRON_NETWORKS + "._list_subnets")
|
||||
@mock.patch(NEUTRON_NETWORKS + "._create_subnet")
|
||||
@mock.patch(NEUTRON_NETWORKS + "._create_network")
|
||||
@ -92,6 +113,53 @@ class NeutronNetworksTestCase(test.TestCase):
|
||||
{"allocation_pools": []})] * subnets_per_network)
|
||||
mock_list.assert_called_once_with()
|
||||
|
||||
@mock.patch(NEUTRON_NETWORKS + "._delete_subnet")
|
||||
@mock.patch(NEUTRON_NETWORKS + "._create_subnet")
|
||||
@mock.patch(NEUTRON_NETWORKS + "._create_network")
|
||||
@mock.patch(NEUTRON_NETWORKS + ".SUBNET_CIDR_START",
|
||||
new_callable=mock.PropertyMock(return_value="default_cidr"))
|
||||
def test_create_and_delete_subnets(self,
|
||||
mock_cidr_start,
|
||||
mock_create_network,
|
||||
mock_create_subnet,
|
||||
mock_delete):
|
||||
scenario = network.NeutronNetworks()
|
||||
mock_create_network.return_value = {"network": {"id": "fake-id"}}
|
||||
subnets_per_network = 4
|
||||
|
||||
self.assertRaises(TypeError, scenario.create_and_delete_subnets)
|
||||
|
||||
mock_create_network.reset_mock()
|
||||
mock_create_subnet.reset_mock()
|
||||
mock_delete.reset_mock()
|
||||
|
||||
# Default options
|
||||
scenario.create_and_delete_subnets(
|
||||
subnets_per_network=subnets_per_network)
|
||||
mock_create_network.assert_called_once_with({})
|
||||
self.assertEqual(mock_create_subnet.mock_calls,
|
||||
[mock.call({"network": {"id": "fake-id"}},
|
||||
{})] * subnets_per_network)
|
||||
mock_delete.assert_called_once()
|
||||
self.assertEqual(scenario.SUBNET_CIDR_START, "default_cidr")
|
||||
|
||||
mock_create_network.reset_mock()
|
||||
mock_create_subnet.reset_mock()
|
||||
mock_delete.reset_mock()
|
||||
|
||||
# Custom options
|
||||
scenario.create_and_delete_subnets(
|
||||
subnet_create_args={"allocation_pools": []},
|
||||
subnet_cidr_start="custom_cidr",
|
||||
subnets_per_network=subnets_per_network)
|
||||
self.assertEqual(scenario.SUBNET_CIDR_START, "custom_cidr")
|
||||
mock_create_network.assert_called_once_with({})
|
||||
self.assertEqual(
|
||||
mock_create_subnet.mock_calls,
|
||||
[mock.call({"network": {"id": "fake-id"}},
|
||||
{"allocation_pools": []})] * subnets_per_network)
|
||||
mock_delete.assert_called_once()
|
||||
|
||||
@mock.patch(NEUTRON_NETWORKS + "._list_routers")
|
||||
@mock.patch(NEUTRON_NETWORKS + "._create_router")
|
||||
@mock.patch(NEUTRON_NETWORKS + "._create_subnet")
|
||||
@ -205,3 +273,44 @@ class NeutronNetworksTestCase(test.TestCase):
|
||||
mock_create_port.mock_calls,
|
||||
[mock.call(net, {"allocation_pools": []})] * ports_per_network)
|
||||
mock_list.assert_called_once_with()
|
||||
|
||||
@mock.patch(NEUTRON_NETWORKS + "._generate_random_name")
|
||||
@mock.patch(NEUTRON_NETWORKS + "._delete_port")
|
||||
@mock.patch(NEUTRON_NETWORKS + "._create_port")
|
||||
@mock.patch(NEUTRON_NETWORKS + "._create_network")
|
||||
def test_create_and_delete_ports(self,
|
||||
mock_create_network,
|
||||
mock_create_port,
|
||||
mock_delete,
|
||||
mock_random_name):
|
||||
scenario = network.NeutronNetworks()
|
||||
mock_random_name.return_value = "random-name"
|
||||
net = {"network": {"id": "fake-id"}}
|
||||
mock_create_network.return_value = net
|
||||
ports_per_network = 10
|
||||
|
||||
self.assertRaises(TypeError, scenario.create_and_delete_ports)
|
||||
|
||||
mock_create_network.reset_mock()
|
||||
|
||||
# Default options
|
||||
scenario.create_and_delete_ports(ports_per_network=ports_per_network)
|
||||
mock_create_network.assert_called_once_with({})
|
||||
self.assertEqual(mock_create_port.mock_calls,
|
||||
[mock.call(net, {})] * ports_per_network)
|
||||
mock_delete.assert_called_once()
|
||||
|
||||
mock_create_network.reset_mock()
|
||||
mock_create_port.reset_mock()
|
||||
mock_delete.reset()
|
||||
|
||||
# Custom options
|
||||
scenario.create_and_delete_ports(
|
||||
network_create_args={"name": "given-name"},
|
||||
port_create_args={"allocation_pools": []},
|
||||
ports_per_network=ports_per_network)
|
||||
mock_create_network.assert_called_once_with({"name": "given-name"})
|
||||
self.assertEqual(
|
||||
mock_create_port.mock_calls,
|
||||
[mock.call(net, {"allocation_pools": []})] * ports_per_network)
|
||||
mock_delete.assert_called_once()
|
||||
|
@ -75,6 +75,16 @@ class NeutronScenarioTestCase(test.TestCase):
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
'neutron.list_networks')
|
||||
|
||||
@mock.patch(NEUTRON_UTILS + 'NeutronScenario.clients')
|
||||
def test_delete_network(self, mock_clients):
|
||||
scenario = utils.NeutronScenario()
|
||||
|
||||
network_create_args = {}
|
||||
network = scenario._create_network(network_create_args)
|
||||
scenario._delete_network(network)
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
'neutron.delete_network')
|
||||
|
||||
@mock.patch(NEUTRON_UTILS + 'NeutronScenario._generate_random_name')
|
||||
@mock.patch(NEUTRON_UTILS + "NeutronScenario._generate_subnet_cidr")
|
||||
@mock.patch(NEUTRON_UTILS + "NeutronScenario.clients")
|
||||
@ -125,6 +135,17 @@ class NeutronScenarioTestCase(test.TestCase):
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"neutron.list_subnets")
|
||||
|
||||
@mock.patch(NEUTRON_UTILS + 'NeutronScenario.clients')
|
||||
def test_delete_subnet(self, mock_clients):
|
||||
scenario = utils.NeutronScenario()
|
||||
|
||||
network = scenario._create_network({})
|
||||
subnet = scenario._create_subnet(network, {})
|
||||
scenario._delete_subnet(subnet)
|
||||
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
'neutron.delete_subnet')
|
||||
|
||||
@mock.patch(NEUTRON_UTILS + 'NeutronScenario._generate_random_name')
|
||||
@mock.patch(NEUTRON_UTILS + 'NeutronScenario.clients')
|
||||
def test_create_router(self, mock_clients, mock_random_name):
|
||||
@ -229,3 +250,14 @@ class NeutronScenarioTestCase(test.TestCase):
|
||||
self.assertEqual(ports, scenario._list_ports())
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"neutron.list_ports")
|
||||
|
||||
@mock.patch(NEUTRON_UTILS + 'NeutronScenario.clients')
|
||||
def test_delete_port(self, mock_clients):
|
||||
scenario = utils.NeutronScenario()
|
||||
|
||||
network = scenario._create_network({})
|
||||
port = scenario._create_port(network, {})
|
||||
scenario._delete_port(port)
|
||||
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"neutron.create_port")
|
||||
|
Loading…
Reference in New Issue
Block a user