Commit ead6d65a01 for frr
commit ead6d65a01be213ef9626cddbdca12a58a212974
Author: Carmine Scarpitta <cscarpit@cisco.com>
Date: Fri Oct 30 21:31:15 2026 +0100
tests: Apply black formatting
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
diff --git a/tests/topotests/bgp_link_state/test_bgp_link_state.py b/tests/topotests/bgp_link_state/test_bgp_link_state.py
index 8382594312..9a413ec7d6 100644
--- a/tests/topotests/bgp_link_state/test_bgp_link_state.py
+++ b/tests/topotests/bgp_link_state/test_bgp_link_state.py
@@ -57,6 +57,7 @@ pytestmark = [pytest.mark.bgpd, pytest.mark.isisd]
# Helper functions for BGP-LS validation
#
+
def extract_bgp_ls_routes(json_data):
"""
Extract routes from BGP-LS JSON output.
@@ -437,6 +438,7 @@ def test_bgp_ls_routes_consumer():
assertmsg = '"rr" BGP-LS routes not received correctly'
assert result is None, assertmsg
+
def test_bgp_ls_attributes_consumer():
tgen = get_topogen()
@@ -506,18 +508,26 @@ def test_bgp_ls_static_route_add():
# Verify route count increased by 1
new_count_r2 = get_bgp_ls_count(r2)
- assert new_count_r2 == initial_count_r2 + 1, f'"r2" route count should be {initial_count_r2 + 1}, got {new_count_r2}'
+ assert (
+ new_count_r2 == initial_count_r2 + 1
+ ), f'"r2" route count should be {initial_count_r2 + 1}, got {new_count_r2}'
# Verify consumer rr received the update
test_func = functools.partial(
- check_bgp_ls_prefix, consumer, "192.168.100.0/24", protocol_id=2, should_exist=True
+ check_bgp_ls_prefix,
+ consumer,
+ "192.168.100.0/24",
+ protocol_id=2,
+ should_exist=True,
)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assert result is None, '"rr" did not receive BGP-LS static route update'
# Verify route count increased by 1
new_count_rr = get_bgp_ls_count(consumer)
- assert new_count_rr == initial_count_rr + 1, f'"rr" route count should be {initial_count_rr + 1}, got {new_count_rr}'
+ assert (
+ new_count_rr == initial_count_rr + 1
+ ), f'"rr" route count should be {initial_count_rr + 1}, got {new_count_rr}'
def test_bgp_ls_static_route_remove():
@@ -550,18 +560,26 @@ def test_bgp_ls_static_route_remove():
# Verify route count decreased by 1
new_count_r2 = get_bgp_ls_count(r2)
- assert new_count_r2 == initial_count_r2 - 1, f'"r2" route count should be {initial_count_r2 - 1}, got {new_count_r2}'
+ assert (
+ new_count_r2 == initial_count_r2 - 1
+ ), f'"r2" route count should be {initial_count_r2 - 1}, got {new_count_r2}'
# Verify consumer rr received the withdrawal
test_func = functools.partial(
- check_bgp_ls_prefix, consumer, "192.168.100.0/24", protocol_id=2, should_exist=False
+ check_bgp_ls_prefix,
+ consumer,
+ "192.168.100.0/24",
+ protocol_id=2,
+ should_exist=False,
)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assert result is None, '"rr" did not receive BGP-LS static route withdrawal'
# Verify route count decreased by 1
new_count_rr = get_bgp_ls_count(consumer)
- assert new_count_rr == initial_count_rr - 1, f'"rr" route count should be {initial_count_rr - 1}, got {new_count_rr}'
+ assert (
+ new_count_rr == initial_count_rr - 1
+ ), f'"rr" route count should be {initial_count_rr - 1}, got {new_count_rr}'
# Verify r2 routes match original reference file
reffile = os.path.join(CWD, "r2/bgp_ls_nlri.json")
@@ -573,7 +591,9 @@ def test_bgp_ls_static_route_remove():
expected,
)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
- assert result is None, '"r2" BGP-LS routes do not match expected after route removal'
+ assert (
+ result is None
+ ), '"r2" BGP-LS routes do not match expected after route removal'
# Verify rr routes match original reference file
reffile = os.path.join(CWD, "rr/bgp_ls_nlri.json")
@@ -585,7 +605,9 @@ def test_bgp_ls_static_route_remove():
expected,
)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
- assert result is None, '"rr" BGP-LS routes do not match expected after route removal'
+ assert (
+ result is None
+ ), '"rr" BGP-LS routes do not match expected after route removal'
def test_bgp_ls_interface_address_add():
@@ -618,7 +640,9 @@ def test_bgp_ls_interface_address_add():
# Verify route count increased by 1
new_count_r2 = get_bgp_ls_count(r2)
- assert new_count_r2 == initial_count_r2 + 1, f'"r2" route count should be {initial_count_r2 + 1}, got {new_count_r2}'
+ assert (
+ new_count_r2 == initial_count_r2 + 1
+ ), f'"r2" route count should be {initial_count_r2 + 1}, got {new_count_r2}'
# Verify consumer rr received the update
test_func = functools.partial(
@@ -629,7 +653,9 @@ def test_bgp_ls_interface_address_add():
# Verify route count increased by 1
new_count_rr = get_bgp_ls_count(consumer)
- assert new_count_rr == initial_count_rr + 1, f'"rr" route count should be {initial_count_rr + 1}, got {new_count_rr}'
+ assert (
+ new_count_rr == initial_count_rr + 1
+ ), f'"rr" route count should be {initial_count_rr + 1}, got {new_count_rr}'
def test_bgp_ls_interface_address_remove():
@@ -662,7 +688,9 @@ def test_bgp_ls_interface_address_remove():
# Verify route count decreased by 1
new_count_r2 = get_bgp_ls_count(r2)
- assert new_count_r2 == initial_count_r2 - 1, f'"r2" route count should be {initial_count_r2 - 1}, got {new_count_r2}'
+ assert (
+ new_count_r2 == initial_count_r2 - 1
+ ), f'"r2" route count should be {initial_count_r2 - 1}, got {new_count_r2}'
# Verify consumer rr received the withdrawal
test_func = functools.partial(
@@ -673,7 +701,9 @@ def test_bgp_ls_interface_address_remove():
# Verify route count decreased by 1
new_count_rr = get_bgp_ls_count(consumer)
- assert new_count_rr == initial_count_rr - 1, f'"rr" route count should be {initial_count_rr - 1}, got {new_count_rr}'
+ assert (
+ new_count_rr == initial_count_rr - 1
+ ), f'"rr" route count should be {initial_count_rr - 1}, got {new_count_rr}'
# Verify routes match original reference files
reffile = os.path.join(CWD, "r2/bgp_ls_nlri.json")
@@ -742,7 +772,9 @@ def test_bgp_ls_ipv6_address_remove():
router = tgen.gears["r1"]
# Remove secondary IPv6 address from r1
- router.vtysh_cmd("configure terminal\ninterface lo\nno ipv6 address fc00:0:1::11/128")
+ router.vtysh_cmd(
+ "configure terminal\ninterface lo\nno ipv6 address fc00:0:1::11/128"
+ )
# Wait for ISIS to propagate to r2, then BGP-LS to withdraw the prefix
r2 = tgen.gears["r2"]
@@ -758,7 +790,9 @@ def test_bgp_ls_ipv6_address_remove():
check_bgp_ls_prefix, consumer, "fc00:0:1::11/128", should_exist=False
)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
- assert result is None, '"rr" did not receive BGP-LS IPv6 secondary address withdrawal'
+ assert (
+ result is None
+ ), '"rr" did not receive BGP-LS IPv6 secondary address withdrawal'
def test_bgp_ls_ipv6_static_route_add():
@@ -817,7 +851,11 @@ def test_bgp_ls_ipv6_static_route_remove():
# Verify consumer rr received the withdrawal
consumer = tgen.gears["rr"]
test_func = functools.partial(
- check_bgp_ls_prefix, consumer, "fc00:100::/64", protocol_id=2, should_exist=False
+ check_bgp_ls_prefix,
+ consumer,
+ "fc00:100::/64",
+ protocol_id=2,
+ should_exist=False,
)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assert result is None, '"rr" did not receive BGP-LS static IPv6 route withdrawal'
@@ -840,7 +878,11 @@ def test_bgp_ls_r4_link_shutdown():
# Wait for ISIS to detect the link down and propagate to r2, then BGP-LS to withdraw link NLRI
r2 = tgen.gears["r2"]
test_func = functools.partial(
- check_bgp_ls_link, r2, "0000.0000.0004.00", "0000.0000.0001.00", should_exist=False
+ check_bgp_ls_link,
+ r2,
+ "0000.0000.0004.00",
+ "0000.0000.0001.00",
+ should_exist=False,
)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assert result is None, '"r2" BGP-LS r4 link down not reflected'
@@ -848,7 +890,11 @@ def test_bgp_ls_r4_link_shutdown():
# Verify consumer rr received the update
consumer = tgen.gears["rr"]
test_func = functools.partial(
- check_bgp_ls_link, consumer, "0000.0000.0004.00", "0000.0000.0001.00", should_exist=False
+ check_bgp_ls_link,
+ consumer,
+ "0000.0000.0004.00",
+ "0000.0000.0001.00",
+ should_exist=False,
)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assert result is None, '"rr" did not receive BGP-LS r4 link down update'
@@ -871,7 +917,11 @@ def test_bgp_ls_r4_link_no_shutdown():
# Wait for ISIS adjacency to re-establish and propagate to r2, then BGP-LS to advertise link NLRI
r2 = tgen.gears["r2"]
test_func = functools.partial(
- check_bgp_ls_link, r2, "0000.0000.0004.00", "0000.0000.0001.00", should_exist=True
+ check_bgp_ls_link,
+ r2,
+ "0000.0000.0004.00",
+ "0000.0000.0001.00",
+ should_exist=True,
)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assert result is None, '"r2" BGP-LS r4 link up not reflected'
@@ -879,7 +929,11 @@ def test_bgp_ls_r4_link_no_shutdown():
# Verify consumer rr received the update
consumer = tgen.gears["rr"]
test_func = functools.partial(
- check_bgp_ls_link, consumer, "0000.0000.0004.00", "0000.0000.0001.00", should_exist=True
+ check_bgp_ls_link,
+ consumer,
+ "0000.0000.0004.00",
+ "0000.0000.0001.00",
+ should_exist=True,
)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assert result is None, '"rr" did not receive BGP-LS r4 link up update'
@@ -960,7 +1014,9 @@ def test_bgp_ls_peer_reactivate():
expected,
)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
- assert result is None, '"r2" did not re-originate BGP-LS routes after peer reactivation'
+ assert (
+ result is None
+ ), '"r2" did not re-originate BGP-LS routes after peer reactivation'
# rr (consumer) must receive all BGP-LS routes again
consumer = tgen.gears["rr"]
@@ -973,7 +1029,9 @@ def test_bgp_ls_peer_reactivate():
expected,
)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
- assert result is None, '"rr" did not receive BGP-LS routes after r2 peer reactivation'
+ assert (
+ result is None
+ ), '"rr" did not receive BGP-LS routes after r2 peer reactivation'
def test_bgp_ls_sync_on_isis_producer_registration():
@@ -983,9 +1041,7 @@ def test_bgp_ls_sync_on_isis_producer_registration():
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
- logger.info(
- "Checking BGP-LS TED sync when IS-IS MPLS-TE export is enabled late"
- )
+ logger.info("Checking BGP-LS TED sync when IS-IS MPLS-TE export is enabled late")
r2 = tgen.gears["r2"]
consumer = tgen.gears["rr"]
@@ -999,15 +1055,15 @@ def test_bgp_ls_sync_on_isis_producer_registration():
)
test_func = functools.partial(check_bgp_ls_empty, r2)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
- assert result is None, (
- '"r2" BGP-LS routes not cleared before producer notification test'
- )
+ assert (
+ result is None
+ ), '"r2" BGP-LS routes not cleared before producer notification test'
test_func = functools.partial(check_bgp_ls_empty, consumer)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
- assert result is None, (
- '"rr" BGP-LS routes not cleared before producer notification test'
- )
+ assert (
+ result is None
+ ), '"rr" BGP-LS routes not cleared before producer notification test'
# Reactivate the consumer while the IS-IS producer is unavailable. BGP
# should request a sync when Zebra notifies it that IS-IS registers later.
@@ -1031,11 +1087,7 @@ def test_bgp_ls_sync_on_isis_producer_registration():
_, result = topotest.run_and_expect(test_func, None, count=5, wait=1)
assert result is None, '"r2" received TED data before IS-IS export was enabled'
- r2.vtysh_cmd(
- "configure terminal\n"
- "router isis 1\n"
- "mpls-te export"
- )
+ r2.vtysh_cmd("configure terminal\n" "router isis 1\n" "mpls-te export")
# The producer-registration notification must trigger a sync of the full
# pre-existing IS-IS TED, not just later changes to it.
@@ -1048,9 +1100,9 @@ def test_bgp_ls_sync_on_isis_producer_registration():
expected,
)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
- assert result is None, (
- '"r2" did not receive the full IS-IS TED after export was enabled'
- )
+ assert (
+ result is None
+ ), '"r2" did not receive the full IS-IS TED after export was enabled'
reffile = os.path.join(CWD, "rr/bgp_ls_nlri.json")
expected = json.loads(open(reffile).read())
@@ -1061,9 +1113,9 @@ def test_bgp_ls_sync_on_isis_producer_registration():
expected,
)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
- assert result is None, (
- '"rr" did not receive the full IS-IS TED after export was enabled'
- )
+ assert (
+ result is None
+ ), '"rr" did not receive the full IS-IS TED after export was enabled'
def test_memory_leak():