Skip to content

Commit

Permalink
skip tun kernel route for test_cont_link_flap case (sonic-net#7438)
Browse files Browse the repository at this point in the history
skip tunnel kernel route for test_cont_link_flap case

Signed-off-by: xuliping <[email protected]>
  • Loading branch information
lipxu authored Feb 14, 2023
1 parent 0288924 commit 8bbd362
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
32 changes: 31 additions & 1 deletion tests/common/devices/sonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1336,16 +1336,46 @@ def _parse_route_summary(self, output):
ret[key] = val
return ret

def get_ip_route_summary(self):
def get_ip_route_summary(self, skip_kernel_tunnel=False):
"""
@summary: issue "show ip[v6] route summary" and parse output into dicitionary.
Going forward, this show command should use tabular output so that
we can simply call show_and_parse() function.
"""
ipv4_output = self.shell("show ip route sum")["stdout_lines"]
ipv4_summary = self._parse_route_summary(ipv4_output)

if skip_kernel_tunnel == True:
ipv4_route_kernel_output = self.shell("show ip route kernel")["stdout_lines"]
ipv4_route_kernel_count = 0
for string in ipv4_route_kernel_output:
if re.search('tun', string):
ipv4_route_kernel_count += 1
logging.debug("IPv4 kernel tun route {}, {}".format(ipv4_route_kernel_count, ipv4_route_kernel_output))

if ipv4_route_kernel_count > 0:
ipv4_summary['kernel']['routes'] -= ipv4_route_kernel_count
ipv4_summary['kernel']['FIB'] -= ipv4_route_kernel_count
ipv4_summary['Totals']['routes'] -= ipv4_route_kernel_count
ipv4_summary['Totals']['FIB'] -= ipv4_route_kernel_count

ipv6_output = self.shell("show ipv6 route sum")["stdout_lines"]
ipv6_summary = self._parse_route_summary(ipv6_output)

if skip_kernel_tunnel == True:
ipv6_route_kernel_output = self.shell("show ipv6 route kernel")["stdout_lines"]
ipv6_route_kernel_count = 0
for string in ipv6_route_kernel_output:
if re.search('tun', string):
ipv6_route_kernel_count += 1
logging.debug("IPv6 kernel tun route {}, {}".format(ipv6_route_kernel_count, ipv6_route_kernel_output))

if ipv6_route_kernel_count > 0:
ipv6_summary['kernel']['routes'] -= ipv6_route_kernel_count
ipv6_summary['kernel']['FIB'] -= ipv6_route_kernel_count
ipv6_summary['Totals']['routes'] -= ipv6_route_kernel_count
ipv6_summary['Totals']['FIB'] -= ipv6_route_kernel_count

return ipv4_summary, ipv6_summary

def get_dut_iface_mac(self, iface_name):
Expand Down
2 changes: 1 addition & 1 deletion tests/platform_tests/link_flap/link_flap_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def check_bgp_routes(dut, start_time_ipv4_route_counts, start_time_ipv6_route_co
"""
MAX_DIFF = 5

sumv4, sumv6 = dut.get_ip_route_summary()
sumv4, sumv6 = dut.get_ip_route_summary(skip_kernel_tunnel=True)
totalsv4 = sumv4.get('Totals', {})
totalsv6 = sumv6.get('Totals', {})
routesv4 = totalsv4.get('routes', 0)
Expand Down
7 changes: 5 additions & 2 deletions tests/platform_tests/link_flap/test_cont_link_flap.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ def test_cont_link_flap(self, request, duthosts, nbrhosts, enum_rand_one_per_hws
logging.info("Redis Memory: %s M", start_time_redis_memory)

# Record ipv4 route counts at start
sumv4, sumv6 = duthost.get_ip_route_summary()
sumv4, sumv6 = duthost.get_ip_route_summary(skip_kernel_tunnel=True)
logging.debug("sumv4 {} ".format(sumv4))
logging.debug("sumv6 {} ".format(sumv6))

totalsv4 = sumv4.get('Totals', {})
totalsv6 = sumv6.get('Totals', {})
start_time_ipv4_route_counts = totalsv4.get('routes', 0)
Expand Down Expand Up @@ -86,7 +89,7 @@ def test_cont_link_flap(self, request, duthosts, nbrhosts, enum_rand_one_per_hws

# Make Sure all ipv4/ipv6 routes are relearned with jitter of ~5
if not wait_until(120, 2, 0, check_bgp_routes, duthost, start_time_ipv4_route_counts, start_time_ipv6_route_counts):
endv4, endv6 = duthost.get_ip_route_summary()
endv4, endv6 = duthost.get_ip_route_summary(skip_kernel_tunnel=True)
failmsg = []
failmsg.append(
"IP routes are not equal after link flap: before ipv4 {} ipv6 {}, after ipv4 {} ipv6 {}".format(sumv4,
Expand Down

0 comments on commit 8bbd362

Please sign in to comment.