From fe0b0985ebdd3f35f62d02ab5827f632a175e102 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Fri, 24 Feb 2023 11:53:46 +0100 Subject: [PATCH] topotests: add bgp test to check the ADJ-RIB-IN label value The test is done on r2. A BGP update is received on r2, and is filtered on r2. The RIB of r2 does not have the BGP update stored, but the ADJ-RIB-IN is yet present. To demonstrate this, if the inbound route-map is removed, then the BGP update should be copied from the the ADJ-RIB-IN and added to the RIB with the label value. Signed-off-by: Philippe Guibert Signed-off-by: Louis Scalbert --- .../bgp_vpnv4_ebgp/test_bgp_vpnv4_ebgp.py | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/tests/topotests/bgp_vpnv4_ebgp/test_bgp_vpnv4_ebgp.py b/tests/topotests/bgp_vpnv4_ebgp/test_bgp_vpnv4_ebgp.py index da7ac96e6035..2b8024178dc0 100644 --- a/tests/topotests/bgp_vpnv4_ebgp/test_bgp_vpnv4_ebgp.py +++ b/tests/topotests/bgp_vpnv4_ebgp/test_bgp_vpnv4_ebgp.py @@ -438,6 +438,93 @@ def test_adj_rib_out_label_change(): assert result is None, assertmsg +def test_adj_rib_in_label_change(): + """ + Check that syncinig with ADJ-RIB-in on r2 + permits restoring the initial label value + """ + tgen = get_topogen() + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + logger.info("Enable soft-reconfiguration inbound on r2") + + r2 = tgen.gears["r2"] + r2.vtysh_cmd( + """ +configure terminal +router bgp 65501 + address-family ipv4 vpn + neighbor 192.168.0.1 soft-reconfiguration inbound +""" + ) + + logger.info("Applying a deny-all route-map to input on r2") + r2.vtysh_cmd( + """ +configure terminal +route-map DENY-ALL deny 1 +! +router bgp 65501 + address-family ipv4 vpn + neighbor 192.168.0.1 route-map DENY-ALL in +""" + ) + + # check that 172.31.0.1 should not be present + logger.info("Check that received update 172.31.0.1 is not present") + + expected = {} + test_func = partial( + topotest.router_json_cmp, + r2, + "show bgp ipv4 vpn 172.31.0.1/32 json", + expected, + exact=True, + ) + success, result = topotest.run_and_expect(test_func, None, count=10, wait=0.5) + assert success, "r2, vpnv4 update 172.31.0.1 still present" + + + +def test_adj_rib_in_label_change_remove_rmap(): + """ + Check that syncinig with ADJ-RIB-in on r2 + permits restoring the initial label value + """ + tgen = get_topogen() + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + logger.info("Removing the deny-all route-map from input on r2") + + r2 = tgen.gears["r2"] + r2.vtysh_cmd( + """ +configure terminal +router bgp 65501 + address-family ipv4 vpn + no neighbor 192.168.0.1 route-map DENY-ALL in +""" + ) + # Check BGP IPv4 route entry for 172.31.0.1 on r1 + logger.info( + "Checking that 172.31.0.1 BGP update is present and has valid label on r2" + ) + json_file = "{}/{}/bgp_ipv4_vpn_route_1723101.json".format(CWD, r2.name) + + expected = json.loads(open(json_file).read()) + test_func = partial( + topotest.router_json_cmp, + r2, + "show bgp ipv4 vpn 172.31.0.1/32 json", + expected, + ) + _, result = topotest.run_and_expect(test_func, None, count=10, wait=0.5) + assertmsg = '"{}" JSON output mismatches'.format(r2.name) + assert result is None, assertmsg + + def test_memory_leak(): "Run the memory leak test and report results." tgen = get_topogen()