Skip to content

Conversation

@ashishpawar-google
Copy link
Contributor

Added Slow collector test for AFT including subtests.

@ashishpawar-google ashishpawar-google requested a review from a team as a code owner December 26, 2025 12:13
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ashishpawar-google, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request adds a robust test case designed to assess the resilience and performance of the Abstract Forwarding Table (AFT) when gNMI telemetry collectors experience delays. It simulates real-world conditions by introducing latency into a gNMI stream and then observes how the DUT's AFT converges and how system resources are utilized during various BGP route manipulation events. The test ensures that the AFT remains consistent and accurate even when telemetry updates are slowed.

Highlights

  • New Test Case: Introduced a new 'Slow Collector Test' for the Abstract Forwarding Table (AFT) to evaluate system behavior under gNMI telemetry latency.
  • Latency Simulation: The test simulates slow gNMI collectors by injecting artificial latency into one of the two gNMI client streams, allowing for verification of AFT convergence under adverse telemetry conditions.
  • Comprehensive AFT Verification: Includes detailed verification of AFT consistency across multiple gNMI sessions, ensuring correct prefix and next-hop states after various network events.
  • Dynamic Network Scenarios: The test covers several dynamic scenarios, including initial BGP and ISIS route advertisement, partial BGP route withdrawal, complete BGP route withdrawal, and subsequent re-advertisement of routes.
  • Resource Monitoring: Incorporates CPU and memory usage checks for Arista and Cisco devices throughout the test, providing insights into the DUT's resource consumption during AFT churn and telemetry stress.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@OpenConfigBot
Copy link

OpenConfigBot commented Dec 26, 2025

Pull Request Functional Test Report for #4962 / 54da950

Virtual Devices

Device Test Test Documentation Job Raw Log
Arista cEOS status
AFT-1.2: AFTs slow collector
Cisco 8000E status
AFT-1.2: AFTs slow collector
Cisco XRd status
AFT-1.2: AFTs slow collector
Juniper ncPTX status
AFT-1.2: AFTs slow collector
Nokia SR Linux status
AFT-1.2: AFTs slow collector
Openconfig Lemming status
AFT-1.2: AFTs slow collector

Hardware Devices

Device Test Test Documentation Raw Log
Arista 7808 status
AFT-1.2: AFTs slow collector
Cisco 8808 status
AFT-1.2: AFTs slow collector
Juniper PTX10008 status
AFT-1.2: AFTs slow collector
Nokia 7250 IXR-10e status
AFT-1.2: AFTs slow collector

Help

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a comprehensive new test for AFT (Abstract Forwarding Table) telemetry with a slow collector. The test covers various scenarios including initial sync, route withdrawal, and re-advertisement, while also monitoring DUT resource usage. The overall structure is good, but there are several areas for improvement. I've identified a critical issue with missing constant definitions that will cause compilation errors. Additionally, there are opportunities to improve code maintainability by refactoring duplicated code in configuration helpers and by structuring the main test function with t.Run for subtests as recommended by the style guide.

Comment on lines 85 to 86
cpuPctThreshold = 6.0
memPctThreshold = 10.0
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The constants maxMemoryIncreasePercent and maxCPUIncreasePercent used in checkMemoryUsage and checkCPUUsage are not defined, which will cause a compilation error. Conversely, the constants cpuPctThreshold and memPctThreshold are defined but never used. It seems the intention was to use these values. Please define the required constants and remove the unused ones.

Suggested change
cpuPctThreshold = 6.0
memPctThreshold = 10.0
maxCPUIncreasePercent = 6.0
maxMemoryIncreasePercent = 10.0

Comment on lines 27 to 28
"github.com/google/go-cmp/cmp"
"github.com/google/go-grpc/grpc"
"github.com/google/go-grpc/metadata"
"github.com/google/go-cmp/cmp/cmpopts"
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The imports in this file are not alphabetically sorted. According to the Google Go Style Guide, which is referenced in the repository's contribution guidelines, imports should be grouped by standard library, third-party, and local packages, and sorted alphabetically within each group. Running goimports would automatically fix this.

Suggested change
"github.com/google/go-cmp/cmp"
"github.com/google/go-grpc/grpc"
"github.com/google/go-grpc/metadata"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/go-grpc/grpc"
"github.com/google/go-grpc/metadata"
References
  1. The repository style guide requires following the Google Go Style Guide, which recommends sorting imports. (link)

