tests: Check prefix statistics for path-attribute discard/withdraw

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
This commit is contained in:
Donatas Abraitis 2024-12-30 12:27:00 +02:00
parent 28e62b46ba
commit 6fb7b3401b
2 changed files with 42 additions and 0 deletions

View 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 = {

View 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."