Skip to content

Commit

Permalink
Merge branch 'main' into System-1-MotdBanner-(OC-1.1)
Browse files Browse the repository at this point in the history
  • Loading branch information
ram-mac authored Jan 30, 2025
2 parents d0eeec3 + b02122c commit 90a1256
Show file tree
Hide file tree
Showing 18 changed files with 311 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ func configureRoutePolicy(t *testing.T, dut *ondatra.DUTDevice, name string, pr
t.Fatalf("AppendNewStatement(%s) failed: %v", name, err)
}
stmt.GetOrCreateActions().PolicyResult = pr
stmt.GetOrCreateConditions().InstallProtocolEq = oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP
gnmi.Update(t, dut, gnmi.OC().RoutingPolicy().Config(), rp)

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ platform_exceptions: {
deviations: {
ipv4_missing_enabled: true
interface_counters_from_container: true
interface_counters_update_delayed: true
}
}
platform_exceptions: {
Expand All @@ -24,6 +25,7 @@ platform_exceptions: {
ipv4_missing_enabled: true
interface_counters_from_container: true
os_component_parent_is_supervisor_or_linecard: true
interface_counters_update_delayed: true
}
}
platform_exceptions: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"math"
"regexp"
"strconv"
"sync"
"testing"
"time"

Expand All @@ -27,6 +28,7 @@ import (
"github.com/openconfig/featureprofiles/internal/deviations"
"github.com/openconfig/featureprofiles/internal/fptest"
"github.com/openconfig/featureprofiles/internal/otgutils"
"github.com/openconfig/featureprofiles/internal/samplestream"
"github.com/openconfig/ondatra"
"github.com/openconfig/ondatra/gnmi"
"github.com/openconfig/ondatra/gnmi/oc"
Expand Down Expand Up @@ -398,8 +400,9 @@ func verifyChassisIsAncestor(t *testing.T, dut *ondatra.DUTDevice, comp string)
t.Errorf("Chassis component NOT found as an ancestor of component %s", comp)
break
}
got := gnmi.Get(t, dut, gnmi.OC().Component(val).Type().State())
if got == chassisType {
gotV := gnmi.Lookup(t, dut, gnmi.OC().Component(val).Type().State())
got, present := gotV.Val()
if present && got == chassisType {
t.Logf("Found chassis component as an ancestor of component %s", comp)
break
}
Expand Down Expand Up @@ -765,16 +768,51 @@ func TestP4rtNodeID(t *testing.T) {
}
}

