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

fix counters for interfaces #3683

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,22 @@ paths:
/interfaces/interface/subinterfaces/subinterface/ipv6/config/enabled:

## State Paths ##
/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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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 {
Expand Down Expand Up @@ -548,3 +603,39 @@ func waitOTGARPEntry(t *testing.T) {
}).Await(t)

}

func (tc *testCase) setupAggregateAtomically(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be moved to internal/cfgplugins/interface.go and represent the generate config part of the work.

In the Test function, a gnmi.Replace can use the output of the cfgplugin

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Darren, actually these functions are not used in this test, will remove it from here.

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())
}
}
Loading