Add BGP VPN scenarios

Add NeutronBGPVPN.create_and_list_routers_associations
and NeutronBGPVPN.create_and_list_networks_associations.

Measure the neutron bgpvpn-net-assoc-list and
neutron neutron bgpvpn-router-assoc-list commands performance.

Change-Id: I8880da0e9f7b76e25ce842d688edf3ca256237a9
This commit is contained in:
Cédric Savignan 2017-05-30 16:13:51 +02:00 committed by chenhb
parent c4026b3ec4
commit be710cc1f6
17 changed files with 399 additions and 93 deletions

View File

@ -68,6 +68,7 @@
users:
tenants: 3
users_per_tenant: 2
network: {}
sla:
failure_rate:
max: 0
@ -82,6 +83,37 @@
users:
tenants: 3
users_per_tenant: 2
router: {}
sla:
failure_rate:
max: 0
NeutronBGPVPN.create_and_list_networks_associations:
-
runner:
type: "constant"
times: 10
concurrency: 2
context:
users:
tenants: 3
users_per_tenant: 2
network: {}
sla:
failure_rate:
max: 0
NeutronBGPVPN.create_and_list_routers_associations:
-
runner:
type: "constant"
times: 10
concurrency: 2
context:
users:
tenants: 3
users_per_tenant: 2
router: {}
sla:
failure_rate:
max: 0

View File

