diff --git a/neutron/tests/common/conn_testers.py b/neutron/tests/common/conn_testers.py index f8b302ef1e9..78460c01d6a 100644 --- a/neutron/tests/common/conn_testers.py +++ b/neutron/tests/common/conn_testers.py @@ -15,13 +15,24 @@ import functools import fixtures +from neutron_lib import constants as n_consts from oslo_utils import uuidutils from neutron.agent import firewall +from neutron.agent.linux import ip_lib from neutron.common import constants from neutron.tests.common import machine_fixtures from neutron.tests.common import net_helpers +# NOTE: IPv6 uses NDP for obtaining destination endpoints link address that +# extends round-trip packet time in ICMP tests. The timeout value should be +# sufficient for correct scenarios but not too high because of negative +# tests. +ICMP_VERSION_TIMEOUTS = { + n_consts.IP_VERSION_4: 1, + n_consts.IP_VERSION_6: 2, +} + class ConnectionTesterException(Exception): pass @@ -139,8 +150,11 @@ class ConnectionTester(fixtures.Fixture): def _test_icmp_connectivity(self, direction, protocol, src_port, dst_port): src_namespace, ip_address = self._get_namespace_and_address(direction) + ip_version = ip_lib.get_ip_version(ip_address) + icmp_timeout = ICMP_VERSION_TIMEOUTS[ip_version] try: - net_helpers.assert_ping(src_namespace, ip_address) + net_helpers.assert_ping(src_namespace, ip_address, + timeout=icmp_timeout) except RuntimeError: raise ConnectionTesterException( "ICMP packets can't get from %s namespace to %s address" % (