Skip to content
Open
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@

const (
prefixesStart = "2001:db8:1::1"
prefixP6Len = 128
prefixesCount = 1
pathID = 1
defaultRoute = "0:0:0:0:0:0:0:0"
ateNetPrefix = "2001:0db8::192:0:3:1"
timeout = 10 * time.Second
)

var (
Expand Down Expand Up @@ -175,7 +174,8 @@
// Disable port1 to force traffic to port2
gnmi.Replace(t, dut, gnmi.OC().Interface(p1.Name()).Enabled().Config(), false)
gnmi.Await(t, dut, gnmi.OC().Interface(p1.Name()).OperStatus().State(), 1*time.Minute, oc.Interface_OperStatus_DOWN)
time.Sleep(10 * time.Second)
t.Logf("sleeping for %v to ensure DUT has aged out ARP entry for port1", timeout)
time.Sleep(timeout)

bs.ATE.OTG().StartTraffic(t)
time.Sleep(30 * time.Second)
Expand All @@ -186,7 +186,7 @@
framesRx := gnmi.Get(t, bs.ATE.OTG(), gnmi.OTG().Port(bs.ATE.Port(t, "port2").ID()).Counters().InFrames().State())
lossV6 := otgutils.GetFlowLossPct(t, bs.ATE.OTG(), "v6Flow", 10*time.Second)
t.Logf("Frames sent/received: got: %d, want: %d, loss: %f", framesRx, framesTx, lossV6)
if lossV6 > lossTolerance || framesRx < framesTx {
if lossV6 > lossTolerance {
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

With the simplification of the loss check, the manually fetched port counters framesRx and framesTx (lines 185-186) are now only used for the error message. However, these values are fetched before otgutils.GetFlowLossPct completes its internal wait for the flow to stop, meaning they may not accurately reflect the final state used for the loss calculation. It is recommended to use the flow counters returned by otgutils.GetFlowStats or simply report the loss percentage in the error message for consistency with other subtests (e.g., line 165).

References
  1. In test suites, maintaining a consistent code style across similar tests is preferred, even if it means not renaming variables that shadow package names.

t.Errorf("Frames sent/received: got: %d, want: %d", framesRx, framesTx)
}
})
Expand All @@ -201,7 +201,8 @@
gnmi.Replace(t, dut, gnmi.OC().Interface(p2.Name()).Enabled().Config(), false)
gnmi.Await(t, dut, gnmi.OC().Interface(p1.Name()).OperStatus().State(), 1*time.Minute, oc.Interface_OperStatus_DOWN)
gnmi.Await(t, dut, gnmi.OC().Interface(p2.Name()).OperStatus().State(), 1*time.Minute, oc.Interface_OperStatus_DOWN)
time.Sleep(10 * time.Second)
t.Logf("sleeping for %v to ensure DUT has aged out ARP entry for port1 and port2", timeout)
time.Sleep(timeout)

bs.ATE.OTG().StartTraffic(t)
time.Sleep(30 * time.Second)
Expand All @@ -210,7 +211,8 @@
otgutils.LogPortMetrics(t, bs.ATE.OTG(), bs.ATETop)
framesTx := gnmi.Get(t, bs.ATE.OTG(), gnmi.OTG().Port(bs.ATE.Port(t, "port4").ID()).Counters().OutFrames().State())
framesRx := gnmi.Get(t, bs.ATE.OTG(), gnmi.OTG().Port(bs.ATE.Port(t, "port3").ID()).Counters().InFrames().State())
if lossPct(float64(framesTx), float64(framesRx)) > lossTolerance {
lossV6 := otgutils.GetFlowLossPct(t, bs.ATE.OTG(), "v6Flow", 10*time.Second)
if lossV6 > lossTolerance {
Comment thread
fmolinar marked this conversation as resolved.
Outdated
t.Errorf("Frames sent/received: got: %d, want: %d", framesRx, framesTx)
}
})
Expand All @@ -223,7 +225,8 @@
// Disable Port 2 to force traffic to Port 1
gnmi.Replace(t, dut, gnmi.OC().Interface(p2.Name()).Enabled().Config(), false)
gnmi.Await(t, dut, gnmi.OC().Interface(p2.Name()).OperStatus().State(), 1*time.Minute, oc.Interface_OperStatus_DOWN)
time.Sleep(5 * time.Second)
t.Logf("sleeping for %v to ensure DUT has aged out ARP entry for port1 and port2", timeout)
Comment thread
karthikeya-remilla marked this conversation as resolved.
Outdated
time.Sleep(timeout)

bs.ATE.OTG().StartTraffic(t)
time.Sleep(30 * time.Second)
Expand All @@ -233,7 +236,7 @@
framesTx := gnmi.Get(t, bs.ATE.OTG(), gnmi.OTG().Port(bs.ATE.Port(t, "port4").ID()).Counters().OutFrames().State())
framesRx := gnmi.Get(t, bs.ATE.OTG(), gnmi.OTG().Port(bs.ATE.Port(t, "port1").ID()).Counters().InFrames().State())
lossV6 := otgutils.GetFlowLossPct(t, bs.ATE.OTG(), "v6Flow", 10*time.Second)
if lossV6 > lossTolerance || framesRx < framesTx {
if lossV6 > lossTolerance {
t.Errorf("Frames sent/received: got: %d, want: %d", framesRx, framesTx)
}
})
Expand Down Expand Up @@ -304,7 +307,6 @@
bgp6PeerRoute.SetNextHopMode(gosnappi.BgpV6RouteRangeNextHopMode.MANUAL)
bgp6PeerRoute.AddPath().SetPathId(pathID)

bgp6PeerRoute.Addresses().Add().SetAddress(prefixesStart).SetPrefix(prefixP6Len).SetCount(prefixesCount)
bgp6PeerRoute.Addresses().Add().SetAddress(defaultRoute).SetPrefix(0)
}
}
Expand Down Expand Up @@ -470,7 +472,7 @@
batchSet.Set(t, bs.DUT)
}

func lossPct(tx, rx float64) float64 {

Check failure on line 475 in feature/system/management/otg_tests/management_ha_test/management_ha_test.go

View workflow job for this annotation

GitHub Actions / Static Analysis

func lossPct is unused (U1000)
return (math.Abs(tx-rx) * 100) / tx
}

Expand Down
Loading