Comment on lines +301 to +310
switch nbr.version {
case IPv4:
neighbor.SetPeerGroup(peerGrpNameV4)
neighbor.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).SetEnabled(true)
neighbourAFV4 := peerGroupV4.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST)
neighbourAFV4.SetEnabled(true)
applyPolicy := neighbourAFV4.GetOrCreateApplyPolicy()
applyPolicy.ImportPolicy = []string{applyPolicyName}
applyPolicy.ExportPolicy = []string{applyPolicyName}
case IPv6:
neighbor.SetPeerGroup(peerGrpNameV6)
neighbor.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).SetEnabled(true)
neighbourAFV6 := peerGroupV6.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST)
neighbourAFV6.SetEnabled(true)
applyPolicy := neighbourAFV6.GetOrCreateApplyPolicy()
applyPolicy.ImportPolicy = []string{applyPolicyName}
applyPolicy.ExportPolicy = []string{applyPolicyName}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The switch statement contains duplicated logic for configuring the AFI-SAFI policy for IPv4 and IPv6. This can be refactored to reduce repetition and improve maintainability, following the "Effective Go" principle of avoiding repetition. Consider creating a helper function or using local variables to abstract the common configuration logic.

References
  1. The repository style guide references 'Effective Go', which recommends avoiding repetition in code. (link)

Comment on lines +372 to +476
// Configuration on port1.
d1Eth := d1.Ethernets().
Add().
SetName(d1.Name() + ".eth").
SetMac(port1MAC).
SetMtu(mtu)
d1Eth.
Connection().
SetPortName(p1.Name())

d1IPv4 := d1Eth.
Ipv4Addresses().
Add().
SetName(d1Eth.Name() + ".IPv4").
SetAddress(ateP1.IPv4).
SetGateway(dutP1.IPv4).
SetPrefix(v4PrefixLen)

d1IPv6 := d1Eth.
Ipv6Addresses().
Add().
SetName(d1Eth.Name() + ".IPv6").
SetAddress(ateP1.IPv6).
SetGateway(dutP1.IPv6).
SetPrefix(v6PrefixLen)

d1ISIS := d1.Isis().
SetName(d1.Name() + ".isis").
SetSystemId(isisSystemID)
d1ISIS.Basic().
SetIpv4TeRouterId(d1IPv4.Address()).
SetHostname("ixia-c-port1")
d1ISIS.Advanced().SetAreaAddresses([]string{"49"})
d1ISISInt := d1ISIS.Interfaces().
Add().
SetName(d1ISIS.Name() + ".intf").
SetEthName(d1Eth.Name()).
SetNetworkType(gosnappi.IsisInterfaceNetworkType.POINT_TO_POINT).
SetLevelType(gosnappi.IsisInterfaceLevelType.LEVEL_2).
SetMetric(10)
d1ISISInt.TrafficEngineering().Add().PriorityBandwidths()
d1ISISInt.Advanced().SetAutoAdjustMtu(true).SetAutoAdjustArea(true).SetAutoAdjustSupportedProtocols(true)

d1ISISRoute := d1ISIS.V4Routes().Add().SetName(d1ISIS.Name() + ".rr")
d1ISISRoute.Addresses().
Add().
SetAddress(isisRoute).
SetPrefix(advertisedRoutesV4Prefix).SetCount(isisRouteCount)

d1ISISRouteV6 := d1ISIS.V6Routes().Add().SetName(d1ISISRoute.Name() + ".v6")
d1ISISRouteV6.Addresses().
Add().
SetAddress(isisRoutev6).
SetPrefix(advertisedRoutesV6Prefix).SetCount(isisRouteCount)

tc.configureBGPDev(d1, d1IPv4, d1IPv6)

// Configuration on port2
d2Eth := d2.Ethernets().
Add().
SetName(d2.Name() + ".eth").
SetMac(port2MAC).
SetMtu(mtu)
d2Eth.
Connection().
SetPortName(p2.Name())
d2IPv4 := d2Eth.Ipv4Addresses().
Add().
SetName(d2Eth.Name() + ".IPv4").
SetAddress(ateP2.IPv4).
SetGateway(dutP2.IPv4).
SetPrefix(v4PrefixLen)

d2IPv6 := d2Eth.
Ipv6Addresses().
Add().
SetName(d2Eth.Name() + ".IPv6").
SetAddress(ateP2.IPv6).
SetGateway(dutP2.IPv6).
SetPrefix(v6PrefixLen)

