Skip to content

Update P4rt-5.3#5499

Open
AmrNJ wants to merge 2 commits into
mainfrom
AmrNJ-patch-3
Open

Update P4rt-5.3#5499
AmrNJ wants to merge 2 commits into
mainfrom
AmrNJ-patch-3

Conversation

@AmrNJ
Copy link
Copy Markdown
Contributor

@AmrNJ AmrNJ commented May 22, 2026

  1. Increased packet-in timeouts from 30s to 45s.
  2. Added 1% tolerance for packet count received as the traffic distribution verification function later anyways have 2% tolerance. This avoids the test from failing early.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request updates the P4rt-5.3 test suite to enhance reliability. By extending timeout windows and introducing a margin of error for packet counts, the changes prevent transient network fluctuations from causing premature test failures.

Highlights

  • Timeout Adjustment: Increased the packet-in timeout duration from 30 seconds to 45 seconds to improve test stability.
  • Packet Count Tolerance: Introduced a 1% tolerance threshold for packet count verification to align with existing traffic distribution validation logic.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@AmrNJ AmrNJ marked this pull request as ready for review May 22, 2026 06:06
@AmrNJ AmrNJ requested a review from a team as a code owner May 22, 2026 06:06
@OpenConfigBot
Copy link
Copy Markdown

OpenConfigBot commented May 22, 2026

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request modifies the testPacketIn function to implement a tolerance-based check (1%) for the number of received packets instead of an exact match, and increases the packet retrieval timeout to 45 seconds. Review feedback indicates that the error from StreamChannelGetPackets is now being ignored, which should be handled with t.Fatalf to ensure the test fails immediately upon connection loss. Additionally, it was suggested to define the tolerance value as a named constant to avoid the use of magic numbers.

if err != nil {
t.Errorf("Unexpected error on fetchPackets: %v", err)
}
_, packets, _ := test.client.StreamChannelGetPackets(&streamName, uint64(test.wantPkts), 45*time.Second)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The error returned by StreamChannelGetPackets is now explicitly ignored using _. This can hide critical failures like connection loss. Per repository rules, t.Fatalf should be used instead of t.Errorf because a failure to retrieve packets makes the subsequent tolerance checks meaningless. This ensures the test fails fast.

			_, packets, err := test.client.StreamChannelGetPackets(&streamName, uint64(test.wantPkts), 45*time.Second)
			if err != nil {
				t.Fatalf("Unexpected error on fetchPackets: %v", err)
			}
References
  1. In tests, t.Fatalf is preferred over t.Errorf when a failure makes subsequent test steps meaningless, as this fails fast and reduces overall test execution time.

gotPkts := 0
t.Logf("Start to decode packet and compare with expected packets.")
wantPacket := args.packetIO.GetPacketTemplate()
tolerance := 0.01
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The tolerance value 0.01 is a magic number. It is better to define it as a named constant or add a comment explaining why this specific value was chosen. If this value represents a limitation due to external factors, it can be retained as a magic number provided there is a comment explaining the condition.

Suggested change
tolerance := 0.01
const tolerance = 0.01
References
  1. Magic numbers that represent temporary fixes or limitations due to external factors can be retained in the code with appropriate comments explaining their temporary nature.

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.

2 participants