]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests: Check prefix statistics for path-attribute discard/withdraw 17734/head
authorDonatas Abraitis <donatas@opensourcerouting.org>
Mon, 30 Dec 2024 10:27:00 +0000 (12:27 +0200)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Mon, 30 Dec 2024 10:27:00 +0000 (12:27 +0200)
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
tests/topotests/bgp_path_attribute_discard/test_bgp_path_attribute_discard.py
tests/topotests/bgp_path_attribute_treat_as_withdraw/test_bgp_path_attribute_treat_as_withdraw.py

index adc92f59fe4b963d79ef7d310935a04fb9d89d97..c6f1b6193b024eebc5cc9276c519313107e65443 100644 (file)
@@ -142,6 +142,27 @@ def test_bgp_path_attribute_discard():
         result is None
     ), "Failed to discard path attributes (atomic-aggregate, community)"
 
+    def _bgp_check_attributes_discarded_stats():
+        output = json.loads(r1.vtysh_cmd("show bgp neighbor json"))
+        expected = {
+            "10.0.0.254": {
+                "prefixStats": {
+                    "inboundFiltered": 0,
+                    "aspathLoop": 0,
+                    "originatorLoop": 0,
+                    "clusterLoop": 0,
+                    "invalidNextHop": 0,
+                    "withdrawn": 0,
+                    "attributesDiscarded": 3,
+                }
+            }
+        }
+        return topotest.json_cmp(output, expected)
+
+    test_func = functools.partial(_bgp_check_attributes_discarded_stats)
+    _, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
+    assert result is None, "Discarded path attributes count is not as expected"
+
     def _bgp_check_if_aigp_invalid_attribute_discarded():
         output = json.loads(r2.vtysh_cmd("show bgp ipv4 unicast json detail"))
         expected = {
index a9d678a42dd4d540ff63bd8afc9e2505a7ea3272..4f6472f3c55a2ea4fe53f4aae86d6db2ad62122a 100644 (file)
@@ -134,6 +134,27 @@ def test_bgp_path_attribute_treat_as_withdraw():
     _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
     assert result is None, "Failed to withdraw prefixes with atomic-aggregate attribute"
 
+    def _bgp_check_attributes_withdrawn_stats():
+        output = json.loads(r2.vtysh_cmd("show bgp neighbor json"))
+        expected = {
+            "10.0.0.1": {
+                "prefixStats": {
+                    "inboundFiltered": 0,
+                    "aspathLoop": 0,
+                    "originatorLoop": 0,
+                    "clusterLoop": 0,
+                    "invalidNextHop": 0,
+                    "withdrawn": 1,
+                    "attributesDiscarded": 0,
+                }
+            }
+        }
+        return topotest.json_cmp(output, expected)
+
+    test_func = functools.partial(_bgp_check_attributes_withdrawn_stats)
+    _, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
+    assert result is None, "Withdrawn prefix count is not as expected"
+
 
 def test_memory_leak():
     "Run the memory leak test and report results."