@ -145,6 +145,7 @@ class CreateAndUpdateBgpvpns(utils.NeutronScenario):
@validation.add("required_services", services=[consts.Service.NEUTRON])
@validation.add("required_platform", platform="openstack",
admin=True, users=True)
@validation.add("required_contexts", contexts=("network"))
@scenario.configure(context={"admin_cleanup": ["neutron"],
"cleanup": ["neutron"]},
name="NeutronBGPVPN.create_bgpvpn_assoc_disassoc_networks")
@ -167,18 +168,14 @@ class CreateAndAssociateDissassociateNetworks(utils.NeutronScenario):
Acceptable formats: l2 and l3
"""
networks = self._list_networks(
tenant_id=self.context["user"]["tenant_id"])
if not networks:
network = self._create_network({})
else:
network = {"network": networks[0]}
networks = self.context.get("tenant", {}).get("networks", [])
network = networks[0]
bgpvpn = self._create_bgpvpn(route_targets=route_targets,
import_targets=import_targets,
export_targets=export_targets,
route_distinguishers=route_distinguishers,
type=bgpvpn_type,
tenant_id=network["network"]["tenant_id"])
tenant_id=network["tenant_id"])
net_asso = self._create_bgpvpn_network_assoc(bgpvpn, network)
self._delete_bgpvpn_network_assoc(bgpvpn, net_asso)
@ -189,6 +186,7 @@ class CreateAndAssociateDissassociateNetworks(utils.NeutronScenario):
@validation.add("required_services", services=[consts.Service.NEUTRON])
@validation.add("required_platform", platform="openstack",
admin=True, users=True)
@validation.add("required_contexts", contexts=("router"))
@scenario.configure(context={"admin_cleanup": ["neutron"],
"cleanup": ["neutron"]},
name="NeutronBGPVPN.create_bgpvpn_assoc_disassoc_routers")
@ -212,16 +210,112 @@ class CreateAndAssociateDissassociateRouters(utils.NeutronScenario):
Acceptable formats: l2 and l3
"""
routers = self._list_routers()
if not routers:
router = self._create_router({})
else:
router = {"router": routers[0]}
routers = self.context.get("tenant", {}).get("routers", [])
router = routers[0]["router"]
bgpvpn = self._create_bgpvpn(route_targets=route_targets,
import_targets=import_targets,
export_targets=export_targets,
route_distinguishers=route_distinguishers,
type=bgpvpn_type,
tenant_id=router["router"]["tenant_id"])
tenant_id=router["tenant_id"])
router_asso = self._create_bgpvpn_router_assoc(bgpvpn, router)
self._delete_bgpvpn_router_assoc(bgpvpn, router_asso)
@validation.add("enum", param_name="bgpvpn_type", values=["l2", "l3"],
missed=True)
@validation.add("required_neutron_extensions", extensions=["bgpvpn"])
@validation.add("required_services", services=[consts.Service.NEUTRON])
@validation.add("required_platform", platform="openstack",
admin=True, users=True)
@validation.add("required_contexts", contexts=("network"))
@scenario.configure(context={"admin_cleanup": ["neutron"]},
name="NeutronBGPVPN.create_and_list_networks_associations")
class CreateAndListNetworksAssocs(utils.NeutronScenario):
def run(self, route_targets=None, import_targets=None,
export_targets=None, route_distinguishers=None, bgpvpn_type="l3"):
"""Associate a network and list networks associations.
Measure the "neutron bgpvpn-create",
"neutron bgpvpn-net-assoc-create" and
"neutron bgpvpn-net-assoc-list" command performance.
:param route_targets: Route Targets that will be both imported and
used for export
:param import_targets: Additional Route Targets that will be imported
:param export_targets: Additional Route Targets that will be used
for export.
:param route_distinguishers: List of route distinguisher strings
:param bgpvpn_type: type of VPN and the technology behind it.
Acceptable formats: l2 and l3
"""
networks = self.context.get("tenant", {}).get("networks", [])
network = networks[0]
bgpvpn = self._create_bgpvpn(route_targets=route_targets,
import_targets=import_targets,
export_targets=export_targets,
route_distinguishers=route_distinguishers,
type=bgpvpn_type,
tenant_id=network["tenant_id"])
self._create_bgpvpn_network_assoc(bgpvpn, network)
net_assocs = self._list_bgpvpn_network_assocs(
bgpvpn)["network_associations"]
network_id = network["id"]
msg = ("Network not included into list of associated networks\n"
"Network created: {}\n"
"List of associations: {}").format(network, net_assocs)
list_networks = [net_assoc["network_id"] for net_assoc in net_assocs]
self.assertIn(network_id, list_networks, err_msg=msg)
@validation.add("enum", param_name="bgpvpn_type", values=["l2", "l3"],
missed=True)
@validation.add("required_neutron_extensions", extensions=["bgpvpn"])
@validation.add("required_services", services=[consts.Service.NEUTRON])
@validation.add("required_platform", platform="openstack",
admin=True, users=True)
@validation.add("required_contexts", contexts=("router"))
@scenario.configure(context={"admin_cleanup": ["neutron"]},
name="NeutronBGPVPN.create_and_list_routers_associations")
class CreateAndListRoutersAssocs(utils.NeutronScenario):
def run(self, route_targets=None, import_targets=None,
export_targets=None, route_distinguishers=None, bgpvpn_type="l3"):
"""Associate a router and list routers associations.
Measure the "neutron bgpvpn-create",
"neutron bgpvpn-router-assoc-create" and
"neutron bgpvpn-router-assoc-list" command performance.
:param route_targets: Route Targets that will be both imported and
used for export
:param import_targets: Additional Route Targets that will be imported
:param export_targets: Additional Route Targets that will be used
for export.
:param route_distinguishers: List of route distinguisher strings
:param bgpvpn_type: type of VPN and the technology behind it.
Acceptable formats: l2 and l3
"""
routers = self.context.get("tenant", {}).get("routers", [])
router = routers[0]["router"]
bgpvpn = self._create_bgpvpn(route_targets=route_targets,
import_targets=import_targets,
export_targets=export_targets,
route_distinguishers=route_distinguishers,
type=bgpvpn_type,
tenant_id=router["tenant_id"])
self._create_bgpvpn_router_assoc(bgpvpn, router)
router_assocs = self._list_bgpvpn_router_assocs(
bgpvpn)["router_associations"]
router_id = router["id"]
msg = ("Router not included into list of associated routers\n"
"Router created: {}\n"
"List of associations: {}").format(router, router_assocs)
list_routers = [r_assoc["router_id"] for r_assoc in router_assocs]
self.assertIn(router_id, list_routers, err_msg=msg)

View File

