Skip to content

[tests] Add packet level tests for Path tracing Midpoint #10486

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cscarpitta
Copy link

@cscarpitta cscarpitta commented Oct 25, 2023

Description of PR

Summary:
This PR adds the packet level tests to verify Path Tracing Midpoint functionality.
Path Tracing HLD is available here: sonic-net/SONiC#1456

Type of change

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

Back port request

  • 201911
  • 202012
  • 202205
  • 202305

Approach

What is the motivation for this PR?

Add packet level tests to verify Path Tracing Midpoint.

How did you do it?

Added a new test case tests/path_tracing.py

How did you verify/test it?

  • Execute path_tracing.py with pytest locally

@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 tests/path_tracing/test_path_tracing_midpoint.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/path_tracing/test_path_tracing_midpoint.py:165:31: F821 undefined name 'TestIPPacket'
tests/path_tracing/test_path_tracing_midpoint.py:288:121: E501 line too long (141 > 120 characters)
tests/path_tracing/test_path_tracing_midpoint.py:320:25: F523 '...'.format(...) has unused arguments at position(s): 0
tests/path_tracing/test_path_tracing_midpoint.py:328:25: F523 '...'.format(...) has unused arguments at position(s): 1
tests/path_tracing/test_path_tracing_midpoint.py:329:121: E501 line too long (121 > 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>

@ahsalam
Copy link

ahsalam commented Oct 27, 2023

@lguohan we added the packet level testing as per your suggestion. could you review ?

@zhangyanzhao zhangyanzhao requested a review from kperumalbfn May 22, 2024 16:47
@zhangyanzhao
Copy link
Contributor

@kperumalbfn can you please help to review this test PR as well? Thanks.

logger.info("Show rif counters failed with exception: {}".format(repr(e)))
rif_support = False

for prefix in ["2001:db8:2::1/128"]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

May be copy this test V6 prefix to a member and reuse in all the methods?

logger.info("Disable Path Tracing")
self.config_path_tracing(duthost, ifname="Ethernet8", enable=False)

def simple_ipv6_packet(
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can use simple_tcpv6 or simple_udpv6 from testutils. Please check the other tests.

(peer_ip_ifaces_pair, rif_rx_ifaces, rif_support, ptf_port_idx,
pc_ports_map, ptf_indices, ingress_router_mac) = common_param

ipv6_pkt = TestPathTracingMidpoint.simple_ipv6_packet(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it possible to update this V6 extension to PTF utils repo? Will be useful for other test cases as well.

logger.info("out_rif_ifaces: {}, out_ifaces: {}".format(out_rif_ifaces, out_ifaces))
out_ptf_indices = [ptf_indices[iface] for iface in out_ifaces]

self.config_path_tracing(duthost, ifname=out_ifaces[0], enable=True, interface_id=128)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we have one testcase for ECMP and verify the packet with either one egress interface in the PT?

Expected result:
- The DUT pushes a new MCD before forwarding the packet on the outgoing interface
"""
duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname]
Copy link
Collaborator

Choose a reason for hiding this comment

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

how do we skip this test on SKUs that doesn't support PT?

@cscarpitta cscarpitta force-pushed the path_tracing_midpoint branch from 4578d21 to 86a30af Compare August 26, 2024 15:40
@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...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

tests/path_tracing/test_path_tracing_midpoint.py:3:1: F401 'ipaddress' imported but unused
tests/path_tracing/test_path_tracing_midpoint.py:4:1: F401 're' imported but unused
tests/path_tracing/test_path_tracing_midpoint.py:8:1: F401 'collections.defaultdict' imported but unused
tests/path_tracing/test_path_tracing_midpoint.py:130:20: F821 undefined name 'ipaddr'
tests/path_tracing/test_path_tracing_midpoint.py:135:20: F821 undefined name 'ipaddr'
tests/path_tracing/test_path_tracing_midpoint.py:149:25: F821 undefined name 'setup_info'
tests/path_tracing/test_path_tracing_midpoint.py:150:9: F841 local variable 'nexthop_addr' is assigned to but never used
tests/path_tracing/test_path_tracing_midpoint.py:150:24: F821 undefined name 'setup_info'
tests/path_tracing/test_path_tracing_midpoint.py:151:9: F841 local variable 'nexthop_ptf_port_idx' is assigned to but never used
tests/path_tracing/test_path_tracing_midpoint.py:151:32: F821 undefined name 'setup_info'
tests/path_tracing/test_path_tracing_midpoint.py:160:9: F841 local variable 'ptf_tx_port_idx' is assigned to but never used
...
[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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants