Skip to content
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
merged 15 commits into from
Aug 14, 2023

Conversation

SuvarnaMeenakshi
Copy link
Contributor

@SuvarnaMeenakshi SuvarnaMeenakshi commented Aug 4, 2023

Description of PR

Summary:
Fixes # (issue)

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • Test case(new/improvement)

Back port request

  • 201911
  • 202012
  • 202205

Approach

What is the motivation for this PR?

Test added to use link local IP address as snmpagent address.

How did you do it?

Use ink local IP of eth0 IP address, configure that as MGMT address.
Restart SNMP service so that snmpd.conf uses newly assigned MGMT address as snmpagent address
Query using link local address
Check if snmpresult is as expected.
reload config to remove the MGMT link local IP assignment.

How did you verify/test it?

Verified on VS testbed,.

Any platform specific information?

Supported testbed topology if it's a new test case?

Documentation

@mssonicbld
Copy link
Collaborator

The pre-commit check detected issues in the files touched by this pull request.
The pre-commit check is a mandatory check, please fix detected issues.

Detailed pre-commit check results:
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check yaml...............................................................Passed
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

tests/snmp/test_snmp_link_local.py:13:9: E128 continuation line under-indented for visual indent
tests/snmp/test_snmp_link_local.py:21:24: E128 continuation line under-indented for visual indent
tests/snmp/test_snmp_link_local.py:46:78: E502 the backslash is redundant between brackets
tests/snmp/test_snmp_link_local.py:50:97: E502 the backslash is redundant between brackets
tests/snmp/test_snmp_link_local.py:51:13: E128 continuation line under-indented for visual indent

flake8...............................................(no files to check)Skipped
check conditional mark sort..............................................Passed

To run the pre-commit checks locally, you can follow below steps:

  1. Ensure that default python is python3. In sonic-mgmt docker container, default python is python2. You can run
    the check by activating the python3 virtual environment in sonic-mgmt docker container or outside of sonic-mgmt
    docker container.
  2. Ensure that the pre-commit package is installed:
sudo pip install pre-commit
  1. Go to repository root folder
  2. Install the pre-commit hooks:
pre-commit install
  1. Use pre-commit to check staged file:
pre-commit
  1. Alternatively, you can check committed files using:
pre-commit run --from-ref <commit_id> --to-ref <commit_id>

@mssonicbld
Copy link
Collaborator

The pre-commit check detected issues in the files touched by this pull request.
The pre-commit check is a mandatory check, please fix detected issues.

Detailed pre-commit check results:
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check yaml...............................................................Passed
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

tests/snmp/test_snmp_link_local.py:13:9: E128 continuation line under-indented for visual indent
tests/snmp/test_snmp_link_local.py:21:24: E128 continuation line under-indented for visual indent
tests/snmp/test_snmp_link_local.py:46:78: E502 the backslash is redundant between brackets
tests/snmp/test_snmp_link_local.py:50:97: E502 the backslash is redundant between brackets
tests/snmp/test_snmp_link_local.py:51:13: E128 continuation line under-indented for visual indent

flake8...............................................(no files to check)Skipped
check conditional mark sort..............................................Passed

To run the pre-commit checks locally, you can follow below steps:

  1. Ensure that default python is python3. In sonic-mgmt docker container, default python is python2. You can run
    the check by activating the python3 virtual environment in sonic-mgmt docker container or outside of sonic-mgmt
    docker container.
  2. Ensure that the pre-commit package is installed:
sudo pip install pre-commit
  1. Go to repository root folder
  2. Install the pre-commit hooks:
pre-commit install
  1. Use pre-commit to check staged file:
pre-commit
  1. Alternatively, you can check committed files using:
pre-commit run --from-ref <commit_id> --to-ref <commit_id>

