# 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"
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"'
)
)
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"
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"