Modify Bgpvpn scenarios to test true bgpvpn

Currently the bgpvpn scenarios test only a record in the database when
a bgpvpn is created and associated with a network or a router.

To test a true bgpvpn and not only a record in the neutron database
a active port need to be created in the network associated to the bgpvpn.

This change add a server which belong to a network in the context of all
the bgpvpn scenarios concerned. If a bgpvpn driver is used on the openstack,
a true bgpvpn is created.

Change-Id: I64fb6bacf7866332ea55b3c5792bb23db366decd
This commit is contained in:
Cédric Savignan 2017-11-21 15:18:50 +01:00
parent 5b1dbc71e8
commit d6f8c33baf
11 changed files with 170 additions and 36 deletions

View File

@ -1,3 +1,4 @@
{% set flavor_name = flavor_name or "m1.tiny" %}
---
NeutronLoadbalancerV2.create_and_list_loadbalancers:
-
@ -69,6 +70,13 @@
tenants: 2
users_per_tenant: 1
network: {}
servers:
servers_per_tenant: 1
auto_assign_nic: True
flavor:
name: "{{flavor_name}}"
image:
name: "^cirros.*-disk$"
sla:
failure_rate:
max: 0
@ -83,7 +91,14 @@
users:
tenants: 2
users_per_tenant: 1
router: {}
network: {}
servers:
servers_per_tenant: 1
auto_assign_nic: True
flavor:
name: "{{flavor_name}}"
image:
name: "^cirros.*-disk$"
sla:
failure_rate:
max: 0
@ -99,6 +114,13 @@
tenants: 2
users_per_tenant: 1
network: {}
servers:
servers_per_tenant: 1
auto_assign_nic: True
flavor:
name: "{{flavor_name}}"
image:
name: "^cirros.*-disk$"
sla:
failure_rate:
max: 0
@ -113,7 +135,14 @@
users:
tenants: 2
users_per_tenant: 1
router: {}
network: {}
servers:
servers_per_tenant: 1
auto_assign_nic: True
flavor:
name: "{{flavor_name}}"
image:
name: "^cirros.*-disk$"
sla:
failure_rate:
max: 0

View File