d2ISIS := d2.Isis().
SetName(d2.Name() + ".isis").
SetSystemId(isisSystemID)
d2ISIS.Basic().
SetIpv4TeRouterId(d2IPv4.Address()).
SetHostname("ixia-c-port2")
d2ISIS.Advanced().SetAreaAddresses([]string{"49"})
d2ISISInt := d2ISIS.Interfaces().
Add().
SetName(d2ISIS.Name() + ".intf").
SetEthName(d2Eth.Name()).
SetNetworkType(gosnappi.IsisInterfaceNetworkType.POINT_TO_POINT).
SetLevelType(gosnappi.IsisInterfaceLevelType.LEVEL_2).
SetMetric(10)
d2ISISInt.TrafficEngineering().Add().PriorityBandwidths()
d2ISISInt.Advanced().SetAutoAdjustMtu(true).SetAutoAdjustArea(true).SetAutoAdjustSupportedProtocols(true)

d2ISISRoute := d2ISIS.V4Routes().Add().SetName(d2ISIS.Name() + ".rr")
d2ISISRoute.Addresses().
Add().
SetAddress(isisRoute).
SetPrefix(advertisedRoutesV4Prefix).
SetCount(isisRouteCount)

d2ISISRouteV6 := d2ISIS.V6Routes().Add().SetName(d2ISISRoute.Name() + ".v6")
d2ISISRouteV6.Addresses().
Add().
SetAddress(isisRoutev6).
SetPrefix(advertisedRoutesV6Prefix).
SetCount(isisRouteCount)

tc.configureBGPDev(d2, d2IPv4, d2IPv6)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The configureATE function contains a large amount of duplicated code for configuring ATE devices d1 (on port1) and d2 (on port2). This makes the function long and hard to maintain. This code can be refactored into a helper function to improve readability and maintainability, in line with the "Effective Go" principle of avoiding repetition.

For example, you could create a helper function like configureATEDevice that takes parameters for the device, port, IPs, MAC, etc., and call it for each ATE port.

func (tc *testCase) configureATEDevice(t *testing.T, config gosnappi.Config, port gosnappi.Port, dev gosnappi.Device, mac string, ateAttrs, dutAttrs attrs.Attributes) {
    // ... configuration logic for one device ...
}

func (tc *testCase) configureATE(t *testing.T) {
    // ...
    tc.configureATEDevice(t, config, p1, d1, port1MAC, ateP1, dutP1)
    tc.configureATEDevice(t, config, p2, d2, port2MAC, ateP2, dutP2)
    // ...
}
References
  1. The repository style guide references 'Effective Go', which recommends avoiding repetition in code. (link)

Comment on lines 1081 to 1169
// AFT-1.2.2: AFT route withdrawal from one BGP peer scenario 1
t.Log("Subtest 2: Withdraw BGP routes from ATE port 2...")

p2Name := ate.Port(t, port2Name).ID()
d2Name := p2Name + ".d2"
bgp4PeerName := d2Name + ".BGP4.peer"
bgp6PeerName := d2Name + ".BGP6.peer"
v4RouteName := bgp4PeerName + ".v4route"
v6RouteName := bgp6PeerName + ".v6route"
controlState := gosnappi.NewControlState()
controlState.Protocol().Route().
SetNames([]string{v4RouteName, v6RouteName}).
SetState(gosnappi.StateProtocolRouteState.WITHDRAW)
ate.OTG().SetControlState(t, controlState)

t.Log("SubTest 2: Withdrew BGP routes from ATE port 2.")
if err := tc.waitForBGPSessions(t, []string{ateP1.IPv4}, []string{ateP1.IPv6}); err != nil {
t.Fatalf("Unable to establish BGP session: %v", err)
}

startTime = time.Now()
wantIPv4NHsAfterWithdraw := map[string]bool{ateP1.IPv4: true}
wantIPv6NHsAfterWithdraw := getPostChurnIPv6NH(dut)
stoppingCondition = aftcache.InitialSyncStoppingCondition(t, dut, wantPrefixes, wantIPv4NHsAfterWithdraw, wantIPv6NHsAfterWithdraw)

waitAndVerify("route withdrawal convergence", "post-route-withdrawal-port2", 1, false)

// AFT-1.2.3: AFT Withdraw prefixes from both the BGP neighbor scenario 2
t.Log("Subtest 3: Withdraw BGP routes from ATE port 1...")