@ -718,7 +718,7 @@ class NeutronScenario(scenario.OpenStackScenario):
def _list_bgpvpns(self, **kwargs):
"""Return bgpvpns list.
:param kwargs: dict, POST /bgpvpn/bgpvpns request options
:param kwargs: dict, GET /bgpvpn/bgpvpns request options
:returns: bgpvpns list
"""
return self.admin_clients("neutron").list_bgpvpns(
@ -747,7 +747,7 @@ class NeutronScenario(scenario.OpenStackScenario):
:param network: dict, network
:return dict: network_association
"""
netassoc = {"network_id": network["network"]["id"]}
netassoc = {"network_id": network["id"]}
return self.clients("neutron").create_bgpvpn_network_assoc(
bgpvpn["bgpvpn"]["id"], {"network_association": netassoc})
@ -770,7 +770,7 @@ class NeutronScenario(scenario.OpenStackScenario):
:param router: dict, router
:return dict: network_association
"""
router_assoc = {"router_id": router["router"]["id"]}
router_assoc = {"router_id": router["id"]}
return self.clients("neutron").create_bgpvpn_router_assoc(
bgpvpn["bgpvpn"]["id"], {"router_association": router_assoc})
@ -785,6 +785,28 @@ class NeutronScenario(scenario.OpenStackScenario):
return self.clients("neutron").delete_bgpvpn_router_assoc(
bgpvpn["bgpvpn"]["id"], router_assoc["router_association"]["id"])
@atomic.action_timer("neutron.list_bgpvpn_network_assocs")
def _list_bgpvpn_network_assocs(self, bgpvpn, **kwargs):
"""List network association of bgpvpn
:param bgpvpn: dict, bgpvpn
:param **kwargs: dict, optional parameters
:return dict: network_association
"""
return self.clients("neutron").list_bgpvpn_network_assocs(
bgpvpn["bgpvpn"]["id"], **kwargs)
@atomic.action_timer("neutron.list_bgpvpn_router_assocs")
def _list_bgpvpn_router_assocs(self, bgpvpn, **kwargs):
"""List router association of bgpvpn
:param bgpvpn: dict, bgpvpn
:param **kwargs: dict, optional parameters
:return dict: router_association
"""
return self.clients("neutron").list_bgpvpn_router_assocs(
bgpvpn["bgpvpn"]["id"], **kwargs)
@atomic.action_timer("neutron.create_security_group_rule")
def _create_security_group_rule(self, security_group_id,
**security_group_rule_args):

View File

@ -12,11 +12,7 @@
"tenants": 1,
"users_per_tenant": 1
},
"quotas": {
"neutron": {
"network": -1
}
}
"network":{}
},
"sla": {
"failure_rate": {
@ -25,4 +21,4 @@
}
}
]
}
}

View File

@ -10,9 +10,7 @@
users:
tenants: 1
users_per_tenant: 1
quotas:
neutron:
network: -1
network: {}
sla:
failure_rate:
max: 0
max: 0

View File

@ -12,11 +12,7 @@
"tenants": 1,
"users_per_tenant": 1
},
"quotas": {
"neutron": {
"router": -1
}
}
"router":{}
},
"sla": {
"failure_rate": {
@ -25,4 +21,4 @@
}
}
]
}
}

View File

@ -10,9 +10,7 @@
users:
tenants: 1
users_per_tenant: 1
quotas:
neutron:
router: -1
router: {}
sla:
failure_rate:
max: 0
max: 0

View File

@ -20,4 +20,4 @@
}
}
]
}
}

View File

@ -20,4 +20,4 @@
}
}
]
}
}

View File

@ -0,0 +1,24 @@
{
"NeutronBGPVPN.create_and_list_networks_associations": [
{
"args":{},
"runner": {
"type": "constant",
"times": 10,
"concurrency": 2
},
"context": {
"users": {
"tenants": 1,
"users_per_tenant": 1
},
"network":{}
},
"sla": {
"failure_rate": {
"max": 0
}
}
}
]
}

View File

@ -0,0 +1,16 @@
---
NeutronBGPVPN.create_and_list_networks_associations:
-
args: {}
runner:
type: "constant"
times: 10
concurrency: 2
context:
users:
tenants: 1
users_per_tenant: 1
network: {}
sla:
failure_rate:
max: 0

