Skip to content

[DP-1.11] qos: wait for flow transmission stop and in-flight packet drain in bursty_traffic_test - #6259

Open
arnavanand-lgtm wants to merge 1 commit into
openconfig:mainfrom
arnavanand-lgtm:fix-bursty-traffic-test-drain
Open

arnavanand-lgtm wants to merge 1 commit into
openconfig:mainfrom
arnavanand-lgtm:fix-bursty-traffic-test-drain

Conversation

@arnavanand-lgtm

Copy link
Copy Markdown
Contributor

Summary

In #5941, stopTrafficOnFlows was introduced to asynchronously stop traffic flows between subtests using gosnappi.StateTrafficFlowTransmitState.STOP. However, SetControlState returns immediately without waiting for transmission to halt or in-flight packets to clear the link and switch buffers.

When sampling flow counters immediately after stopTrafficOnFlows, transient in-flight packets (~90–200 packets / 48–100 KB) caused ateOutPkts > ateInPkts at the instant gnmi.Get was called. Because the physical DUT switch forwarded all traffic without drops (dutDropOctetCounterDiff = 0), the assertion:
if dutDropOctetCounterDiff < ateDropOctetCounterDiff { t.Errorf(...) }
failed with got 0, want >= <ateDrop> across all 7 QoS queue subtests, despite 100% throughput verified moments later once counters settled.

Changes Made

  1. Two-Phase Quiescence in stopTrafficOnFlows:
    • Phase 1 (Transmit State): Awaits gnmi.OTG().Flow(id).Transmit().State() == false to ensure OTG transmission has stopped.
    • Phase 2 (In-Flight Packet Drain): Awaits receiver gnmi.OTG().Flow(id).Counters().InPkts().State() counter stabilization across consecutive samples to ensure all in-flight packets clear the 100G links and switch buffers before assertions execute.
  2. Removed Redundant Sleep: Removed the arbitrary time.Sleep(30 * time.Second) before startTrafficOnFlows, reducing test execution time by ~3.5 minutes without impacting traffic stability.

Verification

Validated on physical hardware testbeds across two independent Arista DCS-7280 switches (Broadcom Jericho2) connected to Keysight Novus 100G traffic generation modules. All 7 QoS queues (NC1, AF4, AF3, AF2, AF1, BE0, BE1) passed with 100% throughput and zero drops across 6 consecutive runs.

DP-1.11 Pass 1.log
DP-1.11 Pass 2.log
DP-1.11 Pass 3.log
DP-1.11 Pass 4.log
DP-1.11 Pass 5.log
DP-1.11 Pass 6.log

@arnavanand-lgtm
arnavanand-lgtm requested a review from a team as a code owner November 8, 2026 19:20
@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 addresses a race condition in the bursty_traffic_test where assertions were failing due to transient in-flight packets being counted before they had fully cleared the network buffers. By introducing explicit state monitoring for transmission status and packet counter stabilization, the test now ensures accurate measurement of traffic drops. Additionally, the removal of an arbitrary sleep timer improves the efficiency of the test suite.

Highlights

  • Improved Traffic Quiescence: Implemented a two-phase waiting mechanism in stopTrafficOnFlows to ensure OTG transmission has fully stopped and in-flight packets have drained before proceeding with assertions.
  • Optimized Test Execution: Removed an unnecessary 30-second sleep period before starting traffic flows, reducing overall test execution time by approximately 3.5 minutes.
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. ↩

@OpenConfigBot

Copy link
Copy Markdown

Pull Request Functional Test Report for #6259 / c0bb10a

Virtual Devices

Device Test Status Test Documentation Job Raw Log
Arista cEOS status
DP-1.11: pending authorization
DP-1.11: Bursty traffic test
Cisco 8000E status
DP-1.11: pending authorization
DP-1.11: Bursty traffic test
Cisco XRd status
DP-1.11: pending authorization
DP-1.11: Bursty traffic test
Juniper ncPTX status
DP-1.11: pending authorization
DP-1.11: Bursty traffic test
Nokia SR Linux status
DP-1.11: pending authorization
DP-1.11: Bursty traffic test
Openconfig Lemming status
DP-1.11: pending authorization
DP-1.11: Bursty traffic test

Hardware Devices

Device Test Status Test Documentation Raw Log
Arista status
DP-1.11: pending authorization
DP-1.11: Bursty traffic test
Cisco status
DP-1.11: pending authorization
DP-1.11: Bursty traffic test
Juniper status
DP-1.11: pending authorization
DP-1.11: Bursty traffic test
Nokia status
DP-1.11: pending authorization
DP-1.11: Bursty traffic test

Help

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

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.

Code Review

This pull request optimizes the bursty traffic test by removing a static 30-second sleep before starting traffic and introducing dynamic waiting logic in stopTrafficOnFlows using gnmi.Watch to confirm transmission has stopped and in-flight packets have drained. The review feedback identifies a bug in the packet-draining watch logic where a flow receiving zero packets (e.g., due to a traffic generation failure) will cause the watch to always time out after 15 seconds. A code suggestion is provided to resolve this by tracking the previous sample state with a boolean flag instead of a rx > 0 check.

Comment on lines +132 to +149
var lastRx uint64
var unchangedCount int
_, _ = gnmi.Watch(t, ate.OTG(), gnmi.OTG().Flow(trafficID).Counters().InPkts().State(), 15*time.Second, func(val *ygnmi.Value[uint64]) bool {
rx, present := val.Val()
if !present {
return false
}
if rx > 0 && rx == lastRx {
unchangedCount++
if unchangedCount >= 2 {
return true
}
} else {
lastRx = rx
unchangedCount = 0
}
return false
}).Await(t)

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

If a flow does not receive any packets (e.g., due to a traffic generation issue, test failure, or in a negative test scenario), rx will be 0. Because of the rx > 0 guard, the else block will always execute, resetting unchangedCount to 0. This causes the gnmi.Watch to always time out after 15 seconds per flow, unnecessarily delaying the test execution when failures occur.

We can track whether we have received a previous sample using a boolean flag (e.g., hasLastRx) instead of checking rx > 0. This allows the watch to successfully terminate when the counter is stable at 0.

		var lastRx uint64
		var hasLastRx bool
		var unchangedCount int
		_, _ = gnmi.Watch(t, ate.OTG(), gnmi.OTG().Flow(trafficID).Counters().InPkts().State(), 15*time.Second, func(val *ygnmi.Value[uint64]) bool {
			rx, present := val.Val()
			if !present {
				return false
			}
			if hasLastRx && rx == lastRx {
				unchangedCount++
				if unchangedCount >= 2 {
					return true
				}
			} else {
				lastRx = rx
				hasLastRx = true
				unchangedCount = 0
			}
			return false
		}).Await(t)
References
  1. In gNMI telemetry tests, distinguish between cumulative counters and rate metrics: while zero is valid for counters, rates should often be checked for non-zero values (e.g., using IsZero()) to verify active reporting.

This branch has not been deployed

No deployments
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