p1Name := ate.Port(t, port1Name).ID()
d1Name := p1Name + ".d1"
bgp4PeerNameP1 := d1Name + ".BGP4.peer"
bgp6PeerNameP1 := d1Name + ".BGP6.peer"
v4RouteNameP1 := bgp4PeerNameP1 + ".v4route"
v6RouteNameP1 := bgp6PeerNameP1 + ".v6route"
controlStateP1 := gosnappi.NewControlState()
controlStateP1.Protocol().Route().
SetNames([]string{v4RouteNameP1, v6RouteNameP1}).
SetState(gosnappi.StateProtocolRouteState.WITHDRAW)
ate.OTG().SetControlState(t, controlStateP1)

t.Log("Withdrew BGP routes from ATE port 1. Waiting for convergence...")

startTime = time.Now()
// Stopping condition: Wait for BGP routes to be deleted.
stoppingCondition = aftcache.DeletionStoppingCondition(t, dut, wantPrefixes)

waitAndVerify("complete route withdrawal convergence", "post-route-withdrawal-all", 0, true)

// AFT-1.2.4: AFT readvertise the prefixes from port1 bgp neighbor scenario 3
t.Log("Subtest 4: Re-advertise BGP routes from ATE port 1...")
if err := tc.waitForBGPSessions(t, []string{ateP1.IPv4}, []string{ateP1.IPv6}); err != nil {
t.Fatalf("Unable to establish BGP session: %v", err)
}

controlStateP1Adv := gosnappi.NewControlState()
controlStateP1Adv.Protocol().Route().
SetNames([]string{v4RouteNameP1, v6RouteNameP1}).
SetState(gosnappi.StateProtocolRouteState.ADVERTISE)
ate.OTG().SetControlState(t, controlStateP1Adv)

t.Log("Re-advertised BGP routes from ATE port 1. Waiting for convergence...")

startTime = time.Now()
wantIPv4NHsP1 := map[string]bool{ateP1.IPv4: true}
wantIPv6NHsP1 := getPostChurnIPv6NH(dut)
stoppingCondition = aftcache.InitialSyncStoppingCondition(t, dut, wantPrefixes, wantIPv4NHsP1, wantIPv6NHsP1)

waitAndVerify("re-advertise convergence", "post-readvertise-port1", 1, false)

// AFT-1.2.5: AFT Readvertise the BGP prefixes from both the neighbors scenario 4
t.Log("Subtest 5: Re-advertise BGP routes from ATE port 1 and port 2...")
if err := tc.waitForBGPSessions(t, []string{ateP1.IPv4, ateP2.IPv4}, []string{ateP1.IPv6, ateP2.IPv6}); err != nil {
t.Fatalf("Unable to establish BGP session: %v", err)
}

controlStateAllAdv := gosnappi.NewControlState()
controlStateAllAdv.Protocol().Route().
SetNames([]string{v4RouteName, v6RouteName, v4RouteNameP1, v6RouteNameP1}).
SetState(gosnappi.StateProtocolRouteState.ADVERTISE)
ate.OTG().SetControlState(t, controlStateAllAdv)

t.Log("Re-advertised BGP routes from ATE port 1 and 2. Waiting for convergence...")

startTime = time.Now()
stoppingCondition = aftcache.InitialSyncStoppingCondition(t, dut, wantPrefixes, wantIPv4NHs, wantIPv6NHs)

waitAndVerify("re-advertise convergence", "post-readvertise-all", 2, false)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The repository style guide states, "Use t.Run for subtests so output clearly reflects passed/failed steps." This test implements multiple logical sub-scenarios sequentially within the TestSlowCollector function, identified by comments like // AFT-1.2.2: .... To improve test readability, output clarity, and adherence to the style guide, these scenarios should be refactored into t.Run blocks.

For example, the route withdrawal test could be wrapped as follows:

t.Run("AFT-1.2.2: Withdraw BGP routes from ATE port 2", func(t *testing.T) {
    t.Log("Subtest 2: Withdraw BGP routes from ATE port 2...")
    // ... logic for withdrawing routes from port 2 ...
    waitAndVerify("route withdrawal convergence", "post-route-withdrawal-port2", 1, false)
})

This should be applied to all logical subtests in this function.

References
  1. The repository style guide requires the use of t.Run for subtests to ensure clear output for passed/failed steps. (link)

@coveralls
Copy link

coveralls commented Dec 26, 2025

Pull Request Test Coverage Report for Build 20651105042

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 10.03%

Totals Coverage Status
Change from base Build 20650373581: 0.0%
Covered Lines: 2227
Relevant Lines: 22203

💛 - Coveralls

@ashishpawar-google ashishpawar-google force-pushed the aft_slow_collector_test branch 8 times, most recently from 1427fbf to 81c928a Compare January 2, 2026 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants