From 7a653131dbda7fd2e27f829aa7554f5042c51930 Mon Sep 17 00:00:00 2001 From: Ram Machat Date: Tue, 7 Jan 2025 05:30:43 +0000 Subject: [PATCH 1/3] fix counters for interfaces --- .../README.md | 16 +++ ...elemetry_interface_packet_counters_test.go | 107 ++++++++++++++++-- 2 files changed, 115 insertions(+), 8 deletions(-) diff --git a/feature/gnmi/otg_tests/telemetry_interface_packet_counters_test/README.md b/feature/gnmi/otg_tests/telemetry_interface_packet_counters_test/README.md index b44dab58262..28294385537 100644 --- a/feature/gnmi/otg_tests/telemetry_interface_packet_counters_test/README.md +++ b/feature/gnmi/otg_tests/telemetry_interface_packet_counters_test/README.md @@ -74,6 +74,22 @@ paths: ## State Paths ## /interfaces/interface/state/counters/in-pkts: /interfaces/interface/state/counters/out-pkts: + /interfaces/interface/state/counters/carrier-transitions: + /interfaces/interface/state/counters/in-broadcast-pkts: + /interfaces/interface/state/counters/in-discards: + /interfaces/interface/state/counters/in-errors: + /interfaces/interface/state/counters/in-fcs-errors: + /interfaces/interface/state/counters/in-multicast-pkts: + /interfaces/interface/state/counters/in-octets: + /interfaces/interface/state/counters/in-pkts: + /interfaces/interface/state/counters/in-unicast-pkts: + /interfaces/interface/state/counters/out-broadcast-pkts: + /interfaces/interface/state/counters/out-discards: + /interfaces/interface/state/counters/out-errors: + /interfaces/interface/state/counters/out-multicast-pkts: + /interfaces/interface/state/counters/out-octets: + /interfaces/interface/state/counters/out-pkts: + /interfaces/interface/state/counters/out-unicast-pkts: /interfaces/interface/subinterfaces/subinterface/ipv4/state/counters/in-pkts: /interfaces/interface/subinterfaces/subinterface/ipv4/state/counters/out-pkts: /interfaces/interface/subinterfaces/subinterface/ipv6/state/counters/in-pkts: diff --git a/feature/gnmi/otg_tests/telemetry_interface_packet_counters_test/telemetry_interface_packet_counters_test.go b/feature/gnmi/otg_tests/telemetry_interface_packet_counters_test/telemetry_interface_packet_counters_test.go index 9cc8591a9ab..a9eb6412c98 100644 --- a/feature/gnmi/otg_tests/telemetry_interface_packet_counters_test/telemetry_interface_packet_counters_test.go +++ b/feature/gnmi/otg_tests/telemetry_interface_packet_counters_test/telemetry_interface_packet_counters_test.go @@ -37,6 +37,38 @@ func TestMain(m *testing.M) { fptest.RunTests(m) } +type testCase struct { + lagType oc.E_IfAggregate_AggregationType + + dut *ondatra.DUTDevice + ate *ondatra.ATEDevice + top gosnappi.Config + + // dutPorts is the set of ports the DUT -- the first (i.e., dutPorts[0]) + // is not configured in the aggregate interface. + dutPorts []*ondatra.Port + // atePorts is the set of ports on the ATE -- the first, as with the DUT + // is not configured in the aggregate interface. + // is not configured in the aggregate interface. + atePorts []*ondatra.Port + aggID string +} + +const ( + lagTypeLACP = oc.IfAggregate_AggregationType_LACP + lagTypeSTATIC = oc.IfAggregate_AggregationType_STATIC +) + +const ( + ethernetCsmacd = oc.IETFInterfaces_InterfaceType_ethernetCsmacd + ieee8023adLag = oc.IETFInterfaces_InterfaceType_ieee8023adLag + adminUp = oc.Interface_AdminStatus_UP + opUp = oc.Interface_OperStatus_UP + opDown = oc.Interface_OperStatus_DOWN + full = oc.Ethernet_DuplexMode_FULL + dynamic = oc.IfIp_NeighborOrigin_DYNAMIC +) + func TestEthernetCounters(t *testing.T) { dut := ondatra.DUT(t, "dut") dp := dut.Port(t, "port2") @@ -118,9 +150,17 @@ func TestInterfaceCounters(t *testing.T) { path: intfCounterPath + "in-unicast-pkts", counter: intfCounters.InUnicastPkts().State(), }, { - desc: "InUnicastPkts", - path: intfCounterPath + "in-unicast-pkts", - counter: intfCounters.InUnicastPkts().State(), + desc: "OutUnicastPkts", + path: intfCounterPath + "out-unicast-pkts", + counter: intfCounters.OutUnicastPkts().State(), + }, { + desc: "InMulticastPkts", + path: intfCounterPath + "in-multicast-pkts", + counter: intfCounters.InMulticastPkts().State(), + }, { + desc: "OutMulticastPkts", + path: intfCounterPath + "out-multicast-pkts", + counter: intfCounters.OutMulticastPkts().State(), }, { desc: "InPkts", path: intfCounterPath + "in-pkts", @@ -129,26 +169,42 @@ func TestInterfaceCounters(t *testing.T) { desc: "OutPkts", path: intfCounterPath + "out-pkts", counter: intfCounters.OutPkts().State(), + }, { + desc: "InDiscards", + path: intfCounterPath + "in-discards", + counter: intfCounters.InDiscards().State(), + }, { + desc: "OutDiscards", + path: intfCounterPath + "out-discards", + counter: intfCounters.OutDiscards().State(), + }, { + desc: "InErrors", + path: intfCounterPath + "in-errors", + counter: intfCounters.InErrors().State(), + }, { + desc: "OutErrors", + path: intfCounterPath + "out-errors", + counter: intfCounters.OutErrors().State(), + }, { + desc: "InFcsErrors", + path: intfCounterPath + "in-fcs-errors", + counter: intfCounters.InFcsErrors().State(), }, { desc: "IPv4InPkts", path: ipv4CounterPath + "in-pkts", counter: ipv4Counters.InPkts().State(), - skip: skipSubinterfacePacketCountersMissing, }, { desc: "IPv4OutPkts", path: ipv4CounterPath + "out-pkts", counter: ipv4Counters.OutPkts().State(), - skip: skipSubinterfacePacketCountersMissing, }, { desc: "IPv6InPkts", path: ipv6CounterPath + "in-pkts", counter: ipv6Counters.InPkts().State(), - skip: skipSubinterfacePacketCountersMissing, }, { desc: "IPv6OutPkts", path: ipv6CounterPath + "out-pkts", counter: ipv6Counters.OutPkts().State(), - skip: skipSubinterfacePacketCountersMissing, }, { desc: "IPv6InDiscardedPkts", path: ipv6CounterPath + "in-discarded-pkts", @@ -160,7 +216,6 @@ func TestInterfaceCounters(t *testing.T) { counter: ipv6Counters.OutDiscardedPkts().State(), skip: skipIpv6DiscardedPkts, }} - for _, tc := range cases { t.Run(tc.desc, func(t *testing.T) { if tc.skip { @@ -548,3 +603,39 @@ func waitOTGARPEntry(t *testing.T) { }).Await(t) } + +func (tc *testCase) setupAggregateAtomically(t *testing.T) { + d := &oc.Root{} + + if tc.lagType == lagTypeLACP { + d.GetOrCreateLacp().GetOrCreateInterface(tc.aggID) + } + + agg := d.GetOrCreateInterface(tc.aggID) + agg.GetOrCreateAggregation().LagType = tc.lagType + agg.Type = ieee8023adLag + + for _, port := range tc.dutPorts[1:] { + i := d.GetOrCreateInterface(port.Name()) + i.GetOrCreateEthernet().AggregateId = ygot.String(tc.aggID) + i.Type = ethernetCsmacd + + if deviations.InterfaceEnabled(tc.dut) { + i.Enabled = ygot.Bool(true) + } + } + + p := gnmi.OC() + fptest.LogQuery(t, fmt.Sprintf("%s to Update()", tc.dut), p.Config(), d) + gnmi.Update(t, tc.dut, p.Config(), d) +} + +func (tc *testCase) clearAggregate(t *testing.T) { + // Clear the aggregate minlink. + gnmi.Delete(t, tc.dut, gnmi.OC().Interface(tc.aggID).Aggregation().MinLinks().Config()) + + // Clear the members of the aggregate. + for _, port := range tc.dutPorts[1:] { + gnmi.Delete(t, tc.dut, gnmi.OC().Interface(port.Name()).Ethernet().AggregateId().Config()) + } +} From b8190698d2792729ca0f2c7b04069ecf15ca4495 Mon Sep 17 00:00:00 2001 From: Ram Machat Date: Tue, 7 Jan 2025 05:39:23 +0000 Subject: [PATCH 2/3] fixed readme error in repeated paths --- .../telemetry_interface_packet_counters_test/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/feature/gnmi/otg_tests/telemetry_interface_packet_counters_test/README.md b/feature/gnmi/otg_tests/telemetry_interface_packet_counters_test/README.md index 28294385537..1c4f5d3b0dd 100644 --- a/feature/gnmi/otg_tests/telemetry_interface_packet_counters_test/README.md +++ b/feature/gnmi/otg_tests/telemetry_interface_packet_counters_test/README.md @@ -72,8 +72,6 @@ paths: /interfaces/interface/subinterfaces/subinterface/ipv6/config/enabled: ## State Paths ## - /interfaces/interface/state/counters/in-pkts: - /interfaces/interface/state/counters/out-pkts: /interfaces/interface/state/counters/carrier-transitions: /interfaces/interface/state/counters/in-broadcast-pkts: /interfaces/interface/state/counters/in-discards: From 201d74380d8a4fc1e3697101d63a255177721867 Mon Sep 17 00:00:00 2001 From: Ram Machat Date: Thu, 16 Jan 2025 03:42:48 +0000 Subject: [PATCH 3/3] removed irrelevant functions setupAggregateAtomically and clearAggregate, not used in this test --- ...elemetry_interface_packet_counters_test.go | 35 ------------------- 1 file changed, 35 deletions(-) diff --git a/feature/gnmi/otg_tests/telemetry_interface_packet_counters_test/telemetry_interface_packet_counters_test.go b/feature/gnmi/otg_tests/telemetry_interface_packet_counters_test/telemetry_interface_packet_counters_test.go index a9eb6412c98..da3fc5afe72 100644 --- a/feature/gnmi/otg_tests/telemetry_interface_packet_counters_test/telemetry_interface_packet_counters_test.go +++ b/feature/gnmi/otg_tests/telemetry_interface_packet_counters_test/telemetry_interface_packet_counters_test.go @@ -604,38 +604,3 @@ func waitOTGARPEntry(t *testing.T) { } -func (tc *testCase) setupAggregateAtomically(t *testing.T) { - d := &oc.Root{} - - if tc.lagType == lagTypeLACP { - d.GetOrCreateLacp().GetOrCreateInterface(tc.aggID) - } - - agg := d.GetOrCreateInterface(tc.aggID) - agg.GetOrCreateAggregation().LagType = tc.lagType - agg.Type = ieee8023adLag - - for _, port := range tc.dutPorts[1:] { - i := d.GetOrCreateInterface(port.Name()) - i.GetOrCreateEthernet().AggregateId = ygot.String(tc.aggID) - i.Type = ethernetCsmacd - - if deviations.InterfaceEnabled(tc.dut) { - i.Enabled = ygot.Bool(true) - } - } - - p := gnmi.OC() - fptest.LogQuery(t, fmt.Sprintf("%s to Update()", tc.dut), p.Config(), d) - gnmi.Update(t, tc.dut, p.Config(), d) -} - -func (tc *testCase) clearAggregate(t *testing.T) { - // Clear the aggregate minlink. - gnmi.Delete(t, tc.dut, gnmi.OC().Interface(tc.aggID).Aggregation().MinLinks().Config()) - - // Clear the members of the aggregate. - for _, port := range tc.dutPorts[1:] { - gnmi.Delete(t, tc.dut, gnmi.OC().Interface(port.Name()).Ethernet().AggregateId().Config()) - } -}