Skip to content

Commit

Permalink
tests: add bgp4v2 MIB traps test
Browse files Browse the repository at this point in the history
Signed-off-by: Francois Dumontet <[email protected]>
  • Loading branch information
fdumontet6WIND committed Oct 2, 2023
1 parent 1d1b96c commit f5da2b9
Showing 1 changed file with 45 additions and 6 deletions.
51 changes: 45 additions & 6 deletions tests/topotests/bgp_snmp_bgp4v2mib/test_bgp_snmp_bgp4v2mib.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def _snmpwalk_origin():
}

# bgp4V2NlriOrigin
tgen.mininet_cli()
#tgen.mininet_cli()
output, _ = snmp.walk(".1.3.6.1.3.5.1.1.9.1.9")
logger.info("FMJA")
logger.info(output)
Expand Down Expand Up @@ -245,19 +245,58 @@ def _snmptrap_ipv4():
]

# load trapd resulting file
tgen.mininet_cli()
# os.path.join(CWD, "{}/{}/snmptrapd.log".format(r2.logdir,r2.name))
# tgen.mininet_cli()

snmptrapfile = "{}/{}/snmptrapd.log".format(r2.logdir, r2.name)
outputfile = open(snmptrapfile).read()
output = snmp.trap(outputfile)
logger.info(output)
output = snmp.trap_v4(outputfile)
return output == expected

r1.vtysh_cmd("clear bgp *")
_, result = topotest.run_and_expect(_snmptrap_ipv4, True, count=15, wait=2)
_, result = topotest.run_and_expect(_snmptrap_ipv4, True, count=2, wait=10)
assertmsg = "Can't fetch SNMP trap for ipv4"
assert result, assertmsg

def _snmptrap_ipv6():
expected = [
("1.3.6.1.3.5.1.1.2.1.13.1.4.192.168.12.1", "7"),
("1.3.6.1.3.5.1.1.2.1.6.1.4.192.168.12.1", "179"),
("1.3.6.1.3.5.1.1.3.1.1.1.4.192.168.12.1", "6"),
("1.3.6.1.3.5.1.1.3.1.2.1.4.192.168.12.1", "4"),
("1.3.6.1.3.5.1.1.3.1.4.1.4.192.168.12.1", '"00 "'),
("1.3.6.1.3.5.1.1.2.1.13.2.16.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.1", "7"),
("1.3.6.1.3.5.1.1.2.1.6.2.16.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.1", "179"),
("1.3.6.1.3.5.1.1.3.1.1.2.16.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.1", "6"),
("1.3.6.1.3.5.1.1.3.1.2.2.16.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.1", "4"),
(
"1.3.6.1.3.5.1.1.3.1.4.2.16.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.1",
'"00 "',
),
("1.3.6.1.3.5.1.1.2.1.13.1.4.192.168.12.1", "6"),
("1.3.6.1.3.5.1.1.2.1.6.1.4.192.168.12.1", "179"),
("1.3.6.1.3.5.1.1.2.1.13.2.16.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.1", "6"),
("1.3.6.1.3.5.1.1.2.1.6.2.16.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.1", "179"),
]

# load trapd resulting file
# tgen.mininet_cli()

snmptrapfile = "{}/{}/snmptrapd.log".format(r2.logdir, r2.name)
outputfile = open(snmptrapfile).read()
output = snmp.trap_v6(outputfile)
return output == expected

snmptrapfile = "{}/{}/snmptrapd.log".format(r2.logdir, r2.name)
trap_file = open(snmptrapfile, "w")
trap_file.truncate(0)
trap_file.close()
r2.vtysh_cmd("conf\nbgp snmp traps bgp4-mibv2 enable")
r2.vtysh_cmd("conf\nbgp snmp traps rfc4273 disable")
r1.vtysh_cmd("clear bgp *")
_, result = topotest.run_and_expect(_snmptrap_ipv6, True, count=2, wait=10)
assertmsg = "Can't fetch SNMP trap for ipv6"
assert result, assertmsg


def test_memory_leak():
"Run the memory leak test and report results."
Expand Down

0 comments on commit f5da2b9

Please sign in to comment.