From f9855b42c0c73ecc87a4cb5e1f306d04ff918f17 Mon Sep 17 00:00:00 2001 From: mojiiba Date: Wed, 12 Oct 2022 01:14:28 -0400 Subject: [PATCH 1/4] add InterfaceOperStatus deviation --- .../aggregate/ate_tests/aggregate_test/aggregate_test.go | 3 +++ internal/deviations/deviations.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/feature/interface/aggregate/ate_tests/aggregate_test/aggregate_test.go b/feature/interface/aggregate/ate_tests/aggregate_test/aggregate_test.go index 661b95fb43d..1b263f69a58 100644 --- a/feature/interface/aggregate/ate_tests/aggregate_test/aggregate_test.go +++ b/feature/interface/aggregate/ate_tests/aggregate_test/aggregate_test.go @@ -392,6 +392,9 @@ func (tc *testCase) verifyMinLinks(t *testing.T) { dip.OperStatus().Await(t, time.Minute, opDown) t.Log("Port is down.") } + if *deviations.InterfaceOperStatus && tf.want == telemetry.Interface_OperStatus_LOWER_LAYER_DOWN { + tf.want = opDown + } tc.dut.Telemetry().Interface(tc.aggID).OperStatus().Await(t, 1*time.Minute, tf.want) }) } diff --git a/internal/deviations/deviations.go b/internal/deviations/deviations.go index b143f45262c..027e851b420 100644 --- a/internal/deviations/deviations.go +++ b/internal/deviations/deviations.go @@ -69,6 +69,9 @@ import "flag" var ( InterfaceEnabled = flag.Bool("deviation_interface_enabled", false, "Device requires interface enabled leaf booleans to be explicitly set to true. Full OpenConfig compliant devices should pass both with and without this deviation.") + + InterfaceOperStatus = flag.Bool("deviation_interface_operstatus", false, + "Device generates Interface_OperStatus_DOWN instead of Interface_OperStatus_LOWER_LAYER_DOWN for an aggregated link.") AggregateAtomicUpdate = flag.Bool("deviation_aggregate_atomic_update", false, "Device requires that aggregate Port-Channel and its members be defined in a single gNMI Update transaction at /interfaces; otherwise lag-type will be dropped, and no member can be added to the aggregate. Full OpenConfig compliant devices should pass both with and without this deviation.") From ce700b375d1ee521b751b43820625c01b9d59035 Mon Sep 17 00:00:00 2001 From: mojiiba Date: Wed, 12 Oct 2022 18:24:59 -0400 Subject: [PATCH 2/4] Revert "add InterfaceOperStatus deviation" This reverts commit f9855b42c0c73ecc87a4cb5e1f306d04ff918f17. --- .../aggregate/ate_tests/aggregate_test/aggregate_test.go | 3 --- internal/deviations/deviations.go | 3 --- 2 files changed, 6 deletions(-) diff --git a/feature/interface/aggregate/ate_tests/aggregate_test/aggregate_test.go b/feature/interface/aggregate/ate_tests/aggregate_test/aggregate_test.go index 1b263f69a58..661b95fb43d 100644 --- a/feature/interface/aggregate/ate_tests/aggregate_test/aggregate_test.go +++ b/feature/interface/aggregate/ate_tests/aggregate_test/aggregate_test.go @@ -392,9 +392,6 @@ func (tc *testCase) verifyMinLinks(t *testing.T) { dip.OperStatus().Await(t, time.Minute, opDown) t.Log("Port is down.") } - if *deviations.InterfaceOperStatus && tf.want == telemetry.Interface_OperStatus_LOWER_LAYER_DOWN { - tf.want = opDown - } tc.dut.Telemetry().Interface(tc.aggID).OperStatus().Await(t, 1*time.Minute, tf.want) }) } diff --git a/internal/deviations/deviations.go b/internal/deviations/deviations.go index 027e851b420..b143f45262c 100644 --- a/internal/deviations/deviations.go +++ b/internal/deviations/deviations.go @@ -69,9 +69,6 @@ import "flag" var ( InterfaceEnabled = flag.Bool("deviation_interface_enabled", false, "Device requires interface enabled leaf booleans to be explicitly set to true. Full OpenConfig compliant devices should pass both with and without this deviation.") - - InterfaceOperStatus = flag.Bool("deviation_interface_operstatus", false, - "Device generates Interface_OperStatus_DOWN instead of Interface_OperStatus_LOWER_LAYER_DOWN for an aggregated link.") AggregateAtomicUpdate = flag.Bool("deviation_aggregate_atomic_update", false, "Device requires that aggregate Port-Channel and its members be defined in a single gNMI Update transaction at /interfaces; otherwise lag-type will be dropped, and no member can be added to the aggregate. Full OpenConfig compliant devices should pass both with and without this deviation.") From af1f08876671737b32dc6dcfe01333b451b265b6 Mon Sep 17 00:00:00 2001 From: mojiiba Date: Wed, 26 Oct 2022 16:32:15 -0400 Subject: [PATCH 3/4] status test is passing --- .../chassis_reboot_status_and_cancel_test.go | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/feature/gnoi/system/tests/chassis_reboot_status_and_cancel_test/chassis_reboot_status_and_cancel_test.go b/feature/gnoi/system/tests/chassis_reboot_status_and_cancel_test/chassis_reboot_status_and_cancel_test.go index 5410fb09598..a3295d951f5 100644 --- a/feature/gnoi/system/tests/chassis_reboot_status_and_cancel_test/chassis_reboot_status_and_cancel_test.go +++ b/feature/gnoi/system/tests/chassis_reboot_status_and_cancel_test/chassis_reboot_status_and_cancel_test.go @@ -20,6 +20,7 @@ import ( "github.com/openconfig/featureprofiles/internal/fptest" spb "github.com/openconfig/gnoi/system" + tpb "github.com/openconfig/gnoi/types" "github.com/openconfig/ondatra" ) @@ -93,8 +94,16 @@ func TestRebootStatus(t *testing.T) { t.Fatalf("Failed to request reboot with unexpected err: %v", err) } } + statusReq := &spb.RebootStatusRequest{ + Subcomponents: []*tpb.Path{ + { + Origin: "openconfig", + Elem: []*tpb.PathElem{{Name: "components"}, {Name: "component", Key: map[string]string{"name": "0/RP0/CPU0"}}}, + }, + }, + } - resp, err := gnoiClient.System().RebootStatus(context.Background(), &spb.RebootStatusRequest{}) + resp, err := gnoiClient.System().RebootStatus(context.Background(), statusReq) t.Logf("DUT rebootStatus: %v, err: %v", resp, err) if err != nil { t.Fatalf("Failed to get reboot status with unexpected err: %v", err) @@ -117,6 +126,7 @@ func TestRebootStatus(t *testing.T) { }) t.Logf("Cancel reboot request after the test") + rebootCancel, err := gnoiClient.System().CancelReboot(context.Background(), &spb.CancelRebootRequest{}) if err != nil { t.Fatalf("Failed to cancel reboot with unexpected err: %v", err) @@ -149,8 +159,15 @@ func TestCancelReboot(t *testing.T) { if err != nil { t.Fatalf("Failed to request reboot with unexpected err: %v", err) } - - rebootStatus, err := gnoiClient.System().RebootStatus(context.Background(), &spb.RebootStatusRequest{}) + statusReq := &spb.RebootStatusRequest{ + Subcomponents: []*tpb.Path{ + { + Origin: "openconfig", + Elem: []*tpb.PathElem{{Name: "components"}, {Name: "component", Key: map[string]string{"name": "0/RP0/CPU0"}}}, + }, + }, + } + rebootStatus, err := gnoiClient.System().RebootStatus(context.Background(), statusReq) t.Logf("DUT rebootStatus: %v, err: %v", rebootStatus, err) if err != nil { t.Fatalf("Failed to get reboot status with unexpected err: %v", err) @@ -166,7 +183,7 @@ func TestCancelReboot(t *testing.T) { t.Fatalf("Failed to cancel reboot with unexpected err: %v", err) } - rebootStatus, err = gnoiClient.System().RebootStatus(context.Background(), &spb.RebootStatusRequest{}) + rebootStatus, err = gnoiClient.System().RebootStatus(context.Background(), statusReq) t.Logf("DUT rebootStatus: %v, err: %v", rebootStatus, err) if err != nil { t.Fatalf("Failed to get reboot status with unexpected err: %v", err) From a33bd37a42827de92e5763720f54a5d30771e85f Mon Sep 17 00:00:00 2001 From: mojiiba Date: Sat, 29 Oct 2022 01:47:26 -0400 Subject: [PATCH 4/4] fix gnoi path and subcomponent name for reboot status --- .../chassis_reboot_status_and_cancel_test.go | 36 +++++++++++-------- internal/components/components.go | 18 ++++++++++ internal/deviations/deviations.go | 4 +++ 3 files changed, 43 insertions(+), 15 deletions(-) diff --git a/feature/gnoi/system/tests/chassis_reboot_status_and_cancel_test/chassis_reboot_status_and_cancel_test.go b/feature/gnoi/system/tests/chassis_reboot_status_and_cancel_test/chassis_reboot_status_and_cancel_test.go index a3295d951f5..bdc396351fd 100644 --- a/feature/gnoi/system/tests/chassis_reboot_status_and_cancel_test/chassis_reboot_status_and_cancel_test.go +++ b/feature/gnoi/system/tests/chassis_reboot_status_and_cancel_test/chassis_reboot_status_and_cancel_test.go @@ -18,10 +18,13 @@ import ( "context" "testing" + "github.com/openconfig/featureprofiles/internal/components" + "github.com/openconfig/featureprofiles/internal/deviations" "github.com/openconfig/featureprofiles/internal/fptest" spb "github.com/openconfig/gnoi/system" tpb "github.com/openconfig/gnoi/types" "github.com/openconfig/ondatra" + "github.com/openconfig/ondatra/telemetry" ) const ( @@ -84,6 +87,16 @@ func TestRebootStatus(t *testing.T) { }, } + statusReq := &spb.RebootStatusRequest{Subcomponents: []*tpb.Path{}} + if !*deviations.GNOIStatusWithEmptySubcomponent { + supervisors := components.FindComponentsByType(t, dut, telemetry.PlatformTypes_OPENCONFIG_HARDWARE_COMPONENT_CONTROLLER_CARD) + // the test reboots the chasis, so any subcomponent should be ok to check the status + statusReq = &spb.RebootStatusRequest{ + Subcomponents: []*tpb.Path{ + components.GetSubcomponentPath(supervisors[0]), + }, + } + } for _, tc := range cases { t.Run(tc.desc, func(t *testing.T) { if tc.rebootRequest != nil { @@ -94,15 +107,6 @@ func TestRebootStatus(t *testing.T) { t.Fatalf("Failed to request reboot with unexpected err: %v", err) } } - statusReq := &spb.RebootStatusRequest{ - Subcomponents: []*tpb.Path{ - { - Origin: "openconfig", - Elem: []*tpb.PathElem{{Name: "components"}, {Name: "component", Key: map[string]string{"name": "0/RP0/CPU0"}}}, - }, - }, - } - resp, err := gnoiClient.System().RebootStatus(context.Background(), statusReq) t.Logf("DUT rebootStatus: %v, err: %v", resp, err) if err != nil { @@ -159,13 +163,15 @@ func TestCancelReboot(t *testing.T) { if err != nil { t.Fatalf("Failed to request reboot with unexpected err: %v", err) } - statusReq := &spb.RebootStatusRequest{ - Subcomponents: []*tpb.Path{ - { - Origin: "openconfig", - Elem: []*tpb.PathElem{{Name: "components"}, {Name: "component", Key: map[string]string{"name": "0/RP0/CPU0"}}}, + statusReq := &spb.RebootStatusRequest{Subcomponents: []*tpb.Path{}} + if !*deviations.GNOIStatusWithEmptySubcomponent { + supervisors := components.FindComponentsByType(t, dut, telemetry.PlatformTypes_OPENCONFIG_HARDWARE_COMPONENT_CONTROLLER_CARD) + // the test reboots the chasis, so any subcomponent should be ok to check the status + statusReq = &spb.RebootStatusRequest{ + Subcomponents: []*tpb.Path{ + components.GetSubcomponentPath(supervisors[0]), }, - }, + } } rebootStatus, err := gnoiClient.System().RebootStatus(context.Background(), statusReq) t.Logf("DUT rebootStatus: %v, err: %v", rebootStatus, err) diff --git a/internal/components/components.go b/internal/components/components.go index 381a52acffe..82f03ac3f0e 100644 --- a/internal/components/components.go +++ b/internal/components/components.go @@ -19,6 +19,8 @@ import ( "regexp" "testing" + "github.com/openconfig/featureprofiles/internal/deviations" + tpb "github.com/openconfig/gnoi/types" "github.com/openconfig/ondatra" "github.com/openconfig/ondatra/telemetry" ) @@ -57,3 +59,19 @@ func FindMatchingStrings(components []string, r *regexp.Regexp) []string { } return s } + +// GetSubcomponentPath creates a gNMI path based on the componnent name. +func GetSubcomponentPath(name string) *tpb.Path { + if *deviations.GNOISubcomponentPath { + return &tpb.Path{ + Elem: []*tpb.PathElem{{Name: name}}, + } + } + return &tpb.Path{ + Origin: "openconfig", + Elem: []*tpb.PathElem{ + {Name: "components"}, + {Name: "component", Key: map[string]string{"name": name}}, + }, + } +} diff --git a/internal/deviations/deviations.go b/internal/deviations/deviations.go index 63b2afac966..a4678c17e52 100644 --- a/internal/deviations/deviations.go +++ b/internal/deviations/deviations.go @@ -96,4 +96,8 @@ var ( NextHopAFTNotSupported = flag.Bool("deviation_nexthop_aft_not_supported", false, "Device currently doesnot support AFT Next Hop Telemetry. A fully compliant device should support all types of AFT telemetry without this deviation.") StaticProtocolName = flag.String("deviation_static_protocol_name", "DEFAULT", "The name used for the static routing protocol. The default name in OpenConfig is \"DEFAULT\" but some devices use other names.") + + GNOISubcomponentPath = flag.Bool("deviation_gnoi_subcomponent_path", false, "Device currently uses component name instead of a full openconfig path, so suppress creating a full oc compliant path for subcomponent.") + + GNOIStatusWithEmptySubcomponent = flag.Bool("deviation_gnoi_status_empty_subcomponent", false, "The response of gNOI reboot status is a single value (not a list), so the device requires explict component path to account for a situation when there is more than one active reboot requests.") )