]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests: Add more tests for labeled-unicast and addpath 12477/head
authorDonatas Abraitis <donatas@opensourcerouting.org>
Fri, 9 Dec 2022 12:12:32 +0000 (14:12 +0200)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Fri, 9 Dec 2022 12:12:32 +0000 (14:12 +0200)
Check if we advertise more routes when an additional path comes up, and
if we withdraw if dissapears.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
tests/topotests/bgp_labeled_unicast_addpath/r3/bgpd.conf
tests/topotests/bgp_labeled_unicast_addpath/r3/zebra.conf
tests/topotests/bgp_labeled_unicast_addpath/r5/bgpd.conf [new file with mode: 0644]
tests/topotests/bgp_labeled_unicast_addpath/r5/zebra.conf [new file with mode: 0644]
tests/topotests/bgp_labeled_unicast_addpath/test_bgp_labeled_unicast_addpath.py

index c38ed7ef6f81deb97ce2a50f4d7755a0d0018751..6dd8f7f67e52a95ce5a4f3efa4829c46e73ac7e5 100644 (file)
@@ -13,9 +13,14 @@ router bgp 65003
  neighbor 192.168.34.4 remote-as external
  neighbor 192.168.34.4 timers 1 3
  neighbor 192.168.34.4 timers connect 1
+ neighbor 192.168.35.5 remote-as external
+ neighbor 192.168.35.5 timers 1 3
+ neighbor 192.168.35.5 timers connect 1
+ neighbor 192.168.35.5 shutdown
  address-family ipv4 labeled-unicast
   neighbor 192.168.31.1 activate
   neighbor 192.168.32.2 activate
+  neighbor 192.168.35.5 activate
   neighbor 192.168.34.4 activate
   neighbor 192.168.34.4 route-map r4 out
   neighbor 192.168.34.4 addpath-tx-all-paths
index 1cc2ca2edfca585d58c0222b738e3c5c746eeffe..838413ac6fd9c2c6e1f2ef988e3d2577b509aace 100644 (file)
@@ -8,3 +8,6 @@ interface r3-eth1
 interface r3-eth2
  ip address 192.168.34.3/24
 !
+interface r3-eth3
+ ip address 192.168.35.3/24
+!
diff --git a/tests/topotests/bgp_labeled_unicast_addpath/r5/bgpd.conf b/tests/topotests/bgp_labeled_unicast_addpath/r5/bgpd.conf
new file mode 100644 (file)
index 0000000..5b38b5a
--- /dev/null
@@ -0,0 +1,14 @@
+router bgp 65005
+ no bgp ebgp-requires-policy
+ no bgp default ipv4-unicast
+ neighbor 192.168.35.3 remote-as external
+ neighbor 192.168.35.3 timers 1 3
+ neighbor 192.168.35.3 timers connect 1
+ address-family ipv4 unicast
+  redistribute connected
+ exit-address-family
+ !
+ address-family ipv4 labeled-unicast
+  neighbor 192.168.35.3 activate
+ exit-address-family
+!
diff --git a/tests/topotests/bgp_labeled_unicast_addpath/r5/zebra.conf b/tests/topotests/bgp_labeled_unicast_addpath/r5/zebra.conf
new file mode 100644 (file)
index 0000000..6289e4f
--- /dev/null
@@ -0,0 +1,7 @@
+!
+interface lo
+ ip address 10.0.0.1/32
+!
+interface r5-eth0
+ ip address 192.168.35.5/24
+!
index 9e7dd403f526af7c46dc1f317f9c7966be9070a5..aae901eabee4e79b087b487afadd5b88896c3d52 100644 (file)
@@ -21,6 +21,9 @@
 
 """
 Check if labeled-unicast works correctly with addpath capability.
+Initially R3 MUST announce 10.0.0.1/32 multipath(2) from R1 + R2.
+Later, we enable R5 and 10.0.0.1/32 multipath(3) MUST be announced,
+R1 + R2 + R5.
 """
 
 import os
@@ -41,7 +44,7 @@ pytestmark = [pytest.mark.bgpd]
 
 
 def build_topo(tgen):
-    for routern in range(1, 5):
+    for routern in range(1, 6):
         tgen.add_router("r{}".format(routern))
 
     switch = tgen.add_switch("s1")
@@ -56,6 +59,10 @@ def build_topo(tgen):
     switch.add_link(tgen.gears["r3"])
     switch.add_link(tgen.gears["r4"])
 
+    switch = tgen.add_switch("s4")
+    switch.add_link(tgen.gears["r3"])
+    switch.add_link(tgen.gears["r5"])
+
 
 def setup_module(mod):
     tgen = Topogen(build_topo, mod.__name__)
@@ -88,7 +95,7 @@ def test_bgp_addpath_labeled_unicast():
     r3 = tgen.gears["r3"]
     r4 = tgen.gears["r4"]
 
-    def _bgp_check_advertised_routes():
+    def _bgp_check_advertised_routes(prefix_num):
         output = json.loads(
             r3.vtysh_cmd(
                 "show bgp ipv4 labeled-unicast neighbors 192.168.34.4 advertised-routes json"
@@ -104,11 +111,11 @@ def test_bgp_addpath_labeled_unicast():
                     }
                 }
             },
-            "totalPrefixCounter": 2,
+            "totalPrefixCounter": prefix_num,
         }
         return topotest.json_cmp(output, expected)
 
-    test_func = functools.partial(_bgp_check_advertised_routes)
+    test_func = functools.partial(_bgp_check_advertised_routes, 2)
     _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
     assert (
         result is None
@@ -136,6 +143,36 @@ def test_bgp_addpath_labeled_unicast():
     _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
     assert result is None, "Failed to receive labeled-unicast with addpath (multipath)"
 
+    step("Enable BGP session for R5")
+    r3.vtysh_cmd(
+        """
+          configure terminal
+            router bgp 65003
+              no neighbor 192.168.35.5 shutdown
+        """
+    )
+
+    test_func = functools.partial(_bgp_check_advertised_routes, 3)
+    _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+    assert (
+        result is None
+    ), "Failed to advertise labeled-unicast with addpath (multipath)"
+
+    step("Disable BGP session for R5")
+    r3.vtysh_cmd(
+        """
+          configure terminal
+            router bgp 65003
+              neighbor 192.168.35.5 shutdown
+        """
+    )
+
+    test_func = functools.partial(_bgp_check_advertised_routes, 2)
+    _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+    assert (
+        result is None
+    ), "Failed to advertise labeled-unicast with addpath (multipath)"
+
 
 if __name__ == "__main__":
     args = ["-s"] + sys.argv[1:]