From 4168e20243abdedd0d7901c5369106a12f0967fe Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Tue, 17 Nov 2020 12:53:03 -0800 Subject: [PATCH] auto-t: add test_ip_connected to testutil Used to check IP connectivity between namespaces. The input should be two tuples containing the IP and namespace to ping from/to. --- autotests/util/testutil.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/autotests/util/testutil.py b/autotests/util/testutil.py index faa81f65..94f8ef32 100644 --- a/autotests/util/testutil.py +++ b/autotests/util/testutil.py @@ -152,3 +152,13 @@ def test_ip_address_match(intf, ip): if ip != addr: raise Exception('IP for %s did not match %s (was %s)' % (intf, ip, addr)) + +def test_ip_connected(tup0, tup1): + ip0, ns0 = tup0 + ip1, ns1 = tup1 + + try: + ns0.start_process(['ping', '-c', '5', '-i', '0.2', ip1], check=True) + ns1.start_process(['ping', '-c', '5', '-i', '0.2', ip0], check=True) + except: + raise Exception('Could not ping between %s and %s' % (ip0, ip1))