]> git.puffer.fish Git - matthieu/frr.git/commitdiff
tests: extend tests for aspath exclude
authorFrancois Dumontet <francois.dumontet@6wind.com>
Wed, 14 Feb 2024 16:13:40 +0000 (17:13 +0100)
committerMergify <37929162+mergify[bot]@users.noreply.github.com>
Tue, 27 Feb 2024 07:53:29 +0000 (07:53 +0000)
adding a tests about:
"no bgp as-path access-list" command.

the folloxing "clear bgp *" command leads to the
crash exhibited above.

a sleep had been added to capture the crash befor the end of scenario.

50 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
[Current thread is 1 (Thread 0x7f5f05cbb9c0 (LWP 1371086))]
(gdb) bt
    context=0x7ffcf2c216c0) at lib/sigevent.c:248
    acl_list=0x55c976ec03c0) at bgpd/bgp_aspath.c:1688
    dummy=0x7ffcf2c22340, object=0x7ffcf2c21e70) at bgpd/bgp_routemap.c:2401
    match_object=0x7ffcf2c21e70, set_object=0x7ffcf2c21e70, pref=0x0)
    at lib/routemap.c:2687
    attr=0x7ffcf2c220b0, afi=AFI_IP, safi=SAFI_UNICAST, rmap_name=0x0, label=0x0,
    num_labels=0, dest=0x55c976ebeaf0) at bgpd/bgp_route.c:1807
    addpath_id=0, attr=0x7ffcf2c22450, afi=AFI_IP, safi=SAFI_UNICAST, type=10,
    sub_type=0, prd=0x0, label=0x0, num_labels=0, soft_reconfig=0, evpn=0x0)
    at bgpd/bgp_route.c:4424
    packet=0x7ffcf2c22410) at bgpd/bgp_route.c:6266
    packet=0x7ffcf2c22410, mp_withdraw=false) at bgpd/bgp_packet.c:341
    peer=0x55c976e89ed0, size=43) at bgpd/bgp_packet.c:2414
    at bgpd/bgp_packet.c:3899

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
(cherry picked from commit 324fa2101550b542946a34de09b394df8bf8ba9d)

tests/topotests/bgp_set_aspath_exclude/test_bgp_set_aspath_exclude.py

index a0cd89f064ce963824cbe1a68c789c2eca848bb4..d373a749fe87e63c0443f8f53accb80e1716d380 100644 (file)
@@ -62,23 +62,48 @@ def teardown_module(mod):
     tgen.stop_topology()
 
 
+expected_1 = {
+    "routes": {
+        "172.16.255.31/32": [{"path": "65002"}],
+        "172.16.255.32/32": [{"path": ""}],
+    }
+}
+
+expected_2 = {
+    "routes": {
+        "172.16.255.31/32": [{"path": ""}],
+        "172.16.255.32/32": [{"path": ""}],
+    }
+}
+
+expected_3 = {
+    "routes": {
+        "172.16.255.31/32": [{"path": "65003"}],
+        "172.16.255.32/32": [{"path": "65003"}],
+    }
+}
+
+expected_4 = {
+    "routes": {
+        "172.16.255.31/32": [{"path": "65002 65003"}],
+        "172.16.255.32/32": [{"path": "65002 65003"}],
+    }
+}
+
+
+def bgp_converge(router, expected):
+    output = json.loads(router.vtysh_cmd("show bgp ipv4 unicast json"))
+
+    return topotest.json_cmp(output, expected)
+
+
 def test_bgp_set_aspath_exclude():
     tgen = get_topogen()
 
     if tgen.routers_have_failure():
         pytest.skip(tgen.errors)
 
-    def _bgp_converge(router):
-        output = json.loads(router.vtysh_cmd("show bgp ipv4 unicast json"))
-        expected = {
-            "routes": {
-                "172.16.255.31/32": [{"path": "65002"}],
-                "172.16.255.32/32": [{"path": ""}],
-            }
-        }
-        return topotest.json_cmp(output, expected)
-
-    test_func = functools.partial(_bgp_converge, tgen.gears["r1"])
+    test_func = functools.partial(bgp_converge, tgen.gears["r1"], expected_1)
     _, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
 
     assert result is None, "Failed overriding incoming AS-PATH with route-map"
@@ -102,19 +127,7 @@ conf
     """
     )
 
-    expected = {
-        "routes": {
-            "172.16.255.31/32": [{"path": ""}],
-            "172.16.255.32/32": [{"path": ""}],
-        }
-    }
-
-    def _bgp_regexp_1(router):
-        output = json.loads(router.vtysh_cmd("show bgp ipv4 unicast json"))
-
-        return topotest.json_cmp(output, expected)
-
-    test_func = functools.partial(_bgp_regexp_1, tgen.gears["r1"])
+    test_func = functools.partial(bgp_converge, tgen.gears["r1"], expected_2)
     _, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
 
     assert result is None, "Failed overriding incoming AS-PATH with regex 1 route-map"
@@ -127,19 +140,46 @@ conf
     """
     )
 
-    expected = {
-        "routes": {
-            "172.16.255.31/32": [{"path": "65003"}],
-            "172.16.255.32/32": [{"path": "65003"}],
-        }
-    }
-
-    test_func = functools.partial(_bgp_regexp_1, tgen.gears["r1"])
+    # tgen.mininet_cli()
+    test_func = functools.partial(bgp_converge, tgen.gears["r1"], expected_3)
     _, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
 
     assert result is None, "Failed overriding incoming AS-PATH with regex 2 route-map"
 
 
+def test_no_bgp_set_aspath_exclude_access_list():
+    tgen = get_topogen()
+
+    if tgen.routers_have_failure():
+        pytest.skip(tgen.errors)
+
+    rname = "r1"
+    r1 = tgen.gears[rname]
+
+    r1.vtysh_cmd(
+        """
+conf
+ no bgp as-path access-list SECOND permit 2
+    """
+    )
+
+    test_func = functools.partial(bgp_converge, tgen.gears["r1"], expected_3)
+    _, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
+
+    assert result is None, "Failed removing bgp as-path access-list"
+
+    r1.vtysh_cmd(
+        """
+clear bgp *
+    """
+    )
+
+    test_func = functools.partial(bgp_converge, tgen.gears["r1"], expected_4)
+    _, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
+
+    assert result is None, "Failed to renegotiate with peers"
+
+
 if __name__ == "__main__":
     args = ["-s"] + sys.argv[1:]
     sys.exit(pytest.main(args))