Skip to content

Commit e1834cf

Browse files
authored
[action] [PR:18271] Handle multi-asic systems in get_frr_daemon_memory_usage (sonic-net#265)
Without this change `stress/test_stress_routes.py` will fail on multi-asic systems with: ``` E tests.common.errors.RunAnsibleModuleFail: run module shell failed, Ansible Results => E failed = True E changed = True E rc = 1 E cmd = vtysh -c "show memory bgpd" E start = 2025-04-27 06:02:20.869391 E end = 2025-04-27 06:02:20.882943 E delta = 0:00:00.013552 E msg = non-zero return code E invocation = {'module_args': {'_raw_params': 'vtysh -c "show memory bgpd"', '_uses_shell': True, 'warn': False, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}} E _ansible_no_log = None E stdout = E stderr = E Usage: /usr/bin/vtysh -n [0 to 1] [OPTION]... ``` Summary: Fixes sonic-net#18270 ### Type of change - [x] Bug fix - [ ] Testbed and Framework(new/improvement) - [ ] New Test case - [ ] Skipped for non-supported platforms - [ ] Test case improvement ### Back port request - [ ] 202012 - [ ] 202205 - [ ] 202305 - [ ] 202311 - [ ] 202405 - [ ] 202411 - [x] msft-202503
1 parent 83132c5 commit e1834cf

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

tests/stress/test_stress_routes.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def test_announce_withdraw_route(duthosts, localhost, tbinfo, get_function_compl
7777
loop_times = LOOP_TIMES_LEVEL_MAP[normalized_level]
7878

7979
frr_demons_to_check = ['bgpd', 'zebra']
80-
start_time_frr_daemon_memory = get_frr_daemon_memory_usage(duthost, frr_demons_to_check)
80+
start_time_frr_daemon_memory = get_frr_daemon_memory_usage(duthost, frr_demons_to_check, namespace)
8181
logging.info(f"memory usage at start: {start_time_frr_daemon_memory}")
8282

8383
while loop_times > 0:
@@ -94,7 +94,7 @@ def test_announce_withdraw_route(duthosts, localhost, tbinfo, get_function_compl
9494
pytest_assert(abs(ipv6_route_used_after - ipv6_route_used_before) < ALLOW_ROUTES_CHANGE_NUMS,
9595
"ipv6 route used after is not equal to it used before")
9696

97-
end_time_frr_daemon_memory = get_frr_daemon_memory_usage(duthost, frr_demons_to_check)
97+
end_time_frr_daemon_memory = get_frr_daemon_memory_usage(duthost, frr_demons_to_check, namespace)
9898
logging.info(f"memory usage at end: {end_time_frr_daemon_memory}")
9999
check_memory_usage_is_expected(duthost, frr_demons_to_check, start_time_frr_daemon_memory,
100100
end_time_frr_daemon_memory)
@@ -122,12 +122,14 @@ def check_memory_usage_is_expected(duthost, frr_demons_to_check, start_time_frr_
122122
f"The increase memory should not exceed than {incr_frr_daemon_memory_threshold_dict[daemon]} MiB")
123123

124124

125-
def get_frr_daemon_memory_usage(duthost, daemon_list):
125+
def get_frr_daemon_memory_usage(duthost, daemon_list, namespace):
126126
frr_daemon_memory_dict = {}
127127
for daemon in daemon_list:
128-
frr_daemon_memory_output = duthost.shell(f'vtysh -c "show memory {daemon}"')["stdout"]
128+
frr_daemon_memory_output = duthost.shell(duthost.get_vtysh_cmd_for_namespace(
129+
f'vtysh -c "show memory {daemon}"', namespace))["stdout"]
129130
logging.info(f"{daemon} memory status: \n%s", frr_daemon_memory_output)
130-
output = duthost.shell(f'vtysh -c "show memory {daemon}" | grep "Free ordinary blocks"')["stdout"]
131+
output = duthost.shell(duthost.get_vtysh_cmd_for_namespace(
132+
f'vtysh -c "show memory {daemon}" | grep "Free ordinary blocks"', namespace))["stdout"]
131133
frr_daemon_memory = int(output.split()[-2])
132134
unit = output.split()[-1]
133135
if unit == "KiB":

0 commit comments

Comments
 (0)