Signed-off-by: Suvarna Meenakshi <sumeenak@microsoft.com>
break
# configure link local IP in config_db
duthost.shell(
'redis-cli -n 4 hset "MGMT_INTERFACE|eth0|{}" "gwaddr" "fe80::1"'
Copy link
Contributor

@qiluo-msft qiluo-msft Aug 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redis-cli -n 4

sonic-db-cli CONFIG_DB is better. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

udpated

# 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"
Copy link
Contributor

@qiluo-msft qiluo-msft Aug 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.3.6.1.2.1.1.1.0

Better to have a named constant, so audience could understand what is the OID meaning. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@SuvarnaMeenakshi SuvarnaMeenakshi marked this pull request as ready for review August 11, 2023 19:28
@SuvarnaMeenakshi
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@SuvarnaMeenakshi SuvarnaMeenakshi merged commit f55ba68 into sonic-net:master Aug 14, 2023
13 checks passed
@wangxin
Copy link
Collaborator

wangxin commented Aug 16, 2023

@SuvarnaMeenakshi This is to add a new test. Do we really need it in 202205 branch?

mssonicbld pushed a commit to mssonicbld/sonic-mgmt that referenced this pull request Aug 16, 2023
…ic-net#9268)

What is the motivation for this PR?
Test added to use link local IP address as snmpagent address.

How did you do it?
Use ink local IP of eth0 IP address, configure that as MGMT address.
Restart SNMP service so that snmpd.conf uses newly assigned MGMT address as snmpagent address
Query using link local address
Check if snmpresult is as expected.
reload config to remove the MGMT link local IP assignment.

How did you verify/test it?
Verified on VS testbed,.
@mssonicbld
Copy link
Collaborator

Cherry-pick PR to 202305: #9490

mssonicbld pushed a commit that referenced this pull request Aug 18, 2023
What is the motivation for this PR?
Test added to use link local IP address as snmpagent address.

How did you do it?
Use ink local IP of eth0 IP address, configure that as MGMT address.
Restart SNMP service so that snmpd.conf uses newly assigned MGMT address as snmpagent address
Query using link local address
Check if snmpresult is as expected.
reload config to remove the MGMT link local IP assignment.

How did you verify/test it?
Verified on VS testbed,.
@SuvarnaMeenakshi
Copy link
Contributor Author

@SuvarnaMeenakshi This is to add a new test. Do we really need it in 202205 branch?

@wangxin The change to support IPv6 SNMP is merged in 202205 and this change caused SNMP over link local IPv6 to fail.
As the change is added in 202205, it will be good to add this test in 202205 also.
@qiluo-msft any suggestion.

mssonicbld pushed a commit to mssonicbld/sonic-mgmt that referenced this pull request Aug 28, 2023
…ic-net#9268)

What is the motivation for this PR?
Test added to use link local IP address as snmpagent address.

How did you do it?
Use ink local IP of eth0 IP address, configure that as MGMT address.
Restart SNMP service so that snmpd.conf uses newly assigned MGMT address as snmpagent address
Query using link local address
Check if snmpresult is as expected.
reload config to remove the MGMT link local IP assignment.

How did you verify/test it?
Verified on VS testbed,.
@mssonicbld
Copy link
Collaborator

Cherry-pick PR to 202205: #9710

mssonicbld pushed a commit that referenced this pull request Aug 31, 2023
What is the motivation for this PR?
Test added to use link local IP address as snmpagent address.

How did you do it?
Use ink local IP of eth0 IP address, configure that as MGMT address.
Restart SNMP service so that snmpd.conf uses newly assigned MGMT address as snmpagent address
Query using link local address
Check if snmpresult is as expected.
reload config to remove the MGMT link local IP assignment.

How did you verify/test it?
Verified on VS testbed,.
AharonMalkin pushed a commit to AharonMalkin/sonic-mgmt that referenced this pull request Jan 25, 2024
…ic-net#9268)

What is the motivation for this PR?
Test added to use link local IP address as snmpagent address.

How did you do it?
Use ink local IP of eth0 IP address, configure that as MGMT address.
Restart SNMP service so that snmpd.conf uses newly assigned MGMT address as snmpagent address
Query using link local address
Check if snmpresult is as expected.
reload config to remove the MGMT link local IP assignment.

How did you verify/test it?
Verified on VS testbed,.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants