Skip to content

fix dhcp relay test failure with backgound traffic#6809

Merged
jcaiMR merged 3 commits intosonic-net:masterfrom
jcaiMR:dev/fix_dhcp_test
Nov 15, 2022
Merged

fix dhcp relay test failure with backgound traffic#6809
jcaiMR merged 3 commits intosonic-net:masterfrom
jcaiMR:dev/fix_dhcp_test

Conversation

@jcaiMR
Copy link
Contributor

@jcaiMR jcaiMR commented Nov 11, 2022

Description of PR

Fix dhcp relay test failure when there is background(noise) dhcp packets on dhcp server side during test.

Summary:
Fixes # (issue)
In original test script, sniffer call back function destination ip check is not right, it only accept the first dhcp server ip.
If configure multiple dhcp servers, actually only one packet to server will match sniffer condition. So when there is background/noise packets, it's easy to loss the relay packets send from DUT and cause test failure.

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?

Improve test stability

How did you do it?

Define strict filter handler to keep the noise packets impact to minimal.

How did you verify/test it?

test on dut.

/root/env-python3/bin/ptf --test-dir ptftests/py3 dhcp_relay_test.DHCPTest --platform-dir ptftests --platform remote -t "relay_iface_mac='00:e0:ec:c2:af:fd';client_iface_alias='etp2';relay_iface_netmask='255.255.248.0';uplink_mac='00:e0:ec:c2:af:fd';testing_mode='single';num_dhcp_servers=48;relay_iface_ip='192.168.0.1';testbed_mode='single_testbed';dest_mac_address='ff:ff:ff:ff:ff:ff';hostname='str-dx010-acs-5';leaf_port_indices='[29, 28, 31, 30]';client_udp_src_port=68;server_ip=['192.0.0.1', '192.0.0.2', '192.0.0.3', '192.0.0.4', '192.0.0.5', '192.0.0.6', '192.0.0.7', '192.0.0.8', '192.0.0.9', '192.0.0.10', '192.0.0.11', '192.0.0.12', '192.0.0.13', '192.0.0.14', '192.0.0.15', '192.0.0.16', '192.0.0.17', '192.0.0.18', '192.0.0.19', '192.0.0.20', '192.0.0.21', '192.0.0.22', '192.0.0.23', '192.0.0.24', '192.0.0.25', '192.0.0.26', '192.0.0.27', '192.0.0.28', '192.0.0.29', '192.0.0.30', '192.0.0.31', '192.0.0.32', '192.0.0.33', '192.0.0.34', '192.0.0.35', '192.0.0.36', '192.0.0.37', '192.0.0.38', '192.0.0.39', '192.0.0.40', '192.0.0.41', '192.0.0.42', '192.0.0.43', '192.0.0.44', '192.0.0.45', '192.0.0.46', '192.0.0.47', '192.0.0.48'];client_port_index=1;switch_loopback_ip='10.1.0.32'" --relax --debug info --log-file /tmp/dhcp_relay_test.DHCPTest.log
/root/env-python3/bin/ptf:19: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
Using packet manipulation module: ptf.packet_scapy
dhcp_relay_test.DHCPTest ... > /root/ptftests/py3/dhcp_relay_test.py(748)runTest()
-> for interface_index in self.server_port_indices:
(Pdb) c
ok

----------------------------------------------------------------------
Ran 1 test in 11.363s

OK

@azure-pipelines
Copy link

The pre-commit check detected issues in the files touched by this pull request.
The detected issues may be old or new. For new issues, please try to fix them.

For old issues, it is not mandatory to fix them because they were not caused by this change. It is unfair to blame
author of this pull request. But if you can take extra effort to fix the old issues as well, that would be great!

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/dhcp_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

ansible/roles/test/files/ptftests/py3/dhcp_relay_test.py:34:24: F821 undefined name 'os'
ansible/roles/test/files/ptftests/py3/dhcp_relay_test.py:41:1: E305 expected 2 blank lines after class or function definition, found 1
ansible/roles/test/files/ptftests/py3/dhcp_relay_test.py:63:121: E501 line too long (449 > 120 characters)
ansible/roles/test/files/ptftests/py3/dhcp_relay_test.py:66:121: E501 line too long (121 > 120 characters)
ansible/roles/test/files/ptftests/py3/dhcp_relay_test.py:70:121: E501 line too long (134 > 120 characters)
...
[truncated extra lines, please run pre-commit locally to view full check results]

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>

Copy link
Collaborator

@StormLiangMS StormLiangMS left a comment

Choose a reason for hiding this comment

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

LGTM

@wangxin
Copy link
Collaborator

wangxin commented Nov 15, 2022

@jcaiMR There are conflicts merging this PR to 202012 branch. Can you create a separate PR to 202012 branch to include this change?

wangxin pushed a commit that referenced this pull request Nov 15, 2022
* fix route flap script issue on dual tor

* fix dhcp relay unstable issue with backgound dhcp packets
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.

3 participants