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

Fix dual-tor dhcpv6 relay test cases failure in latest image #9842

Merged
merged 1 commit into from
Sep 6, 2023

Conversation

jcaiMR
Copy link
Contributor

@jcaiMR jcaiMR commented Sep 5, 2023

Description of PR

Fix test_dhcpv6_relay.py case test_dhcp_relay_default and test_dhcpv6_relay_counter failure on dualtor.
The issue is test gap after code commit of sonic-net/sonic-dhcp-relay#42 in master
and sonic-net/sonic-dhcp-relay#40 in 202012.

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?

Fix test_dhcpv6_relay.py case test_dhcp_relay_default and test_dhcpv6_relay_counter failure on dualtor.

  1. Based on latest dhcprelay code, dhcpv6 relay will use loopback0 ipv6 address as source ip when relay packets to server.
    So test case need modify to send Relay-Reply to loopback0 ipv6 address.
  2. Improve test case behavior, enable source ipv6 check during test
  3. remove unused option order sequence related test code
  4. check loopback0 Relay-Reply counter in dualtor instead of vlan interface counter
  5. change DUID LLT to LL, since LLT is different based on different timestamp during test which may cause packet comparation failure

Note for future code change:

  1. Relay interface should always means Vlan interfaces
  2. Loopback interface used in dual tor only, interface id option is enabled by default in dual tor case (for the consideration of second level relay agent case which has zero link address and we need use interface id for downlink interface selection)
  3. Uplink interface mac should be server response dest mac
  4. Relay-Forward source ipv6 address (Single Tor: vlan ipv6 address, Dual Tor: loopback ipv6 address), dest ipv6 address is server address
  5. Relay-Reply source ipv6 address is server address, destination ipv6 address is same as Relay-Forward source ipv6 address

How did you do it?

run dhcp_relay/test_dhcpv6_relay.py

How did you verify/test it?

Test case pass on dual tor and single tor

Any platform specific information?

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

Documentation

@jcaiMR jcaiMR requested review from kellyyeh and yaqiangz September 5, 2023 17:03
@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.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Fixing ansible/roles/test/files/ptftests/py3/dhcpv6_relay_test.py

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/dhcp_relay/test_dhcpv6_relay.py:228:16: F632 use ==/!= to compare constant literals (str, bytes, int, float, tuple)
tests/dhcp_relay/test_dhcpv6_relay.py:240:29: F811 redefinition of unused 'toggle_all_simulator_ports_to_rand_selected_tor_m' from line 15

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>

@jcaiMR jcaiMR force-pushed the dev/jcai_fix_dhcpv6_relay branch from 4284792 to 8db29e7 Compare September 6, 2023 02:37
@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.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Fixing ansible/roles/test/files/ptftests/py3/dhcpv6_relay_test.py

fix end of files.........................................................Passed
check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Passed
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>

@jcaiMR jcaiMR force-pushed the dev/jcai_fix_dhcpv6_relay branch from 8db29e7 to 851c45b Compare September 6, 2023 05:18
Copy link
Contributor

@XuChen-MSFT XuChen-MSFT left a comment

Choose a reason for hiding this comment

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

LGTM

@mssonicbld
Copy link
Collaborator

Cherry-pick PR to 202305: #9941

@mssonicbld
Copy link
Collaborator

@jcaiMR PR conflicts with 202205 branch

wangxin pushed a commit that referenced this pull request Sep 14, 2023
What is the motivation for this PR?
Cherry pick (#9842) to 202205
Code gap is big, solution refined based on 202205 base code.

How did you do it?
How did you verify/test it?
dhcp_relay/test_dhcpv6_relay.py::test_dhcp_relay_default
dhcp_relay/test_dhcpv6_relay.py::test_dhcpv6_relay_counter
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.

5 participants