-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add files via upload * Update metadata.textproto * Update ingress_police_default_test.go with github paths * Update ingress_police_default_test.go * Update deviations.go to include gRIBI encap header unsupported * Update metadata.proto to include gRIBI encap header unsupported * Update metadata.textproto with proto-file comment * Update metadata.textproto * Update metadata.textproto * Update metadata.pb.go with gribi encap header unsupported * Added Cisco platform deviations * Update deviations.go after resolving merge conflicts with GribiEncapHeaderUnsupported * Update ingress_police_default_test.go with gofmt changes * Update ingress_police_default_test.go * Update ingress_police_default_test.go with queue name "DEFAULT" instead of "default" Some how queue name is misinterpreted as network instance and check style is cribbing about it. * Added the missing files. * Update README.md missing colon at description. * Update metadata.textproto Use unique UUID * Update ingress_police_default_test.go Using QosSchedulerIngressPolicer deviation. * Update metadata.textproto Using QosSchedulerIngressPolicer deviation. * Update deviations.go Using QosSchedulerIngressPolicer deviation. * Update metadata.proto Using deviation QosSchedulerIngressPolicer * Update metadata.pb.go * Update metadata.pb.go * Add TODO for OC * Fix indent. * Fix indent. * Fix indent. --------- Co-authored-by: sezhang2 <[email protected]>
- Loading branch information
1 parent
a77004e
commit 3947e68
Showing
6 changed files
with
419 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
287 changes: 287 additions & 0 deletions
287
feature/qos/otg_tests/ingress_police_default/ingress_police_default_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,287 @@ | ||
// 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: | ||
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) | ||
} else { | ||
// TODO: Generate openconfig for ingress policier and use gNMI to set it. | ||
} | ||
// 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, | ||
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
31
feature/qos/otg_tests/ingress_police_default/metadata.textproto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.