-
Notifications
You must be signed in to change notification settings - Fork 236
[Optimization] Improve traceroute_packetin_with_vrf_selection_test run time #5806
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
base: main
Are you sure you want to change the base?
Changes from all commits
8e2843b
40b9d52
49eba6d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -27,6 +27,7 @@ import ( | |||||||||||||
| "github.com/google/gopacket" | ||||||||||||||
| "github.com/google/gopacket/layers" | ||||||||||||||
| "github.com/open-traffic-generator/snappi/gosnappi" | ||||||||||||||
| "github.com/openconfig/featureprofiles/internal/otgutils" | ||||||||||||||
| "github.com/openconfig/featureprofiles/internal/p4rtutils" | ||||||||||||||
| "github.com/openconfig/ondatra" | ||||||||||||||
| "github.com/openconfig/ondatra/gnmi" | ||||||||||||||
|
|
@@ -102,7 +103,7 @@ func decodePacket6(t *testing.T, packetData []byte) uint8 { | |||||||||||||
|
|
||||||||||||||
| // testTraffic sends traffic flow for duration seconds and returns the | ||||||||||||||
| // number of packets sent out. | ||||||||||||||
| func testTraffic(t *testing.T, top gosnappi.Config, ate *ondatra.ATEDevice, flows []gosnappi.Flow, srcEndPoint gosnappi.Port, duration int, cs gosnappi.ControlState) int { | ||||||||||||||
| func testTraffic(t *testing.T, top gosnappi.Config, ate *ondatra.ATEDevice, flows []gosnappi.Flow, srcEndPoint gosnappi.Port, targetPkts uint64, cs gosnappi.ControlState) int { | ||||||||||||||
| t.Helper() | ||||||||||||||
| initialOutPkts := make(map[string]uint64, len(flows)) | ||||||||||||||
| top.Flows().Clear() | ||||||||||||||
|
|
@@ -113,12 +114,27 @@ func testTraffic(t *testing.T, top gosnappi.Config, ate *ondatra.ATEDevice, flow | |||||||||||||
| } | ||||||||||||||
| ate.OTG().PushConfig(t, top) | ||||||||||||||
| ate.OTG().StartProtocols(t) | ||||||||||||||
| time.Sleep(30 * time.Second) | ||||||||||||||
| otgutils.WaitForARP(t, ate.OTG(), top, "IPv4") | ||||||||||||||
| otgutils.WaitForARP(t, ate.OTG(), top, "IPv6") | ||||||||||||||
|
|
||||||||||||||
| // START THE PACKET CAPTURE AFTER CONFIG IS PUSHED | ||||||||||||||
| ate.OTG().SetControlState(t, cs) | ||||||||||||||
|
|
||||||||||||||
| for _, flow := range flows { | ||||||||||||||
| initialOutPkts[flow.Name()] = gnmi.Get(t, ate.OTG(), gnmi.OTG().Flow(flow.Name()).Counters().OutPkts().State()) | ||||||||||||||
| } | ||||||||||||||
| ate.OTG().StartTraffic(t) | ||||||||||||||
| time.Sleep(time.Duration(duration) * time.Second) | ||||||||||||||
| // AWAIT LOGIC INSTEAD OF SLEEP | ||||||||||||||
| for _, flow := range flows { | ||||||||||||||
| _, ok := gnmi.Watch(t, ate.OTG(), gnmi.OTG().Flow(flow.Name()).Counters().OutPkts().State(), time.Minute, func(val *ygnmi.Value[uint64]) bool { | ||||||||||||||
| pkts, present := val.Val() | ||||||||||||||
| return present && (pkts >= initialOutPkts[flow.Name()]+targetPkts) | ||||||||||||||
| }).Await(t) | ||||||||||||||
|
|
||||||||||||||
| if !ok { | ||||||||||||||
| t.Errorf("Traffic flow %s did not reach the target of %d packets within the timeout", flow.Name(), targetPkts) | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
+134
to
+136
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the traffic flow fails to reach the target number of packets, the subsequent packet-in validations will inevitably fail or produce misleading results due to missing packets. Consider using
Suggested change
References
|
||||||||||||||
| } | ||||||||||||||
| ate.OTG().StopTraffic(t) | ||||||||||||||
|
|
||||||||||||||
| cs.Port().Capture().SetState(gosnappi.StatePortCaptureState.STOP) | ||||||||||||||
|
|
@@ -174,7 +190,7 @@ func testPacketIn(ctx context.Context, t *testing.T, args *testArgs, isIPv4 bool | |||||||||||||
| for _, flowValue := range flowValues { | ||||||||||||||
| flow = append(flow, args.packetIO.GetTrafficFlow(args.ate, dstMac, isIPv4, 1, 300, 50, ipv4InnerDst, flowValue)) | ||||||||||||||
| } | ||||||||||||||
| pktOut := testTraffic(t, args.top, args.ate, flow, srcEndPoint, 60, cs) | ||||||||||||||
| pktOut := testTraffic(t, args.top, args.ate, flow, srcEndPoint, 500, cs) | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why 500s? 60s seems fine. |
||||||||||||||
| var countPkts = map[string]int{"11": 0, "12": 0, "13": 0, "14": 0, "15": 0, "16": 0, "17": 0} | ||||||||||||||
|
|
||||||||||||||
| packetInTests := []struct { | ||||||||||||||
|
|
||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.