diff --git a/neutron/tests/common/helpers.py b/neutron/tests/common/helpers.py index 21540516fc4..63a132b8cdb 100644 --- a/neutron/tests/common/helpers.py +++ b/neutron/tests/common/helpers.py @@ -13,6 +13,8 @@ # under the License. import datetime +from distutils import version +import functools import os import random @@ -22,6 +24,7 @@ import six import testtools import neutron +from neutron.agent.common import ovs_lib from neutron.common import topics from neutron import context from neutron.db import agents_db @@ -220,3 +223,21 @@ def get_not_used_vlan(bridge, vlan_range): used_vlan_tags = {val['tag'] for val in port_vlans} available_vlans = vlan_range - used_vlan_tags return random.choice(list(available_vlans)) + + +def skip_if_ovs_older_than(ovs_version): + """Decorator for test method to skip if OVS version doesn't meet + minimal requirement. + """ + def skip_if_bad_ovs(f): + @functools.wraps(f) + def check_ovs_and_skip(test): + ovs = ovs_lib.BaseOVS() + current_ovs_version = version.StrictVersion( + ovs.config['ovs_version']) + if current_ovs_version < version.StrictVersion(ovs_version): + test.skip("This test requires OVS version %s or higher." % + ovs_version) + return f(test) + return check_ovs_and_skip + return skip_if_bad_ovs diff --git a/neutron/tests/contrib/gate_hook.sh b/neutron/tests/contrib/gate_hook.sh index 1911ec0f729..bbd82e4ffc1 100644 --- a/neutron/tests/contrib/gate_hook.sh +++ b/neutron/tests/contrib/gate_hook.sh @@ -63,14 +63,11 @@ case $VENV in configure_host_for_func_testing - # Kernel modules are not needed for functional job. They are needed only - # for fullstack because of bug present in Ubuntu Xenial kernel version - # that makes VXLAN local tunneling fail. - if [[ "$VENV" =~ "dsvm-functional" ]]; then - compile_modules=False - NEUTRON_OVERRIDE_OVS_BRANCH=v2.5.1 + # Because of bug present in current Ubuntu Xenial kernel version + # we need a fix for VXLAN local tunneling. + if [[ "$VENV" =~ "dsvm-fullstack" ]]; then + upgrade_ovs_if_necessary fi - upgrade_ovs_if_necessary $compile_modules # prepare base environment for ./stack.sh load_rc_hook stack_base diff --git a/neutron/tests/functional/agent/test_ovs_flows.py b/neutron/tests/functional/agent/test_ovs_flows.py index 48e323064f8..2dad61f8a07 100644 --- a/neutron/tests/functional/agent/test_ovs_flows.py +++ b/neutron/tests/functional/agent/test_ovs_flows.py @@ -32,6 +32,7 @@ from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants from neutron.plugins.ml2.drivers.openvswitch.agent \ import ovs_neutron_agent as ovsagt from neutron.tests.common import base as common_base +from neutron.tests.common import helpers from neutron.tests.common import net_helpers from neutron.tests.functional.agent import test_ovs_lib from neutron.tests.functional import base @@ -387,6 +388,7 @@ class OVSFlowTestCase(OVSAgentTestBase): self.assertIn(("dl_src=%(gateway_mac)s" % kwargs), trace["Final flow"]) + @helpers.skip_if_ovs_older_than("2.5.1") def test_install_flood_to_tun(self): attrs = { 'remote_ip': '192.0.2.1', # RFC 5737 TEST-NET-1