Skip to content

Commit

Permalink
Merge branch 'main' into decap
Browse files Browse the repository at this point in the history
  • Loading branch information
vishnureddybadveli authored Jan 9, 2025
2 parents 0602b4d + 37ae75e commit be094e1
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 125 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/required_approvals.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
read_org_scoped_token: ${{ secrets.READ_ORG_SCOPED_TOKEN }}
org_name: openconfig
min_approvals: 2
min_approvals: 1
approval_mode: ALL
pr_number: ${{ github.event.number }}
require_all_approvals_latest_commit: false
40 changes: 21 additions & 19 deletions feature/gribi/otg_tests/gribi_route_test/gribi_route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,26 @@ func TestGRIBIFailover(t *testing.T) {
t.Log("Configure VRF_Policy")
configureVrfSelectionPolicyC(t, dut)
t.Log("Configure GRIBI")
configureGribiRoute(t, dut)

ctx := context.Background()
gribic := dut.RawAPIs().GRIBI(t)
client := fluent.NewClient()
client.Connection().WithStub(gribic).WithPersistence().WithInitialElectionID(12, 0).
WithRedundancyMode(fluent.ElectedPrimaryClient).WithFIBACK()
client.Start(ctx, t)
defer client.Stop(t)
gribi.FlushAll(client)
defer gribi.FlushAll(client)
client.StartSending(ctx, t)
gribi.BecomeLeader(t, client)

tcArgs := &testArgs{
ctx: ctx,
client: client,
dut: dut,
}

configureGribiRoute(t, dut, tcArgs)

llAddress, found := gnmi.Watch(t, ate.OTG(), gnmi.OTG().Interface("port1.Eth").Ipv4Neighbor(dutPort1.IPv4).LinkLayerAddress().State(), time.Minute, func(val *ygnmi.Value[string]) bool {
return val.IsPresent()
Expand Down Expand Up @@ -394,25 +413,8 @@ func configureVrfSelectionPolicyC(t *testing.T, dut *ondatra.DUTDevice) {
gnmi.Replace(t, dut, dutPolFwdPath.Config(), niP)
}

func configureGribiRoute(t *testing.T, dut *ondatra.DUTDevice) {
func configureGribiRoute(t *testing.T, dut *ondatra.DUTDevice, tcArgs *testArgs) {
t.Helper()
ctx := context.Background()
gribic := dut.RawAPIs().GRIBI(t)
client := fluent.NewClient()
client.Connection().WithStub(gribic).WithPersistence().WithInitialElectionID(12, 0).
WithRedundancyMode(fluent.ElectedPrimaryClient).WithFIBACK()
client.Start(ctx, t)
defer client.Stop(t)
gribi.FlushAll(client)
defer gribi.FlushAll(client)
client.StartSending(ctx, t)
gribi.BecomeLeader(t, client)

tcArgs := &testArgs{
ctx: ctx,
client: client,
dut: dut,
}
tcArgs.client.Modify().AddEntry(t,
fluent.NextHopEntry().WithNetworkInstance(deviations.DefaultNetworkInstance(tcArgs.dut)).
WithIndex(uint64(1)).WithDecapsulateHeader(fluent.IPinIP).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ func TestFabricPowerAdmin(t *testing.T) {
for _, f := range fs {
t.Run(f, func(t *testing.T) {

if !gnmi.Get(t, dut, gnmi.OC().Component(f).Removable().State()) {
t.Skipf("Skip the test on non-removable fabric.")
}

empty, ok := gnmi.Lookup(t, dut, gnmi.OC().Component(f).Empty().State()).Val()
if ok && empty {
t.Skipf("Fabric Component %s is empty, hence skipping", f)
}

if !gnmi.Get(t, dut, gnmi.OC().Component(f).Removable().State()) {
t.Skipf("Skip the test on non-removable fabric.")
}

oper := gnmi.Get(t, dut, gnmi.OC().Component(f).OperStatus().State())

if got, want := oper, oc.PlatformTypes_COMPONENT_OPER_STATUS_ACTIVE; got != want {
Expand Down
1 change: 0 additions & 1 deletion feature/sflow/otg_tests/sflow_base_test/metadata.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ platform_exceptions: {
}
deviations: {
explicit_port_speed: true
explicit_interface_in_default_vrf: true
interface_enabled: true
static_protocol_name: "static"
}
Expand Down
79 changes: 47 additions & 32 deletions feature/sflow/otg_tests/sflow_base_test/sflow_base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,20 @@ var (
flowConfigs = []flowConfig{
{
name: "flowS",
packetsToSend: 1000000,
ppsRate: 100000,
packetsToSend: 10000000,
ppsRate: 300000,
frameSize: 64,
},
{
name: "flowM",
packetsToSend: 1000000,
ppsRate: 100000,
packetsToSend: 10000000,
ppsRate: 300000,
frameSize: 512,
},
{
name: "flowL",
packetsToSend: 1000000,
ppsRate: 100000,
packetsToSend: 10000000,
ppsRate: 300000,
frameSize: 1500,
},
}
Expand Down Expand Up @@ -206,25 +206,6 @@ func TestSFlowTraffic(t *testing.T) {
cfgplugins.NewStaticRouteCfg(srBatch, staticRouteV6, dut)
srBatch.Set(t, dut)

t.Run("SFLOW-1.1_ReplaceDUTConfigSFlow", func(t *testing.T) {
sfBatch := &gnmi.SetBatch{}
cfgplugins.NewSFlowGlobalCfg(t, sfBatch, nil, dut, mgmtVRF, loopbackIntfName, dutlo0Attrs.IPv4, dutlo0Attrs.IPv6)
sfBatch.Set(t, dut)

gotSamplingConfig := gnmi.Get(t, dut, gnmi.OC().Sampling().Sflow().Config())
json, err := ygot.EmitJSON(gotSamplingConfig, &ygot.EmitJSONConfig{
Format: ygot.RFC7951,
Indent: " ",
RFC7951Config: &ygot.RFC7951JSONConfig{
AppendModuleName: true,
},
})
if err != nil {
t.Errorf("Error decoding sampling config: %v", err)
}
t.Logf("Got sampling config: %v", json)
})

/* TODO: implement this when a suitable ygot.diffBatch function exists
// Validate DUT sampling config matches what we set it to
diff, err := ygot.Diff(gotSamplingConfig, sfBatch)
Expand All @@ -239,16 +220,46 @@ func TestSFlowTraffic(t *testing.T) {

t.Run("SFLOW-1.2_TestFlowFixed", func(t *testing.T) {
t.Run("SFLOW-1.2.1_IPv4", func(t *testing.T) {
configSflow(t, dut, loopbackIntfName, IPv4)
enableCapture(t, ate, config, IPv4)
testFlowFixed(t, ate, config, IPv4)
})
t.Run("SFLOW-1.2.2_IPv6", func(t *testing.T) {
configSflow(t, dut, loopbackIntfName, IPv6)
enableCapture(t, ate, config, IPv6)
testFlowFixed(t, ate, config, IPv6)
})
})
}

func configSflow(t *testing.T, dut *ondatra.DUTDevice, loopbackIntfName string, ip IPType) {

t.Run("SFLOW-1.1_ReplaceDUTConfigSFlow", func(t *testing.T) {
sfBatch := &gnmi.SetBatch{}
switch ip {
case IPv4:
cfgplugins.NewSFlowGlobalCfg(t, sfBatch, nil, dut, mgmtVRF, loopbackIntfName, dutlo0Attrs.IPv4, dutlo0Attrs.IPv6, IPv4)
case IPv6:
cfgplugins.NewSFlowGlobalCfg(t, sfBatch, nil, dut, mgmtVRF, loopbackIntfName, dutlo0Attrs.IPv4, dutlo0Attrs.IPv6, IPv6)
}
sfBatch.Set(t, dut)

gotSamplingConfig := gnmi.Get(t, dut, gnmi.OC().Sampling().Sflow().Config())
json, err := ygot.EmitJSON(gotSamplingConfig, &ygot.EmitJSONConfig{
Format: ygot.RFC7951,
Indent: " ",
RFC7951Config: &ygot.RFC7951JSONConfig{
AppendModuleName: true,
},
})
if err != nil {
t.Errorf("Error decoding sampling config: %v", err)
}
t.Logf("Got sampling config: %v", json)
})

}

func testFlowFixed(t *testing.T, ate *ondatra.ATEDevice, config gosnappi.Config, ip IPType) {
for _, fc := range flowConfigs {
flowName := string(ip) + fc.name
Expand Down Expand Up @@ -374,7 +385,6 @@ func createFlow(t *testing.T, ate *ondatra.ATEDevice, config gosnappi.Config, fc
flow.Metrics().SetEnable(true)
flow.Size().SetFixed(fc.frameSize)
flow.Rate().SetPps(fc.ppsRate)
flow.Duration().FixedPackets().SetPackets(fc.packetsToSend)
e1 := flow.Packet().Add().Ethernet()
e1.Src().SetValues([]string{ateSrc.MAC})

Expand Down Expand Up @@ -414,6 +424,7 @@ func validatePackets(t *testing.T, filename string, ip IPType, fc flowConfig) {

found := false
packetCount := 0
sampleCount := 0
sflowSamples := uint32(0)
for packet := range packetSource.Packets() {
if ipLayer := packet.Layer(layers.LayerTypeIPv4); ipLayer != nil {
Expand All @@ -422,7 +433,7 @@ func validatePackets(t *testing.T, filename string, ip IPType, fc flowConfig) {
t.Logf("tos %d, payload %d, content %d, length %d", ipv4.TOS, len(ipv4.Payload), len(ipv4.Contents), ipv4.Length)
if ipv4.TOS == 32 {
found = true
break
sampleCount++
}
}
} else if ipLayer := packet.Layer(layers.LayerTypeIPv6); ipLayer != nil {
Expand All @@ -431,16 +442,22 @@ func validatePackets(t *testing.T, filename string, ip IPType, fc flowConfig) {
t.Logf("tos %d, payload %d, content %d, length %d", ipv6.TrafficClass, len(ipv6.Payload), len(ipv6.Contents), ipv6.Length)
if ipv6.TrafficClass == 32 {
found = true
break
sampleCount++
}
}
}

}
if !found {
t.Error("sflow packets not found")

expectedSampleCount := float64(fc.packetsToSend / samplingRate)
minAllowedSamples := expectedSampleCount * sampleTolerance
t.Logf("SFlow samples captured: %v", sampleCount)
if !found || sampleCount < int(minAllowedSamples) {
t.Errorf("sflow packets not found: got %v, want >= %v", sampleCount, minAllowedSamples)
}

handle, _ = pcap.OpenOffline(filename)
packetSource = gopacket.NewPacketSource(handle, handle.LinkType())
for packet := range packetSource.Packets() {
if sflowLayer := packet.Layer(layers.LayerTypeSFlow); sflowLayer != nil {
sflow := sflowLayer.(*layers.SFlowDatagram)
Expand All @@ -450,8 +467,6 @@ func validatePackets(t *testing.T, filename string, ip IPType, fc flowConfig) {
}
}

expectedSampleCount := float64(fc.packetsToSend / samplingRate)
minAllowedSamples := expectedSampleCount * sampleTolerance
if sflowSamples < uint32(minAllowedSamples) {
t.Errorf("SFlow sample count %v, want > %v", sflowSamples, expectedSampleCount)
}
Expand Down
20 changes: 10 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ require (
cloud.google.com/go/pubsub v1.36.1
cloud.google.com/go/storage v1.38.0
github.com/cisco-open/go-p4 v0.1.2
github.com/go-git/go-billy/v5 v5.5.0
github.com/go-git/go-git/v5 v5.11.0
github.com/go-git/go-billy/v5 v5.6.0
github.com/go-git/go-git/v5 v5.13.0
github.com/golang/glog v1.2.1
github.com/google/go-cmp v0.6.0
github.com/google/go-github/v50 v50.1.0
Expand Down Expand Up @@ -42,7 +42,7 @@ require (
github.com/yoheimuta/go-protoparser/v4 v4.9.0
github.com/yuin/goldmark v1.4.13
golang.org/x/crypto v0.31.0
golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
golang.org/x/text v0.21.0
google.golang.org/api v0.171.0
google.golang.org/grpc v1.66.2
Expand All @@ -65,7 +65,7 @@ require (
cloud.google.com/go/compute/metadata v0.3.0 // indirect
cloud.google.com/go/iam v1.1.6 // indirect
dario.cat/mergo v1.0.0 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
github.com/ProtonMail/go-crypto v1.1.3 // indirect
github.com/aristanetworks/arista-ceoslab-operator/v2 v2.1.2 // indirect
github.com/carlmontanari/difflibgo v0.0.0-20210718194309-31b9e131c298 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
Expand All @@ -74,7 +74,7 @@ require (
github.com/cloudflare/circl v1.3.7 // indirect
github.com/cncf/xds/go v0.0.0-20240423153145-555b57ec207b // indirect
github.com/creack/pty v1.1.18 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/cyphar/filepath-securejoin v0.2.5 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/drivenets/cdnos-controller v1.7.4 // indirect
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
Expand Down Expand Up @@ -134,9 +134,9 @@ require (
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/scrapli/scrapligo v1.1.11 // indirect
github.com/scrapli/scrapligocfg v1.0.0 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/sirikothe/gotextfsm v1.0.1-0.20200816110946-6aa2cfd355e4 // indirect
github.com/skeema/knownhosts v1.2.1 // indirect
github.com/skeema/knownhosts v1.3.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
Expand All @@ -152,13 +152,13 @@ require (
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/mod v0.18.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/mod v0.19.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.22.0 // indirect
golang.org/x/tools v0.23.0 // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240604185151-ef581f913117 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
Expand Down
Loading

0 comments on commit be094e1

Please sign in to comment.