Merge "Skip MTU check during deletion of Networks"
This commit is contained in:
commit
d786643214
@ -1938,7 +1938,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
# change in segments could affect resulting network mtu, so let's
|
||||
# recalculate it
|
||||
network_db = self._get_network(context, network_id)
|
||||
network_db.mtu = self._get_network_mtu(network_db)
|
||||
network_db.mtu = self._get_network_mtu(network_db,
|
||||
validate=(event != events.PRECOMMIT_DELETE))
|
||||
network_db.save(session=context.session)
|
||||
|
||||
try:
|
||||
|
@ -57,6 +57,11 @@ class ClientFixture(fixtures.Fixture):
|
||||
resp = update(id, body=body)
|
||||
return resp[resource_type]
|
||||
|
||||
def _delete_resource(self, resource_type, id):
|
||||
delete = getattr(self.client, 'delete_%s' % resource_type)
|
||||
|
||||
return delete(id)
|
||||
|
||||
def create_router(self, tenant_id, name=None, ha=False,
|
||||
external_network=None):
|
||||
resource_type = 'router'
|
||||
@ -70,7 +75,7 @@ class ClientFixture(fixtures.Fixture):
|
||||
|
||||
def create_network(self, tenant_id, name=None, external=False,
|
||||
network_type=None, segmentation_id=None,
|
||||
physical_network=None):
|
||||
physical_network=None, mtu=None):
|
||||
resource_type = 'network'
|
||||
|
||||
name = name or utils.get_rand_name(prefix=resource_type)
|
||||
@ -83,12 +88,17 @@ class ClientFixture(fixtures.Fixture):
|
||||
spec['provider:network_type'] = network_type
|
||||
if physical_network is not None:
|
||||
spec['provider:physical_network'] = physical_network
|
||||
if mtu is not None:
|
||||
spec['mtu'] = mtu
|
||||
|
||||
return self._create_resource(resource_type, spec)
|
||||
|
||||
def update_network(self, id, **kwargs):
|
||||
return self._update_resource('network', id, kwargs)
|
||||
|
||||
def delete_network(self, id):
|
||||
return self._delete_resource('network', id)
|
||||
|
||||
def create_subnet(self, tenant_id, network_id,
|
||||
cidr, gateway_ip=None, name=None, enable_dhcp=True,
|
||||
ipv6_address_mode='slaac', ipv6_ra_mode='slaac'):
|
||||
|
@ -61,6 +61,7 @@ class NeutronConfigFixture(ConfigFixture):
|
||||
'service_plugins': env_desc.service_plugins,
|
||||
'auth_strategy': 'noauth',
|
||||
'debug': 'True',
|
||||
'global_physnet_mtu': env_desc.global_mtu,
|
||||
'agent_down_time': str(env_desc.agent_down_time),
|
||||
'transport_url':
|
||||
'rabbit://%(user)s:%(password)s@%(host)s:5672/%(vhost)s' %
|
||||
|
@ -18,6 +18,7 @@ from neutronclient.common import exceptions as nc_exc
|
||||
from oslo_config import cfg
|
||||
|
||||
from neutron.agent.linux import ip_lib
|
||||
from neutron.common import constants as common_const
|
||||
from neutron.common import utils as common_utils
|
||||
from neutron.plugins.ml2.drivers.linuxbridge.agent import \
|
||||
linuxbridge_neutron_agent as lb_agent
|
||||
@ -36,7 +37,8 @@ class EnvironmentDescription(object):
|
||||
def __init__(self, network_type='vxlan', l2_pop=True, qos=False,
|
||||
mech_drivers='openvswitch,linuxbridge',
|
||||
service_plugins='router', arp_responder=False,
|
||||
agent_down_time=75, router_scheduler=None):
|
||||
agent_down_time=75, router_scheduler=None,
|
||||
global_mtu=common_const.DEFAULT_NETWORK_MTU):
|
||||
self.network_type = network_type
|
||||
self.l2_pop = l2_pop
|
||||
self.qos = qos
|
||||
@ -45,7 +47,7 @@ class EnvironmentDescription(object):
|
||||
self.arp_responder = arp_responder
|
||||
self.agent_down_time = agent_down_time
|
||||
self.router_scheduler = router_scheduler
|
||||
|
||||
self.global_mtu = global_mtu
|
||||
self.service_plugins = service_plugins
|
||||
if self.qos:
|
||||
self.service_plugins += ',qos'
|
||||
|
61
neutron/tests/fullstack/test_mtu.py
Normal file
61
neutron/tests/fullstack/test_mtu.py
Normal file
@ -0,0 +1,61 @@
|
||||
# Copyright 2017 NEC India
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
# from neutronclient.common import exceptions
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from neutron.tests.fullstack import base
|
||||
from neutron.tests.fullstack.resources import environment
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
||||
load_tests = testlib_api.module_load_tests
|
||||
|
||||
|
||||
class MTUNetworkTestSetup(base.BaseFullStackTestCase):
|
||||
host_desc = [] # No need to register agents for this test case
|
||||
|
||||
def setUp(self):
|
||||
env = environment.Environment(
|
||||
environment.EnvironmentDescription(),
|
||||
self.host_desc)
|
||||
super(MTUNetworkTestSetup, self).setUp(env)
|
||||
|
||||
self.tenant_id = uuidutils.generate_uuid()
|
||||
|
||||
def _restart_neutron_server(self, global_mtu):
|
||||
env = environment.Environment(
|
||||
environment.EnvironmentDescription(global_mtu=global_mtu),
|
||||
self.host_desc)
|
||||
env.test_name = self.get_name()
|
||||
self.useFixture(env)
|
||||
env.neutron_server.restart()
|
||||
|
||||
|
||||
class TestMTUScenarios(MTUNetworkTestSetup):
|
||||
|
||||
def test_mtu_update_delete_network(self):
|
||||
network = self.safe_client.create_network(self.tenant_id,
|
||||
name='mtu-test-network',
|
||||
mtu=1450)
|
||||
self.safe_client.update_network(network['id'], mtu=9000)
|
||||
res = self.safe_client.delete_network(network['id'])
|
||||
self.assertEqual((), res)
|
||||
|
||||
def test_global_physnet_mtu_update_delete_network(self):
|
||||
network = self.safe_client.create_network(self.tenant_id,
|
||||
name='mtu-test-network',
|
||||
mtu=1450)
|
||||
self._restart_neutron_server(1400)
|
||||
res = self.safe_client.delete_network(network['id'])
|
||||
self.assertEqual((), res)
|
Loading…
Reference in New Issue
Block a user