from lib.topogen import Topogen, TopoRouter, get_topogen
from lib.topolog import logger
from lib.common_config import required_linux_kernel_version
+from lib.checkping import check_ping
pytestmark = [pytest.mark.bgpd]
tgen.stop_topology()
-def check_ping4(name, dest_addr, expected):
- def _check(name, dest_addr, match):
- tgen = get_topogen()
- output = tgen.gears[name].run("ping {} -c 1 -w 1".format(dest_addr))
- logger.info(output)
- if match not in output:
- return "ping fail"
-
- match = ", {} packet loss".format("0%" if expected else "100%")
- logger.info("[+] check {} {} {}".format(name, dest_addr, match))
- tgen = get_topogen()
- func = functools.partial(_check, name, dest_addr, match)
- success, result = topotest.run_and_expect(func, None, count=10, wait=1)
- assert result is None, "Failed"
-
-
def test_ping():
tgen = get_topogen()
- check_ping4("c11", "192.168.2.1", True)
- check_ping4("c11", "192.168.3.1", True)
- check_ping4("c12", "192.168.2.1", True)
- check_ping4("c12", "192.168.3.1", True)
- check_ping4("c21", "192.168.3.1", True)
- check_ping4("c22", "192.168.3.1", True)
+ check_ping("c11", "192.168.2.1", True, 10, 1)
+ check_ping("c11", "192.168.3.1", True, 10, 1)
+ check_ping("c12", "192.168.2.1", True, 10, 1)
+ check_ping("c12", "192.168.3.1", True, 10, 1)
+ check_ping("c21", "192.168.3.1", True, 10, 1)
+ check_ping("c22", "192.168.3.1", True, 10, 1)
if __name__ == "__main__":
from lib.topogen import Topogen, TopoRouter, get_topogen
from lib.topolog import logger
from lib.common_config import required_linux_kernel_version
+from lib.checkping import check_ping
def build_topo(tgen):
assert False, "Could not read file {}".format(filename)
-def check_ping(name, dest_addr, expect_connected):
- def _check(name, dest_addr, match):
- tgen = get_topogen()
- output = tgen.gears[name].run("ping {} -c 1 -w 1".format(dest_addr))
- logger.info(output)
- if match not in output:
- return True
-
- match = ", {} packet loss".format("0%" if expect_connected else "100%")
- logger.info("[+] check {} {} {}".format(name, dest_addr, match))
- tgen = get_topogen()
- func = functools.partial(_check, name, dest_addr, match)
- success, result = topotest.run_and_expect(func, None, count=10, wait=0.5)
- assert result is None, "Failed"
-
-
def check_rib(name, cmd, expected_file):
def _check(name, cmd, expected_file):
logger.info("polling")
def test_ping():
- check_ping("ce1", "2001:2::2", True)
- check_ping("ce1", "2001:3::2", True)
- check_ping("ce1", "2001:4::2", False)
- check_ping("ce1", "2001:5::2", False)
- check_ping("ce1", "2001:6::2", False)
- check_ping("ce4", "2001:1::2", False)
- check_ping("ce4", "2001:2::2", False)
- check_ping("ce4", "2001:3::2", False)
- check_ping("ce4", "2001:5::2", True)
- check_ping("ce4", "2001:6::2", True)
+ check_ping("ce1", "2001:2::2", True, 10, 0.5)
+ check_ping("ce1", "2001:3::2", True, 10, 0.5)
+ check_ping("ce1", "2001:4::2", False, 10, 0.5)
+ check_ping("ce1", "2001:5::2", False, 10, 0.5)
+ check_ping("ce1", "2001:6::2", False, 10, 0.5)
+ check_ping("ce4", "2001:1::2", False, 10, 0.5)
+ check_ping("ce4", "2001:2::2", False, 10, 0.5)
+ check_ping("ce4", "2001:3::2", False, 10, 0.5)
+ check_ping("ce4", "2001:5::2", True, 10, 0.5)
+ check_ping("ce4", "2001:6::2", True, 10, 0.5)
def test_sid_per_afv6_auto():
check_rib("r1", "show ipv6 route vrf vrf10 json", "r1/vrf10_afv6_auto_sid_rib.json")
- check_ping("ce1", "2001:2::2", True)
+ check_ping("ce1", "2001:2::2", True, 10, 0.5)
get_topogen().gears["r2"].vtysh_cmd(
"""
configure terminal
check_rib(
"r1", "show ipv6 route vrf vrf10 json", "r1/vrf10_afv6_auto_no_sid_rib.json"
)
- check_ping("ce1", "2001:2::2", False)
+ check_ping("ce1", "2001:2::2", False, 10, 0.5)
get_topogen().gears["r2"].vtysh_cmd(
"""
"""
)
check_rib("r1", "show ipv6 route vrf vrf10 json", "r1/vrf10_afv6_auto_sid_rib.json")
- check_ping("ce1", "2001:2::2", True)
+ check_ping("ce1", "2001:2::2", True, 10, 0.5)
get_topogen().gears["r2"].vtysh_cmd(
"""
check_rib(
"r1", "show ipv6 route vrf vrf10 json", "r1/vrf10_afv6_auto_no_sid_rib.json"
)
- check_ping("ce1", "2001:2::2", False)
+ check_ping("ce1", "2001:2::2", False, 10, 0.5)
def test_sid_per_afv6_manual():
check_rib(
"r1", "show ipv6 route vrf vrf10 json", "r1/vrf10_afv6_manual_no_sid_rib.json"
)
- check_ping("ce1", "2001:2::2", False)
+ check_ping("ce1", "2001:2::2", False, 10, 0.5)
get_topogen().gears["r2"].vtysh_cmd(
"""
check_rib(
"r1", "show ipv6 route vrf vrf10 json", "r1/vrf10_afv6_manual_sid_rib.json"
)
- check_ping("ce1", "2001:2::2", True)
+ check_ping("ce1", "2001:2::2", True, 10, 0.5)
get_topogen().gears["r2"].vtysh_cmd(
"""
check_rib(
"r1", "show ipv6 route vrf vrf10 json", "r1/vrf10_afv6_manual_no_sid_rib.json"
)
- check_ping("ce1", "2001:2::2", False)
+ check_ping("ce1", "2001:2::2", False, 10, 0.5)
def test_sid_per_afv4_auto():
check_rib("r1", "show ip route vrf vrf10 json", "r1/vrf10_afv4_auto_sid_rib.json")
- check_ping("ce1", "192.168.2.2", True)
+ check_ping("ce1", "192.168.2.2", True, 10, 0.5)
get_topogen().gears["r2"].vtysh_cmd(
"""
configure terminal
check_rib(
"r1", "show ip route vrf vrf10 json", "r1/vrf10_afv4_auto_no_sid_rib.json"
)
- check_ping("ce1", "192.168.2.2", False)
+ check_ping("ce1", "192.168.2.2", False, 10, 0.5)
get_topogen().gears["r2"].vtysh_cmd(
"""
)
check_rib("r1", "show ip route vrf vrf10 json", "r1/vrf10_afv4_auto_sid_rib.json")
- check_ping("ce1", "192.168.2.2", True)
+ check_ping("ce1", "192.168.2.2", True, 10, 0.5)
get_topogen().gears["r2"].vtysh_cmd(
"""
check_rib(
"r1", "show ip route vrf vrf10 json", "r1/vrf10_afv4_auto_no_sid_rib.json"
)
- check_ping("ce1", "192.168.2.2", False)
+ check_ping("ce1", "192.168.2.2", False, 10, 0.5)
def test_sid_per_afv4_manual():
check_rib(
"r1", "show ip route vrf vrf10 json", "r1/vrf10_afv4_manual_no_sid_rib.json"
)
- check_ping("ce1", "192.168.2.2", False)
+ check_ping("ce1", "192.168.2.2", False, 10, 0.5)
get_topogen().gears["r2"].vtysh_cmd(
"""
configure terminal
)
check_rib("r1", "show ip route vrf vrf10 json", "r1/vrf10_afv4_manual_sid_rib.json")
- check_ping("ce1", "192.168.2.2", True)
+ check_ping("ce1", "192.168.2.2", True, 10, 0.5)
get_topogen().gears["r2"].vtysh_cmd(
"""
no sid vpn export 8
"""
)
- check_ping("ce1", "192.168.2.2", False)
+ check_ping("ce1", "192.168.2.2", False, 10, 0.5)
check_rib(
"r1", "show ip route vrf vrf10 json", "r1/vrf10_afv4_manual_no_sid_rib.json"
)
check_rib(
"r1", "show ipv6 route vrf vrf10 json", "r1/vrf10_pervrf_auto_no_sid_rib.json"
)
- check_ping("ce1", "2001:2::2", False)
+ check_ping("ce1", "2001:2::2", False, 10, 0.5)
get_topogen().gears["r2"].vtysh_cmd(
"""
configure terminal
check_rib(
"r1", "show ipv6 route vrf vrf10 json", "r1/vrf10_pervrf6_auto_sid_rib.json"
)
- check_ping("ce1", "2001:2::2", True)
+ check_ping("ce1", "2001:2::2", True, 10, 0.5)
check_rib(
"r1", "show ip route vrf vrf10 json", "r1/vrf10_pervrf4_auto_sid_rib.json"
)
- check_ping("ce1", "192.168.2.2", True)
+ check_ping("ce1", "192.168.2.2", True, 10, 0.5)
get_topogen().gears["r2"].vtysh_cmd(
"""
check_rib(
"r1", "show ipv6 route vrf vrf10 json", "r1/vrf10_pervrf_auto_no_sid_rib.json"
)
- check_ping("ce1", "2001:2::2", False)
+ check_ping("ce1", "2001:2::2", False, 10, 0.5)
def test_sid_per_vrf_manual():
check_rib(
"r1", "show ip route vrf vrf10 json", "r1/vrf10_pervrf_manual_no_sid_rib.json"
)
- check_ping("ce1", "192.168.2.2", False)
+ check_ping("ce1", "192.168.2.2", False, 10, 0.5)
get_topogen().gears["r2"].vtysh_cmd(
"""
configure terminal
check_rib(
"r1", "show ipv6 route vrf vrf10 json", "r1/vrf10_pervrf6_manual_sid_rib.json"
)
- check_ping("ce1", "2001:2::2", True)
+ check_ping("ce1", "2001:2::2", True, 10, 0.5)
check_rib(
"r1", "show ip route vrf vrf10 json", "r1/vrf10_pervrf4_manual_sid_rib.json"
)
- check_ping("ce1", "192.168.2.2", True)
+ check_ping("ce1", "192.168.2.2", True, 10, 0.5)
get_topogen().gears["r2"].vtysh_cmd(
"""
check_rib(
"r1", "show ip route vrf vrf10 json", "r1/vrf10_pervrf_manual_no_sid_rib.json"
)
- check_ping("ce1", "192.168.2.2", False)
+ check_ping("ce1", "192.168.2.2", False, 10, 0.5)
if __name__ == "__main__":
from lib.topogen import Topogen, TopoRouter, get_topogen
from lib.topolog import logger
from lib.common_config import required_linux_kernel_version
+from lib.checkping import check_ping
pytestmark = [pytest.mark.bgpd]
assert False, "Could not read file {}".format(filename)
-def check_ping(name, dest_addr, expect_connected):
- def _check(name, dest_addr, match):
- tgen = get_topogen()
- output = tgen.gears[name].run("ping6 {} -c 1 -w 1".format(dest_addr))
- logger.info(output)
- if match not in output:
- return "ping fail"
-
- match = ", {} packet loss".format("0%" if expect_connected else "100%")
- logger.info("[+] check {} {} {}".format(name, dest_addr, match))
- tgen = get_topogen()
- func = functools.partial(_check, name, dest_addr, match)
- success, result = topotest.run_and_expect(func, None, count=10, wait=1)
- assert result is None, "Failed"
-
-
def check_rib(name, cmd, expected_file):
def _check(name, cmd, expected_file):
logger.info("polling")
def test_ping():
- check_ping("ce1", "2001:2::2", True)
- check_ping("ce1", "2001:3::2", True)
- check_ping("ce1", "2001:4::2", False)
- check_ping("ce1", "2001:5::2", False)
- check_ping("ce1", "2001:6::2", False)
- check_ping("ce4", "2001:1::2", False)
- check_ping("ce4", "2001:2::2", False)
- check_ping("ce4", "2001:3::2", False)
- check_ping("ce4", "2001:5::2", True)
- check_ping("ce4", "2001:6::2", True)
+ check_ping("ce1", "2001:2::2", True, 10, 1)
+ check_ping("ce1", "2001:3::2", True, 10, 1)
+ check_ping("ce1", "2001:4::2", False, 10, 1)
+ check_ping("ce1", "2001:5::2", False, 10, 1)
+ check_ping("ce1", "2001:6::2", False, 10, 1)
+ check_ping("ce4", "2001:1::2", False, 10, 1)
+ check_ping("ce4", "2001:2::2", False, 10, 1)
+ check_ping("ce4", "2001:3::2", False, 10, 1)
+ check_ping("ce4", "2001:5::2", True, 10, 1)
+ check_ping("ce4", "2001:6::2", True, 10, 1)
def test_locator_delete():
- check_ping("ce1", "2001:2::2", True)
+ check_ping("ce1", "2001:2::2", True, 10, 1)
get_topogen().gears["r1"].vtysh_cmd(
"""
configure terminal
)
check_rib("r1", "show bgp ipv6 vpn json", "r1/vpnv6_rib_locator_deleted.json")
check_rib("r2", "show bgp ipv6 vpn json", "r2/vpnv6_rib_locator_deleted.json")
- check_ping("ce1", "2001:2::2", False)
+ check_ping("ce1", "2001:2::2", False, 10, 1)
def test_locator_recreate():
- check_ping("ce1", "2001:2::2", False)
+ check_ping("ce1", "2001:2::2", False, 10, 1)
get_topogen().gears["r1"].vtysh_cmd(
"""
configure terminal
)
check_rib("r1", "show bgp ipv6 vpn json", "r1/vpnv6_rib_locator_recreated.json")
check_rib("r2", "show bgp ipv6 vpn json", "r2/vpnv6_rib_locator_recreated.json")
- check_ping("ce1", "2001:2::2", True)
+ check_ping("ce1", "2001:2::2", True, 10, 1)
def test_bgp_locator_unset():
- check_ping("ce1", "2001:2::2", True)
+ check_ping("ce1", "2001:2::2", True, 10, 1)
get_topogen().gears["r1"].vtysh_cmd(
"""
configure terminal
)
check_rib("r1", "show bgp ipv6 vpn json", "r1/vpnv6_rib_locator_deleted.json")
check_rib("r2", "show bgp ipv6 vpn json", "r2/vpnv6_rib_locator_deleted.json")
- check_ping("ce1", "2001:2::2", False)
+ check_ping("ce1", "2001:2::2", False, 10, 1)
def test_bgp_locator_reset():
- check_ping("ce1", "2001:2::2", False)
+ check_ping("ce1", "2001:2::2", False, 10, 1)
get_topogen().gears["r1"].vtysh_cmd(
"""
configure terminal
)
check_rib("r1", "show bgp ipv6 vpn json", "r1/vpnv6_rib_locator_recreated.json")
check_rib("r2", "show bgp ipv6 vpn json", "r2/vpnv6_rib_locator_recreated.json")
- check_ping("ce1", "2001:2::2", True)
+ check_ping("ce1", "2001:2::2", True, 10, 1)
def test_bgp_srv6_unset():
- check_ping("ce1", "2001:2::2", True)
+ check_ping("ce1", "2001:2::2", True, 10, 1)
get_topogen().gears["r1"].vtysh_cmd(
"""
configure terminal
)
check_rib("r1", "show bgp ipv6 vpn json", "r1/vpnv6_rib_locator_deleted.json")
check_rib("r2", "show bgp ipv6 vpn json", "r2/vpnv6_rib_locator_deleted.json")
- check_ping("ce1", "2001:2::2", False)
+ check_ping("ce1", "2001:2::2", False, 10, 1)
def test_bgp_srv6_reset():
- check_ping("ce1", "2001:2::2", False)
+ check_ping("ce1", "2001:2::2", False, 10, 1)
get_topogen().gears["r1"].vtysh_cmd(
"""
configure terminal
)
check_rib("r1", "show bgp ipv6 vpn json", "r1/vpnv6_rib_locator_recreated.json")
check_rib("r2", "show bgp ipv6 vpn json", "r2/vpnv6_rib_locator_recreated.json")
- check_ping("ce1", "2001:2::2", True)
+ check_ping("ce1", "2001:2::2", True, 10, 1)
if __name__ == "__main__":
from lib.topogen import Topogen, TopoRouter, get_topogen
from lib.topolog import logger
from lib.common_config import required_linux_kernel_version
+from lib.checkping import check_ping
pytestmark = [pytest.mark.bgpd]
assert False, "Could not read file {}".format(filename)
-def check_ping(name, dest_addr, expect_connected):
- def _check(name, dest_addr, match):
- tgen = get_topogen()
- output = tgen.gears[name].run("ping {} -c 1 -w 1".format(dest_addr))
- logger.info(output)
- assert match in output, "ping fail"
-
- match = ", {} packet loss".format("0%" if expect_connected else "100%")
- logger.info("[+] check {} {} {}".format(name, dest_addr, match))
- tgen = get_topogen()
- func = functools.partial(_check, name, dest_addr, match)
- success, result = topotest.run_and_expect(func, None, count=10, wait=0.5)
- assert result is None, "Failed"
-
-
def check_rib(name, cmd, expected_file):
def _check(name, dest_addr, match):
logger.info("polling")
def test_ping():
- check_ping("ce1", "192.168.2.2", True)
- check_ping("ce1", "192.168.3.2", True)
- check_ping("ce1", "192.168.4.2", False)
- check_ping("ce1", "192.168.5.2", False)
- check_ping("ce1", "192.168.6.2", False)
- check_ping("ce4", "192.168.1.2", False)
- check_ping("ce4", "192.168.2.2", False)
- check_ping("ce4", "192.168.3.2", False)
- check_ping("ce4", "192.168.5.2", True)
- check_ping("ce4", "192.168.6.2", True)
+ check_ping("ce1", "192.168.2.2", True, 10, 0.5)
+ check_ping("ce1", "192.168.3.2", True, 10, 0.5)
+ check_ping("ce1", "192.168.4.2", False, 10, 0.5)
+ check_ping("ce1", "192.168.5.2", False, 10, 0.5)
+ check_ping("ce1", "192.168.6.2", False, 10, 0.5)
+ check_ping("ce4", "192.168.1.2", False, 10, 0.5)
+ check_ping("ce4", "192.168.2.2", False, 10, 0.5)
+ check_ping("ce4", "192.168.3.2", False, 10, 0.5)
+ check_ping("ce4", "192.168.5.2", True, 10, 0.5)
+ check_ping("ce4", "192.168.6.2", True, 10, 0.5)
if __name__ == "__main__":
from lib.topogen import Topogen, TopoRouter, get_topogen
from lib.topolog import logger
from lib.common_config import required_linux_kernel_version
+from lib.checkping import check_ping, check_ping
pytestmark = [pytest.mark.bgpd]
assert False, "Could not read file {}".format(filename)
-def check_ping4(name, dest_addr, expect_connected):
- def _check(name, dest_addr, match):
- tgen = get_topogen()
- output = tgen.gears[name].run("ping {} -c 1 -w 1".format(dest_addr))
- logger.info(output)
- if match not in output:
- return "ping fail"
-
- match = ", {} packet loss".format("0%" if expect_connected else "100%")
- logger.info("[+] check {} {} {}".format(name, dest_addr, match))
- tgen = get_topogen()
- func = functools.partial(_check, name, dest_addr, match)
- success, result = topotest.run_and_expect(func, None, count=10, wait=0.5)
- assert result is None, "Failed"
-
-
-def check_ping6(name, dest_addr, expect_connected):
- def _check(name, dest_addr, match):
- tgen = get_topogen()
- output = tgen.gears[name].run("ping6 {} -c 1 -w 1".format(dest_addr))
- logger.info(output)
- if match not in output:
- return "ping fail"
-
- match = "{} packet loss".format("0%" if expect_connected else "100%")
- logger.info("[+] check {} {} {}".format(name, dest_addr, match))
- tgen = get_topogen()
- func = functools.partial(_check, name, dest_addr, match)
- success, result = topotest.run_and_expect(func, None, count=10, wait=1)
- assert result is None, "Failed"
-
-
def check_rib(name, cmd, expected_file):
def _check(name, dest_addr, match):
logger.info("polling")
def test_ping():
- check_ping4("ce1", "192.168.2.2", True)
- check_ping4("ce1", "192.168.3.2", True)
- check_ping4("ce1", "192.168.4.2", False)
- check_ping4("ce1", "192.168.5.2", False)
- check_ping4("ce1", "192.168.6.2", False)
- check_ping4("ce4", "192.168.1.2", False)
- check_ping4("ce4", "192.168.2.2", False)
- check_ping4("ce4", "192.168.3.2", False)
- check_ping4("ce4", "192.168.5.2", True)
- check_ping4("ce4", "192.168.6.2", True)
-
- check_ping6("ce1", "2001:2::2", True)
- check_ping6("ce1", "2001:3::2", True)
- check_ping6("ce1", "2001:4::2", False)
- check_ping6("ce1", "2001:5::2", False)
- check_ping6("ce1", "2001:6::2", False)
- check_ping6("ce4", "2001:1::2", False)
- check_ping6("ce4", "2001:2::2", False)
- check_ping6("ce4", "2001:3::2", False)
- check_ping6("ce4", "2001:5::2", True)
- check_ping6("ce4", "2001:6::2", True)
+ check_ping("ce1", "192.168.2.2", True, 10, 0.5)
+ check_ping("ce1", "192.168.3.2", True, 10, 0.5)
+ check_ping("ce1", "192.168.4.2", False, 10, 0.5)
+ check_ping("ce1", "192.168.5.2", False, 10, 0.5)
+ check_ping("ce1", "192.168.6.2", False, 10, 0.5)
+ check_ping("ce4", "192.168.1.2", False, 10, 0.5)
+ check_ping("ce4", "192.168.2.2", False, 10, 0.5)
+ check_ping("ce4", "192.168.3.2", False, 10, 0.5)
+ check_ping("ce4", "192.168.5.2", True, 10, 0.5)
+ check_ping("ce4", "192.168.6.2", True, 10, 0.5)
+
+ check_ping("ce1", "2001:2::2", True, 10, 1)
+ check_ping("ce1", "2001:3::2", True, 10, 1)
+ check_ping("ce1", "2001:4::2", False, 10, 1)
+ check_ping("ce1", "2001:5::2", False, 10, 1)
+ check_ping("ce1", "2001:6::2", False, 10, 1)
+ check_ping("ce4", "2001:1::2", False, 10, 1)
+ check_ping("ce4", "2001:2::2", False, 10, 1)
+ check_ping("ce4", "2001:3::2", False, 10, 1)
+ check_ping("ce4", "2001:5::2", True, 10, 1)
+ check_ping("ce4", "2001:6::2", True, 10, 1)
def test_bgp_sid_vpn_export_disable():
- check_ping4("ce1", "192.168.2.2", True)
- check_ping6("ce1", "2001:2::2", True)
+ check_ping("ce1", "192.168.2.2", True, 10, 0.5)
+ check_ping("ce1", "2001:2::2", True, 10, 1)
get_topogen().gears["r1"].vtysh_cmd(
"""
configure terminal
check_rib(
"r2", "show bgp ipv6 vpn json", "r2/vpnv6_rib_sid_vpn_export_disabled.json"
)
- check_ping4("ce1", "192.168.2.2", False)
- check_ping6("ce1", "2001:2::2", False)
+ check_ping("ce1", "192.168.2.2", False, 10, 0.5)
+ check_ping("ce1", "2001:2::2", False, 10, 1)
def test_bgp_sid_vpn_export_reenable():
- check_ping4("ce1", "192.168.2.2", False)
- check_ping6("ce1", "2001:2::2", False)
+ check_ping("ce1", "192.168.2.2", False, 10, 0.5)
+ check_ping("ce1", "2001:2::2", False, 10, 1)
get_topogen().gears["r1"].vtysh_cmd(
"""
configure terminal
check_rib(
"r2", "show bgp ipv6 vpn json", "r2/vpnv6_rib_sid_vpn_export_reenabled.json"
)
- check_ping4("ce1", "192.168.2.2", True)
- check_ping6("ce1", "2001:2::2", True)
+ check_ping("ce1", "192.168.2.2", True, 10, 0.5)
+ check_ping("ce1", "2001:2::2", True, 10, 1)
def test_locator_delete():
- check_ping4("ce1", "192.168.2.2", True)
- check_ping6("ce1", "2001:2::2", True)
+ check_ping("ce1", "192.168.2.2", True, 10, 0.5)
+ check_ping("ce1", "2001:2::2", True, 10, 1)
get_topogen().gears["r1"].vtysh_cmd(
"""
configure terminal
check_rib("r2", "show bgp ipv4 vpn json", "r2/vpnv4_rib_locator_deleted.json")
check_rib("r1", "show bgp ipv6 vpn json", "r1/vpnv6_rib_locator_deleted.json")
check_rib("r2", "show bgp ipv6 vpn json", "r2/vpnv6_rib_locator_deleted.json")
- check_ping4("ce1", "192.168.2.2", False)
- check_ping6("ce1", "2001:2::2", False)
+ check_ping("ce1", "192.168.2.2", False, 10, 0.5)
+ check_ping("ce1", "2001:2::2", False, 10, 1)
def test_locator_recreate():
- check_ping4("ce1", "192.168.2.2", False)
- check_ping6("ce1", "2001:2::2", False)
+ check_ping("ce1", "192.168.2.2", False, 10, 0.5)
+ check_ping("ce1", "2001:2::2", False, 10, 1)
get_topogen().gears["r1"].vtysh_cmd(
"""
configure terminal
check_rib("r2", "show bgp ipv4 vpn json", "r2/vpnv4_rib_locator_recreated.json")
check_rib("r1", "show bgp ipv6 vpn json", "r1/vpnv6_rib_locator_recreated.json")
check_rib("r2", "show bgp ipv6 vpn json", "r2/vpnv6_rib_locator_recreated.json")
- check_ping4("ce1", "192.168.2.2", True)
- check_ping6("ce1", "2001:2::2", True)
+ check_ping("ce1", "192.168.2.2", True, 10, 0.5)
+ check_ping("ce1", "2001:2::2", True, 10, 1)
def test_bgp_locator_unset():
- check_ping4("ce1", "192.168.2.2", True)
- check_ping6("ce1", "2001:2::2", True)
+ check_ping("ce1", "192.168.2.2", True, 10, 0.5)
+ check_ping("ce1", "2001:2::2", True, 10, 1)
get_topogen().gears["r1"].vtysh_cmd(
"""
configure terminal
check_rib("r2", "show bgp ipv4 vpn json", "r2/vpnv4_rib_locator_deleted.json")
check_rib("r1", "show bgp ipv6 vpn json", "r1/vpnv6_rib_locator_deleted.json")
check_rib("r2", "show bgp ipv6 vpn json", "r2/vpnv6_rib_locator_deleted.json")
- check_ping4("ce1", "192.168.2.2", False)
- check_ping6("ce1", "2001:2::2", False)
+ check_ping("ce1", "192.168.2.2", False, 10, 0.5)
+ check_ping("ce1", "2001:2::2", False, 10, 1)
def test_bgp_locator_reset():
- check_ping4("ce1", "192.168.2.2", False)
- check_ping6("ce1", "2001:2::2", False)
+ check_ping("ce1", "192.168.2.2", False, 10, 0.5)
+ check_ping("ce1", "2001:2::2", False, 10, 1)
get_topogen().gears["r1"].vtysh_cmd(
"""
configure terminal
check_rib("r2", "show bgp ipv4 vpn json", "r2/vpnv4_rib_locator_recreated.json")
check_rib("r1", "show bgp ipv6 vpn json", "r1/vpnv6_rib_locator_recreated.json")
check_rib("r2", "show bgp ipv6 vpn json", "r2/vpnv6_rib_locator_recreated.json")
- check_ping4("ce1", "192.168.2.2", True)
- check_ping6("ce1", "2001:2::2", True)
+ check_ping("ce1", "192.168.2.2", True, 10, 0.5)
+ check_ping("ce1", "2001:2::2", True, 10, 1)
def test_bgp_srv6_unset():
- check_ping4("ce1", "192.168.2.2", True)
- check_ping6("ce1", "2001:2::2", True)
+ check_ping("ce1", "192.168.2.2", True, 10, 0.5)
+ check_ping("ce1", "2001:2::2", True, 10, 1)
get_topogen().gears["r1"].vtysh_cmd(
"""
configure terminal
check_rib("r2", "show bgp ipv4 vpn json", "r2/vpnv4_rib_locator_deleted.json")
check_rib("r1", "show bgp ipv6 vpn json", "r1/vpnv6_rib_locator_deleted.json")
check_rib("r2", "show bgp ipv6 vpn json", "r2/vpnv6_rib_locator_deleted.json")
- check_ping4("ce1", "192.168.2.2", False)
- check_ping6("ce1", "2001:2::2", False)
+ check_ping("ce1", "192.168.2.2", False, 10, 0.5)
+ check_ping("ce1", "2001:2::2", False, 10, 1)
def test_bgp_srv6_reset():
- check_ping4("ce1", "192.168.2.2", False)
- check_ping6("ce1", "2001:2::2", False)
+ check_ping("ce1", "192.168.2.2", False, 10, 0.5)
+ check_ping("ce1", "2001:2::2", False, 10, 1)
get_topogen().gears["r1"].vtysh_cmd(
"""
configure terminal
check_rib("r2", "show bgp ipv4 vpn json", "r2/vpnv4_rib_locator_recreated.json")
check_rib("r1", "show bgp ipv6 vpn json", "r1/vpnv6_rib_locator_recreated.json")
check_rib("r2", "show bgp ipv6 vpn json", "r2/vpnv6_rib_locator_recreated.json")
- check_ping4("ce1", "192.168.2.2", True)
- check_ping6("ce1", "2001:2::2", True)
+ check_ping("ce1", "192.168.2.2", True, 10, 0.5)
+ check_ping("ce1", "2001:2::2", True, 10, 1)
if __name__ == "__main__":
from lib import topotest
from lib.topogen import Topogen, TopoRouter, get_topogen
from lib.topolog import logger
+from lib.checkping import check_ping
+
# Required to instantiate the topology builder class.
)
-def check_ping(name, dest_addr, expect_connected):
- """
- Assert that ping to dest_addr is expected
- * 'name': the router to set the ping from
- * 'dest_addr': The destination ip address to ping
- * 'expect_connected': True if ping is expected to pass
- """
-
- def _check(name, dest_addr, match):
- tgen = get_topogen()
- output = tgen.gears[name].run("ping {} -c 1 -w 1".format(dest_addr))
- logger.info(output)
- if match not in output:
- return "ping fail"
-
- match = ", {} packet loss".format("0%" if expect_connected else "100%")
- logger.info("[+] check {} {} {}".format(name, dest_addr, match))
- tgen = get_topogen()
- func = functools.partial(_check, name, dest_addr, match)
- success, result = topotest.run_and_expect(func, None, count=20, wait=0.5)
- assert result is None, "Failed"
-
-
def check_show_bgp_vpn_prefix_found(
router, ipversion, prefix, rd, label=None, nexthop=None
):
check_show_bgp_vpn_ok(router, vpnv4_checks)
logger.info("h1, check that ping from h1 to (h2,h3) is ok")
- check_ping("h1", "172.31.1.10", True)
- check_ping("h1", "172.31.2.10", True)
+ check_ping("h1", "172.31.1.10", True, 20, 0.5)
+ check_ping("h1", "172.31.2.10", True, 20, 0.5)
def test_r3_prefixes_removed():
check_show_bgp_vpn_ok(router, vpnv4_checks)
logger.info("h1, check that ping from h1 to (h2,h3) is ok")
- check_ping("h1", "172.31.1.10", True)
- check_ping("h1", "172.31.2.10", True)
+ check_ping("h1", "172.31.1.10", True, 20, 0.5)
+ check_ping("h1", "172.31.2.10", True, 20, 0.5)
# diagnostic
logger.info("Dumping mplsvpn nexthop table")
router.vtysh_cmd("show bgp mplsvpn-nh-label-bind detail", isjson=False)
--- /dev/null
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Copyright 2023 Quentin Young
+
+import functools
+from lib.topogen import get_topogen
+from lib.topolog import logger
+from lib import topotest
+
+
+def check_ping(name, dest_addr, expect_connected, count, wait):
+ """
+ Assert that ping to dest_addr is expected
+ * 'name': the router to set the ping from
+ * 'dest_addr': The destination ip address to ping
+ * 'expect_connected': True if ping is expected to pass
+ * 'count': how many echos to send
+ * 'wait': how long ping should wait to receive all replies
+ """
+
+ def _check(name, dest_addr, match):
+ tgen = get_topogen()
+ output = tgen.gears[name].run("ping {} -c 1 -w 1".format(dest_addr))
+ logger.info(output)
+ if match not in output:
+ return "ping fail"
+
+ match = ", {} packet loss".format("0%" if expect_connected else "100%")
+ logger.info("[+] check {} {} {}".format(name, dest_addr, match))
+ tgen = get_topogen()
+ func = functools.partial(_check, name, dest_addr, match)
+ success, result = topotest.run_and_expect(func, None, count=count, wait=wait)
+ assert result is None, "Failed"