mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-09 09:47:11 +00:00
Merge pull request #13522 from LabNConsulting/chopps/fix-bgp-test
tests: improve bgp test determinism
This commit is contained in:
commit
2bbda57677
@ -176,6 +176,19 @@ def test_bgp_convergence():
|
||||
# tgen.mininet_cli()
|
||||
|
||||
|
||||
def get_shut_msg_count(tgen):
|
||||
shuts = {}
|
||||
for rtrNum in [2, 4]:
|
||||
shutmsg = tgen.net["r{}".format(rtrNum)].cmd_nostatus(
|
||||
'grep -c "NOTIFICATION.*Cease/Administrative Shutdown" bgpd.log', warn=False
|
||||
)
|
||||
try:
|
||||
shuts[rtrNum] = int(shutmsg.strip())
|
||||
except ValueError:
|
||||
shuts[rtrNum] = 0
|
||||
return shuts
|
||||
|
||||
|
||||
def test_bgp_shutdown():
|
||||
"Test BGP instance shutdown"
|
||||
|
||||
@ -185,6 +198,8 @@ def test_bgp_shutdown():
|
||||
if tgen.routers_have_failure():
|
||||
pytest.skip(tgen.errors)
|
||||
|
||||
shuts_before = get_shut_msg_count(tgen)
|
||||
|
||||
tgen.net["r1"].cmd(
|
||||
'vtysh -c "conf t" -c "router bgp 65000" -c "bgp shutdown message ABCDabcd"'
|
||||
)
|
||||
@ -208,6 +223,11 @@ def test_bgp_shutdown():
|
||||
)
|
||||
assert res is None, assertmsg
|
||||
|
||||
shuts_after = get_shut_msg_count(tgen)
|
||||
|
||||
for k in shuts_before:
|
||||
assert shuts_before[k] + 1 == shuts_after[k]
|
||||
|
||||
|
||||
def test_bgp_shutdown_message():
|
||||
"Test BGP Peer Shutdown Message"
|
||||
@ -222,18 +242,11 @@ def test_bgp_shutdown_message():
|
||||
logger.info("Checking BGP shutdown received on router r{}".format(rtrNum))
|
||||
|
||||
shut_message = tgen.net["r{}".format(rtrNum)].cmd(
|
||||
'tail bgpd.log | grep "NOTIFICATION.*Cease/Administrative Shutdown"'
|
||||
'grep -e "NOTIFICATION.*Cease/Administrative Shutdown.*ABCDabcd" bgpd.log'
|
||||
)
|
||||
assertmsg = "BGP shutdown message not received on router R{}".format(rtrNum)
|
||||
assert shut_message != "", assertmsg
|
||||
|
||||
assertmsg = "Incorrect BGP shutdown message received on router R{}".format(
|
||||
rtrNum
|
||||
)
|
||||
assert "ABCDabcd" in shut_message, assertmsg
|
||||
|
||||
# tgen.mininet_cli()
|
||||
|
||||
|
||||
def test_bgp_no_shutdown():
|
||||
"Test BGP instance no shutdown"
|
||||
|
Loading…
Reference in New Issue
Block a user