Skip to content

Commit

Permalink
Merge pull request #14450 from kuldeepkash/general_fixes
Browse files Browse the repository at this point in the history
tests: Adding BGP convergence verification before starting PIM tests
  • Loading branch information
donaldsharp authored Sep 22, 2023
2 parents 1adbce9 + 8824e30 commit eceb1ca
Show file tree
Hide file tree
Showing 7 changed files with 206 additions and 17 deletions.
30 changes: 19 additions & 11 deletions tests/topotests/lib/bgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,7 @@ def verify_router_id(tgen, topo, input_dict, expected=True):


@retry(retry_timeout=150)
def verify_bgp_convergence(tgen, topo=None, dut=None, expected=True):
def verify_bgp_convergence(tgen, topo=None, dut=None, expected=True, addr_type=None):
"""
API will verify if BGP is converged with in the given time frame.
Running "show bgp summary json" command and verify bgp neighbor
Expand All @@ -1336,6 +1336,7 @@ def verify_bgp_convergence(tgen, topo=None, dut=None, expected=True):
* `tgen`: topogen object
* `topo`: input json file data
* `dut`: device under test
* `addr_type` : address type for which verification to be done, by-default both v4 and v6
Usage
-----
Expand Down Expand Up @@ -1439,20 +1440,27 @@ def verify_bgp_convergence(tgen, topo=None, dut=None, expected=True):
return errormsg
else:
total_peer = 0
for addr_type in bgp_addr_type.keys():
if not check_address_types(addr_type):
for _addr_type in bgp_addr_type.keys():
if not check_address_types(_addr_type):
continue

if addr_type and addr_type != _addr_type:
continue

bgp_neighbors = bgp_addr_type[addr_type]["unicast"]["neighbor"]
bgp_neighbors = bgp_addr_type[_addr_type]["unicast"]["neighbor"]

for bgp_neighbor in bgp_neighbors:
total_peer += len(bgp_neighbors[bgp_neighbor]["dest_link"])

no_of_peer = 0
for addr_type in bgp_addr_type.keys():
for _addr_type in bgp_addr_type.keys():
if not check_address_types(addr_type):
continue
bgp_neighbors = bgp_addr_type[addr_type]["unicast"]["neighbor"]

if addr_type and addr_type != _addr_type:
continue

bgp_neighbors = bgp_addr_type[_addr_type]["unicast"]["neighbor"]

for bgp_neighbor, peer_data in bgp_neighbors.items():
for dest_link in peer_data["dest_link"].keys():
Expand All @@ -1473,7 +1481,7 @@ def verify_bgp_convergence(tgen, topo=None, dut=None, expected=True):
elif "source_link" in peer_details:
neighbor_ip = topo["routers"][bgp_neighbor][
"links"
][peer_details["source_link"]][addr_type].split(
][peer_details["source_link"]][_addr_type].split(
"/"
)[
0
Expand All @@ -1484,12 +1492,12 @@ def verify_bgp_convergence(tgen, topo=None, dut=None, expected=True):
):
neighbor_ip = data[dest_link]["peer-interface"]
else:
neighbor_ip = data[dest_link][addr_type].split("/")[
0
]
neighbor_ip = data[dest_link][_addr_type].split(
"/"
)[0]
nh_state = None
neighbor_ip = neighbor_ip.lower()
if addr_type == "ipv4":
if _addr_type == "ipv4":
ipv4_data = show_bgp_json[vrf]["ipv4Unicast"][
"peers"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
verify_pim_rp_info,
verify_upstream_iif,
)
from lib.bgp import (
verify_bgp_convergence,
)

from lib.topogen import Topogen, get_topogen
from lib.topojson import build_config_from_json
from lib.topolog import logger
Expand Down Expand Up @@ -126,6 +130,13 @@ def setup_module(mod):

# Creating configuration from JSON
build_config_from_json(tgen, topo)

# Verify BGP convergence
BGP_CONVERGENCE = verify_bgp_convergence(tgen, topo, addr_type="ipv6")
assert BGP_CONVERGENCE is True, "setup_module : Failed \n Error:" " {}".format(
BGP_CONVERGENCE
)

# Verify PIM neighbors
result = verify_pim_neighbors(tgen, topo)
assert result is True, " Verify PIM neighbor: Failed Error: {}".format(result)
Expand Down Expand Up @@ -177,6 +188,10 @@ def test_mld_local_joins_p0(request):

reset_config_on_routers(tgen)

# Verify BGP convergence
result = verify_bgp_convergence(tgen, topo, addr_type="ipv6")
assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

step("configure BGP on R1, R2, R3, R4 and enable redistribute static/connected")
step("Enable the MLD on R11 interfac of R1 and configure local mld groups")
intf_r1_i1 = topo["routers"]["r1"]["links"]["i1"]["interface"]
Expand Down Expand Up @@ -249,6 +264,10 @@ def test_mroute_with_mld_local_joins_p0(request):

reset_config_on_routers(tgen)

# Verify BGP convergence
result = verify_bgp_convergence(tgen, topo, addr_type="ipv6")
assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

app_helper.stop_all_hosts()

step("Enable the PIM on all the interfaces of R1, R2, R3, R4")
Expand Down Expand Up @@ -442,6 +461,10 @@ def test_remove_add_mld_local_joins_p1(request):

reset_config_on_routers(tgen)

# Verify BGP convergence
result = verify_bgp_convergence(tgen, topo, addr_type="ipv6")
assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

app_helper.stop_all_hosts()

step("Enable the PIM on all the interfaces of R1, R2, R3, R4")
Expand Down Expand Up @@ -694,6 +717,10 @@ def test_remove_add_mld_config_with_local_joins_p1(request):

reset_config_on_routers(tgen)

# Verify BGP convergence
result = verify_bgp_convergence(tgen, topo, addr_type="ipv6")
assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

app_helper.stop_all_hosts()

step("Enable the PIM on all the interfaces of R1, R2, R3, R4")
Expand Down
37 changes: 37 additions & 0 deletions tests/topotests/multicast_pim6_sm_topo1/test_multicast_pim6_sm1.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
verify_sg_traffic,
verify_upstream_iif,
)
from lib.bgp import (
verify_bgp_convergence,
)
from lib.topogen import Topogen, get_topogen
from lib.topojson import build_config_from_json
from lib.topolog import logger
Expand Down Expand Up @@ -140,6 +143,12 @@ def setup_module(mod):
global app_helper
app_helper = McastTesterHelper(tgen)

# Verify BGP convergence
BGP_CONVERGENCE = verify_bgp_convergence(tgen, topo, addr_type="ipv6")
assert BGP_CONVERGENCE is True, "setup_module : Failed \n Error:" " {}".format(
BGP_CONVERGENCE
)

logger.info("Running setup_module() done")


Expand Down Expand Up @@ -276,6 +285,10 @@ def test_multicast_data_traffic_static_RP_send_traffic_then_join_p0(request):
# Creating configuration from JSON
reset_config_on_routers(tgen)

# Verify BGP convergence
result = verify_bgp_convergence(tgen, topo, addr_type="ipv6")
assert result is True, "Testcase {} : Failed \n Error {}".format(tc_name, result)

app_helper.stop_all_hosts()

# Don"t run this test if we have any failure.
Expand Down Expand Up @@ -480,6 +493,10 @@ def test_verify_mroute_when_receiver_is_outside_frr_p0(request):
# Creating configuration from JSON
reset_config_on_routers(tgen)

# Verify BGP convergence
result = verify_bgp_convergence(tgen, topo, addr_type="ipv6")
assert result is True, "Testcase {} : Failed \n Error {}".format(tc_name, result)

# Don"t run this test if we have any failure.
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
Expand Down Expand Up @@ -648,6 +665,10 @@ def test_verify_mroute_when_frr_is_transit_router_p2(request):
# Creating configuration from JSON
reset_config_on_routers(tgen)

# Verify BGP convergence
result = verify_bgp_convergence(tgen, topo, addr_type="ipv6")
assert result is True, "Testcase {} : Failed \n Error {}".format(tc_name, result)

app_helper.stop_all_hosts()

# Don"t run this test if we have any failure.
Expand Down Expand Up @@ -803,6 +824,10 @@ def test_verify_mroute_when_RP_unreachable_p1(request):
# Creating configuration from JSON
reset_config_on_routers(tgen)

# Verify BGP convergence
result = verify_bgp_convergence(tgen, topo, addr_type="ipv6")
assert result is True, "Testcase {} : Failed \n Error {}".format(tc_name, result)

app_helper.stop_all_hosts()

# Don"t run this test if we have any failure.
Expand Down Expand Up @@ -929,6 +954,10 @@ def test_modify_mld_query_timer_p0(request):
# Creating configuration from JSON
reset_config_on_routers(tgen)

# Verify BGP convergence
result = verify_bgp_convergence(tgen, topo, addr_type="ipv6")
assert result is True, "Testcase {} : Failed \n Error {}".format(tc_name, result)

app_helper.stop_all_hosts()

# Don"t run this test if we have any failure.
Expand Down Expand Up @@ -1108,6 +1137,10 @@ def test_modify_mld_max_query_response_timer_p0(request):
# Creating configuration from JSON
reset_config_on_routers(tgen)

# Verify BGP convergence
result = verify_bgp_convergence(tgen, topo, addr_type="ipv6")
assert result is True, "Testcase {} : Failed \n Error {}".format(tc_name, result)

app_helper.stop_all_hosts()

# Don"t run this test if we have any failure.
Expand Down Expand Up @@ -1377,6 +1410,10 @@ def test_verify_impact_on_multicast_traffic_when_RP_removed_p0(request):
# Creating configuration from JSON
reset_config_on_routers(tgen)

# Verify BGP convergence
result = verify_bgp_convergence(tgen, topo, addr_type="ipv6")
assert result is True, "Testcase {} : Failed \n Error {}".format(tc_name, result)

app_helper.stop_all_hosts()

# Don"t run this test if we have any failure.
Expand Down
17 changes: 17 additions & 0 deletions tests/topotests/multicast_pim6_sm_topo1/test_multicast_pim6_sm2.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
verify_sg_traffic,
verify_upstream_iif,
)
from lib.bgp import (
verify_bgp_convergence,
)
from lib.topogen import Topogen, get_topogen
from lib.topojson import build_config_from_json
from lib.topolog import logger
Expand Down Expand Up @@ -129,6 +132,12 @@ def setup_module(mod):
# Creating configuration from JSON
build_config_from_json(tgen, tgen.json_topo)

# Verify BGP convergence
BGP_CONVERGENCE = verify_bgp_convergence(tgen, topo, addr_type="ipv6")
assert BGP_CONVERGENCE is True, "setup_module : Failed \n Error:" " {}".format(
BGP_CONVERGENCE
)

logger.info("Running setup_module() done")


Expand Down Expand Up @@ -213,6 +222,10 @@ def test_clear_mroute_and_verify_multicast_data_p0(request, app_helper):
# Creating configuration from JSON
reset_config_on_routers(tgen)

# Verify BGP convergence
result = verify_bgp_convergence(tgen, topo, addr_type="ipv6")
assert result is True, "Testcase {} : Failed \n Error {}".format(tc_name, result)

app_helper.stop_all_hosts()

# Don"t run this test if we have any failure.
Expand Down Expand Up @@ -444,6 +457,10 @@ def test_verify_SPT_switchover_when_RPT_and_SPT_path_is_different_p0(
# Creating configuration from JSON
reset_config_on_routers(tgen)

# Verify BGP convergence
result = verify_bgp_convergence(tgen, topo, addr_type="ipv6")
assert result is True, "Testcase {} : Failed \n Error {}".format(tc_name, result)

# Don"t run this test if we have any failure.
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
Expand Down
Loading

0 comments on commit eceb1ca

Please sign in to comment.