summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Haley <brian.haley@hpe.com>2016-08-04 15:31:44 -0400
committerArmando Migliaccio <armamig@gmail.com>2016-08-04 21:02:12 +0000
commit395f34d47ddbe7776deecf4b98a6270a963849de (patch)
treeeabfa0a417dcde57e9caa09dac4c608ffc063bf6
parentcc6c2029ba05068df025643efdb373503b6cd40f (diff)
downloadneutron-395f34d47ddbe7776deecf4b98a6270a963849de.tar.gz
Restore old assert_ping behavior
assert_ping() was changed recently to be async-friendly, but the change caused the drop of a single packet to throw an error. Since occasionally the first packet is lost due to address resolution (ARP) we can't use it for checking liveness of an IP. Restored assert_ping() and moved updated code to assert_async_ping() since that is a special-case. (cherry picked from commit ca2aa3ca05aafcd3b7a81b81f8280ed363009f11) Change-Id: Ibe69417a0d819d4cd87e2f487c08fd126b1024e2
-rw-r--r--neutron/tests/common/net_helpers.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/neutron/tests/common/net_helpers.py b/neutron/tests/common/net_helpers.py
index 8cc57f82f3..ebf89e3fa8 100644
--- a/neutron/tests/common/net_helpers.py
+++ b/neutron/tests/common/net_helpers.py
@@ -86,7 +86,15 @@ def set_namespace_gateway(port_dev, gateway_ip):
port_dev.route.add_gateway(gateway_ip)
-def assert_ping(src_namespace, dst_ip, timeout=1, count=1, interval=1):
+def assert_ping(src_namespace, dst_ip, timeout=1, count=1):
+ ipversion = netaddr.IPAddress(dst_ip).version
+ ping_command = 'ping' if ipversion == 4 else 'ping6'
+ ns_ip_wrapper = ip_lib.IPWrapper(src_namespace)
+ ns_ip_wrapper.netns.execute([ping_command, '-c', count, '-W', timeout,
+ dst_ip])
+
+
+def assert_async_ping(src_namespace, dst_ip, timeout=1, count=1, interval=1):
ipversion = netaddr.IPAddress(dst_ip).version
ping_command = 'ping' if ipversion == 4 else 'ping6'
ns_ip_wrapper = ip_lib.IPWrapper(src_namespace)
@@ -107,7 +115,7 @@ def assert_ping(src_namespace, dst_ip, timeout=1, count=1, interval=1):
@contextlib.contextmanager
def async_ping(namespace, ips):
with futures.ThreadPoolExecutor(max_workers=len(ips)) as executor:
- fs = [executor.submit(assert_ping, namespace, ip, count=10)
+ fs = [executor.submit(assert_async_ping, namespace, ip, count=10)
for ip in ips]
yield lambda: all(f.done() for f in fs)
futures.wait(fs)