Skip to content

Commit e811808

Browse files
author
Hammad Khan (hammadkh)
committed
plq tolerance
1 parent 44b589c commit e811808

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

feature/gnoi/packet_link_qualification/tests/packet_link_qualification_test/packet_link_qualification_test.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ func testLinkQualification(t *testing.T, dut *ondatra.DUTDevice, dp1 *ondatra.Po
562562
t.Fatalf("Failed to handle LinkQualification().Get(): %v", err)
563563
}
564564

565-
// The packet counters between Generator and Reflector mismatch tolerance level in percentage.
565+
// The packet counters between Generator and Reflector mismatch tolerance level in percentage
566566
tolerance := 0.0001
567567

568568
for _, result := range getResp.GetResults() {
@@ -572,17 +572,14 @@ func testLinkQualification(t *testing.T, dut *ondatra.DUTDevice, dp1 *ondatra.Po
572572
if got, want := result.GetState(), plqpb.QualificationState_QUALIFICATION_STATE_COMPLETED; got != want {
573573
t.Errorf("result.GetState(): got %v, want %v", got, want)
574574
}
575-
576-
// Apply tolerance-based checks for packets error and dropped only when
577-
// packets were sent, as reflector results report 0 packets sent.
575+
if got, want := result.GetPacketsError(), uint64(0); got != want {
576+
t.Errorf("result.GetPacketsError(): got %v, want %v", got, want)
577+
}
578578
if result.GetPacketsSent() > 0 {
579-
if (float64(result.GetPacketsError())/float64(result.GetPacketsSent()))*100.00 > tolerance {
580-
t.Errorf("result.GetPacketsError() greater than %0.4f percent: got %v, packetsSent %v",
581-
tolerance, result.GetPacketsError(), result.GetPacketsSent())
582-
}
583-
if (float64(result.GetPacketsDropped())/float64(result.GetPacketsSent()))*100.00 > tolerance {
584-
t.Errorf("result.GetPacketsDropped() greater than %0.4f percent: got %v, packetsSent %v",
585-
tolerance, result.GetPacketsDropped(), result.GetPacketsSent())
579+
droppedPct := (float64(result.GetPacketsDropped()) / float64(result.GetPacketsSent())) * 100.0
580+
if droppedPct > tolerance {
581+
t.Errorf("result.GetPacketsDropped(): got %v (%.6f%%), want <= %.4f%% of packets sent (%v)",
582+
result.GetPacketsDropped(), droppedPct, tolerance, result.GetPacketsSent())
586583
}
587584
}
588585

0 commit comments

Comments
 (0)