Skip to content

Commit

Permalink
Merge branch 'main' into certz4
Browse files Browse the repository at this point in the history
  • Loading branch information
lvaish05 authored Jan 29, 2025
2 parents 760f41f + 7e0ec6f commit f526ddf
Show file tree
Hide file tree
Showing 19 changed files with 933 additions and 78 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 @@ -48,11 +48,11 @@ const (

// Destination ATE MAC address for port-2 and port-3.
pMAC = "00:1A:11:00:1A:BC"
// 12-bit filter for egress flow tracking. ABC in hex == 0xabc in hexadecimal.
pMACFilter = "0xabc"
pMACFilterport2 = "0xab9"
pMACFilterport3 = "0xaba"
pMACFilterport4 = "0xabb"
// 8-bit filter for egress flow tracking. ABC in hex == 0xabc in hexadecimal.
pMACFilter = "0xbc"
pMACFilterport2 = "0xb9"
pMACFilterport3 = "0xba"
pMACFilterport4 = "0xbb"

// port-2 nexthop ID.
p2NHID = 40
Expand Down Expand Up @@ -99,7 +99,7 @@ const (
port4mac = "00:1A:11:00:1A:BB"
vip1 = "198.18.196.1"
outerSrcIP = "203.0.113.0"
fps = 1000000 // traffic frames per second
fps = 100000 // traffic frames per second
innerSrcIP = "198.51.100.61"
vrfPrefixcount = 10000
ipv4Prefixcount = 700
Expand Down Expand Up @@ -541,7 +541,7 @@ func createFlow(_ *testing.T, name string, ateTop gosnappi.Config, drain, transi
flowipv4.Rate().SetPps(fps)
eth := flowipv4.EgressPacket().Add().Ethernet()
ethTag := eth.Dst().MetricTags().Add()
ethTag.SetName("EgressTrackingFlow").SetOffset(36).SetLength(12)
ethTag.SetName("EgressTrackingFlow").SetOffset(40).SetLength(8)

return flowipv4
}
Expand Down Expand Up @@ -624,7 +624,7 @@ func validateTrafficFlows(t *testing.T, ate *ondatra.ATEDevice, good, bad, lb []
if got := ets[0].GetCounters().GetInPkts(); got != rxPkts {
t.Errorf("EgressTracking counter in-pkts got %d, want %d", got, rxPkts)
} else {
t.Logf("Received %d packets with %s as the last 12 bits in the dst MAC", got, macFilter)
t.Logf("Received %d packets with %s as the last 8 bits in the dst MAC", got, macFilter)
}

}
Expand Down
2 changes: 1 addition & 1 deletion feature/gribi/otg_tests/mpls_in_udp/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# TE-18.1 gRIBI MPLS in UDP Encapsulation
# TE-18.1: gRIBI MPLS in UDP Encapsulation

Create AFT entries using gRIBI to match on next hop group in a
network-instance and encapsulate the matching packets in MPLS in UDP with outer header as IPv6 Header.
Expand Down
31 changes: 31 additions & 0 deletions feature/gribi/otg_tests/mpls_in_udp/metadata.textproto
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# proto-file: github.com/openconfig/featureprofiles/proto/metadata.proto
# proto-message: Metadata

uuid: "36cc79b5-3766-4cb4-b83b-1baea1464dc8"
plan_id: "TE-18.1"
description: "gRIBI MPLS in UDP Encapsulation"
testbed: TESTBED_DUT_ATE_4LINKS
platform_exceptions: {
platform: {
vendor: ARISTA
}
deviations: {
static_protocol_name: "STATIC"
gribi_encap_header_unsupported: true
gribi_mac_override_static_arp_static_route: true
interface_enabled: true
default_network_instance: "default"
}
}
platform_exceptions: {
platform: {
vendor: CISCO
}
deviations: {
static_protocol_name: "STATIC"
gribi_encap_header_unsupported: true
gribi_mac_override_static_arp_static_route: true
interface_enabled: true
default_network_instance: "default"
}
}
Loading

0 comments on commit f526ddf

Please sign in to comment.