func fetchInAndOutPkts(t *testing.T, dut *ondatra.DUTDevice, dp1, dp2 *ondatra.Port) (uint64, uint64) {
if deviations.InterfaceCountersFromContainer(dut) {
inPkts := *gnmi.Get(t, dut, gnmi.OC().Interface(dp1.Name()).Counters().State()).InUnicastPkts
outPkts := *gnmi.Get(t, dut, gnmi.OC().Interface(dp2.Name()).Counters().State()).OutUnicastPkts
return inPkts, outPkts
func fetchInAndOutPkts(t *testing.T, dut *ondatra.DUTDevice, dp1, dp2 *ondatra.Port,
inTarget, outTarget uint64) (uint64, uint64) {
t.Helper()

inPktStream := samplestream.New(t, dut, gnmi.OC().Interface(dp1.Name()).Counters().InUnicastPkts().State(), 10*time.Second)
defer inPktStream.Close()
outPktStream := samplestream.New(t, dut, gnmi.OC().Interface(dp2.Name()).Counters().OutUnicastPkts().State(), 10*time.Second)
defer outPktStream.Close()

var wg sync.WaitGroup
var inPktsV, outPktsV uint64

startTime := time.Now()
timeout := 10 * time.Second
if deviations.InterfaceCountersUpdateDelayed(dut) {
timeout = 30 * time.Second
}

for {
wg.Add(1)
go func() {
defer wg.Done()
if v := inPktStream.Next(); v != nil {
if val, ok := v.Val(); ok {
inPktsV = val
}
}
}()
if v := outPktStream.Next(); v != nil {
if val, ok := v.Val(); ok {
outPktsV = val
}
}
wg.Wait()

if inPktsV >= inTarget && outPktsV >= outTarget {
break
}

if time.Since(startTime) > timeout {
t.Fatalf("Did not receive a packet counters in time")
}
}

inPkts := gnmi.Get(t, dut, gnmi.OC().Interface(dp1.Name()).Counters().InUnicastPkts().State())
outPkts := gnmi.Get(t, dut, gnmi.OC().Interface(dp2.Name()).Counters().OutUnicastPkts().State())
return inPkts, outPkts
return inPktsV, outPktsV
}

func TestIntfCounterUpdate(t *testing.T) {
Expand Down Expand Up @@ -822,9 +860,10 @@ func TestIntfCounterUpdate(t *testing.T) {
v4.Priority().Dscp().Phb().SetValue(56)
otg.PushConfig(t, config)
otg.StartProtocols(t)
otgutils.WaitForARP(t, ate.OTG(), config, "IPv4")

t.Log("Running traffic on DUT interfaces: ", dp1, dp2)
dutInPktsBeforeTraffic, dutOutPktsBeforeTraffic := fetchInAndOutPkts(t, dut, dp1, dp2)
dutInPktsBeforeTraffic, dutOutPktsBeforeTraffic := fetchInAndOutPkts(t, dut, dp1, dp2, 0, 0)
t.Log("inPkts and outPkts counters before traffic: ", dutInPktsBeforeTraffic, dutOutPktsBeforeTraffic)
otg.StartTraffic(t)
time.Sleep(10 * time.Second)
Expand All @@ -847,24 +886,25 @@ func TestIntfCounterUpdate(t *testing.T) {
}

otgutils.LogFlowMetrics(t, otg, config)
ateInPkts := float32(gnmi.Get(t, otg, gnmi.OTG().Flow(flowName).Counters().InPkts().State()))
ateOutPkts := float32(gnmi.Get(t, otg, gnmi.OTG().Flow(flowName).Counters().OutPkts().State()))
ateInPkts := gnmi.Get(t, otg, gnmi.OTG().Flow(flowName).Counters().InPkts().State())
ateOutPkts := gnmi.Get(t, otg, gnmi.OTG().Flow(flowName).Counters().OutPkts().State())

if ateOutPkts == 0 {
t.Errorf("Get(out packets for flow %q: got %v, want nonzero", flowName, ateOutPkts)
}
lossPct := (ateOutPkts - ateInPkts) * 100 / ateOutPkts
lossPct := float64(ateOutPkts-ateInPkts) * 100 / float64(ateOutPkts)
if lossPct >= 0.1 {
t.Errorf("Get(traffic loss for flow %q: got %v, want < 0.1", flowName, lossPct)
}
dutInPktsAfterTraffic, dutOutPktsAfterTraffic := fetchInAndOutPkts(t, dut, dp1, dp2)
dutInPktsAfterTraffic, dutOutPktsAfterTraffic := fetchInAndOutPkts(t, dut, dp1, dp2,
dutInPktsBeforeTraffic+ateOutPkts, dutOutPktsBeforeTraffic+ateInPkts)
t.Log("inPkts and outPkts counters after traffic: ", dutInPktsAfterTraffic, dutOutPktsAfterTraffic)

if dutInPktsAfterTraffic-dutInPktsBeforeTraffic < uint64(ateInPkts) {
t.Errorf("Get less inPkts from telemetry: got %v, want >= %v", dutInPktsAfterTraffic-dutInPktsBeforeTraffic, ateOutPkts)
if got, want := dutInPktsAfterTraffic-dutInPktsBeforeTraffic, ateOutPkts; got < want {
t.Errorf("Get less inPkts from telemetry: got %v, want >= %v", got, want)
}
if dutOutPktsAfterTraffic-dutOutPktsBeforeTraffic < uint64(ateOutPkts) {
t.Errorf("Get less outPkts from telemetry: got %v, want >= %v", dutOutPktsAfterTraffic-dutOutPktsBeforeTraffic, ateOutPkts)
if got, want := dutOutPktsAfterTraffic-dutOutPktsBeforeTraffic, ateInPkts; got < want {
t.Errorf("Get less outPkts from telemetry: got %v, want >= %v", got, want)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ func configureISIS(t *testing.T, ts *isissession.TestSession) {
globalIsis.GetOrCreateAf(oc.IsisTypes_AFI_TYPE_IPV6, oc.IsisTypes_SAFI_TYPE_UNICAST).Enabled = ygot.Bool(true)
globalIsis.LevelCapability = oc.Isis_LevelType_LEVEL_2
globalIsis.GetOrCreateTimers().LspLifetimeInterval = ygot.Uint16(lspLifetime)
if deviations.ISISLspLifetimeIntervalRequiresLspRefreshInterval(ts.DUT) {
globalIsis.GetOrCreateTimers().LspRefreshInterval = ygot.Uint16(60)
}
}

// configureOTG configures isis and traffic on OTG.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ platform_exceptions: {
interface_enabled: true
default_network_instance: "default"
isis_interface_afi_unsupported: true
isis_lsp_lifetime_interval_requires_lsp_refresh_interval: true
isis_lsp_metadata_leafs_unsupported: true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ func TestIsisInterfaceHelloPaddingEnable(t *testing.T) {
t.Run("Traffic checks", func(t *testing.T) {
t.Logf("Starting traffic")
otg.StartTraffic(t)
time.Sleep(time.Second * 15)
time.Sleep(time.Second * 30)
t.Logf("Stop traffic")
otg.StopTraffic(t)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ platform_exceptions: {
missing_value_for_defaults: true
interface_enabled: true
default_network_instance: "default"
isis_lsp_lifetime_interval_requires_lsp_refresh_interval: true
isis_timers_csnp_interval_unsupported: true
isis_counter_manual_address_drop_from_areas_unsupported: true
isis_counter_part_changes_unsupported: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ platform_exceptions: {
interface_enabled: true
default_network_instance: "default"
isis_interface_afi_unsupported: true
isis_lsp_lifetime_interval_requires_lsp_refresh_interval: true
isis_timers_csnp_interval_unsupported: true
isis_counter_manual_address_drop_from_areas_unsupported: true
isis_counter_part_changes_unsupported: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ platform_exceptions: {
interface_enabled: true
default_network_instance: "default"
isis_interface_afi_unsupported: true
isis_lsp_lifetime_interval_requires_lsp_refresh_interval: true
isis_timers_csnp_interval_unsupported: true
isis_counter_manual_address_drop_from_areas_unsupported: true
isis_counter_part_changes_unsupported: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ platform_exceptions: {
missing_value_for_defaults: true
interface_enabled: true
default_network_instance: "default"
isis_lsp_lifetime_interval_requires_lsp_refresh_interval: true
isis_timers_csnp_interval_unsupported: true
isis_counter_manual_address_drop_from_areas_unsupported: true
isis_counter_part_changes_unsupported: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ const (
v6Flow = "v6Flow"
trafficDuration = 30 * time.Second
prefixMatch = "exact"
v4tagSet = "tag-set-v4"
v4RoutePolicy = "route-policy-v4"
v4Statement = "statement-v4"
v4PrefixSet = "prefix-set-v4"
v6tagSet = "tag-set-v6"
v6RoutePolicy = "route-policy-v6"
v6Statement = "statement-v6"
v6PrefixSet = "prefix-set-v6"
Expand Down Expand Up @@ -234,7 +236,6 @@ func configureRoutePolicy(dut *ondatra.DUTDevice, rplName string, statement stri
if err != nil {
return nil, err
}
v4tagSet := getTagSetName(dut, rplName, v4Statement, "v4")
tagSet1 := rp.GetOrCreateDefinedSets().GetOrCreateTagSet(v4tagSet)
tagSet1.SetTagValue([]oc.RoutingPolicy_DefinedSets_TagSet_TagValue_Union{oc.UnionUint32(V4tagValue)})
stmt1.GetOrCreateConditions().GetOrCreateMatchTagSet().SetTagSet(v4tagSet)
Expand All @@ -244,7 +245,6 @@ func configureRoutePolicy(dut *ondatra.DUTDevice, rplName string, statement stri
if err != nil {
return nil, err
}
v6tagSet := getTagSetName(dut, rplName, v6Statement, "v6")
tagSet2 := rp.GetOrCreateDefinedSets().GetOrCreateTagSet(v6tagSet)
tagSet2.SetTagValue([]oc.RoutingPolicy_DefinedSets_TagSet_TagValue_Union{oc.UnionUint32(V6tagValue)})
stmt2.GetOrCreateConditions().GetOrCreateMatchTagSet().SetTagSet(v6tagSet)
Expand Down Expand Up @@ -367,13 +367,6 @@ func verifyRplConfig(t *testing.T, dut *ondatra.DUTDevice, tagSetName string, ta
}
}

func getTagSetName(dut *ondatra.DUTDevice, policyName, stmtName, afStr string) string {
if deviations.RoutingPolicyTagSetEmbedded(dut) {
return fmt.Sprintf("%s %s", policyName, stmtName)
}
return fmt.Sprintf("tag-set-%s", afStr)
}

func TestStaticToISISRedistribution(t *testing.T) {
var ts *isissession.TestSession

Expand Down Expand Up @@ -506,8 +499,8 @@ func TestStaticToISISRedistribution(t *testing.T) {

if tc.TagSetCondition {
t.Run("Verify Configuration for RPL TagSet", func(t *testing.T) {
verifyRplConfig(t, ts.DUT, getTagSetName(ts.DUT, tc.RplName, v4Statement, "v4"), oc.UnionUint32(V4tagValue))
verifyRplConfig(t, ts.DUT, getTagSetName(ts.DUT, tc.RplName, v6Statement, "v6"), oc.UnionUint32(V6tagValue))
verifyRplConfig(t, ts.DUT, v4tagSet, oc.UnionUint32(V4tagValue))
verifyRplConfig(t, ts.DUT, v6tagSet, oc.UnionUint32(V6tagValue))
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func TestLinecardPowerAdmin(t *testing.T) {

before := helpers.FetchOperStatusUPIntfs(t, dut, false)

powerDownUp(t, dut, l, oc.PlatformTypes_OPENCONFIG_HARDWARE_COMPONENT_LINECARD, 10*time.Minute)
powerDownUp(t, dut, l, oc.PlatformTypes_OPENCONFIG_HARDWARE_COMPONENT_LINECARD, 20*time.Minute)

helpers.ValidateOperStatusUPIntfs(t, dut, before, 5*time.Minute)
})
Expand Down Expand Up @@ -107,7 +107,7 @@ func TestControllerCardPowerAdmin(t *testing.T) {
t.Skipf("ControllerCard Component %s is already INACTIVE, hence skipping", c)
}

powerDownUp(t, dut, c, oc.PlatformTypes_OPENCONFIG_HARDWARE_COMPONENT_CONTROLLER_CARD, 5*time.Minute)
powerDownUp(t, dut, c, oc.PlatformTypes_OPENCONFIG_HARDWARE_COMPONENT_CONTROLLER_CARD, 20*time.Minute)
})
}
if primary != "" {
Expand Down
19 changes: 19 additions & 0 deletions feature/system/tests/system_base_test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,22 @@ used for mTLS.
2. Each test will then create a client to those services and valid each service is properly
listening on the standard port.
3. Validate client properly connects and execute a simple RPC to validate no errors are returned.

## OpenConfig Path and RPC Coverage

```yaml
paths:
/system/state/motd-banner:
/system/state/login-banner:
/system/state/hostname:
/system/state/current-datetime:
/system/state/boot-time:
/system/clock/state/timezone-name:

rpcs:
gnmi:
gNMI.Set:
replace: true
delete: true
gNMI.Subscribe:
```
35 changes: 32 additions & 3 deletions feature/system/tests/system_base_test/g_protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"testing"
"time"

"github.com/openconfig/featureprofiles/internal/deviations"
"github.com/openconfig/ondatra"
"github.com/openconfig/ondatra/binding/introspect"
"google.golang.org/grpc"
Expand Down Expand Up @@ -58,7 +59,22 @@ func TestGNMIClient(t *testing.T) {
dut := ondatra.DUT(t, "dut")
conn := dialConn(t, dut, introspect.GNMI, 9339)
c := gpb.NewGNMIClient(conn)
if _, err := c.Get(context.Background(), &gpb.GetRequest{Encoding: gpb.Encoding_JSON_IETF, Path: []*gpb.Path{{Elem: []*gpb.PathElem{}}}}); err != nil {

var req *gpb.GetRequest
if deviations.GNMIGetOnRootUnsupported(dut) {
req = &gpb.GetRequest{
Path: []*gpb.Path{{
Elem: []*gpb.PathElem{
{Name: "system"}, {Name: "state"}, {Name: "hostname"}}},
},
Type: gpb.GetRequest_STATE,
Encoding: gpb.Encoding_JSON_IETF,
}
} else {
req = &gpb.GetRequest{Encoding: gpb.Encoding_JSON_IETF, Path: []*gpb.Path{{Elem: []*gpb.PathElem{}}}}
}

if _, err := c.Get(context.Background(), req); err != nil {
t.Fatalf("gnmi.Get failed: %v", err)
}
}
Expand Down Expand Up @@ -105,7 +121,20 @@ func TestP4RTClient(t *testing.T) {
dut := ondatra.DUT(t, "dut")
conn := dialConn(t, dut, introspect.P4RT, 9559)
c := p4rtpb.NewP4RuntimeClient(conn)
if _, err := c.Capabilities(context.Background(), &p4rtpb.CapabilitiesRequest{}); err != nil {
t.Fatalf("p4rt.Capabilites failed: %v", err)
if deviations.P4RTCapabilitiesUnsupported(dut) {
if _, err := c.Read(context.Background(), &p4rtpb.ReadRequest{
DeviceId: 1,
Entities: []*p4rtpb.Entity{
{
Entity: &p4rtpb.Entity_TableEntry{},
},
},
}); err != nil {
t.Fatalf("p4rt.Read failed: %v", err)
}
} else {
if _, err := c.Capabilities(context.Background(), &p4rtpb.CapabilitiesRequest{}); err != nil {
t.Fatalf("p4rt.Capabilites failed: %v", err)
}
}
}
9 changes: 9 additions & 0 deletions feature/system/tests/system_base_test/metadata.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,12 @@ platform_exceptions: {
cli_takes_precedence_over_oc: true
}
}
platform_exceptions: {
platform: {
vendor: CISCO
}
deviations: {
p4rt_capabilities_unsupported: true
gnmi_get_on_root_unsupported: true
}
}
Loading

0 comments on commit 90a1256

Please sign in to comment.