diff --git a/feature/interface/aggregate/otg_tests/balancing_test/balancing_test.go b/feature/interface/aggregate/otg_tests/balancing_test/balancing_test.go index 9937fabf31d..07b576adf29 100644 --- a/feature/interface/aggregate/otg_tests/balancing_test/balancing_test.go +++ b/feature/interface/aggregate/otg_tests/balancing_test/balancing_test.go @@ -241,45 +241,45 @@ func (tc *testCase) verifyLAG(t *testing.T) { if tc.lagType == oc.IfAggregate_AggregationType_LACP { t.Logf("Waiting LAG DUT ports to start collecting and distributing") - for _, dp := range tc.dutPorts[1:] { - _, ok := gnmi.WatchAll(t, tc.dut, gnmi.OC().Lacp().InterfaceAny().Member(dp.Name()).Collecting().State(), time.Minute, func(val *ygnmi.Value[bool]) bool { - col, present := val.Val() - return present && col - }).Await(t) - if !ok { - t.Fatalf("DUT LAG port %v is not collecting", dp) + watchD := gnmi.WatchAll[*oc.Lacp_Interface](t, tc.dut, gnmi.OC().Lacp().InterfaceAny().State(), time.Minute, func(val *ygnmi.Value[*oc.Lacp_Interface]) bool { + col, present := val.Val() + if !present || col == nil { + return false } - _, ok = gnmi.WatchAll(t, tc.dut, gnmi.OC().Lacp().InterfaceAny().Member(dp.Name()).Distributing().State(), time.Minute, func(val *ygnmi.Value[bool]) bool { - dist, present := val.Val() - return present && dist - }).Await(t) - if !ok { - t.Fatalf("DUT LAG port %v is not distributing", dp) + for _, dp := range tc.dutPorts[1:] { + m := col.GetMember(dp.Name()) + if !m.GetCollecting() || !m.GetDistributing() { + return false + } } + return true + }) + if _, ok := watchD.Await(t); !ok { + t.Fatalf("DUT LAG is not ready to collect and distribute") } + t.Logf("Waiting LAG OTG ports to start collecting and distributing") - for _, p := range tc.atePorts[1:] { - _, ok := gnmi.Watch(t, tc.ate.OTG(), gnmi.OTG().Lacp().LagMember(p.ID()).Collecting().State(), time.Minute, func(val *ygnmi.Value[bool]) bool { - col, present := val.Val() - t.Logf("collecting for port %v is %v and present is %v", p.ID(), col, present) - return present && col - }).Await(t) - if !ok { - t.Fatalf("OTG LAG port %v is not collecting", p) + watchO := gnmi.Watch[*otgtelemetry.Lacp](t, tc.ate.OTG(), gnmi.OTG().Lacp().State(), 2*time.Minute, func(val *ygnmi.Value[*otgtelemetry.Lacp]) bool { + col, present := val.Val() + if !present || col == nil { + return false } - _, ok = gnmi.Watch(t, tc.ate.OTG(), gnmi.OTG().Lacp().LagMember(p.ID()).Distributing().State(), time.Minute, func(val *ygnmi.Value[bool]) bool { - dist, present := val.Val() - t.Logf("distributing for port %v is %v and present is %v", p.ID(), dist, present) - return present && dist - }).Await(t) - if !ok { - t.Fatalf("OTG LAG port %v is not distributing", p) + for _, ap := range tc.atePorts[1:] { + m := col.GetLagMember(ap.ID()) + if !m.GetCollecting() || !m.GetDistributing() { + return false + } } + return true + }) + if _, ok := watchO.Await(t); !ok { + t.Fatalf("OTG LAG is not ready to collect and distribute") } + otgutils.LogLACPMetrics(t, tc.ate.OTG(), tc.top) } - otgutils.LogLAGMetrics(t, tc.ate.OTG(), tc.top) + otgutils.LogLAGMetrics(t, tc.ate.OTG(), tc.top) } func (tc *testCase) configureDUT(t *testing.T) { @@ -504,6 +504,7 @@ func (tc *testCase) testFlow(t *testing.T, l3header string) { flow.Size().SetFixed(128) flow.Packet().Add().Ethernet().Src().SetValue(ateSrc.MAC) + ipType := "IPv4" if l3header == "ipv4" { flow.TxRx().Device().SetTxNames([]string{i1 + ".IPv4"}).SetRxNames([]string{i2 + ".IPv4"}) v4 := flow.Packet().Add().Ipv4() @@ -522,6 +523,7 @@ func (tc *testCase) testFlow(t *testing.T, l3header string) { v6 := flow.Packet().Add().Ipv6() v6.Src().SetValue(ateSrc.IPv6) v6.Dst().SetValue(ateDst.IPv6) + ipType = "IPv6" } if l3header == "ipv6inipv4" { flow.TxRx().Device().SetTxNames([]string{i1 + ".IPv4"}).SetRxNames([]string{i2 + ".IPv4"}) @@ -539,7 +541,7 @@ func (tc *testCase) testFlow(t *testing.T, l3header string) { v6.FlowLabel().SetValues(generateRandomFlowLabelList(250000)) v6.Src().SetValue(ateSrc.IPv6) v6.Dst().SetValue(ateDst.IPv6) - + ipType = "IPv6" } tcp := flow.Packet().Add().Tcp() @@ -548,6 +550,8 @@ func (tc *testCase) testFlow(t *testing.T, l3header string) { tc.ate.OTG().PushConfig(t, tc.top) tc.ate.OTG().StartProtocols(t) + otgutils.WaitForARP(t, tc.ate.OTG(), tc.top, ipType) + tc.verifyLAG(t) beforeTrafficCounters := tc.getCounters(t, "before") @@ -567,7 +571,6 @@ func (tc *testCase) testFlow(t *testing.T, l3header string) { } afterTrafficCounters := tc.getCounters(t, "after") tc.verifyCounterDiff(t, beforeTrafficCounters, afterTrafficCounters) - } func (tc *testCase) getCounters(t *testing.T, when string) map[string]*oc.Interface_Counters { diff --git a/feature/platform/integrated_circuit/otg_tests/utilization_test/utilization_test.go b/feature/platform/integrated_circuit/otg_tests/utilization_test/utilization_test.go index 792ba60587c..3cc22db7bf5 100644 --- a/feature/platform/integrated_circuit/otg_tests/utilization_test/utilization_test.go +++ b/feature/platform/integrated_circuit/otg_tests/utilization_test/utilization_test.go @@ -22,6 +22,7 @@ import ( "github.com/openconfig/featureprofiles/internal/attrs" "github.com/openconfig/featureprofiles/internal/deviations" "github.com/openconfig/featureprofiles/internal/fptest" + "github.com/openconfig/featureprofiles/internal/otgutils" "github.com/openconfig/ondatra" "github.com/openconfig/ondatra/gnmi" "github.com/openconfig/ondatra/gnmi/oc" @@ -315,6 +316,8 @@ func configureOTG(t *testing.T, otg *otg.OTG) (gosnappi.BgpV6Peer, gosnappi.Devi otg.StartProtocols(t) time.Sleep(30 * time.Second) + otgutils.WaitForARP(t, otg, config, "IPv4") + return iDut1Bgp6Peer, iDut1Ipv6, config }