-
Notifications
You must be signed in to change notification settings - Fork 712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SNMP]: Add snmp test case using link local as snmpagent address #9268
Merged
SuvarnaMeenakshi
merged 15 commits into
sonic-net:master
from
SuvarnaMeenakshi:link_local
Aug 14, 2023
Merged
Changes from 10 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
d51c9a6
Revert "Change run_tests.sh to use python3 unconditionally (#8988)"
SuvarnaMeenakshi 6ceebe4
Revert "[tests/crm] Fix python3 syntax error in `test_acl_entry` (#92…
SuvarnaMeenakshi a12ac1e
Revert "Fix import issue of tests/snappi_tests in python3 (#9232)"
SuvarnaMeenakshi 3491d00
[SNMP]: Add snmp test case using link local as snmpagent address
SuvarnaMeenakshi 9316dd2
Add test to PR checker
SuvarnaMeenakshi 6b8f998
Merge remote-tracking branch 'origin/master' into link_local
SuvarnaMeenakshi 66cdd4d
Revert "Revert "Fix import issue of tests/snappi_tests in python3 (#9…
SuvarnaMeenakshi 878fa97
Revert "Revert "[tests/crm] Fix python3 syntax error in `test_acl_ent…
SuvarnaMeenakshi de9a166
Revert "Revert "Change run_tests.sh to use python3 unconditionally (#…
SuvarnaMeenakshi 2e9ecf9
Fix flake8 errors
SuvarnaMeenakshi dd256cd
Fix as per review comments
SuvarnaMeenakshi 87ad5db
Revert "Change run_tests.sh to use python3 unconditionally (#8988)"
SuvarnaMeenakshi 28e6321
Revert "Revert "Change run_tests.sh to use python3 unconditionally (#…
SuvarnaMeenakshi 21281b9
Add test_snmp_link_local_ip test to multi-asic VS
SuvarnaMeenakshi 249cf13
Merge remote-tracking branch 'origin/master' into HEAD
SuvarnaMeenakshi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import pytest | ||
from tests.common.helpers.snmp_helpers import get_snmp_facts | ||
from tests.common import config_reload | ||
|
||
pytestmark = [ | ||
pytest.mark.topology('t0', 't1', 't2', 'm0', 'mx'), | ||
pytest.mark.device_type('vs') | ||
] | ||
|
||
|
||
@pytest.fixture(autouse=True, scope='module') | ||
def config_reload_after_test(duthosts, | ||
enum_rand_one_per_hwsku_frontend_hostname): | ||
yield | ||
duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname] | ||
config_reload(duthost, config_source='config_db') | ||
|
||
|
||
@pytest.mark.bsl | ||
def test_snmp_link_local_ip(duthosts, | ||
enum_rand_one_per_hwsku_frontend_hostname, | ||
nbrhosts, tbinfo, localhost, creds_all_duts): | ||
""" | ||
Test SNMP query to DUT over link local IP | ||
- Send SNMP query over link local IP from one of the BGP Neighbors | ||
- Get SysDescr from snmpfacts | ||
- compare result from snmp query over link local IP and snmpfacts | ||
""" | ||
duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname] | ||
hostip = duthost.host.options['inventory_manager'].get_host( | ||
duthost.hostname).vars['ansible_host'] | ||
snmp_facts = get_snmp_facts( | ||
localhost, host=hostip, version="v2c", | ||
community=creds_all_duts[duthost.hostname]["snmp_rocommunity"], | ||
wait=True)['ansible_facts'] | ||
# Get link local IP of mamangement interface | ||
ip_cmd = 'ip addr show eth0 | grep "inet6" | grep "link"\ | ||
| awk "{print $2}" | cut -d/ -f1' | ||
link_local_ips = duthost.shell(ip_cmd)['stdout_lines'] | ||
# configure link local IP in config_db | ||
for ip in link_local_ips: | ||
if ip.split()[1].lower().startswith('fe80'): | ||
link_local_ip = ip.split()[1] | ||
break | ||
# configure link local IP in config_db | ||
duthost.shell( | ||
'redis-cli -n 4 hset "MGMT_INTERFACE|eth0|{}" "gwaddr" "fe80::1"' | ||
.format(link_local_ip)) | ||
# Restart snmp service to regenerate snmpd.conf with | ||
# link local IP configured in MGMT_INTERFACE | ||
duthost.shell("systemctl restart snmp") | ||
stdout_lines = duthost.shell("docker exec snmp snmpget \ | ||
-v2c -c {} {}%eth0 1.3.6.1.2.1.1.1.0" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||
.format(creds_all_duts[duthost.hostname] | ||
['snmp_rocommunity'], | ||
link_local_ip))['stdout_lines'][0] | ||
assert "SONiC Software Version" in stdout_lines,\ | ||
"Sysdescr not found in SNMP result from Link Local IP {}".format( | ||
link_local_ip) | ||
assert snmp_facts['ansible_sysdescr'] in stdout_lines,\ | ||
"Sysdescr from IP{} not matching with result from Mgmt IPv4.".format( | ||
link_local_ip) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sonic-db-cli CONFIG_DB
is better. #ClosedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
udpated