View File

@ -0,0 +1,24 @@
{
"NeutronBGPVPN.create_and_list_routers_associations": [
{
"args":{},
"runner": {
"type": "constant",
"times": 10,
"concurrency": 2
},
"context": {
"users": {
"tenants": 1,
"users_per_tenant": 1
},
"router":{}
},
"sla": {
"failure_rate": {
"max": 0
}
}
}
]
}

View File

@ -0,0 +1,16 @@
---
NeutronBGPVPN.create_and_list_routers_associations:
-
args: {}
runner:
type: "constant"
times: 10
concurrency: 2
context:
users:
tenants: 1
users_per_tenant: 1
router: {}
sla:
failure_rate:
max: 0

View File

@ -1,19 +1,23 @@
{
"NeutronBGPVPN.create_and_update_bgpvpns": [
{
"args":{},
"args":{},
"runner": {
"type": "constant",
"times": 10,
"concurrency": 2
},
"context": {
"context": {
"users": {
"tenants": 1,
"users_per_tenant": 1
}
}
},
"sla": {
"failure_rate": {
"max": 0
}
}
}
]
}
}

View File

@ -9,4 +9,7 @@
context:
users:
tenants: 1
users_per_tenant: 1
users_per_tenant: 1
sla:
failure_rate:
max: 0

View File

