sonic-mgmt
sonic-mgmt copied to clipboard
Add dhcp-relay structured events tests
Description of PR
Summary: Fixes # (issue) 26636373
Type of change
- [ ] Bug fix
- [ ] Testbed and Framework(new/improvement)
- [x] Test case(new/improvement)
Back port request
- [ ] 202012
- [ ] 202205
- [ ] 202305
- [ ] 202311
- [ ] 202405
Approach
What is the motivation for this PR?
Add support for dhcp-relay-discard event, which we use ptfadapter to and ptf.testutils to send a dhcp discover packet to a port that has no ipv4 address assigned.
Add support for dhcp-relay-disparity event which uses same repro for dhcp-relay-disparity but at greater intervals and packets sent due to dhcpmon configuration
How did you do it?
Added new testcase that triggered sending dhcp discover packet which will trigger event.
How did you verify/test it?
Pipeline/Manual test
run_events_test.run_test L0027 INFO | events received:
{
"sonic-events-dhcp-relay:dhcp-relay-discard": {
"ifname": "Vlan1000",
"timestamp": "2024-07-09T01:27:30.395216Z"
}
}
run_events_test.run_test L0027 INFO | events received:
{
"sonic-events-dhcp-relay:dhcp-relay-disparity": {
"duration": "198",
"timestamp": "2024-07-09T01:30:43.711312Z",
"vlan": "Agg-Vlan1000"
}
}
run_events_test.run_test L0027 INFO | events received:
{
"sonic-events-dhcp-relay:dhcp-relay-bind-failure": {
"timestamp": "2024-07-09T01:32:27.667714Z",
"type": "local",
"vlan": "Vlan1000"
}
}
Any platform specific information?
Supported testbed topology if it's a new test case?
Documentation
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...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1
tests/telemetry/conftest.py:167:121: E501 line too long (127 > 120 characters)
tests/telemetry/events/dhcp-relay_events.py:13:1: E302 expected 2 blank lines, found 1
flake8...............................................(no files to check)Skipped
check conditional mark sort..........................(no files to check)Skipped
To run the pre-commit checks locally, you can follow below steps:
- 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.
- Ensure that the
pre-commitpackage is installed:
sudo pip install pre-commit
- Go to repository root folder
- Install the pre-commit hooks:
pre-commit install
- Use pre-commit to check staged file:
pre-commit
- Alternatively, you can check committed files using:
pre-commit run --from-ref <commit_id> --to-ref <commit_id>
Relies on https://github.com/sonic-net/sonic-buildimage/pull/19430
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...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1
tests/telemetry/events/dhcp-relay_events.py:35:41: F821 undefined name 'ptfadataper'
flake8...............................................(no files to check)Skipped
check conditional mark sort..........................(no files to check)Skipped
To run the pre-commit checks locally, you can follow below steps:
- 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.
- Ensure that the
pre-commitpackage is installed:
sudo pip install pre-commit
- Go to repository root folder
- Install the pre-commit hooks:
pre-commit install
- Use pre-commit to check staged file:
pre-commit
- Alternatively, you can check committed files using:
pre-commit run --from-ref <commit_id> --to-ref <commit_id>
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...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1
tests/telemetry/events/event_utils.py:122:121: E501 line too long (138 > 120 characters)
tests/telemetry/events/event_utils.py:127:121: E501 line too long (150 > 120 characters)
tests/telemetry/events/event_utils.py:128:121: E501 line too long (136 > 120 characters)
flake8...............................................(no files to check)Skipped
check conditional mark sort..........................(no files to check)Skipped
To run the pre-commit checks locally, you can follow below steps:
- 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.
- Ensure that the
pre-commitpackage is installed:
sudo pip install pre-commit
- Go to repository root folder
- Install the pre-commit hooks:
pre-commit install
- Use pre-commit to check staged file:
pre-commit
- Alternatively, you can check committed files using:
pre-commit run --from-ref <commit_id> --to-ref <commit_id>
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...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1
tests/telemetry/events/event_utils.py:128:89: E502 the backslash is redundant between brackets
tests/telemetry/events/event_utils.py:130:91: E502 the backslash is redundant between brackets
flake8...............................................(no files to check)Skipped
check conditional mark sort..........................(no files to check)Skipped
To run the pre-commit checks locally, you can follow below steps:
- 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.
- Ensure that the
pre-commitpackage is installed:
sudo pip install pre-commit
- Go to repository root folder
- Install the pre-commit hooks:
pre-commit install
- Use pre-commit to check staged file:
pre-commit
- Alternatively, you can check committed files using:
pre-commit run --from-ref <commit_id> --to-ref <commit_id>
Hi @StormLiangMS, can we have this in 202311?
@zbud-msft PR conflicts with 202405 branch