Skip to content

Commit

Permalink
[Chassis] Snmp fixes - test_snmp_default_route and test_snmp_queue_co…
Browse files Browse the repository at this point in the history
…unters (#15279)

Summary:


This PR fixes test issue introduced as part of #3537 for test_snmp_default_route test, and
General fix for test_snmp_queue_counters test teardown.
Type of change

Approach
What is the motivation for this PR?
After PR #3537 introduction, CLI command output for 'show ip route 0.0.0.0/0' has been changed and a new word 'recursive' gets added. Hence sonic-mgmt needs to be modified to support this new change. For example, "* 11.0.0.145 recursive via iBGP"
During teardown of 'test_snmp_queue_counters' test, sometimes we see the following error while recopying the config_db json file for the duthost.
E           tests.common.errors.RunAnsibleModuleFail: run module copy failed, Ansible Results =>
E           {"changed": false, "failed": true, "msg": "Source /etc/sonic/orig_config_db1.json not found"}

complex_args = {'dest': '/etc/sonic/config_db1.json', 'remote_src': True, 'src': '/etc/sonic/orig_config_db1.json'}
filename   = '/data/tests/snmp/test_snmp_queue_counters.py'
function_name = 'teardown'
How did you do it?
Handle 'recursive' word as well while parsing for ip-address in test_snmp_default_route test case.
Make sure the duthost is same during test call and teardown in test_snmp_queue_counters test case.
How did you verify/test it?
Ran all the above-mentioned test cases on a T2 chassis and made sure tests passed with expected behavior.
  • Loading branch information
sanjair-git authored and mssonicbld committed Dec 17, 2024
1 parent de1caa7 commit 74d936d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/snmp/test_snmp_default_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_snmp_default_route(duthosts, enum_rand_one_per_hwsku_frontend_hostname,
for line in dut_result['stdout_lines']:
if 'via' in line:
ip, interface = line.split('via')
ip = ip.strip("*, ")
ip = ip.strip("*, ,recursive")
interface = interface.strip("*, ")
if interface != "eth0" and 'Ethernet-BP' not in interface:
dut_result_nexthops.append(ip)
Expand Down
7 changes: 3 additions & 4 deletions tests/snmp/test_snmp_queue_counters.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def get_asic_interface(inter_facts):

def test_snmp_queue_counters(duthosts,
enum_rand_one_per_hwsku_frontend_hostname, enum_frontend_asic_index,
creds_all_duts, teardown):
creds_all_duts):
"""
Test SNMP queue counters
- Set "create_only_config_db_buffers" to true in config db, to create
Expand Down Expand Up @@ -172,12 +172,11 @@ def test_snmp_queue_counters(duthosts,
(queue_counters_cnt_pre - multicast_expected_diff)))


@pytest.fixture(scope="module")
@pytest.fixture(autouse=True, scope="module")
def teardown(duthosts, enum_rand_one_per_hwsku_frontend_hostname):
"""
Teardown procedure for all test function
:param duthosts: List of DUT hosts
:param enum_rand_one_per_hwsku_frontend_hostname: hostname of a randomly selected DUT
param duthosts: duthosts object
"""
duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname]
yield
Expand Down

0 comments on commit 74d936d

Please sign in to comment.