Merge "Fullstack: init trunk agent's driver only when necessary"
This commit is contained in:
49
neutron/tests/fullstack/cmd/ovs_agent.py
Executable file
49
neutron/tests/fullstack/cmd/ovs_agent.py
Executable file
@@ -0,0 +1,49 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# Copyright 2017 OVH SAS
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from oslo_config import cfg
|
||||||
|
|
||||||
|
from neutron.services.trunk.drivers.openvswitch.agent \
|
||||||
|
import driver as trunk_driver
|
||||||
|
from neutron.tests.common.agents import ovs_agent
|
||||||
|
|
||||||
|
|
||||||
|
def monkeypatch_init_handler():
|
||||||
|
original_handler = trunk_driver.init_handler
|
||||||
|
|
||||||
|
def new_init_handler(resource, event, trigger, payload=None):
|
||||||
|
# NOTE(slaweq): make this setup conditional based on server-side
|
||||||
|
# capabilities for fullstack tests we can assume that server-side
|
||||||
|
# and agent-side conf are in sync
|
||||||
|
if "trunk" not in cfg.CONF.service_plugins:
|
||||||
|
return
|
||||||
|
original_handler(resource, event, trigger, payload)
|
||||||
|
|
||||||
|
trunk_driver.init_handler = new_init_handler
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
# TODO(slaweq): this monkepatch will not be necessary when
|
||||||
|
# https://review.openstack.org/#/c/506722/ will be merged and ovsdb-server
|
||||||
|
# ovs-vswitchd processes for each test will be isolated in separate
|
||||||
|
# namespace
|
||||||
|
monkeypatch_init_handler()
|
||||||
|
ovs_agent.main()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
@@ -35,7 +35,7 @@ class EnvironmentDescription(object):
|
|||||||
"""
|
"""
|
||||||
def __init__(self, network_type='vxlan', l2_pop=True, qos=False,
|
def __init__(self, network_type='vxlan', l2_pop=True, qos=False,
|
||||||
mech_drivers='openvswitch,linuxbridge',
|
mech_drivers='openvswitch,linuxbridge',
|
||||||
service_plugins='router,trunk', arp_responder=False,
|
service_plugins='router', arp_responder=False,
|
||||||
agent_down_time=75, router_scheduler=None):
|
agent_down_time=75, router_scheduler=None):
|
||||||
self.network_type = network_type
|
self.network_type = network_type
|
||||||
self.l2_pop = l2_pop
|
self.l2_pop = l2_pop
|
||||||
|
@@ -205,7 +205,7 @@ class OVSAgentFixture(ServiceFixture):
|
|||||||
process_name=self.NEUTRON_OVS_AGENT,
|
process_name=self.NEUTRON_OVS_AGENT,
|
||||||
exec_name=spawn.find_executable(
|
exec_name=spawn.find_executable(
|
||||||
'ovs_agent.py',
|
'ovs_agent.py',
|
||||||
path=os.path.join(base.ROOTDIR, 'common', 'agents')),
|
path=os.path.join(fullstack_base.ROOTDIR, 'cmd')),
|
||||||
config_filenames=config_filenames,
|
config_filenames=config_filenames,
|
||||||
kill_signal=signal.SIGTERM))
|
kill_signal=signal.SIGTERM))
|
||||||
|
|
||||||
|
@@ -91,7 +91,7 @@ class TestTrunkPlugin(base.BaseFullStackTestCase):
|
|||||||
host_desc = [environment.HostDescription(
|
host_desc = [environment.HostDescription(
|
||||||
l3_agent=False,
|
l3_agent=False,
|
||||||
l2_agent_type=constants.AGENT_TYPE_OVS)]
|
l2_agent_type=constants.AGENT_TYPE_OVS)]
|
||||||
env_desc = environment.EnvironmentDescription()
|
env_desc = environment.EnvironmentDescription(service_plugins='trunk')
|
||||||
env = environment.Environment(env_desc, host_desc)
|
env = environment.Environment(env_desc, host_desc)
|
||||||
super(TestTrunkPlugin, self).setUp(env)
|
super(TestTrunkPlugin, self).setUp(env)
|
||||||
|
|
||||||
@@ -207,6 +207,14 @@ class TestTrunkPlugin(base.BaseFullStackTestCase):
|
|||||||
vm.add_vlan_interface(
|
vm.add_vlan_interface(
|
||||||
subport['mac_address'], ip_network, subport_network.tag)
|
subport['mac_address'], ip_network, subport_network.tag)
|
||||||
|
|
||||||
|
# NOTE(slaweq): As is described in bug
|
||||||
|
# https://bugs.launchpad.net/neutron/+bug/1687709 when more than one
|
||||||
|
# different ovs-agent with enabled trunk driver is running at a time it
|
||||||
|
# might lead to race contitions between them.
|
||||||
|
# Because of that ovs_agent used for fullstack tests is monkeypatched and
|
||||||
|
# loads trunk driver only if trunk service plugin is enabled.
|
||||||
|
# That makes restriction that only a single set of tests with trunk-enabled
|
||||||
|
# services will run at the same time.
|
||||||
def test_trunk_lifecycle(self):
|
def test_trunk_lifecycle(self):
|
||||||
"""Test life-cycle of a fake VM with trunk port.
|
"""Test life-cycle of a fake VM with trunk port.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user