From d95cf2f6bd6ee9b3162d839bcd20203ce82c999a Mon Sep 17 00:00:00 2001 From: Francois Dumontet Date: Wed, 4 Oct 2023 18:01:02 +0200 Subject: [PATCH] tests: improve test bgp_snmp_bgp4v2mib for snmp multi path support multi path support by snmp implies change in configuration and expected tests results. ipv6 trap test output is now ordered to avoid radom result due to timeline. Signed-off-by: Francois Dumontet Signed-off-by: Philippe Guibert --- .../topotests/bgp_snmp_bgp4v2mib/r1/bgpd.conf | 19 ++- .../topotests/bgp_snmp_bgp4v2mib/r2/bgpd.conf | 18 +- .../topotests/bgp_snmp_bgp4v2mib/r3/bgpd.conf | 25 +++ .../bgp_snmp_bgp4v2mib/r3/zebra.conf | 5 + .../topotests/bgp_snmp_bgp4v2mib/rr/bgpd.conf | 67 ++++++++ .../bgp_snmp_bgp4v2mib/rr/zebra.conf | 5 + .../test_bgp_snmp_bgp4v2mib.py | 157 +++++++++--------- 7 files changed, 202 insertions(+), 94 deletions(-) create mode 100644 tests/topotests/bgp_snmp_bgp4v2mib/r3/bgpd.conf create mode 100644 tests/topotests/bgp_snmp_bgp4v2mib/r3/zebra.conf create mode 100644 tests/topotests/bgp_snmp_bgp4v2mib/rr/bgpd.conf create mode 100644 tests/topotests/bgp_snmp_bgp4v2mib/rr/zebra.conf diff --git a/tests/topotests/bgp_snmp_bgp4v2mib/r1/bgpd.conf b/tests/topotests/bgp_snmp_bgp4v2mib/r1/bgpd.conf index d82a21e1f9fe..73b02b71118d 100644 --- a/tests/topotests/bgp_snmp_bgp4v2mib/r1/bgpd.conf +++ b/tests/topotests/bgp_snmp_bgp4v2mib/r1/bgpd.conf @@ -3,22 +3,24 @@ router bgp 65001 no bgp ebgp-requires-policy no bgp network import-check no bgp default ipv4-unicast - neighbor 192.168.12.2 remote-as external - neighbor 192.168.12.2 timers 1 3 - neighbor 192.168.12.2 timers connect 1 - neighbor 2001:db8::12:2 remote-as external - neighbor 2001:db8::12:2 timers 1 3 - neighbor 2001:db8::12:2 timers connect 1 + neighbor 192.168.12.4 remote-as external + neighbor 192.168.12.4 timers 1 3 + neighbor 192.168.12.4 timers connect 1 + neighbor 2001:db8::12:4 remote-as external + neighbor 2001:db8::12:4 timers 1 3 + neighbor 2001:db8::12:4 timers connect 1 ! address-family ipv4 unicast network 10.0.0.0/31 route-map p1 network 10.0.0.2/32 route-map p2 - neighbor 192.168.12.2 activate + neighbor 192.168.12.4 activate + neighbor 192.168.12.4 addpath-tx-all-paths + network 7.7.7.7/32 exit-address-family address-family ipv6 unicast network 2001:db8::1/128 route-map p1 network 2001:db8:1::/56 route-map p2 - neighbor 2001:db8::12:2 activate + neighbor 2001:db8::12:4 activate exit-address-family ! route-map p1 permit 10 @@ -28,4 +30,3 @@ route-map p2 permit 10 set metric 2 set origin incomplete exit -! diff --git a/tests/topotests/bgp_snmp_bgp4v2mib/r2/bgpd.conf b/tests/topotests/bgp_snmp_bgp4v2mib/r2/bgpd.conf index cf0013e1b7a1..55686f407a7f 100644 --- a/tests/topotests/bgp_snmp_bgp4v2mib/r2/bgpd.conf +++ b/tests/topotests/bgp_snmp_bgp4v2mib/r2/bgpd.conf @@ -5,18 +5,20 @@ router bgp 65002 no bgp ebgp-requires-policy no bgp network import-check no bgp default ipv4-unicast - neighbor 192.168.12.1 remote-as external - neighbor 192.168.12.1 timers 1 3 - neighbor 192.168.12.1 timers connect 1 - neighbor 2001:db8::12:1 remote-as external - neighbor 2001:db8::12:1 timers 1 3 - neighbor 2001:db8::12:1 timers connect 1 + neighbor 192.168.12.4 remote-as external + neighbor 192.168.12.4 timers 1 3 + neighbor 192.168.12.4 timers connect 1 + neighbor 2001:db8::12:4 remote-as external + neighbor 2001:db8::12:4 timers 1 3 + neighbor 2001:db8::12:4 timers connect 1 ! address-family ipv4 unicast - neighbor 192.168.12.1 activate + neighbor 192.168.12.4 activate + neighbor 192.168.12.4 addpath-tx-all-paths + exit-address-family address-family ipv6 unicast - neighbor 2001:db8::12:1 activate + neighbor 2001:db8::12:4 activate exit-address-family ! agentx diff --git a/tests/topotests/bgp_snmp_bgp4v2mib/r3/bgpd.conf b/tests/topotests/bgp_snmp_bgp4v2mib/r3/bgpd.conf new file mode 100644 index 000000000000..cfda6e084ebd --- /dev/null +++ b/tests/topotests/bgp_snmp_bgp4v2mib/r3/bgpd.conf @@ -0,0 +1,25 @@ +! +debug bgp updates +! +router bgp 65003 + no bgp ebgp-requires-policy + no bgp network import-check + no bgp default ipv4-unicast + neighbor 192.168.12.4 remote-as external + neighbor 192.168.12.4 timers 1 3 + neighbor 192.168.12.4 timers connect 1 + neighbor 2001:db8::12:4 remote-as external + neighbor 2001:db8::12:4 timers 1 3 + neighbor 2001:db8::12:4 timers connect 1 + ! + address-family ipv4 unicast + neighbor 192.168.12.4 activate + neighbor 192.168.12.4 addpath-tx-all-paths + network 7.7.7.7/32 + exit-address-family + address-family ipv6 unicast + neighbor 2001:db8::12:4 activate + exit-address-family +! +agentx +! diff --git a/tests/topotests/bgp_snmp_bgp4v2mib/r3/zebra.conf b/tests/topotests/bgp_snmp_bgp4v2mib/r3/zebra.conf new file mode 100644 index 000000000000..398af65ffe57 --- /dev/null +++ b/tests/topotests/bgp_snmp_bgp4v2mib/r3/zebra.conf @@ -0,0 +1,5 @@ +! +interface r3-eth0 + ip address 192.168.12.3/24 + ipv6 address 2001:db8::12:3/64 +! diff --git a/tests/topotests/bgp_snmp_bgp4v2mib/rr/bgpd.conf b/tests/topotests/bgp_snmp_bgp4v2mib/rr/bgpd.conf new file mode 100644 index 000000000000..e9c123eaf255 --- /dev/null +++ b/tests/topotests/bgp_snmp_bgp4v2mib/rr/bgpd.conf @@ -0,0 +1,67 @@ +! +debug bgp updates +! +router bgp 65004 + no bgp ebgp-requires-policy + no bgp network import-check + no bgp default ipv4-unicast + neighbor 192.168.12.1 remote-as external + neighbor 192.168.12.1 timers 1 3 + neighbor 192.168.12.1 timers connect 1 + neighbor 192.168.12.2 remote-as external + neighbor 192.168.12.2 timers 1 3 + neighbor 192.168.12.2 timers connect 1 + neighbor 192.168.12.3 remote-as external + neighbor 192.168.12.3 timers 1 3 + neighbor 192.168.12.3 timers connect 1 + neighbor 2001:db8::12:1 remote-as external + neighbor 2001:db8::12:1 timers 1 3 + neighbor 2001:db8::12:1 timers connect 1 + neighbor 2001:db8::12:2 remote-as external + neighbor 2001:db8::12:2 timers 1 3 + neighbor 2001:db8::12:2 timers connect 1 + neighbor 2001:db8::12:3 remote-as external + neighbor 2001:db8::12:3 timers 1 3 + neighbor 2001:db8::12:3 timers connect 1 + ! + address-family ipv4 unicast + network 10.0.0.0/31 route-map p1 + network 10.0.0.2/32 route-map p2 + neighbor 192.168.12.1 activate + neighbor 192.168.12.2 activate + neighbor 192.168.12.2 addpath-tx-all-paths + neighbor 192.168.12.2 route-map r2-import in + neighbor 192.168.12.2 route-map r2-export out +! neighbor 192.168.12.2 soft-reconfiguration inbound + neighbor 192.168.12.3 activate + exit-address-family + address-family ipv6 unicast + network 2001:db8::1/128 route-map p1 + network 2001:db8:1::/56 route-map p2 + neighbor 2001:db8::12:1 activate + neighbor 2001:db8::12:2 activate + neighbor 2001:db8::12:2 addpath-tx-all-paths + neighbor 2001:db8::12:3 activate + exit-address-family + + +ip prefix-list r2-toto permit any + +route-map r2-import permit 10 + match ip address prefix-list r2-toto + +route-map r2-export permit 10 + match ip address prefix-list r2-toto +! +route-map p1 permit 10 + set metric 1 +exit +route-map p2 permit 10 + set metric 2 + set origin incomplete +exit + + + +agentx +! diff --git a/tests/topotests/bgp_snmp_bgp4v2mib/rr/zebra.conf b/tests/topotests/bgp_snmp_bgp4v2mib/rr/zebra.conf new file mode 100644 index 000000000000..092673b8a977 --- /dev/null +++ b/tests/topotests/bgp_snmp_bgp4v2mib/rr/zebra.conf @@ -0,0 +1,5 @@ +! +interface rr-eth0 + ip address 192.168.12.4/24 + ipv6 address 2001:db8::12:4/64 +! diff --git a/tests/topotests/bgp_snmp_bgp4v2mib/test_bgp_snmp_bgp4v2mib.py b/tests/topotests/bgp_snmp_bgp4v2mib/test_bgp_snmp_bgp4v2mib.py index 14dadd45045b..0ae89af8bf53 100755 --- a/tests/topotests/bgp_snmp_bgp4v2mib/test_bgp_snmp_bgp4v2mib.py +++ b/tests/topotests/bgp_snmp_bgp4v2mib/test_bgp_snmp_bgp4v2mib.py @@ -30,12 +30,16 @@ def build_topo(tgen): - tgen.add_router("r1") - tgen.add_router("r2") + tgen.add_router("r1") + tgen.add_router("r2") + tgen.add_router("r3") + tgen.add_router("rr") - switch = tgen.add_switch("s1") - switch.add_link(tgen.gears["r1"]) - switch.add_link(tgen.gears["r2"]) + switch = tgen.add_switch("s1") + switch.add_link(tgen.gears["r1"]) + switch.add_link(tgen.gears["r2"]) + switch.add_link(tgen.gears["r3"]) + switch.add_link(tgen.gears["rr"]) def setup_module(mod): @@ -57,14 +61,15 @@ def setup_module(mod): "-M snmp", ) - tgen.gears["r2"].load_config( + r2 = tgen.gears["r2"] + r2.load_config( TopoRouter.RD_SNMP, - os.path.join(CWD, "{}/snmpd.conf".format(rname)), + os.path.join(CWD, "{}/snmpd.conf".format(r2.name)), "-Le -Ivacm_conf,usmConf,iquery -V -DAgentX", ) - tgen.gears["r2"].load_config( + r2.load_config( TopoRouter.RD_TRAP, - os.path.join(CWD, "{}/snmptrapd.conf".format(rname)), + os.path.join(CWD, "{}/snmptrapd.conf".format(r2.name)), " -On -OQ ", ) @@ -81,27 +86,29 @@ def test_bgp_snmp_bgp4v2(): r1 = tgen.gears["r1"] r2 = tgen.gears["r2"] + rr = tgen.gears["rr"] def _bgp_converge_summary(): output = json.loads(r2.vtysh_cmd("show bgp summary json")) expected = { "ipv4Unicast": { "peers": { - "192.168.12.1": { + "192.168.12.4": { "state": "Established", - "pfxRcd": 2, + "pfxRcd": 6, } } }, "ipv6Unicast": { "peers": { - "2001:db8::12:1": { + "2001:db8::12:4": { "state": "Established", - "pfxRcd": 2, + "pfxRcd": 4, } } }, } + # tgen.mininet_cli() return topotest.json_cmp(output, expected) test_func = functools.partial(_bgp_converge_summary) @@ -144,6 +151,7 @@ def _bgp_converge_prefixes(): } }, } + # tgen.mininet_cli() return topotest.json_cmp(output, expected) test_func = functools.partial(_bgp_converge_prefixes) @@ -154,12 +162,14 @@ def _bgp_converge_prefixes(): def _snmpwalk_remote_addr(): expected = { - "1.3.6.1.3.5.1.1.2.1.5.1.1.192.168.12.1": "C0 A8 0C 01", - "1.3.6.1.3.5.1.1.2.1.5.1.2.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.1": "20 01 0D B8 00 00 00 00 00 00 00 00 00 12 00 01", + "1.3.6.1.3.5.1.1.2.1.5.1.1.192.168.12.4": "C0 A8 0C 04", + "1.3.6.1.3.5.1.1.2.1.5.1.2.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.4": "20 01 0D B8 00 00 00 00 00 00 00 00 00 12 00 04", } # bgp4V2PeerRemoteAddr + # tgen.mininet_cli() output, _ = snmp.walk(".1.3.6.1.3.5.1.1.2.1.5") + logger.info(output) return output == expected _, result = topotest.run_and_expect(_snmpwalk_remote_addr, True, count=10, wait=1) @@ -168,8 +178,8 @@ def _snmpwalk_remote_addr(): def _snmpwalk_peer_state(): expected = { - "1.3.6.1.3.5.1.1.2.1.13.1.1.192.168.12.1": "6", - "1.3.6.1.3.5.1.1.2.1.13.1.2.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.13.1.1.192.168.12.4": "6", + "1.3.6.1.3.5.1.1.2.1.13.1.2.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.4": "6", } # bgp4V2PeerState @@ -182,8 +192,8 @@ def _snmpwalk_peer_state(): def _snmpwalk_peer_last_error_code_received(): expected = { - "1.3.6.1.3.5.1.1.3.1.1.1.1.192.168.12.1": "0", - "1.3.6.1.3.5.1.1.3.1.1.1.2.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.1": "0", + "1.3.6.1.3.5.1.1.3.1.1.1.1.192.168.12.4": "0", + "1.3.6.1.3.5.1.1.3.1.1.1.2.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.4": "0", } # bgp4V2PeerLastErrorCodeReceived @@ -197,15 +207,21 @@ def _snmpwalk_peer_last_error_code_received(): assert result, assertmsg def _snmpwalk_origin(): + expected = { - "1.3.6.1.3.5.1.1.9.1.9.1.1.1.1.10.0.0.0.31.1.192.168.12.1.1": "1", - "1.3.6.1.3.5.1.1.9.1.9.1.1.1.1.10.0.0.2.32.1.192.168.12.1.1": "3", - "1.3.6.1.3.5.1.1.9.1.9.1.2.1.2.32.1.13.184.0.0.0.0.0.0.0.0.0.0.0.1.128.2.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.1.1": "1", - "1.3.6.1.3.5.1.1.9.1.9.1.2.1.2.32.1.13.184.0.1.0.0.0.0.0.0.0.0.0.0.56.2.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.1.1": "3", + "1.3.6.1.3.5.1.1.9.1.9.1.1.1.1.7.7.7.7.32.1.192.168.12.4.1": "1", + "1.3.6.1.3.5.1.1.9.1.9.1.1.1.1.7.7.7.7.32.1.192.168.12.4.2": "1", + "1.3.6.1.3.5.1.1.9.1.9.1.1.1.1.10.0.0.0.31.1.192.168.12.4.1": "1", + "1.3.6.1.3.5.1.1.9.1.9.1.1.1.1.10.0.0.0.31.1.192.168.12.4.2": "1", + "1.3.6.1.3.5.1.1.9.1.9.1.1.1.1.10.0.0.2.32.1.192.168.12.4.1": "3", + "1.3.6.1.3.5.1.1.9.1.9.1.1.1.1.10.0.0.2.32.1.192.168.12.4.2": "3", + "1.3.6.1.3.5.1.1.9.1.9.1.2.1.2.32.1.13.184.0.0.0.0.0.0.0.0.0.0.0.1.128.2.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.4.1": "1", + "1.3.6.1.3.5.1.1.9.1.9.1.2.1.2.32.1.13.184.0.0.0.0.0.0.0.0.0.0.0.1.128.2.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.4.2": "1", + "1.3.6.1.3.5.1.1.9.1.9.1.2.1.2.32.1.13.184.0.1.0.0.0.0.0.0.0.0.0.0.56.2.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.4.1": "3", + "1.3.6.1.3.5.1.1.9.1.9.1.2.1.2.32.1.13.184.0.1.0.0.0.0.0.0.0.0.0.0.56.2.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.4.2": "3" } # bgp4V2NlriOrigin - # tgen.mininet_cli() output, _ = snmp.walk(".1.3.6.1.3.5.1.1.9.1.9") return output == expected @@ -215,15 +231,21 @@ def _snmpwalk_origin(): def _snmpwalk_med(): expected = { - "1.3.6.1.3.5.1.1.9.1.17.1.1.1.1.10.0.0.0.31.1.192.168.12.1.1": "1", - "1.3.6.1.3.5.1.1.9.1.17.1.1.1.1.10.0.0.2.32.1.192.168.12.1.1": "2", - "1.3.6.1.3.5.1.1.9.1.17.1.2.1.2.32.1.13.184.0.0.0.0.0.0.0.0.0.0.0.1.128.2.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.1.1": "1", - "1.3.6.1.3.5.1.1.9.1.17.1.2.1.2.32.1.13.184.0.1.0.0.0.0.0.0.0.0.0.0.56.2.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.1.1": "2", + "1.3.6.1.3.5.1.1.9.1.17.1.1.1.1.7.7.7.7.32.1.192.168.12.4.1": "0", + "1.3.6.1.3.5.1.1.9.1.17.1.1.1.1.7.7.7.7.32.1.192.168.12.4.2": "0", + "1.3.6.1.3.5.1.1.9.1.17.1.1.1.1.10.0.0.0.31.1.192.168.12.4.1": "1", + "1.3.6.1.3.5.1.1.9.1.17.1.1.1.1.10.0.0.0.31.1.192.168.12.4.2": "0", + "1.3.6.1.3.5.1.1.9.1.17.1.1.1.1.10.0.0.2.32.1.192.168.12.4.1": "2", + "1.3.6.1.3.5.1.1.9.1.17.1.1.1.1.10.0.0.2.32.1.192.168.12.4.2": "0", + "1.3.6.1.3.5.1.1.9.1.17.1.2.1.2.32.1.13.184.0.0.0.0.0.0.0.0.0.0.0.1.128.2.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.4.1": "1", + "1.3.6.1.3.5.1.1.9.1.17.1.2.1.2.32.1.13.184.0.0.0.0.0.0.0.0.0.0.0.1.128.2.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.4.2": "0", + "1.3.6.1.3.5.1.1.9.1.17.1.2.1.2.32.1.13.184.0.1.0.0.0.0.0.0.0.0.0.0.56.2.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.4.1": "2", + "1.3.6.1.3.5.1.1.9.1.17.1.2.1.2.32.1.13.184.0.1.0.0.0.0.0.0.0.0.0.0.56.2.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.4.2": "0" } # bgp4V2NlriMed output, _ = snmp.walk(".1.3.6.1.3.5.1.1.9.1.17") - # tgen.mininet_cli() + # tgen.mininet_cli() return output == expected _, result = topotest.run_and_expect(_snmpwalk_med, True, count=10, wait=1) @@ -232,20 +254,19 @@ def _snmpwalk_med(): def _snmptrap_ipv4(): expected = [ - ("1.3.6.1.2.1.15.3.1.7.192.168.12.1", "192.168.12.1"), - ("1.3.6.1.2.1.15.3.1.14.192.168.12.1", '"06 04 "'), - ("1.3.6.1.2.1.15.3.1.2.192.168.12.1", "7"), - ("1.3.6.1.2.1.15.3.1.7.192.168.12.1", "192.168.12.1"), - ("1.3.6.1.2.1.15.3.1.14.192.168.12.1", '"06 04 "'), - ("1.3.6.1.2.1.15.3.1.2.192.168.12.1", "6"), + ("1.3.6.1.2.1.15.3.1.7.192.168.12.4", "192.168.12.4"), + ("1.3.6.1.2.1.15.3.1.14.192.168.12.4", '"06 04 "'), + ("1.3.6.1.2.1.15.3.1.2.192.168.12.4", "7"), + ("1.3.6.1.2.1.15.3.1.7.192.168.12.4", "192.168.12.4"), + ("1.3.6.1.2.1.15.3.1.14.192.168.12.4", '"06 04 "'), + ("1.3.6.1.2.1.15.3.1.2.192.168.12.4", "6"), ] # load trapd resulting file - # tgen.mininet_cli() - snmptrapfile = "{}/{}/snmptrapd.log".format(r2.logdir, r2.name) outputfile = open(snmptrapfile).read() output = snmp.trap(outputfile) + logger.info(output) return output == expected # skip tests is SNMP not installed @@ -257,51 +278,32 @@ def _snmptrap_ipv4(): trap_file = open(snmptrapfile, "w") trap_file.truncate(0) trap_file.close() - r1.vtysh_cmd("clear bgp *") + rr.vtysh_cmd("clear bgp *") _, 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.1.192.168.12.1", "7"), - ("1.3.6.1.3.5.1.1.2.1.6.1.1.192.168.12.1", "179"), - ("1.3.6.1.3.5.1.1.3.1.1.1.1.192.168.12.1", "6"), - ("1.3.6.1.3.5.1.1.3.1.2.1.1.192.168.12.1", "4"), - ("1.3.6.1.3.5.1.1.3.1.4.1.1.192.168.12.1", '"00 "'), - ("1.3.6.1.3.5.1.1.2.1.13.1.2.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.1.2.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.1.2.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.1.2.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.1.2.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.1.192.168.12.1", "6"), - ("1.3.6.1.3.5.1.1.2.1.6.1.1.192.168.12.1", "179"), - ("1.3.6.1.3.5.1.1.2.1.13.1.2.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.1.2.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.2.1.13.1.1.192.168.12.4", "6"), + ("1.3.6.1.3.5.1.1.2.1.13.1.1.192.168.12.4", "7"), + ("1.3.6.1.3.5.1.1.2.1.13.1.2.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.4", "6"), + ("1.3.6.1.3.5.1.1.2.1.13.1.2.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.4", "7"), + ("1.3.6.1.3.5.1.1.2.1.6.1.1.192.168.12.4", "179"), + ("1.3.6.1.3.5.1.1.2.1.6.1.1.192.168.12.4", "179"), + ("1.3.6.1.3.5.1.1.2.1.6.1.2.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.4", "179"), + ("1.3.6.1.3.5.1.1.2.1.6.1.2.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.4", "179"), + ("1.3.6.1.3.5.1.1.3.1.1.1.1.192.168.12.4", "6"), + ("1.3.6.1.3.5.1.1.3.1.1.1.2.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.4", "6"), + ("1.3.6.1.3.5.1.1.3.1.2.1.1.192.168.12.4", "4"), + ("1.3.6.1.3.5.1.1.3.1.2.1.2.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.4", "4"), + ("1.3.6.1.3.5.1.1.3.1.4.1.1.192.168.12.4", '"00 "'), + ( + "1.3.6.1.3.5.1.1.3.1.4.1.2.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.4", + '"00 "', + ), ] - expected2 = [ - ("1.3.6.1.3.5.1.1.2.1.13.1.2.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.1.2.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.1.2.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.1.2.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.1.2.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.1.192.168.12.1", "7"), - ("1.3.6.1.3.5.1.1.2.1.6.1.1.192.168.12.1", "179"), - ("1.3.6.1.3.5.1.1.3.1.1.1.1.192.168.12.1", "6"), - ("1.3.6.1.3.5.1.1.3.1.2.1.1.192.168.12.1", "4"), - ("1.3.6.1.3.5.1.1.3.1.4.1.1.192.168.12.1", '"00 "'), - ("1.3.6.1.3.5.1.1.2.1.13.1.1.192.168.12.1", "6"), - ("1.3.6.1.3.5.1.1.2.1.6.1.1.192.168.12.1", "179"), - ("1.3.6.1.3.5.1.1.2.1.13.1.2.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.1.2.32.1.13.184.0.0.0.0.0.0.0.0.0.18.0.1", "179"), - ] # load trapd resulting file # tgen.mininet_cli() @@ -309,9 +311,10 @@ def _snmptrap_ipv6(): snmptrapfile = "{}/{}/snmptrapd.log".format(r2.logdir, r2.name) outputfile = open(snmptrapfile).read() output = snmp.trap(outputfile) - logger.info(output) output_cut = output[:14] - return output_cut == expected or output_cut == expected2 + output_cut.sort() + logger.info(output_cut) + return output_cut == expected snmptrapfile = "{}/{}/snmptrapd.log".format(r2.logdir, r2.name) trap_file = open(snmptrapfile, "w") @@ -319,7 +322,7 @@ def _snmptrap_ipv6(): trap_file.close() r2.vtysh_cmd("conf\nbgp snmp traps bgp4-mibv2") r2.vtysh_cmd("conf\nno bgp snmp traps rfc4273") - r1.vtysh_cmd("clear bgp *") + rr.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