From 6fb7b3401b21288a949554564243b10161b6a449 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Mon, 30 Dec 2024 12:27:00 +0200 Subject: [PATCH] tests: Check prefix statistics for path-attribute discard/withdraw Signed-off-by: Donatas Abraitis --- .../test_bgp_path_attribute_discard.py | 21 +++++++++++++++++++ ...st_bgp_path_attribute_treat_as_withdraw.py | 21 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/tests/topotests/bgp_path_attribute_discard/test_bgp_path_attribute_discard.py b/tests/topotests/bgp_path_attribute_discard/test_bgp_path_attribute_discard.py index adc92f59fe..c6f1b6193b 100644 --- a/tests/topotests/bgp_path_attribute_discard/test_bgp_path_attribute_discard.py +++ b/tests/topotests/bgp_path_attribute_discard/test_bgp_path_attribute_discard.py @@ -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 = { diff --git a/tests/topotests/bgp_path_attribute_treat_as_withdraw/test_bgp_path_attribute_treat_as_withdraw.py b/tests/topotests/bgp_path_attribute_treat_as_withdraw/test_bgp_path_attribute_treat_as_withdraw.py index a9d678a42d..4f6472f3c5 100644 --- a/tests/topotests/bgp_path_attribute_treat_as_withdraw/test_bgp_path_attribute_treat_as_withdraw.py +++ b/tests/topotests/bgp_path_attribute_treat_as_withdraw/test_bgp_path_attribute_treat_as_withdraw.py @@ -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." -- 2.39.5