Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DP-2.4 test code #3654

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2893fe4
Add files via upload
vishnureddybadveli Dec 17, 2024
654c858
Update metadata.textproto
vishnureddybadveli Dec 17, 2024
ffb5cf2
Merge branch 'main' into vishnureddybadveli-patch-4
sezhang2 Dec 18, 2024
486c5c8
Update ingress_police_default_test.go with github paths
vishnureddybadveli Dec 19, 2024
d18e16c
Update ingress_police_default_test.go
vishnureddybadveli Dec 19, 2024
4aad252
Merge branch 'main' into vishnureddybadveli-patch-4
vishnureddybadveli Dec 19, 2024
2e74ede
Merge branch 'main' into vishnureddybadveli-patch-4
vishnureddybadveli Dec 26, 2024
868b3ab
Update deviations.go to include gRIBI encap header unsupported
vishnureddybadveli Dec 26, 2024
38fa1da
Update metadata.proto to include gRIBI encap header unsupported
vishnureddybadveli Dec 26, 2024
6b53f56
Update metadata.textproto with proto-file comment
vishnureddybadveli Dec 26, 2024
614d8c3
Update metadata.textproto
vishnureddybadveli Dec 26, 2024
16648f4
Update metadata.textproto
vishnureddybadveli Dec 27, 2024
cd3ffdf
Update metadata.pb.go with gribi encap header unsupported
vishnureddybadveli Dec 27, 2024
8fe6c8f
Merge branch 'main' into vishnureddybadveli-patch-4
vishnureddybadveli Dec 28, 2024
985d2f2
Added Cisco platform deviations
vishnureddybadveli Dec 28, 2024
0501af4
Update deviations.go after resolving merge conflicts with GribiEncapH…
vishnureddybadveli Dec 28, 2024
abadfc3
Update ingress_police_default_test.go with gofmt changes
vishnureddybadveli Dec 28, 2024
84509ce
Update ingress_police_default_test.go
vishnureddybadveli Jan 2, 2025
54dce58
Merge branch 'main' into vishnureddybadveli-patch-4
vishnureddybadveli Jan 2, 2025
3668cae
Update ingress_police_default_test.go with queue name "DEFAULT" inste…
vishnureddybadveli Jan 2, 2025
1e9199d
Added the missing files.
vishnureddybadveli Jan 2, 2025
7716ecb
Merge branch 'main' into vishnureddybadveli-patch-4
vishnureddybadveli Jan 3, 2025
05588fb
Merge branch 'main' into vishnureddybadveli-patch-4
vishnureddybadveli Jan 7, 2025
4ce01a2
Update README.md
vishnureddybadveli Jan 8, 2025
93f0791
Update metadata.textproto
vishnureddybadveli Jan 8, 2025
cc90783
Update ingress_police_default_test.go
vishnureddybadveli Jan 10, 2025
658efe7
Update metadata.textproto
vishnureddybadveli Jan 10, 2025
1981997
Update deviations.go
vishnureddybadveli Jan 10, 2025
e4f9584
Update metadata.proto
vishnureddybadveli Jan 10, 2025
0d5b81b
Update metadata.pb.go
vishnureddybadveli Jan 10, 2025
14687af
Merge branch 'main' into vishnureddybadveli-patch-4
vishnureddybadveli Jan 10, 2025
470b32b
Merge branch 'main' into vishnureddybadveli-patch-4
vishnureddybadveli Jan 13, 2025
657b40f
Update metadata.pb.go
vishnureddybadveli Jan 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion feature/qos/otg_tests/ingress_police_default/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# DP-2.4 Police traffic on input matching all packets using 1 rate, 2 color marker
# DP-2.4: Police traffic on input matching all packets using 1 rate, 2 color marker

## Summary

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,286 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ingress_police_default_test

import (
"fmt"
"testing"
"time"

"github.com/open-traffic-generator/snappi/gosnappi"
"github.com/openconfig/featureprofiles/internal/attrs"
"github.com/openconfig/featureprofiles/internal/deviations"
"github.com/openconfig/featureprofiles/internal/fptest"
"github.com/openconfig/featureprofiles/internal/helpers"
"github.com/openconfig/featureprofiles/internal/otgutils"
"github.com/openconfig/ondatra"
"github.com/openconfig/ondatra/gnmi"
"github.com/openconfig/ondatra/gnmi/oc"
"github.com/openconfig/ygnmi/ygnmi"
"github.com/openconfig/ygot/ygot"
)