@ -20,8 +20,28 @@ from tests.unit import test
@ddt.ddt
class NeutronBgpvpnTestCase(test.TestCase):
def _get_context(self):
def _get_context(self, resource=None):
context = test.get_test_context()
if resource in ("network", "router"):
context.update({
"user": {
"id": "fake_user",
"tenant_id": "fake_tenant",
"credential": mock.MagicMock()}
})
if resource == "network":
context.update(
{"tenant": {"id": "fake_tenant",
resource + "s": [{"id": "fake_net",
"tenant_id": "fake_tenant"}]}
})
elif resource == "router":
context.update(
{"tenant": {"id": "fake_tenant",
resource + "s": [
{resource: {"id": "fake_net",
"tenant_id": "fake_tenant"}}]}
})
return context
def _get_bgpvpn_create_data(self):
@ -107,73 +127,86 @@ class NeutronBgpvpnTestCase(test.TestCase):
scenario._update_bgpvpn.assert_called_once_with(
scenario._create_bgpvpn.return_value, **update_data)
@ddt.data(
{"list_networks": []},
{"list_networks": [{"tenant_id": "tenant_id", "id": "network_id"}]},
)
@ddt.unpack
def test_create_and_associate_disassociate_networks(self,
list_networks=None):
def test_create_and_associate_disassociate_networks(self):
scenario = bgpvpn.CreateAndAssociateDissassociateNetworks(
self._get_context())
self._get_context("network"))
create_data = self._get_bgpvpn_create_data()
create_data["tenant_id"] = "tenant_id"
network = {"network": {"tenant_id": "tenant_id",
"id": "network_id"}}
scenario.context = {"user": {"tenant_id": "tenant_id"}}
scenario._list_networks = mock.Mock(return_value=list_networks)
if not list_networks:
scenario._create_network = mock.Mock(return_value=network)
networks = self._get_context("network")["tenant"]["networks"]
create_data["tenant_id"] = networks[0]["tenant_id"]
scenario._create_bgpvpn = mock.Mock()
scenario._create_bgpvpn_network_assoc = mock.Mock()
scenario._delete_bgpvpn_network_assoc = mock.Mock()
scenario.run()
scenario._create_bgpvpn.assert_called_once_with(
type="l3", **create_data)
if list_networks:
given_network = {"network": {"tenant_id": "tenant_id",
"id": "network_id"}}
else:
scenario._create_network.assert_called_once_with({})
given_network = scenario._create_network.return_value
scenario._create_bgpvpn_network_assoc.assert_called_once_with(
scenario._create_bgpvpn.return_value, given_network)
scenario._create_bgpvpn.return_value, networks[0])
scenario._delete_bgpvpn_network_assoc.assert_called_once_with(
scenario._create_bgpvpn.return_value,
scenario._create_bgpvpn_network_assoc.return_value)
@ddt.data(
{"list_routers": []},
{"list_routers": [{"tenant_id": "tenant_id", "id": "router_id"}]},
)
@ddt.unpack
def test_create_and_associate_disassociate_routers(self,
list_routers=None):
def test_create_and_associate_disassociate_routers(self):
scenario = bgpvpn.CreateAndAssociateDissassociateRouters(
self._get_context())
self._get_context("router"))
create_data = self._get_bgpvpn_create_data()
create_data["tenant_id"] = "tenant_id"
router = {"router": {"tenant_id": "tenant_id",
"id": "router_id"}}
scenario._list_routers = mock.Mock(return_value=list_routers)
if not list_routers:
scenario._create_router = mock.Mock(return_value=router)
routers = self._get_context("router")["tenant"]["routers"]
router = routers[0]["router"]
create_data["tenant_id"] = router["tenant_id"]
scenario._create_bgpvpn = mock.Mock()
scenario._create_bgpvpn_router_assoc = mock.Mock()
scenario._delete_bgpvpn_router_assoc = mock.Mock()
scenario.run()
scenario._create_bgpvpn.assert_called_once_with(
type="l3", **create_data)
if list_routers:
given_router = {"router": {"tenant_id": "tenant_id",
"id": "router_id"}}
else:
scenario._create_router.assert_called_once_with({})
given_router = scenario._create_router.return_value
scenario._create_bgpvpn_router_assoc.assert_called_once_with(
scenario._create_bgpvpn.return_value, given_router)
scenario._create_bgpvpn.return_value, router)
scenario._delete_bgpvpn_router_assoc.assert_called_once_with(
scenario._create_bgpvpn.return_value,
scenario._create_bgpvpn_router_assoc.return_value)
def test_create_and_list_networks_assocs(self):
scenario = bgpvpn.CreateAndListNetworksAssocs(
self._get_context("network"))
create_data = self._get_bgpvpn_create_data()
networks = self._get_context("network")["tenant"]["networks"]
create_data["tenant_id"] = networks[0]["tenant_id"]
network_assocs = {
"network_associations": [{"network_id": networks[0]["id"]}]
}
scenario._create_bgpvpn = mock.Mock()
scenario._create_bgpvpn_network_assoc = mock.Mock()
scenario._list_bgpvpn_network_assocs = mock.Mock(
return_value=network_assocs)
scenario.run()
scenario._create_bgpvpn.assert_called_once_with(
type="l3", **create_data)
scenario._create_bgpvpn_network_assoc.assert_called_once_with(
scenario._create_bgpvpn.return_value, networks[0])
scenario._list_bgpvpn_network_assocs.assert_called_once_with(
scenario._create_bgpvpn.return_value)
def test_create_and_list_routers_assocs(self):
scenario = bgpvpn.CreateAndListRoutersAssocs(
self._get_context("router"))
create_data = self._get_bgpvpn_create_data()
routers = self._get_context("router")["tenant"]["routers"]
router = routers[0]["router"]
create_data["tenant_id"] = router["tenant_id"]
router_assocs = {
"router_associations": [{"router_id": router["id"]}]
}
scenario._create_bgpvpn = mock.Mock()
scenario._create_bgpvpn_router_assoc = mock.Mock()
scenario._list_bgpvpn_router_assocs = mock.Mock(
return_value=router_assocs)
scenario.run()
scenario._create_bgpvpn.assert_called_once_with(
type="l3", **create_data)
scenario._create_bgpvpn_router_assoc.assert_called_once_with(
scenario._create_bgpvpn.return_value, router)
scenario._list_bgpvpn_router_assocs.assert_called_once_with(
scenario._create_bgpvpn.return_value)

View File

