From e6335d13037be864fa87d5963ddb9fa980a441e3 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Wed, 7 Jun 2023 14:56:21 +0200 Subject: [PATCH] topotests: add mpls l3vpn test with default vrf There is no MPLS VPN test with default VRF. Add a test to ensure that the MPLS VPN MIB also works with the default VRF. An additional check is done to refine the real number of interfaces based on the presence or not of the gre0, gretap, and erspan interfaces. Signed-off-by: Philippe Guibert Signed-off-by: Louis Scalbert --- .../topotests/bgp_snmp_mplsl3vpn/r1/bgpd.conf | 9 +++ .../test_bgp_snmp_mplsvpn.py | 57 ++++++++++++------- 2 files changed, 45 insertions(+), 21 deletions(-) diff --git a/tests/topotests/bgp_snmp_mplsl3vpn/r1/bgpd.conf b/tests/topotests/bgp_snmp_mplsl3vpn/r1/bgpd.conf index b80a90ac7d1e..2ba50951bbff 100644 --- a/tests/topotests/bgp_snmp_mplsl3vpn/r1/bgpd.conf +++ b/tests/topotests/bgp_snmp_mplsl3vpn/r1/bgpd.conf @@ -5,6 +5,15 @@ router bgp 65000 neighbor 10.4.4.4 update-source 10.1.1.1 neighbor 10.4.4.4 timers connect 10 ! + address-family ipv4 unicast + network 192.0.2.8/32 + label vpn export 8888 + rd vpn export 88:88 + rt vpn both 88:99 + export vpn + import vpn + exit-address-family + no bgp network import-check address-family ipv4 vpn neighbor 10.4.4.4 activate exit-address-family diff --git a/tests/topotests/bgp_snmp_mplsl3vpn/test_bgp_snmp_mplsvpn.py b/tests/topotests/bgp_snmp_mplsl3vpn/test_bgp_snmp_mplsvpn.py index 09eef51338d9..7264da7e72b3 100755 --- a/tests/topotests/bgp_snmp_mplsl3vpn/test_bgp_snmp_mplsvpn.py +++ b/tests/topotests/bgp_snmp_mplsl3vpn/test_bgp_snmp_mplsvpn.py @@ -253,9 +253,9 @@ def _convergence(): interfaces_up_test = { - "mplsL3VpnConfiguredVrfs": "2", - "mplsL3VpnActiveVrfs": "2", - "mplsL3VpnConnectedInterfaces": "3", + "mplsL3VpnConfiguredVrfs": "3", + "mplsL3VpnActiveVrfs": "3", + "mplsL3VpnConnectedInterfaces": "7", "mplsL3VpnNotificationEnable": "true(1)", "mplsL3VpnVrfConfMaxPossRts": "0", "mplsL3VpnVrfConfRteMxThrshTime": "0 seconds", @@ -263,9 +263,9 @@ def _convergence(): } interfaces_down_test = { - "mplsL3VpnConfiguredVrfs": "2", - "mplsL3VpnActiveVrfs": "1", - "mplsL3VpnConnectedInterfaces": "3", + "mplsL3VpnConfiguredVrfs": "3", + "mplsL3VpnActiveVrfs": "2", + "mplsL3VpnConnectedInterfaces": "7", "mplsL3VpnNotificationEnable": "true(1)", "mplsL3VpnVrfConfMaxPossRts": "0", "mplsL3VpnVrfConfRteMxThrshTime": "0 seconds", @@ -277,6 +277,16 @@ def test_r1_mplsvpn_scalars(): "check scalar values" tgen = get_topogen() r1 = tgen.gears["r1"] + + # hack: count ip_gre module interfaces if present + nb_interfaces = int(interfaces_up_test["mplsL3VpnConnectedInterfaces"]) + output = r1.cmd("ip -br l") + nb_interfaces += 1 if "gre0" in output else 0 + nb_interfaces += 1 if "gretap0" in output else 0 + nb_interfaces += 1 if "erspan0" in output else 0 + interfaces_up_test["mplsL3VpnConnectedInterfaces"] = str(nb_interfaces) + interfaces_down_test["mplsL3VpnConnectedInterfaces"] = str(nb_interfaces) + r1_snmp = SnmpTester(r1, "10.1.1.1", "public", "2c") for item in interfaces_up_test.keys(): @@ -391,17 +401,17 @@ def test_r1_mplsvpn_IfTable(): vrftable_test = { - "mplsL3VpnVrfDescription": ["VRF-a", "VRF-b"], - "mplsL3VpnVrfRD": ['"10:1"', '"10:2"'], - "mplsL3VpnVrfOperStatus": ["up(1)", "up(1)"], - "mplsL3VpnVrfActiveInterfaces": ["2", "1"], - "mplsL3VpnVrfAssociatedInterfaces": ["2", "1"], - "mplsL3VpnVrfConfMidRteThresh": ["0", "0"], - "mplsL3VpnVrfConfHighRteThresh": ["0", "0"], - "mplsL3VpnVrfConfMaxRoutes": ["0", "0"], - "mplsL3VpnVrfConfRowStatus": ["active(1)", "active(1)"], - "mplsL3VpnVrfConfAdminStatus": ["up(1)", "up(1)"], - "mplsL3VpnVrfConfStorageType": ["volatile(2)", "volatile(2)"], + "mplsL3VpnVrfDescription": ["VRF-a", "VRF-b", "default"], + "mplsL3VpnVrfRD": ['"10:1"', '"10:2"', '"88:88"'], + "mplsL3VpnVrfOperStatus": ["up(1)", "up(1)", "up(1)"], + "mplsL3VpnVrfActiveInterfaces": ["2", "1", "3"], + "mplsL3VpnVrfAssociatedInterfaces": ["2", "1", "3"], + "mplsL3VpnVrfConfMidRteThresh": ["0", "0", "0"], + "mplsL3VpnVrfConfHighRteThresh": ["0", "0", "0"], + "mplsL3VpnVrfConfMaxRoutes": ["0", "0", "0"], + "mplsL3VpnVrfConfRowStatus": ["active(1)", "active(1)", "active(1)"], + "mplsL3VpnVrfConfAdminStatus": ["up(1)", "up(1)", "up(1)"], + "mplsL3VpnVrfConfStorageType": ["volatile(2)", "volatile(2)", "volatile(2)"], } @@ -498,10 +508,14 @@ def test_r1_mplsvpn_VrfTable(): rt_table_test = { - "mplsL3VpnVrfRT": ['"1:1"', '"1:2"'], - "mplsL3VpnVrfRTDescr": ["RT both for VRF VRF-a", "RT both for VRF VRF-b"], - "mplsL3VpnVrfRTRowStatus": ["active(1)", "active(1)"], - "mplsL3VpnVrfRTStorageType": ["volatile(2)", "volatile(2)"], + "mplsL3VpnVrfRT": ['"1:1"', '"1:2"', '"88:99"'], + "mplsL3VpnVrfRTDescr": [ + "RT both for VRF VRF-a", + "RT both for VRF VRF-b", + "RT both for VRF default", + ], + "mplsL3VpnVrfRTRowStatus": ["active(1)", "active(1)", "active(1)"], + "mplsL3VpnVrfRTStorageType": ["volatile(2)", "volatile(2)", "volatile(2)"], } @@ -515,6 +529,7 @@ def test_r1_mplsvpn_VrfRT_table(): oids = [] oids.append(generate_vrf_index_type_oid("VRF-a", 1, 3)) oids.append(generate_vrf_index_type_oid("VRF-b", 1, 3)) + oids.append(generate_vrf_index_type_oid("default", 1, 3)) # check items for item in rt_table_test.keys():