var (
intf1 = attrs.Attributes{
Name: "ate1",
MAC: "02:00:01:01:01:01",
IPv4: "198.51.100.1",
IPv4Len: 31,
}

intf2 = attrs.Attributes{
Name: "ate2",
MAC: "02:00:01:02:01:01",
IPv4: "198.51.100.3",
IPv4Len: 31,
}

dutPort1 = attrs.Attributes{
IPv4: "198.51.100.0",
}
dutPort2 = attrs.Attributes{
IPv4: "198.51.100.2",
}
)

type trafficData struct {
expectedThroughputPct float32
gbpsRate uint32
queue string
inputIntf attrs.Attributes
}

func TestMain(m *testing.M) {
fptest.RunTests(m)
}

// configureIntertfaceIngressPolicerCLI is used to configure vendor specific config statements.
func configureIntertfaceIngressPolicerCLI(t *testing.T, dut *ondatra.DUTDevice) {
switch dut.Vendor() {
case ondatra.ARISTA:
vishnureddybadveli marked this conversation as resolved.
Show resolved Hide resolved
var defaultPolicyCLI string
defaultPolicyCLI = fmt.Sprintf("policing \n profile %s rate %d mbps burst-size %d kbytes \n", "DP24", 1000, 1000)
helpers.GnmiCLIConfig(t, dut, defaultPolicyCLI)
defaultPolicyCLI = fmt.Sprintf("interface %s \n policer profile dp24 input \n", dut.Port(t, "port1").Name())
helpers.GnmiCLIConfig(t, dut, defaultPolicyCLI)
case ondatra.CISCO:
var defaultPolicyCLI string
helpers.GnmiCLIConfig(t, dut, "policy-map dp24 \n class class-default \n police 1 gbps \n")
defaultPolicyCLI = fmt.Sprintf("interface %s \n service-policy input dp24 \n", dut.Port(t, "port1").Name())
helpers.GnmiCLIConfig(t, dut, defaultPolicyCLI)
default:
t.Fatalf("Unsupported vendor %s for native command support for deviation 'GribiEncapHeaderUnsupported'", dut.Vendor())
}
}

