Skip to content

Commit

Permalink
Changes for plq test (openconfig#2341)
Browse files Browse the repository at this point in the history
* Changes for plq test

* Reverting changes for error handling

* Resolve merge conflicts

* Resolve deviation conflict

---------

Co-authored-by: root <s-nandu>
Co-authored-by: Arul Kumar Sekar <[email protected]>
  • Loading branch information
s-nandu and arulkumarsekar authored Nov 17, 2023
1 parent 9bf4216 commit 7033cc5
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ platform_exceptions: {
vendor: JUNIPER
}
deviations: {
skip_plq_packets_count_check: true
skip_plq_interface_oper_status_check: true
}
}
platform_exceptions: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,11 @@ func TestLinkQualification(t *testing.T) {
plqID := dut1.Name() + ":" + dp1.Name() + "<->" + dut2.Name() + ":" + dp2.Name()
type LinkQualificationDuration struct {
// time needed to complete preparation
setupDuration time.Duration
generatorsetupDuration time.Duration
reflectorsetupDuration time.Duration
// time duration to wait before starting link qual preparation
preSyncDuration time.Duration
generatorpreSyncDuration time.Duration
reflectorpreSyncDuration time.Duration
// packet linkqual duration
testDuration time.Duration
// time to wait post link-qual before starting teardown
Expand All @@ -245,8 +247,10 @@ func TestLinkQualification(t *testing.T) {
tearDownDuration time.Duration
}
plqDuration := &LinkQualificationDuration{
preSyncDuration: 30 * time.Second,
setupDuration: 30 * time.Second,
generatorpreSyncDuration: 30 * time.Second,
reflectorpreSyncDuration: 0 * time.Second,
generatorsetupDuration: 30 * time.Second,
reflectorsetupDuration: 60 * time.Second,
testDuration: 120 * time.Second,
generatorPostSyncDuration: 5 * time.Second,
reflectorPostSyncDuration: 10 * time.Second,
Expand All @@ -267,8 +271,8 @@ func TestLinkQualification(t *testing.T) {
Timing: &plqpb.QualificationConfiguration_Rpc{
Rpc: &plqpb.RPCSyncedTiming{
Duration: durationpb.New(plqDuration.testDuration),
PreSyncDuration: durationpb.New(plqDuration.preSyncDuration),
SetupDuration: durationpb.New(plqDuration.setupDuration),
PreSyncDuration: durationpb.New(plqDuration.generatorpreSyncDuration),
SetupDuration: durationpb.New(plqDuration.generatorsetupDuration),
PostSyncDuration: durationpb.New(plqDuration.generatorPostSyncDuration),
TeardownDuration: durationpb.New(plqDuration.tearDownDuration),
},
Expand All @@ -285,8 +289,8 @@ func TestLinkQualification(t *testing.T) {
Timing: &plqpb.QualificationConfiguration_Rpc{
Rpc: &plqpb.RPCSyncedTiming{
Duration: durationpb.New(plqDuration.testDuration),
PreSyncDuration: durationpb.New(plqDuration.preSyncDuration),
SetupDuration: durationpb.New(plqDuration.setupDuration),
PreSyncDuration: durationpb.New(plqDuration.reflectorpreSyncDuration),
SetupDuration: durationpb.New(plqDuration.reflectorsetupDuration),
PostSyncDuration: durationpb.New(plqDuration.reflectorPostSyncDuration),
TeardownDuration: durationpb.New(plqDuration.tearDownDuration),
},
Expand Down Expand Up @@ -331,7 +335,7 @@ func TestLinkQualification(t *testing.T) {
}

sleepTime := 30 * time.Second
minTestTime := plqDuration.testDuration + plqDuration.reflectorPostSyncDuration + plqDuration.preSyncDuration + plqDuration.setupDuration + plqDuration.tearDownDuration
minTestTime := plqDuration.testDuration + plqDuration.reflectorPostSyncDuration + plqDuration.generatorpreSyncDuration + plqDuration.generatorsetupDuration + plqDuration.tearDownDuration
counter := int(minTestTime.Seconds())/int(sleepTime.Seconds()) + 2
for i := 0; i <= counter; i++ {
t.Logf("Wait for %v seconds: %d/%d", sleepTime.Seconds(), i+1, counter)
Expand All @@ -350,16 +354,18 @@ func TestLinkQualification(t *testing.T) {
if listResp.GetResults()[j].GetState() != plqpb.QualificationState_QUALIFICATION_STATE_COMPLETED {
testDone = false
}
if listResp.GetResults()[j].GetState() == plqpb.QualificationState_QUALIFICATION_STATE_RUNNING {
if client == gnoiClient1 {
t.Logf("Checking link under qualificaton (generator) interface oper-status (dut: %v, dp: %v)", dut1.Name(), dp1.Name())
if got, want := gnmi.Get(t, dut1, gnmi.OC().Interface(dp1.Name()).OperStatus().State()), oc.Interface_OperStatus_TESTING; got != want {
t.Errorf("Interface(%v) oper-status: got %v, want %v", dp1.Name(), got, oc.Interface_OperStatus_TESTING)
}
} else if client == gnoiClient2 {
t.Logf("Checking link under qualificaton (reflector) interface oper-status (dut: %v, dp: %v)", dut2.Name(), dp2.Name())
if got, want := gnmi.Get(t, dut2, gnmi.OC().Interface(dp2.Name()).OperStatus().State()), oc.Interface_OperStatus_TESTING; got != want {
t.Errorf("Interface(%v) oper-status: got %v, want %v", dp2.Name(), got, oc.Interface_OperStatus_TESTING)
if !deviations.SkipPlqInterfaceOperStatusCheck(dut1) {
if listResp.GetResults()[j].GetState() == plqpb.QualificationState_QUALIFICATION_STATE_RUNNING {
if client == gnoiClient1 {
t.Logf("Checking link under qualificaton (generator) interface oper-status (dut: %v, dp: %v)", dut1.Name(), dp1.Name())
if got, want := gnmi.Get(t, dut1, gnmi.OC().Interface(dp1.Name()).OperStatus().State()), oc.Interface_OperStatus_TESTING; got != want {
t.Errorf("Interface(%v) oper-status: got %v, want %v", dp1.Name(), got, oc.Interface_OperStatus_TESTING)
}
} else if client == gnoiClient2 {
t.Logf("Checking link under qualificaton (reflector) interface oper-status (dut: %v, dp: %v)", dut2.Name(), dp2.Name())
if got, want := gnmi.Get(t, dut2, gnmi.OC().Interface(dp2.Name()).OperStatus().State()), oc.Interface_OperStatus_TESTING; got != want {
t.Errorf("Interface(%v) oper-status: got %v, want %v", dp2.Name(), got, oc.Interface_OperStatus_TESTING)
}
}
}
}
Expand Down Expand Up @@ -415,13 +421,12 @@ 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 ((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 ((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)
}

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 ((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)
}

}
12 changes: 6 additions & 6 deletions internal/deviations/deviations.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,12 +454,6 @@ func NtpNonDefaultVrfUnsupported(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetNtpNonDefaultVrfUnsupported()
}

// SkipPLQPacketsCountCheck returns if PLQ packets count check should be skipped.
// Default value is false.
func SkipPLQPacketsCountCheck(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetSkipPlqPacketsCountCheck()
}

// SkipControllerCardPowerAdmin returns if power-admin-state config on controller card should be skipped.
// Default value is false.
func SkipControllerCardPowerAdmin(dut *ondatra.DUTDevice) bool {
Expand Down Expand Up @@ -685,3 +679,9 @@ func ISISLevelEnabled(dut *ondatra.DUTDevice) bool {
func MemberLinkLoopbackUnsupported(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetMemberLinkLoopbackUnsupported()
}

// SkipPlqInterfaceOperStatusCheck returns true for devices that do not support
// PLQ operational status check for interfaces
func SkipPlqInterfaceOperStatusCheck(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetSkipPlqInterfaceOperStatusCheck()
}
9 changes: 5 additions & 4 deletions proto/metadata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,6 @@ message Metadata {
bool omit_l2_mtu = 50;
// Skip power admin for controller card
bool skip_controller_card_power_admin = 51;
// Skip PLQ packets count check.
bool skip_plq_packets_count_check = 55;
// Device requires the banner to have a delimiter character.
string banner_delimiter = 60;
// Allowed tolerance for BGP traffic flow while comparing for pass or fail
Expand Down Expand Up @@ -364,9 +362,12 @@ message Metadata {
// Devices does not support member link loopback
// Juniper: b/307763669
bool member_link_loopback_unsupported = 125;

// Device does not support PLQ operational status check on interface
// Juniper: b/308990185
bool skip_plq_interface_oper_status_check = 126;

// Reserved field numbers and identifiers.
reserved 84, 9, 28, 20, 90, 97;
reserved 84, 9, 28, 20, 90, 97, 55;
}

message PlatformExceptions {
Expand Down
Loading

0 comments on commit 7033cc5

Please sign in to comment.