@ -9,12 +9,18 @@
# 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 random
from rally import consts
from rally.plugins.openstack import scenario
from rally.plugins.openstack.scenarios.neutron import utils
from rally.task import validation
def _create_random_route_target():
return "{}:{}".format(random.randint(0, 65535),
random.randint(0, 4294967295))
"""Scenarios for Neutron Networking-Bgpvpn."""
@ -148,7 +154,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"))
@validation.add("required_contexts", contexts=["network", "servers"])
@scenario.configure(context={"admin_cleanup@openstack": ["neutron"],
"cleanup@openstack": ["neutron"]},
name="NeutronBGPVPN.create_bgpvpn_assoc_disassoc_networks",
@ -171,9 +177,10 @@ class CreateAndAssociateDissassociateNetworks(utils.NeutronScenario):
: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]
if not route_targets:
route_targets = _create_random_route_target()
bgpvpn = self._create_bgpvpn(route_targets=route_targets,
import_targets=import_targets,
export_targets=export_targets,
@ -190,7 +197,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"))
@validation.add("required_contexts", contexts=["network", "servers"])
@scenario.configure(context={"admin_cleanup@openstack": ["neutron"],
"cleanup@openstack": ["neutron"]},
name="NeutronBGPVPN.create_bgpvpn_assoc_disassoc_routers",
@ -215,14 +222,17 @@ class CreateAndAssociateDissassociateRouters(utils.NeutronScenario):
Acceptable formats: l2 and l3
"""
routers = self.context.get("tenant", {}).get("routers", [])
router = routers[0]["router"]
router = {
"id": self.context["tenant"]["networks"][0]["router_id"]}
tenant_id = self.context["tenant"]["id"]
if not route_targets:
route_targets = _create_random_route_target()
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"])
tenant_id=tenant_id)
router_asso = self._create_bgpvpn_router_assoc(bgpvpn, router)
self._delete_bgpvpn_router_assoc(bgpvpn, router_asso)
@ -233,7 +243,7 @@ class CreateAndAssociateDissassociateRouters(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"))
@validation.add("required_contexts", contexts=["network", "servers"])
@scenario.configure(context={"admin_cleanup@openstack": ["neutron"]},
name="NeutronBGPVPN.create_and_list_networks_associations",
platform="openstack")
@ -259,6 +269,8 @@ class CreateAndListNetworksAssocs(utils.NeutronScenario):
networks = self.context.get("tenant", {}).get("networks", [])
network = networks[0]
if not route_targets:
route_targets = _create_random_route_target()
bgpvpn = self._create_bgpvpn(route_targets=route_targets,
import_targets=import_targets,
export_targets=export_targets,
@ -283,7 +295,7 @@ class CreateAndListNetworksAssocs(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"))
@validation.add("required_contexts", contexts=["network", "servers"])
@scenario.configure(context={"admin_cleanup@openstack": ["neutron"]},
name="NeutronBGPVPN.create_and_list_routers_associations",
platform="openstack")
@ -307,14 +319,18 @@ class CreateAndListRoutersAssocs(utils.NeutronScenario):
Acceptable formats: l2 and l3
"""
routers = self.context.get("tenant", {}).get("routers", [])
router = routers[0]["router"]
router = {
"id": self.context["tenant"]["networks"][0]["router_id"]}
tenant_id = self.context["tenant"]["id"]
if not route_targets:
route_targets = _create_random_route_target()
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"])
tenant_id=tenant_id)
self._create_bgpvpn_router_assoc(bgpvpn, router)
router_assocs = self._list_bgpvpn_router_assocs(
bgpvpn)["router_associations"]

View File

@ -1,3 +1,4 @@
{% set flavor_name = flavor_name or "m1.tiny" %}
{
"NeutronBGPVPN.create_bgpvpn_assoc_disassoc_networks": [
{
@ -9,10 +10,20 @@
},
"context": {
"users": {
"tenants": 1,
"tenants": 2,
"users_per_tenant": 1
},
"network":{}
"network": {},
"servers": {
"servers_per_tenant": 1,
"auto_assign_nic": true,
"flavor" : {
"name": "{{flavor_name}}"
},
"image": {
"name": "^cirros.*-disk$"
}
}
},
"sla": {
"failure_rate": {

View File

@ -1,3 +1,4 @@
{% set flavor_name = flavor_name or "m1.tiny" %}
---
NeutronBGPVPN.create_bgpvpn_assoc_disassoc_networks:
-
@ -8,9 +9,16 @@
concurrency: 2
context:
users:
tenants: 1
tenants: 2
users_per_tenant: 1
network: {}
servers:
servers_per_tenant: 1
auto_assign_nic: True
flavor:
name: "{{flavor_name}}"
image:
name: "^cirros.*-disk$"
sla:
failure_rate:
max: 0

View File

@ -1,3 +1,4 @@
{% set flavor_name = flavor_name or "m1.tiny" %}
{
"NeutronBGPVPN.create_bgpvpn_assoc_disassoc_routers": [
{
@ -9,10 +10,20 @@
},
"context": {
"users": {
"tenants": 1,
"tenants": 2,
"users_per_tenant": 1
},
"router":{}
"network": {},
"servers": {
"servers_per_tenant": 1,
"auto_assign_nic": true,
"flavor" : {
"name": "{{flavor_name}}"
},
"image": {
"name": "^cirros.*-disk$"
}
}
},
"sla": {
"failure_rate": {

View File

@ -1,3 +1,4 @@
{% set flavor_name = flavor_name or "m1.tiny" %}
---
NeutronBGPVPN.create_bgpvpn_assoc_disassoc_routers:
-
@ -8,9 +9,16 @@
concurrency: 2
context:
users:
tenants: 1
tenants: 2
users_per_tenant: 1
router: {}
network: {}
servers:
servers_per_tenant: 1
auto_assign_nic: True
flavor:
name: "{{flavor_name}}"
image:
name: "^cirros.*-disk$"
sla:
failure_rate:
max: 0

View File

@ -1,3 +1,4 @@
{% set flavor_name = flavor_name or "m1.tiny" %}
{
"NeutronBGPVPN.create_and_list_networks_associations": [
{
@ -12,7 +13,17 @@
"tenants": 1,
"users_per_tenant": 1
},
"network":{}
"network": {},
"servers": {
"servers_per_tenant": 1,
"auto_assign_nic": true,
"flavor" : {
"name": "{{flavor_name}}"
},
"image": {
"name": "^cirros.*-disk$"
}
}
},
"sla": {
"failure_rate": {

View File

@ -1,3 +1,4 @@
{% set flavor_name = flavor_name or "m1.tiny" %}
---
NeutronBGPVPN.create_and_list_networks_associations:
-
@ -11,6 +12,13 @@
tenants: 1
users_per_tenant: 1
network: {}
servers:
servers_per_tenant: 1
auto_assign_nic: True
flavor:
name: "{{flavor_name}}"
image:
name: "^cirros.*-disk$"
sla:
failure_rate:
max: 0

View File

@ -1,3 +1,4 @@
{% set flavor_name = flavor_name or "m1.tiny" %}
{
"NeutronBGPVPN.create_and_list_routers_associations": [
{
@ -12,7 +13,17 @@
"tenants": 1,
"users_per_tenant": 1
},
"router":{}
"network": {},
"servers": {
"servers_per_tenant": 1,
"auto_assign_nic": true,
"flavor" : {
"name": "{{flavor_name}}"
},
"image": {
"name": "^cirros.*-disk$"
}
}
},
"sla": {
"failure_rate": {

View File

@ -1,3 +1,4 @@
{% set flavor_name = flavor_name or "m1.tiny" %}
---
NeutronBGPVPN.create_and_list_routers_associations:
-
@ -10,7 +11,14 @@
users:
tenants: 1
users_per_tenant: 1
router: {}
network: {}
servers:
servers_per_tenant: 1
auto_assign_nic: True
flavor:
name: "{{flavor_name}}"
image:
name: "^cirros.*-disk$"
sla:
failure_rate:
max: 0

View File

@ -33,7 +33,8 @@ class NeutronBgpvpnTestCase(test.TestCase):
context.update(
{"tenant": {"id": "fake_tenant",
resource + "s": [{"id": "fake_net",
"tenant_id": "fake_tenant"}]}
"tenant_id": "fake_tenant",
"router_id": "fake_router"}]}
})
elif resource == "router":
context.update(
@ -127,12 +128,15 @@ class NeutronBgpvpnTestCase(test.TestCase):
scenario._update_bgpvpn.assert_called_once_with(
scenario._create_bgpvpn.return_value, **update_data)
def test_create_and_associate_disassociate_networks(self):
@mock.patch.object(bgpvpn, "random")
def test_create_and_associate_disassociate_networks(self, mock_random):
scenario = bgpvpn.CreateAndAssociateDissassociateNetworks(
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"]
mock_random.randint.return_value = 12345
create_data["route_targets"] = "12345:12345"
scenario._create_bgpvpn = mock.Mock()
scenario._create_bgpvpn_network_assoc = mock.Mock()
scenario._delete_bgpvpn_network_assoc = mock.Mock()
@ -146,13 +150,16 @@ class NeutronBgpvpnTestCase(test.TestCase):
scenario._create_bgpvpn.return_value,
scenario._create_bgpvpn_network_assoc.return_value)
def test_create_and_associate_disassociate_routers(self):
@mock.patch.object(bgpvpn, "random")
def test_create_and_associate_disassociate_routers(self, mock_random):
scenario = bgpvpn.CreateAndAssociateDissassociateRouters(
self._get_context("router"))
self._get_context("network"))
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 = {"id": self._get_context(
"network")["tenant"]["networks"][0]["router_id"]}
create_data["tenant_id"] = self._get_context("network")["tenant"]["id"]
mock_random.randint.return_value = 12345
create_data["route_targets"] = "12345:12345"
scenario._create_bgpvpn = mock.Mock()
scenario._create_bgpvpn_router_assoc = mock.Mock()
scenario._delete_bgpvpn_router_assoc = mock.Mock()
@ -166,7 +173,8 @@ class NeutronBgpvpnTestCase(test.TestCase):
scenario._create_bgpvpn.return_value,
scenario._create_bgpvpn_router_assoc.return_value)
def test_create_and_list_networks_assocs(self):
@mock.patch.object(bgpvpn, "random")
def test_create_and_list_networks_assocs(self, mock_random):
scenario = bgpvpn.CreateAndListNetworksAssocs(
self._get_context("network"))
create_data = self._get_bgpvpn_create_data()
@ -175,6 +183,8 @@ class NeutronBgpvpnTestCase(test.TestCase):
network_assocs = {
"network_associations": [{"network_id": networks[0]["id"]}]
}
mock_random.randint.return_value = 12345
create_data["route_targets"] = "12345:12345"
scenario._create_bgpvpn = mock.Mock()
scenario._create_bgpvpn_network_assoc = mock.Mock()
scenario._list_bgpvpn_network_assocs = mock.Mock(
@ -188,16 +198,19 @@ class NeutronBgpvpnTestCase(test.TestCase):
scenario._list_bgpvpn_network_assocs.assert_called_once_with(
scenario._create_bgpvpn.return_value)
def test_create_and_list_routers_assocs(self):
@mock.patch.object(bgpvpn, "random")
def test_create_and_list_routers_assocs(self, mock_random):
scenario = bgpvpn.CreateAndListRoutersAssocs(
self._get_context("router"))
self._get_context("network"))
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 = {"id": self._get_context(
"network")["tenant"]["networks"][0]["router_id"]}
create_data["tenant_id"] = self._get_context("network")["tenant"]["id"]
router_assocs = {
"router_associations": [{"router_id": router["id"]}]
}
mock_random.randint.return_value = 12345
create_data["route_targets"] = "12345:12345"
scenario._create_bgpvpn = mock.Mock()
scenario._create_bgpvpn_router_assoc = mock.Mock()
scenario._list_bgpvpn_router_assocs = mock.Mock(