// Test cases:
// 1. Validate that flow experiences 0 packet loss at 0.7Gbps.
// 2. Validate that flow experiences ~50% packet loss (+/- 1%)
func TestInterfaceIngressPolicer(t *testing.T) {

dut := ondatra.DUT(t, "dut")
dp1 := dut.Port(t, "port1")
dp2 := dut.Port(t, "port2")

// Configure DUT interfaces and QoS.
ConfigureDUTIntf(t, dut)
if deviations.QosSchedulerIngressPolicer(dut) {
configureIntertfaceIngressPolicerCLI(t, dut)
}

// Configure ATE interfaces.
ate := ondatra.ATE(t, "ate")
ap1 := ate.Port(t, "port1")
ap2 := ate.Port(t, "port2")
top := gosnappi.NewConfig()

intf1.AddToOTG(top, ap1, &dutPort1)
intf2.AddToOTG(top, ap2, &dutPort2)
ate.OTG().PushConfig(t, top)

var tolerance float32 = 3.0

// Validate that flow experiences 0 packet loss at 0.7Gbps.
TrafficFlows10 := map[string]*trafficData{
"intf1-be0": {
gbpsRate: 1,
expectedThroughputPct: 100.0,
queue: "DEFAULT",
inputIntf: intf1,
},
}

// Validate that flow experiences ~50% packet loss.
oversubscribedTrafficFlows11 := map[string]*trafficData{
"intf1-be0": {
gbpsRate: 2,
expectedThroughputPct: 100.0,
vishnureddybadveli marked this conversation as resolved.
Show resolved Hide resolved
queue: "DEFAULT",
inputIntf: intf1,
},
}

type test struct {
desc string
trafficFlows map[string]*trafficData
trafficDuration time.Duration
}

cases := []test{
{
desc: "Validate that flow experiences 0 packet loss at 0.7Gbps",
trafficFlows: TrafficFlows10,
trafficDuration: 60 * time.Second,
},
{
desc: "Validate that flow experiences ~50% packet loss at 2Gbps",
trafficFlows: oversubscribedTrafficFlows11,
trafficDuration: 60 * time.Second,
},
}
for _, tc := range cases {
t.Run(tc.desc, func(t *testing.T) {
trafficFlows := tc.trafficFlows
top.Flows().Clear()

for trafficID, data := range trafficFlows {
t.Logf("Configuring flow %s", trafficID)
flow := top.Flows().Add().SetName(trafficID)
flow.Metrics().SetEnable(true)
flow.TxRx().Device().SetTxNames([]string{data.inputIntf.Name + ".IPv4"}).SetRxNames([]string{intf2.Name + ".IPv4"})
ethHeader := flow.Packet().Add().Ethernet()
ethHeader.Src().SetValue(data.inputIntf.MAC)

ipHeader := flow.Packet().Add().Ipv4()
ipHeader.Src().SetValue(data.inputIntf.IPv4)
ipHeader.Dst().SetValue(intf2.IPv4)
flow.Rate().SetGbps(data.gbpsRate)
}

ate.OTG().PushConfig(t, top)
ate.OTG().StartProtocols(t)
otgutils.WaitForARP(t, ate.OTG(), top, "IPv4")

ateOutPkts := make(map[string]uint64)
ateInPkts := make(map[string]uint64)
dutQosPktsBeforeTraffic := make(map[string]uint64)
dutQosPktsAfterTraffic := make(map[string]uint64)
dutQosDroppedPktsBeforeTraffic := make(map[string]uint64)
dutQosDroppedPktsAfterTraffic := make(map[string]uint64)

// Set the initial counters to 0.
for _, data := range trafficFlows {
ateOutPkts[data.queue] = 0
ateInPkts[data.queue] = 0
dutQosPktsBeforeTraffic[data.queue] = 0
dutQosPktsAfterTraffic[data.queue] = 0
dutQosDroppedPktsBeforeTraffic[data.queue] = 0
dutQosDroppedPktsAfterTraffic[data.queue] = 0
}

// Get QoS egress packet counters before the traffic.
const timeout = time.Minute
isPresent := func(val *ygnmi.Value[uint64]) bool { return val.IsPresent() }
for _, data := range trafficFlows {
count, ok := gnmi.Watch(t, dut, gnmi.OC().Qos().Interface(dp2.Name()).Output().Queue(data.queue).TransmitPkts().State(), timeout, isPresent).Await(t)
if !ok {
t.Logf("TransmitPkts count for queue %q on interface %q not available within %v", dp2.Name(), data.queue, timeout)
}
dutQosPktsBeforeTraffic[data.queue], _ = count.Val()

count, ok = gnmi.Watch(t, dut, gnmi.OC().Qos().Interface(dp2.Name()).Output().Queue(data.queue).DroppedPkts().State(), timeout, isPresent).Await(t)
if !ok {
t.Logf("DroppedPkts count for queue %q on interface %q not available within %v", dp2.Name(), data.queue, timeout)
}
dutQosDroppedPktsBeforeTraffic[data.queue], _ = count.Val()
}

t.Logf("Running traffic 1 on DUT interfaces: %s => %s ", dp1.Name(), dp2.Name())
t.Logf("Sending traffic flows: \n%v\n\n", trafficFlows)
ate.OTG().StartTraffic(t)
time.Sleep(tc.trafficDuration)
ate.OTG().StopTraffic(t)
time.Sleep(10 * time.Second)

otgutils.LogFlowMetrics(t, ate.OTG(), top)
for trafficID, data := range trafficFlows {
ateTxPkts := gnmi.Get(t, ate.OTG(), gnmi.OTG().Flow(trafficID).Counters().OutPkts().State())
ateRxPkts := gnmi.Get(t, ate.OTG(), gnmi.OTG().Flow(trafficID).Counters().InPkts().State())
ateOutPkts[data.queue] += ateTxPkts
ateInPkts[data.queue] += ateRxPkts
t.Logf("ateInPkts: %v, txPkts %v, Queue: %v", ateInPkts[data.queue], dutQosPktsAfterTraffic[data.queue], data.queue)
if ateTxPkts == 0 {
t.Fatalf("TxPkts == 0, want >0.")
}
lossPct := (float32)((float64(ateTxPkts-ateRxPkts) * 100.0) / float64(ateTxPkts))
t.Logf("Get flow %q: lossPct: %.2f%% or rxPct: %.2f%%, want: %.2f%%\n\n", data.queue, lossPct, 100.0-lossPct, data.expectedThroughputPct)
if got, want := 100.0-lossPct, data.expectedThroughputPct; got < want-tolerance || got > want+tolerance {
t.Errorf("Get(throughput for queue %q): got %.2f%%, want within [%.2f%%, %.2f%%]", data.queue, got, want-tolerance, want+tolerance)
}
}
})
}
}

