Skip to content
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

waitOTGARPEntry to safeguard StartTraffic #27

Open
wants to merge 1 commit into
base: static
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion feature/experimental/otg_only/otgb2b_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package otg_b2b

Check failure on line 1 in feature/experimental/otg_only/otgb2b_test.go

View workflow job for this annotation

GitHub Actions / Static Analysis

don't use an underscore in package name

import (
"testing"
Expand All @@ -11,6 +11,7 @@
"github.com/openconfig/ondatra"
"github.com/openconfig/ondatra/gnmi"
otg "github.com/openconfig/ondatra/otg"
"github.com/openconfig/ygnmi/ygnmi"
)

var (
Expand Down Expand Up @@ -92,11 +93,29 @@
t.Logf("Pushing config to ATE and starting protocols...")
otg.PushConfig(t, config)
otg.StartProtocols(t)
waitOTGARPEntry(t, "IPv4")
waitOTGARPEntry(t, "IPv6")
return config
}

Copy link
Collaborator

@octpetre octpetre Jul 25, 2023

Choose a reason for hiding this comment

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

Let's use these 2 instead of local func

otgutils.WaitForARP(t, otg, config, "IPv4")
otgutils.WaitForARP(t, otg, config, "IPv6")

func waitOTGARPEntry(t *testing.T, ipType string) {
ate := ondatra.ATE(t, "ate")
otg := ate.OTG()

switch ipType {
case "IPv4":
gnmi.WatchAll(t, otg, gnmi.OTG().Interface(atePort1.Name+".Eth").Ipv4NeighborAny().LinkLayerAddress().State(), time.Minute, func(val *ygnmi.Value[string]) bool {
return val.IsPresent()
}).Await(t)
case "IPv6":
gnmi.WatchAll(t, otg, gnmi.OTG().Interface(atePort1.Name+".Eth").Ipv6NeighborAny().LinkLayerAddress().State(), time.Minute, func(val *ygnmi.Value[string]) bool {
return val.IsPresent()
}).Await(t)
}
}

func testTraffic(t *testing.T, ate *ondatra.ATEDevice, c gosnappi.Config) {
time.Sleep(2 * time.Second)
time.Sleep(1 * time.Second)
trafficDuration := 2 * time.Second
otg := ate.OTG()
// capture
Expand Down
Loading