]> git.puffer.fish Git - matthieu/frr.git/commitdiff
tests: Check if non-transitive link-bandwidth communities are sent/received correctly
authorDonatas Abraitis <donatas@opensourcerouting.org>
Thu, 17 Oct 2024 08:25:39 +0000 (11:25 +0300)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Tue, 22 Oct 2024 06:01:04 +0000 (09:01 +0300)
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
tests/topotests/bgp_extended_link_bandwidth/r1/frr.conf
tests/topotests/bgp_extended_link_bandwidth/r2/frr.conf
tests/topotests/bgp_extended_link_bandwidth/r3/frr.conf [new file with mode: 0644]
tests/topotests/bgp_extended_link_bandwidth/r4/frr.conf [new file with mode: 0644]
tests/topotests/bgp_extended_link_bandwidth/test_bgp_extended_link_bandwidth.py

index d0c0813e842d2be75453412483d7c38fbb0a36eb..18b312c60f14ce6748973f4a0edec76d2ed774c3 100644 (file)
@@ -22,7 +22,7 @@ ip prefix-list p200 seq 5 permit 10.10.10.200/32
 !
 route-map r2 permit 10
  match ip address prefix-list p40
- set extcommunity bandwidth 40000
+ set extcommunity bandwidth 40000 non-transitive
 route-map r2 permit 20
  match ip address prefix-list p100
  set extcommunity bandwidth 100000
index 5cad150aef0b56c0ae5b4c24ca99233f65376da8..af07c7cc5c2530a7852b785ff8b3dac3d907ee81 100644 (file)
@@ -2,9 +2,15 @@
 int r2-eth0
  ip address 192.168.1.2/24
 !
+int r2-eth1
+ ip address 192.168.2.2/24
+!
 router bgp 65000
  no bgp ebgp-requires-policy
  neighbor 192.168.1.1 remote-as internal
  neighbor 192.168.1.1 timers 1 3
  neighbor 192.168.1.1 timers connect 1
+ neighbor 192.168.2.1 remote-as external
+ neighbor 192.168.2.1 timers 1 3
+ neighbor 192.168.2.1 timers connect 1
 !
diff --git a/tests/topotests/bgp_extended_link_bandwidth/r3/frr.conf b/tests/topotests/bgp_extended_link_bandwidth/r3/frr.conf
new file mode 100644 (file)
index 0000000..61b13c8
--- /dev/null
@@ -0,0 +1,16 @@
+!
+int r3-eth0
+ ip address 192.168.2.1/24
+!
+int r3-eth1
+ ip address 192.168.3.1/24
+!
+router bgp 65003
+ no bgp ebgp-requires-policy
+ neighbor 192.168.2.2 remote-as external
+ neighbor 192.168.2.2 timers 1 3
+ neighbor 192.168.2.2 timers connect 1
+ neighbor 192.168.3.2 remote-as external
+ neighbor 192.168.3.2 timers 1 3
+ neighbor 192.168.3.2 timers connect 1
+!
diff --git a/tests/topotests/bgp_extended_link_bandwidth/r4/frr.conf b/tests/topotests/bgp_extended_link_bandwidth/r4/frr.conf
new file mode 100644 (file)
index 0000000..49f0caf
--- /dev/null
@@ -0,0 +1,10 @@
+!
+int r4-eth0
+ ip address 192.168.3.2/24
+!
+router bgp 65004
+ no bgp ebgp-requires-policy
+ neighbor 192.168.3.1 remote-as external
+ neighbor 192.168.3.1 timers 1 3
+ neighbor 192.168.3.1 timers connect 1
+!
index e9006b81c93036455fafeabc7ac26772b8ccc6f5..3e5be0310fe3d289c9add96c4b780cc7bd7b7350 100644 (file)
@@ -22,7 +22,7 @@ pytestmark = [pytest.mark.bgpd]
 
 
 def setup_module(mod):
-    topodef = {"s1": ("r1", "r2")}
+    topodef = {"s1": ("r1", "r2"), "s2": ("r2", "r3"), "s3": ("r3", "r4")}
     tgen = Topogen(topodef, mod.__name__)
     tgen.start_topology()
 
@@ -46,9 +46,11 @@ def test_bgp_dynamic_capability_role():
         pytest.skip(tgen.errors)
 
     r2 = tgen.gears["r2"]
+    r3 = tgen.gears["r3"]
+    r4 = tgen.gears["r4"]
 
-    def _bgp_converge():
-        output = json.loads(r2.vtysh_cmd("show bgp ipv4 unicast json detail"))
+    def _bgp_converge(router):
+        output = json.loads(router.vtysh_cmd("show bgp ipv4 unicast json detail"))
         expected = {
             "routes": {
                 "10.10.10.40/32": {
@@ -84,9 +86,60 @@ def test_bgp_dynamic_capability_role():
 
     test_func = functools.partial(
         _bgp_converge,
+        r2,
     )
     _, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
-    assert result is None, "Can't see link bandwidths as expected"
+    assert result is None, "r2 (iBGP) should see link bandwidth extended communities"
+
+    test_func = functools.partial(
+        _bgp_converge,
+        r3,
+    )
+    _, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
+    assert (
+        result is None
+    ), "r3 (eBGP) should see link bandwidth extended communities (including non-transitive)"
+
+    def _bgp_check_non_transitive_extended_communities():
+        output = json.loads(r4.vtysh_cmd("show bgp ipv4 unicast json detail"))
+        expected = {
+            "routes": {
+                "10.10.10.40/32": {
+                    "paths": [
+                        {
+                            "extendedIpv6Community": None,
+                        }
+                    ]
+                },
+                "10.10.10.100/32": {
+                    "paths": [
+                        {
+                            "extendedIpv6Community": {
+                                "string": "LB:65000:12500000000 (100.000 Gbps)",
+                            }
+                        }
+                    ]
+                },
+                "10.10.10.200/32": {
+                    "paths": [
+                        {
+                            "extendedIpv6Community": {
+                                "string": "LB:65000:25000000000 (200.000 Gbps)",
+                            }
+                        }
+                    ]
+                },
+            }
+        }
+        return topotest.json_cmp(output, expected)
+
+    test_func = functools.partial(
+        _bgp_check_non_transitive_extended_communities,
+    )
+    _, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
+    assert (
+        result is None
+    ), "r4 (eBGP) should NOT see non-transitive link bandwidth extended communities"
 
 
 if __name__ == "__main__":