mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-06 02:46:26 +00:00
tests: add source_addr in check_ping
Allow specifying a source_addr in check_ping library function. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
This commit is contained in:
parent
8b5f6ac982
commit
71e74df14e
@ -8,7 +8,7 @@ from lib.topolog import logger
|
||||
from lib import topotest
|
||||
|
||||
|
||||
def check_ping(name, dest_addr, expect_connected, count, wait):
|
||||
def check_ping(name, dest_addr, expect_connected, count, wait, source_addr=None):
|
||||
"""
|
||||
Assert that ping to dest_addr is expected
|
||||
* 'name': the router to set the ping from
|
||||
@ -18,9 +18,13 @@ def check_ping(name, dest_addr, expect_connected, count, wait):
|
||||
* 'wait': how long ping should wait to receive all replies
|
||||
"""
|
||||
|
||||
def _check(name, dest_addr, match):
|
||||
def _check(name, dest_addr, source_addr, match):
|
||||
tgen = get_topogen()
|
||||
output = tgen.gears[name].run("ping {} -c 1 -w 1".format(dest_addr))
|
||||
cmd = "ping {}".format(dest_addr)
|
||||
if source_addr:
|
||||
cmd += " -I {}".format(source_addr)
|
||||
cmd += " -c 1 -w 1"
|
||||
output = tgen.gears[name].run(cmd)
|
||||
logger.info(output)
|
||||
if match not in output:
|
||||
return "ping fail"
|
||||
@ -28,6 +32,6 @@ def check_ping(name, dest_addr, expect_connected, count, wait):
|
||||
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)
|
||||
func = functools.partial(_check, name, dest_addr, source_addr, match)
|
||||
success, result = topotest.run_and_expect(func, None, count=count, wait=wait)
|
||||
assert result is None, "Failed"
|
||||
|
Loading…
Reference in New Issue
Block a user