Skip to content

Commit

Permalink
packet_link_qual test - add packet counters mismatch tolerance in com…
Browse files Browse the repository at this point in the history
…parison (openconfig#1891)
  • Loading branch information
gforeal authored Jul 28, 2023
1 parent 7ac614e commit 8586dab
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package packet_link_qualification_test

import (
"context"
"math"
"testing"
"time"

Expand Down Expand Up @@ -396,12 +397,14 @@ func TestLinkQualification(t *testing.T) {
}
}

// The packet counters between Generator and Reflector mismatch tolerance level in percentage
var tolerance float64 = 0.0001
if !deviations.SkipPLQPacketsCountCheck(dut1) {
if generatorPktsSent != reflectorPktsRxed {
t.Errorf("Packets received count at Reflector is not matching the packets sent count at Generator: generatorPktsSent %v, reflectorPktsRxed %v", generatorPktsSent, reflectorPktsRxed)
if ((math.Abs(float64(generatorPktsSent)-float64(reflectorPktsRxed)))/(float64(generatorPktsSent)+float64(reflectorPktsRxed)+tolerance))*200.00 > tolerance {
t.Errorf("The difference between packets received count at Reflector and packets sent count at Generator is greater than %0.4f percent: generatorPktsSent %v, reflectorPktsRxed %v", tolerance, generatorPktsSent, reflectorPktsRxed)
}
if reflectorPktsSent != generatorPktsRxed {
t.Errorf("Packets received count at Generator is not matching the packets sent count at Reflector: reflectorPktsSent %v, generatorPktsRxed %v", reflectorPktsSent, generatorPktsRxed)
if ((math.Abs(float64(reflectorPktsSent)-float64(generatorPktsRxed)))/(float64(reflectorPktsSent)+float64(generatorPktsRxed)+tolerance))*200.00 > tolerance {
t.Errorf("The difference between packets received count at Generator and packets sent count at Reflector is greater than %0.4f percent: reflectorPktsSent %v, generatorPktsRxed %v", tolerance, reflectorPktsSent, generatorPktsRxed)
}
}

Expand Down

0 comments on commit 8586dab

Please sign in to comment.