[SNMP]: Fix SNMP test case over Loopback IP to check result of sysDescr#2918
Merged
lguohan merged 3 commits intosonic-net:masterfrom Feb 5, 2021
Merged
[SNMP]: Fix SNMP test case over Loopback IP to check result of sysDescr#2918lguohan merged 3 commits intosonic-net:masterfrom
lguohan merged 3 commits intosonic-net:masterfrom
Conversation
result of sysDescr is correct. Currently the test case only checks if SNMP result from Loopback IP matches with result from Management IP. Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
qiluo-msft
reviewed
Feb 4, 2021
| result = get_snmp_output(loip, duthost, nbr, creds) | ||
| if result is None: | ||
| # TODO: Fix SNMP query over IPv6 and remove the below check. | ||
| if (isinstance(loip, ipaddress.IPv4Address)) == False: |
Contributor
There was a problem hiding this comment.
( [](start = 11, length = 1)
remove the outside (), and use not instead of == False.
Hint: use linter to find this issue automatically, better integrated with an editor. #Closed
Contributor
Author
There was a problem hiding this comment.
Fixed as per comment.
qiluo-msft
reviewed
Feb 4, 2021
| assert len(result[u'stdout_lines']) > 0, 'No result from snmpget' | ||
| assert snmp_facts['ansible_sysdescr'] in result[u'stdout_lines'][0][0], "Sysdescr not found in SNMP result from IP {}".format(ip) | ||
| result = get_snmp_output(loip, duthost, nbr, creds) | ||
| assert result != None, 'No result from snmpget' |
Contributor
There was a problem hiding this comment.
!= [](start = 22, length = 2)
is not #Closed
Contributor
Author
There was a problem hiding this comment.
Fixed as per comment.
qiluo-msft
reviewed
Feb 4, 2021
| assert snmp_facts['ansible_sysdescr'] in result[u'stdout_lines'][0][0], "Sysdescr not found in SNMP result from IP {}".format(ip) | ||
| result = get_snmp_output(loip, duthost, nbr, creds) | ||
| assert result != None, 'No result from snmpget' | ||
| if result != None: |
Contributor
There was a problem hiding this comment.
if result != None: [](start = 8, length = 18)
You already assert it, so no need to check #Closed
Contributor
Author
There was a problem hiding this comment.
Removed this check.
Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
qiluo-msft
approved these changes
Feb 5, 2021
|
This pull request fixes 1 alert when merging ecc871b into 182b6d3 - view on LGTM.com fixed alerts:
|
kazinator-arista
pushed a commit
to kazinator-arista/sonic-mgmt
that referenced
this pull request
Mar 4, 2026
…atically (sonic-net#16110) src/sonic-utilities * 0f001c56 - (HEAD -> 202205, origin/202205) UT change: for db_migrator test do not check for RESTAPI cert values (sonic-net#2919) (4 hours ago) [Vaibhav Hemant Dixit] * 69d348d1 - [CLI][Show][BGP] Show BGP Change for no neighbor scenario (sonic-net#2885) (6 hours ago) [Dev Ojha] * 4c6af3c3 - [multi-asic] Refine [override config table] for corner cases (sonic-net#2918) (6 hours ago) [wenyiz2021] * bef3ffeb - [db_migrator] Set docker_routing_config_mode to the value obtained from minigraph parser (sonic-net#2890) (sonic-net#2922) (7 hours ago) [Vaibhav Hemant Dixit]
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix SNMP test case over Loopback IP to check result of sysDescr.
Currently the test case only checks if SNMP result from Loopback
IP matches with result from Management IP.
Signed-off-by: SuvarnaMeenakshi sumeenak@microsoft.com
Description of PR
Summary:
Fixes # (issue)
Type of change
Approach
What is the motivation for this PR?
Current testcase checks if SNMP result over Loopback IP matches with the result from Management IP.
It does not check for the correctness of the result.
If the SNMP result of sysDescr is wrong from both SNMP query over Loopback and Management IPs, this testcase did not catch it.
How did you do it?
How did you verify/test it?
Run this test on single-asic VS testbed :
pytest --testbed=vms-kvm-t0 --inventory=veos_vtb --testbed_file=vtestbed.csv --host-pattern=vlab-01 --module-path=../ansible/library "snmp/test_snmp_loopback.py" --show-capture=no --disable_loganalyzer --skip_sanity -v
/usr/local/lib/python2.7/dist-packages/ansible/parsing/vault/init.py:44: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release.
from cryptography.exceptions import InvalidSignature
=============================================================================== test session starts ===============================================================================
platform linux2 -- Python 2.7.17, pytest-4.6.5, py-1.10.0, pluggy-0.13.1 -- /usr/bin/python
cachedir: .pytest_cache
metadata: {'Python': '2.7.17', 'Platform': 'Linux-5.4.0-53-generic-x86_64-with-Ubuntu-18.04-bionic', 'Packages': {'py': '1.10.0', 'pytest': '4.6.5', 'pluggy': '0.13.1'}, 'Plugins': {u'repeat': u'0.9.1', u'ansible': u'2.2.2', u'xdist': u'1.28.0', u'html': u'1.22.1', u'forked': u'1.3.0', u'metadata': u'1.11.0'}}
ansible: 2.8.12
rootdir: /data/sonic-mgmt/tests, inifile: pytest.ini
plugins: xdist-1.28.0, html-1.22.1, repeat-0.9.1, forked-1.3.0, metadata-1.11.0, ansible-2.2.2
collected 1 item
snmp/test_snmp_loopback.py::test_snmp_loopback PASSED
Any platform specific information?
Supported testbed topology if it's a new test case?
Documentation