sonic-mgmt icon indicating copy to clipboard operation
sonic-mgmt copied to clipboard

Add dhcp-relay structured events tests

Open zbud-msft opened this issue 1 year ago • 5 comments
trafficstars

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

zbud-msft avatar Jun 28 '24 22:06 zbud-msft

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:

  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 avatar Jun 28 '24 22:06 mssonicbld

Relies on https://github.com/sonic-net/sonic-buildimage/pull/19430

zbud-msft avatar Jul 01 '24 01:07 zbud-msft

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:

  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 avatar Jul 08 '24 19:07 mssonicbld

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:

  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 avatar Jul 09 '24 01:07 mssonicbld

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:

  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 avatar Jul 09 '24 01:07 mssonicbld

Hi @StormLiangMS, can we have this in 202311?

zbud-msft avatar Aug 29 '24 17:08 zbud-msft

@zbud-msft PR conflicts with 202405 branch

mssonicbld avatar Sep 25 '24 22:09 mssonicbld