Skip to content

Commit

Permalink
topotests: fix bgp_vpnvx_per_nexthop prefix not updated
Browse files Browse the repository at this point in the history
The bgp_vpnvx_table_check() function does not wait that vpnvx prefixes
are present before considering there is an error.
Fix this by adding a syncronisation time, in order to let the incoming
prefixes to be available.

Fixes: ae5a6bc ("topotests: add bgp mpls allocation per next-hop test")
Fixes: 37a02a8 ("topotests: add bgp_vpnv6 test allocation")

Signed-off-by: Philippe Guibert <[email protected]>
  • Loading branch information
pguibert6WIND committed Oct 2, 2023
1 parent 51e8992 commit 451b32e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,16 @@ def teardown_module(_mod):
tgen.stop_topology()


def check_bgp_vpnv4_table_check_once(router, prefix):
"Check the presence of a prefix"
tgen = get_topogen()

dump = router.vtysh_cmd("show bgp ipv4 vpn {} json".format(prefix), isjson=True)
if not dump:
return "{}, prefix ipv4 vpn {} is not installed yet".format(router.name, prefix)
return None


def bgp_vpnv4_table_check(router, group, label_list=None, label_value_expected=None):
"""
Dump and check that vpnv4 entries have the same MPLS label value
Expand All @@ -163,6 +173,12 @@ 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_table_check_once, router, prefix)
success, result = 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
)

dump = router.vtysh_cmd("show bgp ipv4 vpn {} json".format(prefix), isjson=True)
assert dump, "{0}, {1}, route distinguisher not present".format(
router.name, prefix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@ def teardown_module(_mod):
tgen.stop_topology()


def check_bgp_vpnv6_table_check_once(router, prefix):
"Check the presence of a prefix"
tgen = get_topogen()

dump = router.vtysh_cmd("show bgp ipv6 vpn {} json".format(prefix), isjson=True)
if not dump:
return "{}, prefix ipv6 vpn {} is not installed yet".format(router.name, prefix)
return None


def bgp_vpnv6_table_check(router, group, label_list=None, label_value_expected=None):
"""
Dump and check that vpnv6 entries have the same MPLS label value
Expand All @@ -162,6 +172,12 @@ 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_table_check_once, router, prefix)
success, result = 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
)

dump = router.vtysh_cmd("show bgp ipv6 vpn {} json".format(prefix), isjson=True)
for rd, pathes in dump.items():
for path in pathes["paths"]:
Expand Down Expand Up @@ -237,7 +253,9 @@ def check_show_mpls_table(router, blacklist=None, label_list=None, whitelist=Non
label_list.add(in_label)
for nh in label_info["nexthops"]:
if "installed" not in nh.keys():
return "{} {} is not installed yet on {}".format(in_label, label_info, router.name)
return "{} {} is not installed yet on {}".format(
in_label, label_info, router.name
)
if nh["installed"] != True or nh["type"] != "BGP":
return "{}, show mpls table, nexthop is not installed".format(
router.name
Expand Down

0 comments on commit 451b32e

Please sign in to comment.