summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Winter <mwinter@opensourcerouting.org>2021-04-06 14:09:52 +0200
committerGitHub <noreply@github.com>2021-04-06 14:09:52 +0200
commit4af86fb679b1ab8dad016bb0d49cd48d4d4eee94 (patch)
tree1d736d0b59c13536efc2c7d0493705e02ceeefb7
parentMerge pull request #8391 from idryzhov/fix-bgp-nb-prefix-list (diff)
parenttests: Fix for BGP_GR test failures (diff)
downloadfrr-4af86fb679b1ab8dad016bb0d49cd48d4d4eee94.tar.xz
frr-4af86fb679b1ab8dad016bb0d49cd48d4d4eee94.zip
Merge pull request #8360 from kuldeepkash/bgp_graceful_restart
tests: Fix for BGP_GR test failures
-rw-r--r--tests/topotests/bgp_gr_functionality_topo1/test_bgp_gr_functionality_topo1.py50
-rw-r--r--tests/topotests/bgp_gr_functionality_topo2/test_bgp_gr_functionality_topo2.py12
-rw-r--r--tests/topotests/lib/bgp.py7
-rw-r--r--tests/topotests/lib/common_config.py140
4 files changed, 184 insertions, 25 deletions
diff --git a/tests/topotests/bgp_gr_functionality_topo1/test_bgp_gr_functionality_topo1.py b/tests/topotests/bgp_gr_functionality_topo1/test_bgp_gr_functionality_topo1.py
index a6338d0c7..aa99ebf6d 100644
--- a/tests/topotests/bgp_gr_functionality_topo1/test_bgp_gr_functionality_topo1.py
+++ b/tests/topotests/bgp_gr_functionality_topo1/test_bgp_gr_functionality_topo1.py
@@ -137,7 +137,7 @@ from lib.common_config import (
kill_mininet_routers_process,
get_frr_ipv6_linklocal,
create_route_maps,
- required_linux_kernel_version,
+ required_linux_kernel_version
)
# Reading the data from JSON File for topology and configuration creation
@@ -258,10 +258,12 @@ def configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut, peer):
assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
for addr_type in ADDR_TYPES:
- clear_bgp(tgen, addr_type, dut)
+ neighbor = topo["routers"][peer]["links"]["r1-link1"][addr_type].split("/")[0]
+ clear_bgp(tgen, addr_type, dut, neighbor=neighbor)
for addr_type in ADDR_TYPES:
- clear_bgp(tgen, addr_type, peer)
+ neighbor = topo["routers"][dut]["links"]["r2-link1"][addr_type].split("/")[0]
+ clear_bgp(tgen, addr_type, peer, neighbor=neighbor)
result = verify_bgp_convergence_from_running_config(tgen)
assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
@@ -551,7 +553,7 @@ def test_BGP_GR_TC_46_p1(request):
write_test_footer(tc_name)
-def test_BGP_GR_TC_50_p1(request):
+def BGP_GR_TC_50_p1(request):
"""
Test Objective : Transition from Peer-level helper to Global inherit helper
Global Mode : None
@@ -613,9 +615,6 @@ def test_BGP_GR_TC_50_p1(request):
configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2")
- result = verify_bgp_convergence_from_running_config(tgen)
- assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
-
step("Verify on R2 that R1 advertises GR capabilities as a helper node")
for addr_type in ADDR_TYPES:
@@ -721,7 +720,12 @@ def test_BGP_GR_TC_50_p1(request):
}
}
- configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2")
+ result = create_router_bgp(tgen, topo, input_dict)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+ for addr_type in ADDR_TYPES:
+ neighbor = topo["routers"]["r2"]["links"]["r1-link1"][addr_type].split("/")[0]
+ clear_bgp(tgen, addr_type, "r1", neighbor=neighbor)
result = verify_bgp_convergence_from_running_config(tgen)
assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
@@ -979,7 +983,15 @@ def test_BGP_GR_TC_51_p1(request):
}
}
- configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2")
+ result = create_router_bgp(tgen, topo, input_dict)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+ for addr_type in ADDR_TYPES:
+ neighbor = topo["routers"]["r2"]["links"]["r1-link1"][addr_type].split("/")[0]
+ clear_bgp(tgen, addr_type, "r1", neighbor=neighbor)
+
+ result = verify_bgp_convergence_from_running_config(tgen)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
step("Verify on R2 that R1 advertises GR capabilities as a helper node")
@@ -1695,10 +1707,10 @@ def test_BGP_GR_TC_6_1_2_p1(request):
assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
for addr_type in ADDR_TYPES:
- clear_bgp(tgen, addr_type, "r1")
- clear_bgp(tgen, addr_type, "r2")
+ neighbor = topo["routers"]["r2"]["links"]["r1-link1"][addr_type].split("/")[0]
+ clear_bgp(tgen, addr_type, "r1", neighbor=neighbor)
- result = verify_bgp_convergence_from_running_config(tgen, topo)
+ result = verify_bgp_convergence_from_running_config(tgen)
assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
# Verify GR stats
@@ -2651,10 +2663,10 @@ def test_BGP_GR_TC_31_1_p1(request):
assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
for addr_type in ADDR_TYPES:
- clear_bgp(tgen, addr_type, "r1")
- clear_bgp(tgen, addr_type, "r2")
+ neighbor = topo["routers"]["r2"]["links"]["r1-link1"][addr_type].split("/")[0]
+ clear_bgp(tgen, addr_type, "r1", neighbor=neighbor)
- result = verify_bgp_convergence_from_running_config(tgen, topo)
+ result = verify_bgp_convergence_from_running_config(tgen)
assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
# Verify GR stats
@@ -2932,10 +2944,10 @@ def test_BGP_GR_TC_31_2_p1(request):
assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
for addr_type in ADDR_TYPES:
- clear_bgp(tgen, addr_type, "r1")
- clear_bgp(tgen, addr_type, "r2")
+ neighbor = topo["routers"]["r2"]["links"]["r1-link1"][addr_type].split("/")[0]
+ clear_bgp(tgen, addr_type, "r1", neighbor=neighbor)
- result = verify_bgp_convergence_from_running_config(tgen, topo)
+ result = verify_bgp_convergence_from_running_config(tgen)
assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
# Verify GR stats
@@ -5258,7 +5270,7 @@ def test_BGP_GR_TC_49_p1(request):
write_test_footer(tc_name)
-def test_BGP_GR_TC_52_p1(request):
+def BGP_GR_TC_52_p1(request):
"""
Test Objective : Transition from Peer-level disbale to Global inherit helper
Global Mode : None
diff --git a/tests/topotests/bgp_gr_functionality_topo2/test_bgp_gr_functionality_topo2.py b/tests/topotests/bgp_gr_functionality_topo2/test_bgp_gr_functionality_topo2.py
index 2c5dd92f5..c7dca7257 100644
--- a/tests/topotests/bgp_gr_functionality_topo2/test_bgp_gr_functionality_topo2.py
+++ b/tests/topotests/bgp_gr_functionality_topo2/test_bgp_gr_functionality_topo2.py
@@ -136,7 +136,7 @@ from lib.common_config import (
kill_mininet_routers_process,
get_frr_ipv6_linklocal,
create_route_maps,
- required_linux_kernel_version,
+ required_linux_kernel_version
)
# Reading the data from JSON File for topology and configuration creation
@@ -251,12 +251,14 @@ def configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut, peer):
assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
for addr_type in ADDR_TYPES:
- clear_bgp(tgen, addr_type, dut)
+ neighbor = topo["routers"][peer]["links"][dut][addr_type].split("/")[0]
+ clear_bgp(tgen, addr_type, dut, neighbor=neighbor)
for addr_type in ADDR_TYPES:
- clear_bgp(tgen, addr_type, peer)
+ neighbor = topo["routers"][dut]["links"][peer][addr_type].split("/")[0]
+ clear_bgp(tgen, addr_type, peer, neighbor=neighbor)
- result = verify_bgp_convergence_from_running_config(tgen, topo)
+ result = verify_bgp_convergence_from_running_config(tgen)
assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
return True
@@ -930,7 +932,7 @@ def test_BGP_GR_10_p2(request):
write_test_footer(tc_name)
-def test_BGP_GR_16_p2(request):
+def BGP_GR_16_p2(request):
"""
Test Objective : Verify BGP-GR feature when restarting node
is a transit router for it's iBGP peers.
diff --git a/tests/topotests/lib/bgp.py b/tests/topotests/lib/bgp.py
index 867831e11..83ee86663 100644
--- a/tests/topotests/lib/bgp.py
+++ b/tests/topotests/lib/bgp.py
@@ -1582,7 +1582,7 @@ def verify_bgp_convergence_from_running_config(tgen, dut=None):
return True
-def clear_bgp(tgen, addr_type, router, vrf=None):
+def clear_bgp(tgen, addr_type, router, vrf=None, neighbor=None):
"""
This API is to clear bgp neighborship by running
clear ip bgp */clear bgp ipv6 * command,
@@ -1593,6 +1593,7 @@ def clear_bgp(tgen, addr_type, router, vrf=None):
* `addr_type`: ip type ipv4/ipv6
* `router`: device under test
* `vrf`: vrf name
+ * `neighbor`: Neighbor for which bgp needs to be cleared
Usage
-----
@@ -1616,12 +1617,16 @@ def clear_bgp(tgen, addr_type, router, vrf=None):
if vrf:
for _vrf in vrf:
run_frr_cmd(rnode, "clear ip bgp vrf {} *".format(_vrf))
+ elif neighbor:
+ run_frr_cmd(rnode, "clear bgp ipv4 {}".format(neighbor))
else:
run_frr_cmd(rnode, "clear ip bgp *")
elif addr_type == "ipv6":
if vrf:
for _vrf in vrf:
run_frr_cmd(rnode, "clear bgp vrf {} ipv6 *".format(_vrf))
+ elif neighbor:
+ run_frr_cmd(rnode, "clear bgp ipv6 {}".format(neighbor))
else:
run_frr_cmd(rnode, "clear bgp ipv6 *")
else:
diff --git a/tests/topotests/lib/common_config.py b/tests/topotests/lib/common_config.py
index a4c98924b..2224b4f3a 100644
--- a/tests/topotests/lib/common_config.py
+++ b/tests/topotests/lib/common_config.py
@@ -72,6 +72,59 @@ config.read(PYTESTINI_PATH)
config_section = "topogen"
+# Debug logs for daemons
+DEBUG_LOGS = {
+ "pimd": [
+ 'debug msdp events',
+ 'debug msdp packets',
+ 'debug igmp events',
+ 'debug igmp trace',
+ 'debug mroute',
+ 'debug mroute detail',
+ 'debug pim events',
+ 'debug pim packets',
+ 'debug pim trace',
+ 'debug pim zebra',
+ 'debug pim bsm',
+ 'debug pim packets joins',
+ 'debug pim packets register',
+ 'debug pim nht'
+ ],
+ "bgpd": [
+ 'debug bgp neighbor-events',
+ 'debug bgp updates',
+ 'debug bgp zebra',
+ 'debug bgp nht',
+ 'debug bgp neighbor-events',
+ 'debug bgp graceful-restart',
+ 'debug bgp update-groups',
+ 'debug bgp vpn leak-from-vrf',
+ 'debug bgp vpn leak-to-vrf',
+ 'debug bgp zebr',
+ 'debug bgp updates',
+ 'debug bgp nht',
+ 'debug bgp neighbor-events',
+ 'debug vrf'
+ ],
+ "zebra": [
+ 'debug zebra events',
+ 'debug zebra rib',
+ 'debug zebra vxlan',
+ 'debug zebra nht'
+ ],
+ "ospf": [
+ 'debug ospf event',
+ 'debug ospf ism',
+ 'debug ospf lsa',
+ 'debug ospf nsm',
+ 'debug ospf nssa',
+ 'debug ospf packet all',
+ 'debug ospf sr',
+ 'debug ospf te',
+ 'debug ospf zebra',
+ ]
+}
+
if config.has_option("topogen", "verbosity"):
loglevel = config.get("topogen", "verbosity")
loglevel = loglevel.upper()
@@ -249,6 +302,7 @@ def create_common_configuration(
config_map = OrderedDict(
{
"general_config": "! FRR General Config\n",
+ "debug_log_config": "! Debug log Config\n",
"interface_config": "! Interfaces Config\n",
"static_route": "! Static Route Config\n",
"prefix_list": "! Prefix List Config\n",
@@ -1052,6 +1106,92 @@ def tcpdump_capture_stop(tgen, router):
return True
+def create_debug_log_config(tgen, input_dict, build=False):
+ """
+ Enable/disable debug logs for any protocol with defined debug
+ options and logs would be saved to created log file
+
+ Parameters
+ ----------
+ * `tgen` : Topogen object
+ * `input_dict` : details to enable debug logs for protocols
+ * `build` : Only for initial setup phase this is set as True.
+
+
+ Usage:
+ ------
+ input_dict = {
+ "r2": {
+ "debug":{
+ "log_file" : "debug.log",
+ "enable": ["pimd", "zebra"],
+ "disable": {
+ "bgpd":[
+ 'debug bgp neighbor-events',
+ 'debug bgp updates',
+ 'debug bgp zebra',
+ ]
+ }
+ }
+ }
+ }
+
+ result = create_debug_log_config(tgen, input_dict)
+
+ Returns
+ -------
+ True or False
+ """
+
+ result = False
+ try:
+ for router in input_dict.keys():
+ debug_config = []
+ if "debug" in input_dict[router]:
+ debug_dict = input_dict[router]["debug"]
+
+ disable_logs = debug_dict.setdefault("disable", None)
+ enable_logs = debug_dict.setdefault("enable", None)
+ log_file = debug_dict.setdefault("log_file", None)
+
+ if log_file:
+ _log_file = os.path.join(LOGDIR, tgen.modname,
+ log_file)
+ debug_config.append("log file {} \n".\
+ format(_log_file))
+
+ if type(enable_logs) is list:
+ for daemon in enable_logs:
+ for debug_log in DEBUG_LOGS[daemon]:
+ debug_config.append("{}".format(debug_log))
+ elif type(enable_logs) is dict:
+ for daemon, debug_logs in enable_logs.items():
+ for debug_log in debug_logs:
+ debug_config.append("{}".format(debug_log))
+
+ if type(disable_logs) is list:
+ for daemon in disable_logs:
+ for debug_log in DEBUG_LOGS[daemon]:
+ debug_config.append("no {}".format(debug_log))
+ elif type(disable_logs) is dict:
+ for daemon, debug_logs in disable_logs.items():
+ for debug_log in debug_logs:
+ debug_config.append("no {}".format(debug_log))
+
+ result = create_common_configuration(tgen, router,
+ debug_config,
+ "debug_log_config",
+ build=build)
+ except InvalidCLIError:
+ # Traceback
+ errormsg = traceback.format_exc()
+ logger.error(errormsg)
+ return errormsg
+
+ logger.debug("Exiting lib API: {}".format(sys._getframe().f_code.co_name))
+ return result
+
+
#############################################
# Common APIs, will be used by all protocols
#############################################