func ConfigureDUTIntf(t *testing.T, dut *ondatra.DUTDevice) {
t.Helper()
dp1 := dut.Port(t, "port1")
dp2 := dut.Port(t, "port2")
dp3 := dut.Port(t, "port3")

dutIntfs := []struct {
desc string
intfName string
ipAddr string
prefixLen uint8
}{{
desc: "Input interface port1",
intfName: dp1.Name(),
ipAddr: dutPort1.IPv4,
prefixLen: 31,
}, {
desc: "Input interface port2",
intfName: dp2.Name(),
ipAddr: dutPort2.IPv4,
prefixLen: 31,
}}

// Configure the interfaces.
for _, intf := range dutIntfs {
t.Logf("Configure DUT interface %s with attributes %v", intf.intfName, intf)
i := &oc.Interface{
Name: ygot.String(intf.intfName),
Description: ygot.String(intf.desc),
Type: oc.IETFInterfaces_InterfaceType_ethernetCsmacd,
Enabled: ygot.Bool(true),
}
i.GetOrCreateEthernet()
s := i.GetOrCreateSubinterface(0).GetOrCreateIpv4()
if deviations.InterfaceEnabled(dut) && !deviations.IPv4MissingEnabled(dut) {
s.Enabled = ygot.Bool(true)
}
a := s.GetOrCreateAddress(intf.ipAddr)
a.PrefixLength = ygot.Uint8(intf.prefixLen)
gnmi.Replace(t, dut, gnmi.OC().Interface(intf.intfName).Config(), i)
if deviations.ExplicitInterfaceInDefaultVRF(dut) {
fptest.AssignToNetworkInstance(t, dut, intf.intfName, deviations.DefaultNetworkInstance(dut), 0)
}
}
if deviations.ExplicitPortSpeed(dut) {
fptest.SetPortSpeed(t, dp1)
fptest.SetPortSpeed(t, dp2)
fptest.SetPortSpeed(t, dp3)
}
}
31 changes: 31 additions & 0 deletions feature/qos/otg_tests/ingress_police_default/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-1baea1464db8"
plan_id: "DP-2.4"
description: "Police traffic on input matching all packets using 1 rate, 2 color marker"
testbed: TESTBED_DUT_ATE_4LINKS
platform_exceptions: {
platform: {
vendor: ARISTA
}
deviations: {
static_protocol_name: "STATIC"
qos_scheduler_ingress_policer_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"
qos_scheduler_ingress_policer_unsupported: true
gribi_mac_override_static_arp_static_route: true
interface_enabled: true
default_network_instance: "default"
}
}
5 changes: 5 additions & 0 deletions internal/deviations/deviations.go
Original file line number Diff line number Diff line change
Expand Up @@ -1292,3 +1292,8 @@ func DefaultBgpInstanceName(dut *ondatra.DUTDevice) string {
}
return "DEFAULT"
}

// QosSchedulerIngressPolicer returns true if qos ingress policing is unsupported
func QosSchedulerIngressPolicer(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetQosSchedulerIngressPolicerUnsupported()
}
4 changes: 3 additions & 1 deletion proto/metadata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,9 @@ message Metadata {
// Cisco: b/388983709
// default bgp instance name is used to set bgp instance name value other than DEFAULT
string default_bgp_instance_name = 246;

// Arista: b/346557012
// Devices that do not support qos scheduler ingress policer.
bool qos_scheduler_ingress_policer_unsupported = 247;
// Reserved field numbers and identifiers.
reserved 84, 9, 28, 20, 90, 97, 55, 89, 19, 36, 35, 40, 173;
}
Expand Down
Loading
Loading