@ -1124,11 +1124,11 @@ class NeutronScenarioTestCase(test.ScenarioTestCase):
"id": bgpvpn_id}}
self.clients(
"neutron").create_bgpvpn_network_assoc.return_value = value
network = {"network": {"id": network_id}}
network = {"id": network_id}
bgpvpn = {"bgpvpn": {"id": bgpvpn_id}}
return_value = self.scenario._create_bgpvpn_network_assoc(bgpvpn,
network)
netassoc = {"network_id": network["network"]["id"]}
netassoc = {"network_id": network["id"]}
self.clients(
"neutron").create_bgpvpn_network_assoc.assert_called_once_with(
bgpvpn_id, {"network_association": netassoc})
@ -1143,11 +1143,11 @@ class NeutronScenarioTestCase(test.ScenarioTestCase):
"router_id": router_id,
"id": "asso_id"}}
self.clients("neutron").create_bgpvpn_router_assoc.return_value = value
router = {"router": {"id": router_id}}
router = {"id": router_id}
bgpvpn = {"bgpvpn": {"id": bgpvpn_id}}
return_value = self.scenario._create_bgpvpn_router_assoc(bgpvpn,
router)
router_assoc = {"router_id": router["router"]["id"]}
router_assoc = {"router_id": router["id"]}
self.clients(
"neutron").create_bgpvpn_router_assoc.assert_called_once_with(
bgpvpn_id, {"router_association": router_assoc})
@ -1155,6 +1155,56 @@ class NeutronScenarioTestCase(test.ScenarioTestCase):
self._test_atomic_action_timer(self.scenario.atomic_actions(),
"neutron.create_bgpvpn_router_assoc")
def test__delete_bgpvpn_network_assoc(self):
bgpvpn_assoc_args = {}
asso_id = "aaaa-bbbb"
network_assoc = {"network_association": {"id": asso_id}}
bgpvpn = self.scenario._create_bgpvpn(**bgpvpn_assoc_args)
self.scenario._delete_bgpvpn_network_assoc(bgpvpn, network_assoc)
self.clients(
"neutron").delete_bgpvpn_network_assoc.assert_called_once_with(
bgpvpn["bgpvpn"]["id"], asso_id)
self._test_atomic_action_timer(self.scenario.atomic_actions(),
"neutron.delete_bgpvpn_network_assoc")
def test__delete_bgpvpn_router_assoc(self):
bgpvpn_assoc_args = {}
asso_id = "aaaa-bbbb"
router_assoc = {"router_association": {"id": asso_id}}
bgpvpn = self.scenario._create_bgpvpn(**bgpvpn_assoc_args)
self.scenario._delete_bgpvpn_router_assoc(bgpvpn, router_assoc)
self.clients(
"neutron").delete_bgpvpn_router_assoc.assert_called_once_with(
bgpvpn["bgpvpn"]["id"], asso_id)
self._test_atomic_action_timer(self.scenario.atomic_actions(),
"neutron.delete_bgpvpn_router_assoc")
def test__list_bgpvpn_network_assocs(self):
value = {"network_associations": []}
bgpvpn_id = "bgpvpn-id"
bgpvpn = {"bgpvpn": {"id": bgpvpn_id}}
self.clients("neutron").list_bgpvpn_network_assocs.return_value = value
return_asso_list = self.scenario._list_bgpvpn_network_assocs(bgpvpn)
self.clients(
"neutron").list_bgpvpn_network_assocs.assert_called_once_with(
bgpvpn_id)
self.assertEqual(value, return_asso_list)
self._test_atomic_action_timer(self.scenario.atomic_actions(),
"neutron.list_bgpvpn_network_assocs")
def test__list_bgpvpn_router_assocs(self):
value = {"router_associations": []}
bgpvpn_id = "bgpvpn-id"
bgpvpn = {"bgpvpn": {"id": bgpvpn_id}}
self.clients("neutron").list_bgpvpn_router_assocs.return_value = value
return_asso_list = self.scenario._list_bgpvpn_router_assocs(bgpvpn)
self.clients(
"neutron").list_bgpvpn_router_assocs.assert_called_once_with(
bgpvpn_id)
self.assertEqual(value, return_asso_list)
self._test_atomic_action_timer(self.scenario.atomic_actions(),
"neutron.list_bgpvpn_router_assocs")
class NeutronScenarioFunctionalTestCase(test.FakeClientsScenarioTestCase):