Skip to content

Commit

Permalink
Merge branch 'main' into gnmi-1.4-fixdeviations
Browse files Browse the repository at this point in the history
  • Loading branch information
LimeHat authored Aug 12, 2024
2 parents 70879c3 + 67b6781 commit 36b3750
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ platform_exceptions: {
skip_set_rp_match_set_options: true
bgp_community_set_refs_unsupported: true
bgp_conditions_match_community_set_unsupported: true
skip_prefix_set_mode: true
bgp_community_member_is_a_string: true
skip_bgp_send_community_type: true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@ uuid: "619040ac-21a0-403f-b38e-6d5d0aed433a"
plan_id: "RT-1.53"
description: "prefix-list test"
testbed: TESTBED_DUT
platform_exceptions: {
platform: {
vendor: NOKIA
}
deviations: {
skip_prefix_set_mode: true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"testing"

"github.com/openconfig/featureprofiles/internal/deviations"
"github.com/openconfig/featureprofiles/internal/fptest"
"github.com/openconfig/featureprofiles/internal/helpers"
"github.com/openconfig/ondatra"
Expand Down Expand Up @@ -47,7 +48,9 @@ func TestPrefixSet(t *testing.T) {

// create a prefix-set with 2 prefixes
v4PrefixSet := ds.GetOrCreatePrefixSet(prefixSetA)
v4PrefixSet.SetMode(oc.PrefixSet_Mode_IPV4)
if !deviations.SkipPrefixSetMode(dut) {
v4PrefixSet.SetMode(oc.PrefixSet_Mode_IPV4)
}
v4PrefixSet.GetOrCreatePrefix(pfx1, mskLen)
v4PrefixSet.GetOrCreatePrefix(pfx2, mskLen)

Expand All @@ -64,9 +67,12 @@ func TestPrefixSet(t *testing.T) {

// replace the prefix-set by replacing an existing prefix with new prefix
v4PrefixSet = ds.GetOrCreatePrefixSet(prefixSetA)
v4PrefixSet.SetMode(oc.PrefixSet_Mode_IPV4)
if !deviations.SkipPrefixSetMode(dut) {
v4PrefixSet.SetMode(oc.PrefixSet_Mode_IPV4)
}
v4PrefixSet.GetOrCreatePrefix(pfx1, mskLen)
v4PrefixSet.GetOrCreatePrefix(pfx3, mskLen)
v4PrefixSet.DeletePrefix(pfx2, mskLen)

gnmi.Replace(t, dut, gnmi.OC().RoutingPolicy().DefinedSets().PrefixSet(prefixSetA).Config(), v4PrefixSet)
prefixSet = gnmi.Get[*oc.RoutingPolicy_DefinedSets_PrefixSet](t, dut, gnmi.OC().RoutingPolicy().DefinedSets().PrefixSet(prefixSetA).State())
Expand All @@ -81,10 +87,13 @@ func TestPrefixSet(t *testing.T) {

// replace the prefix-set with 2 existing and a new prefix
v4PrefixSet = ds.GetOrCreatePrefixSet(prefixSetA)
v4PrefixSet.SetMode(oc.PrefixSet_Mode_IPV4)
if !deviations.SkipPrefixSetMode(dut) {
v4PrefixSet.SetMode(oc.PrefixSet_Mode_IPV4)
}
v4PrefixSet.GetOrCreatePrefix(pfx1, mskLen)
v4PrefixSet.GetOrCreatePrefix(pfx3, mskLen)
v4PrefixSet.GetOrCreatePrefix(pfx4, mskLen)
v4PrefixSet.DeletePrefix(pfx2, mskLen)

gnmi.Replace(t, dut, gnmi.OC().RoutingPolicy().DefinedSets().PrefixSet(prefixSetA).Config(), v4PrefixSet)
prefixSet = gnmi.Get[*oc.RoutingPolicy_DefinedSets_PrefixSet](t, dut, gnmi.OC().RoutingPolicy().DefinedSets().PrefixSet(prefixSetA).State())
Expand Down
7 changes: 6 additions & 1 deletion feature/gnmi/subscribe/tests/gnmi_sample_mode_test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,15 @@ Test to validate basic gNMI streaming telemetry works with `SAMPLE` mode.

The below yaml defines the OC paths intended to be covered by this test. OC paths used for test setup are not listed here.

TODO(OCPATHS): Add paths

```yaml

paths:
## Config Paths ##
/interfaces/interface/config/description:

## State Paths ##
/interfaces/interface/state/description:

rpcs:
gnmi:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,14 @@ func TestGNMISampleMode(t *testing.T) {
p1Stream := samplestream.New(t, dut, gnmi.OC().Interface(p1.Name()).Description().State(), 10*time.Second)
defer p1Stream.Close()

desc := p1Stream.Next()
if desc == nil {
t.Errorf("Interface %q telemetry not received before config", p1.Name())
} else {
v, ok := desc.Val()
if !ok {
t.Errorf("Interface %q telemetry empty before config", p1.Name())
}
t.Logf("Description before config: %s", v)
}

gnmi.Replace(t, dut, gnmi.OC().Interface(p1.Name()).Config(), dutPort1.NewOCInterface(p1.Name(), dut))

desc = p1Stream.Next()
desc := p1Stream.Next()
if desc == nil {
t.Errorf("Interface %q telemetry not received after config", p1.Name())
} else {
v, ok := desc.Val()
t.Logf("Description from stream : %s", v)
if !ok {
t.Errorf("Interface %q telemetry empty after config", p1.Name())
}
Expand All @@ -69,6 +59,7 @@ func TestGNMISampleMode(t *testing.T) {
t.Errorf("Interface %q telemetry not received after description update", p1.Name())
} else {
v, ok := desc.Val()
t.Logf("Description from stream : %s", v)
if !ok {
t.Errorf("Interface %q telemetry empty after description update", p1.Name())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
uuid: "abcc6890-c3e1-4b0e-984e-749c85b54e5a"
plan_id: "gNMI-1.27"
description: "gNMI Sample Mode Test"
testbed: TESTBED_DUT
testbed: TESTBED_DUT_ATE_2LINKS
platform_exceptions: {
platform: {
vendor: ARISTA
Expand All @@ -18,3 +18,11 @@ platform_exceptions: {
isis_interface_afi_unsupported: true
}
}
platform_exceptions: {
platform: {
vendor: NOKIA
}
deviations: {
explicit_interface_in_default_vrf: true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ func addNHGReferencingToDownPort(tcArgs *testArgs, wantACK fluent.ProgrammingRes

tcArgs.client.Modify().AddEntry(t,
fluent.NextHopEntry().WithNetworkInstance(deviations.DefaultNetworkInstance(tcArgs.dut)).
WithIndex(2000).WithInterfaceRef(p.Name()).WithIPAddress(atePort2.IPv4),
WithIndex(2000).WithIPAddress(atePort2.IPv4),
fluent.NextHopGroupEntry().WithNetworkInstance(deviations.DefaultNetworkInstance(tcArgs.dut)).
WithID(2000).AddNextHop(2000, 1),
fluent.IPv4Entry().WithNetworkInstance(deviations.DefaultNetworkInstance(tcArgs.dut)).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,15 @@ func TestAggregateAllNotForwardingViable(t *testing.T) {
changeMetric(t, dut, aggIDs[2], 30)
top := configureATE(t, ate)
installGRIBIRoutes(t, dut, ate, top)
flows := createFlows(t, dut, top, aggIDs)
ate.OTG().PushConfig(t, top)
ate.OTG().StartProtocols(t)
for _, aggID := range aggIDs {
gnmi.Await(t, dut, gnmi.OC().Interface(aggID).OperStatus().State(), 30*time.Second, oc.Interface_OperStatus_UP)
gnmi.Await(t, dut, gnmi.OC().Interface(aggID).OperStatus().State(), 60*time.Second, oc.Interface_OperStatus_UP)
}

flows := createFlows(t, ate, top)
ate.OTG().PushConfig(t, top)
ate.OTG().StartProtocols(t)
for _, agg := range []*aggPortData{agg1, agg2, agg3} {
bgpPath := ocpath.Root().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Bgp()
gnmi.Await(t, dut, bgpPath.Neighbor(agg.ateIPv4).SessionState().State(), time.Minute, oc.Bgp_Neighbor_SessionState_ESTABLISHED)
Expand Down Expand Up @@ -215,7 +217,9 @@ func TestAggregateAllNotForwardingViable(t *testing.T) {
// Ensure ISIS Adjacency is Down on LAG_2

if ok := awaitAdjacency(t, dut, aggIDs[1], oc.Isis_IsisInterfaceAdjState_DOWN); !ok {
t.Fatal("ISIS Adjacency is Established on LAG_2")
if presence := gnmi.LookupAll(t, dut, ocpath.Root().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_ISIS, isisInstance).Isis().Interface(aggIDs[1]).LevelAny().AdjacencyAny().AdjacencyState().State()); len(presence) > 0 {
t.Fatalf("ISIS Adjacency is Established on LAG_2 ")
}
}
startTraffic(t, dut, ate, top)
if err := confirmNonViableForwardingTraffic(t, dut, ate, atePortList[1:agg2.ateLagCount+1], dutPortList[1:agg2.ateLagCount+1]); err != nil {
Expand Down Expand Up @@ -292,7 +296,9 @@ func TestAggregateAllNotForwardingViable(t *testing.T) {
configForwardingViable(t, dut, dutPortList[1:2], false)
// Ensure ISIS Adjacency is Down on LAG_2
if ok := awaitAdjacency(t, dut, aggIDs[1], oc.Isis_IsisInterfaceAdjState_DOWN); !ok {
t.Fatal("ISIS Adjacency is Established on LAG_2")
if presence := gnmi.LookupAll(t, dut, ocpath.Root().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_ISIS, isisInstance).Isis().Interface(aggIDs[1]).LevelAny().AdjacencyAny().AdjacencyState().State()); len(presence) > 0 {
t.Fatalf("ISIS Adjacency is Established on LAG_2")
}
}
startTraffic(t, dut, ate, top)
if err := confirmNonViableForwardingTraffic(t, dut, ate, atePortList[1:(agg2.ateLagCount+1)], dutPortList[1:(agg2.ateLagCount+1)]); err != nil {
Expand Down Expand Up @@ -394,7 +400,7 @@ func configureDUT(t *testing.T, dut *ondatra.DUTDevice) []string {
configureRoutingPolicy(t, dut)
configureDUTISIS(t, dut, aggIDs)

if deviations.MaxEcmpPaths(dut) {
if !deviations.MaxEcmpPaths(dut) {
isisPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_ISIS, isisInstance).Isis()
gnmi.Update(t, dut, isisPath.Global().MaxEcmpPaths().Config(), 2)
}
Expand Down Expand Up @@ -805,9 +811,9 @@ func incrementMAC(mac string, i int) (string, error) {
return newMac.String(), nil
}

func createFlows(t *testing.T, dut *ondatra.DUTDevice, top gosnappi.Config, aggIDs []string) []gosnappi.Flow {
for _, aggID := range aggIDs {
dutAggMac = append(dutAggMac, gnmi.Get(t, dut, gnmi.OC().Lacp().Interface(aggID).SystemIdMac().State()))
func createFlows(t *testing.T, ate *ondatra.ATEDevice, top gosnappi.Config) []gosnappi.Flow {
for _, aggID := range []*aggPortData{agg1, agg2, agg3} {
dutAggMac = append(dutAggMac, gnmi.Get(t, ate.OTG(), gnmi.OTG().Interface(aggID.ateAggName+".Eth").Ipv4Neighbor(aggID.dutIPv4).LinkLayerAddress().State()))
}
f1V4 := configureFlows(t, top, pfx1AdvV4, pfx2AdvV4, "pfx1ToPfx2_3", agg1, []*aggPortData{agg2, agg3}, dutAggMac[0], ipRange[1])
f2V4 := configureFlows(t, top, pfx1AdvV4, pfx4AdvV4, "pfx1ToPfx4", agg1, []*aggPortData{agg2, agg3}, dutAggMac[0], ipRange[0])
Expand Down Expand Up @@ -958,7 +964,7 @@ func awaitAdjacency(t *testing.T, dut *ondatra.DUTDevice, intfName string, state
isisPath := ocpath.Root().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_ISIS, isisInstance).Isis()
intf := isisPath.Interface(intfName)
query := intf.LevelAny().AdjacencyAny().AdjacencyState().State()
_, ok := gnmi.WatchAll(t, dut, query, time.Minute, func(val *ygnmi.Value[oc.E_Isis_IsisInterfaceAdjState]) bool {
_, ok := gnmi.WatchAll(t, dut, query, 90*time.Second, func(val *ygnmi.Value[oc.E_Isis_IsisInterfaceAdjState]) bool {
v, ok := val.Val()
return v == state && ok
}).Await(t)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ platform_exceptions: {
static_protocol_name: "STATIC"
aggregate_atomic_update: true
missing_value_for_defaults: true
max_ecmp_paths: false
max_ecmp_paths: true
explicit_interface_in_default_vrf: false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ func TestOnChangeBackplaneCapacityCounters(t *testing.T) {

fc := (len(fabrics) / 2) + 1
for _, f := range fabrics[:fc] {
empty, ok := gnmi.Lookup(t, dut, gnmi.OC().Component(f).Empty().State()).Val()
if ok && empty {
t.Logf("Fabric Component %s is empty, hence skipping", f)
continue
}
gnmi.Replace(t, dut, gnmi.OC().Component(f).Fabric().PowerAdminState().Config(), oc.Platform_ComponentPowerType_POWER_DISABLED)
gnmi.Await(t, dut, gnmi.OC().Component(f).Fabric().PowerAdminState().State(), time.Minute, oc.Platform_ComponentPowerType_POWER_DISABLED)
}
Expand All @@ -134,6 +139,11 @@ func TestOnChangeBackplaneCapacityCounters(t *testing.T) {
ts2, tocs2, apct2 := getBackplaneCapacityCounters(t, dut, ics)

for _, f := range fabrics[:fc] {
empty, ok := gnmi.Lookup(t, dut, gnmi.OC().Component(f).Empty().State()).Val()
if ok && empty {
t.Logf("Fabric Component %s is empty, hence skipping", f)
continue
}
gnmi.Replace(t, dut, gnmi.OC().Component(f).Fabric().PowerAdminState().Config(), oc.Platform_ComponentPowerType_POWER_ENABLED)
if deviations.MissingValueForDefaults(dut) {
time.Sleep(time.Minute)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,13 @@ platform_exceptions: {
missing_hardware_resource_telemetry_before_config: true
}
}
platform_exceptions: {
platform: {
vendor: NOKIA
}
deviations: {
explicit_interface_in_default_vrf: true
interface_enabled: true
}
}
tags: TAGS_TRANSIT
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

"github.com/open-traffic-generator/snappi/gosnappi"
"github.com/openconfig/featureprofiles/internal/attrs"
"github.com/openconfig/featureprofiles/internal/components"
"github.com/openconfig/featureprofiles/internal/deviations"
"github.com/openconfig/featureprofiles/internal/fptest"
"github.com/openconfig/featureprofiles/internal/otgutils"
Expand All @@ -45,6 +46,7 @@ const (
var (
fibResource = map[ondatra.Vendor]string{
ondatra.ARISTA: "Routing/Resource6",
ondatra.NOKIA: "ip-lpm-routes",
}
dutPort1 = attrs.Attributes{
Desc: "dutPort1",
Expand Down Expand Up @@ -105,46 +107,22 @@ func TestResourceUtilization(t *testing.T) {
otgV6Peer, otgPort1, otgConfig := configureOTG(t, otg)

verifyBgpTelemetry(t, dut)

val, ok := gnmi.Watch(t, dut, gnmi.OC().System().Utilization().Resource(fibResource[dut.Vendor()]).ActiveComponentList().State(), time.Minute, func(v *ygnmi.Value[[]string]) bool {
cs, present := v.Val()
return present && len(cs) > 0
}).Await(t)
if !ok {
switch {
case deviations.MissingHardwareResourceTelemetryBeforeConfig(dut):
t.Log("FIB resource is not active in any available components")
default:
t.Fatalf("FIB resource is not active in any available components")
}
}
comps, _ := val.Val()

gnmi.Replace(t, dut, gnmi.OC().System().Utilization().Resource(fibResource[dut.Vendor()]).Config(), &oc.System_Utilization_Resource{
Name: ygot.String(fibResource[dut.Vendor()]),
UsedThresholdUpper: ygot.Uint8(usedThresholdUpper),
UsedThresholdUpperClear: ygot.Uint8(usedThresholdUpperClear),
})

val, ok = gnmi.Watch(t, dut, gnmi.OC().System().Utilization().Resource(fibResource[dut.Vendor()]).ActiveComponentList().State(), time.Minute, func(v *ygnmi.Value[[]string]) bool {
cs, present := v.Val()
return present && len(cs) > 0
}).Await(t)
if !ok {
t.Fatalf("FIB resource is not active in any available components")
}
comps, _ = val.Val()

comps := components.FindActiveComponentsByType(t, dut, oc.PlatformTypes_OPENCONFIG_HARDWARE_COMPONENT_INTEGRATED_CIRCUIT)
beforeUtzs := componentUtilizations(t, dut, comps)
if len(beforeUtzs) != len(comps) {
t.Fatalf("Couldn't retrieve Utilization information for all Components in active-component-list")
t.Fatalf("Couldn't retrieve Utilization information for all Active Components")
}

injectBGPRoutes(t, otg, otgV6Peer, otgPort1, otgConfig)

afterUtzs := componentUtilizations(t, dut, comps)
if len(afterUtzs) != len(comps) {
t.Fatalf("Couldn't retrieve Utilization information for all Components in active-component-list")
t.Fatalf("Couldn't retrieve Utilization information for all Active Components")
}

t.Run("Utilization after BGP route installation", func(t *testing.T) {
Expand All @@ -162,7 +140,7 @@ func TestResourceUtilization(t *testing.T) {

afterClearUtzs := componentUtilizations(t, dut, comps)
if len(afterClearUtzs) != len(comps) {
t.Fatalf("Couldn't retrieve Utilization information for all Components in active-component-list")
t.Fatalf("Couldn't retrieve Utilization information for all Active Components")
}

t.Run("Utilization after BGP route clear", func(t *testing.T) {
Expand Down
22 changes: 22 additions & 0 deletions internal/components/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,28 @@ func FindComponentsByType(t *testing.T, dut *ondatra.DUTDevice, cType oc.E_Platf
return s
}

// FindActiveComponentsByType finds the list of active components based on hardware type.
func FindActiveComponentsByType(t *testing.T, dut *ondatra.DUTDevice, cType oc.E_PlatformTypes_OPENCONFIG_HARDWARE_COMPONENT) []string {
components := gnmi.GetAll[*oc.Component](t, dut, gnmi.OC().ComponentAny().State())
var s []string
for _, c := range components {
if c.GetType() == nil {
t.Logf("Component %s type is missing from telemetry", c.GetName())
continue
}
t.Logf("Component %s has type: %v", c.GetName(), c.GetType())
switch v := c.GetType().(type) {
case oc.E_PlatformTypes_OPENCONFIG_HARDWARE_COMPONENT:
if v == cType && c.OperStatus == oc.PlatformTypes_COMPONENT_OPER_STATUS_ACTIVE {
s = append(s, c.GetName())
}
default:
t.Logf("Detected non-hardware component: (%T, %v)", c.GetType(), c.GetType())
}
}
return s
}

// FindSWComponentsByType finds the list of SW components based on a type.
func FindSWComponentsByType(t *testing.T, dut *ondatra.DUTDevice, cType oc.E_PlatformTypes_OPENCONFIG_SOFTWARE_COMPONENT) []string {
components := gnmi.GetAll[*oc.Component](t, dut, gnmi.OC().ComponentAny().State())
Expand Down

0 comments on commit 36b3750

Please sign in to comment.