]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests: improve tests for aspath exclude and bgp access list 16285/head
authorFrancois Dumontet <francois.dumontet@6wind.com>
Wed, 24 Apr 2024 12:34:48 +0000 (14:34 +0200)
committerMergify <37929162+mergify[bot]@users.noreply.github.com>
Tue, 25 Jun 2024 05:12:09 +0000 (05:12 +0000)
add some match in route map rules
add some set unset bgp access path list
add another prefix for better tests discrimination
update expected results

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

tests/topotests/bgp_set_aspath_exclude/r1/bgpd.conf
tests/topotests/bgp_set_aspath_exclude/r3/zebra.conf
tests/topotests/bgp_set_aspath_exclude/test_bgp_set_aspath_exclude.py

index 9bef24f931549d26b026f67fc30c4a3d4d4042a3..c70b4934a079ef3fc601c8ef32209f109400ec49 100644 (file)
@@ -8,10 +8,19 @@ router bgp 65001
  exit-address-family
 !
 ip prefix-list p1 seq 5 permit 172.16.255.31/32
+ip prefix-list p2 seq 5 permit 172.16.255.32/32
+ip prefix-list p3 seq 5 permit 172.16.255.30/32
 !
+bgp as-path access-list FIRST permit ^65
+bgp as-path access-list SECOND permit 2$
+
+route-map r2 permit 6
+ match ip address prefix-list p2
+ set as-path exclude as-path-access-list SECOND
 route-map r2 permit 10
  match ip address prefix-list p1
  set as-path exclude 65003
 route-map r2 permit 20
+ match ip address prefix-list p3
  set as-path exclude all
 !
index 3fa6c644844cb225ec2856087862ee5170dcce47..56893158a40389683bbba3b9e89c57c6b8a61d56 100644 (file)
@@ -1,5 +1,6 @@
 !
 int lo
+ ip address 172.16.255.30/32
  ip address 172.16.255.31/32
  ip address 172.16.255.32/32
 !
index d373a749fe87e63c0443f8f53accb80e1716d380..85e7b9676d0e6c4fdc7adc898d1a29ee32a2ae62 100644 (file)
@@ -64,29 +64,33 @@ def teardown_module(mod):
 
 expected_1 = {
     "routes": {
+        "172.16.255.30/32": [{"path": ""}],
         "172.16.255.31/32": [{"path": "65002"}],
-        "172.16.255.32/32": [{"path": ""}],
+        "172.16.255.32/32": [{"path": "65003"}],
     }
 }
 
 expected_2 = {
     "routes": {
-        "172.16.255.31/32": [{"path": ""}],
+        "172.16.255.30/32": [{"path": ""}],
+        "172.16.255.31/32": [{"path": "65002"}],
         "172.16.255.32/32": [{"path": ""}],
     }
 }
 
 expected_3 = {
     "routes": {
-        "172.16.255.31/32": [{"path": "65003"}],
-        "172.16.255.32/32": [{"path": "65003"}],
+        "172.16.255.30/32": [{"path": ""}],
+        "172.16.255.31/32": [{"path": "65002"}],
+        "172.16.255.32/32": [{"path": "65002 65003"}],
     }
 }
 
 expected_4 = {
     "routes": {
-        "172.16.255.31/32": [{"path": "65002 65003"}],
-        "172.16.255.32/32": [{"path": "65002 65003"}],
+        "172.16.255.30/32": [{"path": ""}],
+        "172.16.255.31/32": [{"path": "65002"}],
+        "172.16.255.32/32": [{"path": "65002"}],
     }
 }
 
@@ -117,34 +121,42 @@ def test_bgp_set_aspath_exclude_access_list():
 
     rname = "r1"
     r1 = tgen.gears[rname]
+    # tgen.mininet_cli()
 
     r1.vtysh_cmd(
         """
 conf
  bgp as-path access-list FIRST permit ^65 
  route-map r2 permit 6 
+  no set as-path exclude as-path-access-list SECOND
   set as-path exclude as-path-access-list FIRST
     """
     )
+    # tgen.mininet_cli()
+    r1.vtysh_cmd(
+        """
+clear bgp *
+    """
+    )
 
     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"
+    assert result is None, "Failed change of exclude rule in route map"
     r1.vtysh_cmd(
         """
 conf
- bgp as-path access-list SECOND permit 2
  route-map r2 permit 6
+  no set as-path exclude as-path-access-list FIRST
   set as-path exclude as-path-access-list SECOND
     """
     )
 
     # tgen.mininet_cli()
-    test_func = functools.partial(bgp_converge, tgen.gears["r1"], expected_3)
+    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 regex 2 route-map"
+    assert result is None, "Failed reverting exclude rule in route map"
 
 
 def test_no_bgp_set_aspath_exclude_access_list():
@@ -159,15 +171,28 @@ def test_no_bgp_set_aspath_exclude_access_list():
     r1.vtysh_cmd(
         """
 conf
- no bgp as-path access-list SECOND permit 2
+ no bgp as-path access-list SECOND permit 2$
+    """
+    )
+
+    r1.vtysh_cmd(
+        """
+clear bgp *
     """
     )
 
     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"
+    assert result is None, "Failed to removing current accesslist"
 
+    # tgen.mininet_cli()
+    r1.vtysh_cmd(
+        """
+conf
+ bgp as-path access-list SECOND permit 3$
+    """
+    )
     r1.vtysh_cmd(
         """
 clear bgp *
@@ -177,7 +202,26 @@ 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"
+    assert result is None, "Failed to renegotiate with peers 2"
+
+    r1.vtysh_cmd(
+        """
+conf
+ route-map r2 permit 6
+  no set as-path exclude as-path-access-list SECOND
+    """
+    )
+
+    r1.vtysh_cmd(
+        """
+clear bgp *
+    """
+    )
+
+    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 to renegotiate with peers 2"
 
 
 if __name__ == "__main__":