tests: Allow ping to run multiple times before failing

the bgp_default_originate test brings up the topology and
then immediately pings.  Which sometimes fails.  This is
of course possible since the first ping might actually fail
due to arp going on.  So let's give it a second chance or two.
Especially since the test, at this point, is just installing
a default route.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2023-05-27 08:50:01 -04:00
parent 2fccc9fa10
commit 131153ea22

View File

@ -26,6 +26,7 @@ from time import sleep
from lib.topogen import Topogen, get_topogen
from lib.topojson import build_config_from_json
from lib.topolog import logger
from lib import topotest
from lib.bgp import (
verify_bgp_convergence,
@ -1559,8 +1560,14 @@ def test_verify_default_originate_with_2way_ecmp_p2(request):
step("Ping R1 configure IPv4 and IPv6 loopback address from R2")
pingaddr = topo["routers"]["r1"]["links"]["lo"]["ipv4"].split("/")[0]
router = tgen.gears["r2"]
output = router.run("ping -c 4 -w 4 {}".format(pingaddr))
assert " 0% packet loss" in output, "Ping R1->R2 FAILED"
def ping_router():
output = router.run("ping -c 4 -w 4 {}".format(pingaddr))
logger.info(output)
if " 0% packet loss" not in output:
return False
_, res = topotest.run_and_expect(ping_router, None, count=10, wait=1)
logger.info("Ping from R1 to R2 ... success")
step("Shuting up the active route")