Skip to content

Commit

Permalink
fixed test flakiness for balancing test (#2561)
Browse files Browse the repository at this point in the history
  • Loading branch information
self-maurya authored Jan 22, 2024
1 parent d0474b3 commit fb4ad69
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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()
Expand All @@ -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"})
Expand All @@ -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()
Expand All @@ -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")
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit fb4ad69

Please sign in to comment.