From 48d46b443cb234e6e3b96cead105c4f96e500737 Mon Sep 17 00:00:00 2001 From: Prem Singh <94350992+singh-prem@users.noreply.github.com> Date: Wed, 24 Apr 2024 14:12:14 +0530 Subject: [PATCH] TE-16.1 Basic Encap Test - fix for using l2 rules and sequenceID (#2885) * fixing issues * added deviation for sequential rules under policy * added vendor.CISCO check in PMD check --- .../basic_encap_test/basic_encap_test.go | 29 ++++++++++++++----- .../basic_encap_test/metadata.textproto | 1 + 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/feature/gribi/otg_tests/basic_encap_test/basic_encap_test.go b/feature/gribi/otg_tests/basic_encap_test/basic_encap_test.go index 66b26e27181..a9d33bea3e2 100644 --- a/feature/gribi/otg_tests/basic_encap_test/basic_encap_test.go +++ b/feature/gribi/otg_tests/basic_encap_test/basic_encap_test.go @@ -104,6 +104,7 @@ const ( // observing on IXIA OTG: Cannot start capture on more than one port belonging to the // same resource group or on more than one port behind the same front panel port in the chassis otgMutliPortCaptureSupported = false + seqIDBase = uint32(10) ) var ( @@ -588,6 +589,16 @@ func getPbrRules(dut *ondatra.DUTDevice, clusterFacing bool) []pbrRule { return pbrRules } +// seqIDOffset returns sequence ID offset added with seqIDBase (10), to avoid sequences +// like 1, 10, 11, 12,..., 2, 21, 22, ... while being sent by Ondatra to the DUT. +// It now generates sequences like 11, 12, 13, ..., 19, 20, 21,..., 99. +func seqIDOffset(dut *ondatra.DUTDevice, i uint32) uint32 { + if deviations.PfRequireSequentialOrderPbrRules(dut) { + return i + seqIDBase + } + return i +} + // configDefaultRoute configures a static route in DEFAULT network-instance. func configDefaultRoute(t *testing.T, dut *ondatra.DUTDevice, v4Prefix, v4NextHop, v6Prefix, v6NextHop string) { t.Logf("Configuring static route in DEFAULT network-instance") @@ -630,7 +641,7 @@ func getPbrPolicy(dut *ondatra.DUTDevice, name string, clusterFacing bool) *oc.N p.SetType(oc.Policy_Type_VRF_SELECTION_POLICY) for _, pRule := range getPbrRules(dut, clusterFacing) { - r := p.GetOrCreateRule(pRule.sequence) + r := p.GetOrCreateRule(seqIDOffset(dut, pRule.sequence)) r4 := r.GetOrCreateIpv4() if pRule.dscpSet != nil { @@ -654,6 +665,11 @@ func getPbrPolicy(dut *ondatra.DUTDevice, name string, clusterFacing bool) *oc.N ra.PostDecapNetworkInstance = ygot.String(pRule.decapVrfSet[1]) ra.DecapFallbackNetworkInstance = ygot.String(pRule.decapVrfSet[2]) } + if deviations.PfRequireMatchDefaultRule(dut) { + if pRule.etherType != nil { + r.GetOrCreateL2().Ethertype = pRule.etherType + } + } if pRule.encapVrf != "" { r.GetOrCreateAction().SetNetworkInstance(pRule.encapVrf) @@ -775,7 +791,7 @@ func configureDUT(t *testing.T, dut *ondatra.DUTDevice) { for idx, a := range []attrs.Attributes{dutPort1, dutPort2, dutPort3, dutPort4, dutPort5} { p := portList[idx] intf := a.NewOCInterface(p.Name(), dut) - if p.PMD() == ondatra.PMD100GBASEFR { + if p.PMD() == ondatra.PMD100GBASEFR && dut.Vendor() != ondatra.CISCO { e := intf.GetOrCreateEthernet() e.AutoNegotiate = ygot.Bool(false) e.DuplexMode = oc.Ethernet_DuplexMode_FULL @@ -896,9 +912,6 @@ func (fa *flowAttr) getFlow(flowType string, name string, dscp uint32) gosnappi. v4.Dst().SetValue(fa.dst) v4.TimeToLive().SetValue(ttl) v4.Priority().Dscp().Phb().SetValue(dscp) - udp := flow.Packet().Add().Udp() - udp.SrcPort().SetValues(randRange(50001, 10000)) - udp.DstPort().SetValues(randRange(50001, 10000)) // add inner ipv4 headers if flowType == "ipv4in4" { @@ -919,10 +932,10 @@ func (fa *flowAttr) getFlow(flowType string, name string, dscp uint32) gosnappi. v6.Dst().SetValue(fa.dst) v6.HopLimit().SetValue(ttl) v6.TrafficClass().SetValue(dscp << 2) - udp := flow.Packet().Add().Udp() - udp.SrcPort().SetValues(randRange(50001, 10000)) - udp.DstPort().SetValues(randRange(50001, 10000)) } + udp := flow.Packet().Add().Udp() + udp.SrcPort().SetValues(randRange(50001, 10000)) + udp.DstPort().SetValues(randRange(50001, 10000)) return flow } diff --git a/feature/gribi/otg_tests/basic_encap_test/metadata.textproto b/feature/gribi/otg_tests/basic_encap_test/metadata.textproto index 8170adcc237..adf9ef8379d 100644 --- a/feature/gribi/otg_tests/basic_encap_test/metadata.textproto +++ b/feature/gribi/otg_tests/basic_encap_test/metadata.textproto @@ -15,6 +15,7 @@ platform_exceptions: { interface_ref_interface_id_format: true ttl_copy_unsupported: true pf_require_match_default_rule: true + pf_require_sequential_order_pbr_rules: true } } platform_exceptions: {