mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-09 03:27:39 +00:00
tests: Add global pim join-prune-interval json config option
- cleanup pim configuration code Signed-off-by: Christian Hopps <chopps@labn.net>
This commit is contained in:
parent
e8b7548c0d
commit
0a76e764c8
@ -55,7 +55,7 @@ def create_pim_config(tgen, topo, input_dict=None, build=False, load_config=True
|
|||||||
input_dict = {
|
input_dict = {
|
||||||
"r1": {
|
"r1": {
|
||||||
"pim": {
|
"pim": {
|
||||||
"disable" : ["l1-i1-eth1"],
|
"join-prune-interval": "5",
|
||||||
"rp": [{
|
"rp": [{
|
||||||
"rp_addr" : "1.0.3.17".
|
"rp_addr" : "1.0.3.17".
|
||||||
"keep-alive-timer": "100"
|
"keep-alive-timer": "100"
|
||||||
@ -90,7 +90,7 @@ def create_pim_config(tgen, topo, input_dict=None, build=False, load_config=True
|
|||||||
if "rp" not in input_dict[router]["pim"]:
|
if "rp" not in input_dict[router]["pim"]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
result = _create_pim_config(
|
result = _create_pim_rp_config(
|
||||||
tgen, topo, input_dict, router, build, load_config
|
tgen, topo, input_dict, router, build, load_config
|
||||||
)
|
)
|
||||||
if result is not True:
|
if result is not True:
|
||||||
@ -100,9 +100,9 @@ def create_pim_config(tgen, topo, input_dict=None, build=False, load_config=True
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def _create_pim_config(tgen, topo, input_dict, router, build=False, load_config=False):
|
def _create_pim_rp_config(tgen, topo, input_dict, router, build=False, load_config=False):
|
||||||
"""
|
"""
|
||||||
Helper API to create pim configuration.
|
Helper API to create pim RP configurations.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
@ -119,22 +119,23 @@ def _create_pim_config(tgen, topo, input_dict, router, build=False, load_config=
|
|||||||
|
|
||||||
result = False
|
result = False
|
||||||
logger.debug("Entering lib API: {}".format(sys._getframe().f_code.co_name))
|
logger.debug("Entering lib API: {}".format(sys._getframe().f_code.co_name))
|
||||||
try:
|
|
||||||
|
|
||||||
pim_data = input_dict[router]["pim"]
|
pim_data = input_dict[router]["pim"]
|
||||||
|
|
||||||
for dut in tgen.routers():
|
|
||||||
if "pim" not in input_dict[router]:
|
|
||||||
continue
|
|
||||||
|
|
||||||
for destLink, data in topo[dut]["links"].items():
|
|
||||||
if "pim" not in data:
|
|
||||||
continue
|
|
||||||
|
|
||||||
if "rp" in pim_data:
|
|
||||||
config_data = []
|
|
||||||
rp_data = pim_data["rp"]
|
rp_data = pim_data["rp"]
|
||||||
|
|
||||||
|
# Configure this RP on every router.
|
||||||
|
for dut in tgen.routers():
|
||||||
|
|
||||||
|
# At least one interface must be enabled for PIM on the router
|
||||||
|
pim_if_enabled = False
|
||||||
|
for destLink, data in topo[dut]["links"].items():
|
||||||
|
if "pim" in data:
|
||||||
|
pim_if_enabled = True
|
||||||
|
if not pim_if_enabled:
|
||||||
|
continue
|
||||||
|
|
||||||
|
config_data = []
|
||||||
|
|
||||||
for rp_dict in deepcopy(rp_data):
|
for rp_dict in deepcopy(rp_data):
|
||||||
# ip address of RP
|
# ip address of RP
|
||||||
if "rp_addr" not in rp_dict and build:
|
if "rp_addr" not in rp_dict and build:
|
||||||
@ -169,8 +170,6 @@ def _create_pim_config(tgen, topo, input_dict, router, build=False, load_config=
|
|||||||
|
|
||||||
if keep_alive_timer:
|
if keep_alive_timer:
|
||||||
cmd = "ip pim rp keep-alive-timer {}".format(keep_alive_timer)
|
cmd = "ip pim rp keep-alive-timer {}".format(keep_alive_timer)
|
||||||
config_data.append(cmd)
|
|
||||||
|
|
||||||
if del_action:
|
if del_action:
|
||||||
cmd = "no {}".format(cmd)
|
cmd = "no {}".format(cmd)
|
||||||
config_data.append(cmd)
|
config_data.append(cmd)
|
||||||
@ -182,8 +181,6 @@ def _create_pim_config(tgen, topo, input_dict, router, build=False, load_config=
|
|||||||
|
|
||||||
for grp_addr in group_addr_range:
|
for grp_addr in group_addr_range:
|
||||||
cmd = "ip pim rp {} {}".format(rp_addr, grp_addr)
|
cmd = "ip pim rp {} {}".format(rp_addr, grp_addr)
|
||||||
config_data.append(cmd)
|
|
||||||
|
|
||||||
if del_action:
|
if del_action:
|
||||||
cmd = "no {}".format(cmd)
|
cmd = "no {}".format(cmd)
|
||||||
config_data.append(cmd)
|
config_data.append(cmd)
|
||||||
@ -192,23 +189,23 @@ def _create_pim_config(tgen, topo, input_dict, router, build=False, load_config=
|
|||||||
cmd = "ip pim rp {} prefix-list {}".format(
|
cmd = "ip pim rp {} prefix-list {}".format(
|
||||||
rp_addr, prefix_list
|
rp_addr, prefix_list
|
||||||
)
|
)
|
||||||
config_data.append(cmd)
|
|
||||||
|
|
||||||
if del_action:
|
if del_action:
|
||||||
cmd = "no {}".format(cmd)
|
cmd = "no {}".format(cmd)
|
||||||
config_data.append(cmd)
|
config_data.append(cmd)
|
||||||
|
|
||||||
|
try:
|
||||||
result = create_common_configuration(
|
result = create_common_configuration(
|
||||||
tgen, dut, config_data, "pim", build, load_config
|
tgen, dut, config_data, "pim", build, load_config
|
||||||
)
|
)
|
||||||
if result is not True:
|
if result is not True:
|
||||||
|
logger.error("Error applying PIM config", exc_info=True)
|
||||||
|
logger.debug("Exiting lib API: {}".format(sys._getframe().f_code.co_name))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
except InvalidCLIError:
|
except InvalidCLIError as error:
|
||||||
# Traceback
|
logger.error("Error applying PIM config: %s", error, exc_info=error)
|
||||||
errormsg = traceback.format_exc()
|
logger.debug("Exiting lib API: {}".format(sys._getframe().f_code.co_name))
|
||||||
logger.error(errormsg)
|
return False
|
||||||
return errormsg
|
|
||||||
|
|
||||||
logger.debug("Exiting lib API: {}".format(sys._getframe().f_code.co_name))
|
logger.debug("Exiting lib API: {}".format(sys._getframe().f_code.co_name))
|
||||||
return result
|
return result
|
||||||
@ -338,23 +335,7 @@ def _enable_disable_pim(tgen, topo, input_dict, router, build=False):
|
|||||||
try:
|
try:
|
||||||
config_data = []
|
config_data = []
|
||||||
|
|
||||||
enable_flag = True
|
# Enable pim on interfaces
|
||||||
# Disable pim on interface
|
|
||||||
if "pim" in input_dict[router]:
|
|
||||||
if "disable" in input_dict[router]["pim"]:
|
|
||||||
enable_flag = False
|
|
||||||
interfaces = input_dict[router]["pim"]["disable"]
|
|
||||||
|
|
||||||
if type(interfaces) is not list:
|
|
||||||
interfaces = [interfaces]
|
|
||||||
|
|
||||||
for interface in interfaces:
|
|
||||||
cmd = "interface {}".format(interface)
|
|
||||||
config_data.append(cmd)
|
|
||||||
config_data.append("no ip pim")
|
|
||||||
|
|
||||||
# Enable pim on interface
|
|
||||||
if enable_flag:
|
|
||||||
for destRouterLink, data in sorted(topo[router]["links"].items()):
|
for destRouterLink, data in sorted(topo[router]["links"].items()):
|
||||||
if "pim" in data and data["pim"] == "enable":
|
if "pim" in data and data["pim"] == "enable":
|
||||||
|
|
||||||
@ -374,6 +355,22 @@ def _enable_disable_pim(tgen, topo, input_dict, router, build=False):
|
|||||||
if result is not True:
|
if result is not True:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
config_data = []
|
||||||
|
if "pim" in input_dict[router]:
|
||||||
|
pim_data = input_dict[router]["pim"]
|
||||||
|
for t in [
|
||||||
|
"join-prune-interval",
|
||||||
|
"keep-alive-timer",
|
||||||
|
"register-suppress-time",
|
||||||
|
]:
|
||||||
|
if t in pim_data:
|
||||||
|
cmd = "ip pim {} {}".format(t, pim_data[t])
|
||||||
|
config_data.append(cmd)
|
||||||
|
|
||||||
|
if config_data:
|
||||||
|
result = create_common_configuration(
|
||||||
|
tgen, router, config_data, "pim", build=build
|
||||||
|
)
|
||||||
except InvalidCLIError:
|
except InvalidCLIError:
|
||||||
# Traceback
|
# Traceback
|
||||||
errormsg = traceback.format_exc()
|
errormsg = traceback.format_exc()
|
||||||
|
@ -78,6 +78,7 @@ from lib.common_config import (
|
|||||||
step,
|
step,
|
||||||
iperfSendIGMPJoin,
|
iperfSendIGMPJoin,
|
||||||
addKernelRoute,
|
addKernelRoute,
|
||||||
|
apply_raw_config,
|
||||||
reset_config_on_routers,
|
reset_config_on_routers,
|
||||||
iperfSendTraffic,
|
iperfSendTraffic,
|
||||||
kill_iperf,
|
kill_iperf,
|
||||||
@ -1553,8 +1554,10 @@ def test_modify_igmp_max_query_response_timer_p0(request):
|
|||||||
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
|
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
|
||||||
|
|
||||||
step("Delete the PIM and IGMP on FRR1")
|
step("Delete the PIM and IGMP on FRR1")
|
||||||
input_dict_1 = {"l1": {"pim": {"disable": ["l1-i1-eth1"]}}}
|
raw_config = {
|
||||||
result = create_pim_config(tgen, topo, input_dict_1)
|
"l1": {"raw_config": ["interface l1-i1-eth1", "no ip pim"]}
|
||||||
|
}
|
||||||
|
result = apply_raw_config(tgen, raw_config)
|
||||||
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
|
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
|
||||||
|
|
||||||
input_dict_2 = {
|
input_dict_2 = {
|
||||||
|
@ -2231,8 +2231,10 @@ def test_verify_remove_add_pim_commands_when_igmp_configured_p1(request):
|
|||||||
step("Remove 'no ip pim' on receiver interface on FRR1")
|
step("Remove 'no ip pim' on receiver interface on FRR1")
|
||||||
|
|
||||||
intf_l1_i1 = topo["routers"]["l1"]["links"]["i1"]["interface"]
|
intf_l1_i1 = topo["routers"]["l1"]["links"]["i1"]["interface"]
|
||||||
input_dict_1 = {"l1": {"pim": {"disable": intf_l1_i1}}}
|
raw_config = {
|
||||||
result = create_pim_config(tgen, topo, input_dict_1)
|
"l1": {"raw_config": ["interface {}".format(intf_l1_i1), "no ip pim"]}
|
||||||
|
}
|
||||||
|
result = apply_raw_config(tgen, raw_config)
|
||||||
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
|
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
|
||||||
|
|
||||||
step("Verify that no core is observed")
|
step("Verify that no core is observed")
|
||||||
|
Loading…
Reference in New Issue
Block a user