From ce3cea38dd624af75a1298dd42ff3ddb7a7d0134 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 26 Jul 2024 14:16:36 -0400 Subject: [PATCH] tests: Run black on bgp_vpnv[4|6]_per_nexthop_label I did not have my formatting right, let's get it right for these two. Signed-off-by: Donald Sharp --- .../test_bgp_vpnv4_per_nexthop_label.py | 28 ++++++++++++++----- .../test_bgp_vpnv6_per_nexthop_label.py | 22 +++++++++++---- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/tests/topotests/bgp_vpnv4_per_nexthop_label/test_bgp_vpnv4_per_nexthop_label.py b/tests/topotests/bgp_vpnv4_per_nexthop_label/test_bgp_vpnv4_per_nexthop_label.py index 8a41b55ffb5a..146687d5881b 100644 --- a/tests/topotests/bgp_vpnv4_per_nexthop_label/test_bgp_vpnv4_per_nexthop_label.py +++ b/tests/topotests/bgp_vpnv4_per_nexthop_label/test_bgp_vpnv4_per_nexthop_label.py @@ -163,12 +163,16 @@ def check_bgp_vpnv4_prefix_presence(router, prefix, table_version): for path in paths["paths"]: new_version = path["version"] if new_version <= table_version: - return "{}, prefix ipv4 vpn {} has not been updated yet".format(router.name, prefix) + return "{}, prefix ipv4 vpn {} has not been updated yet".format( + router.name, prefix + ) return None -def bgp_vpnv4_table_check(router, group, label_list=None, label_value_expected=None, table_version=0): +def bgp_vpnv4_table_check( + router, group, label_list=None, label_value_expected=None, table_version=0 +): """ Dump and check that vpnv4 entries have the same MPLS label value * 'router': the router to check @@ -180,7 +184,9 @@ def bgp_vpnv4_table_check(router, group, label_list=None, label_value_expected=N stored_label_inited = False for prefix in group: - test_func = functools.partial(check_bgp_vpnv4_prefix_presence, router, prefix, table_version) + test_func = functools.partial( + check_bgp_vpnv4_prefix_presence, router, prefix, table_version + ) success, _ = topotest.run_and_expect(test_func, None, count=10, wait=0.5) assert success, "{}, prefix ipv4 vpn {} is not installed yet".format( router.name, prefix @@ -243,7 +249,7 @@ def bgp_vpnv4_table_check_all(router, label_list=None, same=False, table_version + PREFIXES_REDIST + PREFIXES_CONNECTED, label_list=label_list, - table_version=table_version + table_version=table_version, ) else: for group in ( @@ -253,7 +259,9 @@ def bgp_vpnv4_table_check_all(router, label_list=None, same=False, table_version PREFIXES_REDIST, PREFIXES_CONNECTED, ): - bgp_vpnv4_table_check(router, group=group, label_list=label_list, table_version=table_version) + bgp_vpnv4_table_check( + router, group=group, label_list=label_list, table_version=table_version + ) def check_show_mpls_table(router, blacklist=None, label_list=None, whitelist=None): @@ -357,10 +365,12 @@ def check_show_mpls_table_entry_label_not_found(router, inlabel): return "not good" return None + def get_table_version(router): table = router.vtysh_cmd("show bgp ipv4 vpn json", isjson=True) return table["tableVersion"] + def mpls_entry_get_interface(router, label): """ Assert that the label is in MPLS table @@ -765,7 +775,9 @@ def test_unconfigure_allocation_mode_nexthop(): # Check vpnv4 routes from r1 logger.info("Checking vpnv4 routes on r1") label_list = set() - bgp_vpnv4_table_check_all(router, label_list=label_list, same=True, table_version=table_version) + bgp_vpnv4_table_check_all( + router, label_list=label_list, same=True, table_version=table_version + ) assert len(label_list) == 1, "r1, multiple Label values found for vpnv4 updates" new_label = label_list.pop() @@ -815,7 +827,9 @@ def test_reconfigure_allocation_mode_nexthop(): # Check vpnv4 routes from r1 logger.info("Checking vpnv4 routes on r1") label_list = set() - bgp_vpnv4_table_check_all(router, label_list=label_list, table_version=table_version) + bgp_vpnv4_table_check_all( + router, label_list=label_list, table_version=table_version + ) assert len(label_list) != 1, "r1, only 1 label values found for vpnv4 updates" # Check mpls table with all values diff --git a/tests/topotests/bgp_vpnv6_per_nexthop_label/test_bgp_vpnv6_per_nexthop_label.py b/tests/topotests/bgp_vpnv6_per_nexthop_label/test_bgp_vpnv6_per_nexthop_label.py index 8f10b3bc7e22..5fef6e9e6062 100644 --- a/tests/topotests/bgp_vpnv6_per_nexthop_label/test_bgp_vpnv6_per_nexthop_label.py +++ b/tests/topotests/bgp_vpnv6_per_nexthop_label/test_bgp_vpnv6_per_nexthop_label.py @@ -162,12 +162,16 @@ def check_bgp_vpnv6_prefix_presence(router, prefix, table_version): for path in paths["paths"]: new_version = path["version"] if new_version <= table_version: - return "{}, prefix ipv6 vpn {} has not been updated yet".format(router.name, prefix) + return "{}, prefix ipv6 vpn {} has not been updated yet".format( + router.name, prefix + ) return None -def bgp_vpnv6_table_check(router, group, label_list=None, label_value_expected=None, table_version=0): +def bgp_vpnv6_table_check( + router, group, label_list=None, label_value_expected=None, table_version=0 +): """ Dump and check that vpnv6 entries have the same MPLS label value * 'router': the router to check @@ -179,7 +183,9 @@ def bgp_vpnv6_table_check(router, group, label_list=None, label_value_expected=N stored_label_inited = False for prefix in group: - test_func = functools.partial(check_bgp_vpnv6_prefix_presence, router, prefix, table_version) + test_func = functools.partial( + check_bgp_vpnv6_prefix_presence, router, prefix, table_version + ) success, _ = topotest.run_and_expect(test_func, None, count=10, wait=0.5) assert success, "{}, prefix ipv6 vpn {} is not installed yet".format( router.name, prefix @@ -238,7 +244,7 @@ def bgp_vpnv6_table_check_all(router, label_list=None, same=False, table_version + PREFIXES_REDIST_R14 + PREFIXES_CONNECTED, label_list=label_list, - table_version=table_version + table_version=table_version, ) else: for group in ( @@ -247,7 +253,9 @@ def bgp_vpnv6_table_check_all(router, label_list=None, same=False, table_version PREFIXES_REDIST_R14, PREFIXES_CONNECTED, ): - bgp_vpnv6_table_check(router, group=group, label_list=label_list, table_version=table_version) + bgp_vpnv6_table_check( + router, group=group, label_list=label_list, table_version=table_version + ) def check_show_mpls_table(router, blacklist=None, label_list=None, whitelist=None): @@ -819,7 +827,9 @@ def test_reconfigure_allocation_mode_nexthop(): # Check vpnv6 routes from r1 logger.info("Checking VPNv6 routes on r1") label_list = set() - bgp_vpnv6_table_check_all(router, label_list=label_list, table_version=table_version) + bgp_vpnv6_table_check_all( + router, label_list=label_list, table_version=table_version + ) assert len(label_list) != 1, "r1, only 1 label values found for VPNv6 updates" # Check mpls table with all values