Repository navigation
Conversation
Pull Request Functional Test Report for #6316 / e25ee08Virtual Devices
Hardware Devices
|
Summary of ChangesHello, 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 introduces a new test suite for the AIGP (Accumulated IGP Metric) feature in BGP. It includes the implementation of the test logic, necessary infrastructure updates to handle AIGP-specific routing policies and interface configurations, and the addition of required platform deviations to ensure compatibility across different vendors. Highlights
Using Gemini Code AssistThe 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
Customization To customize the 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 Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive test suite for BGP AIGP feature support, along with corresponding helper functions, configuration plugins, and platform deviations. The review feedback highlights several critical issues that need to be addressed: a protocol stoppage in testAIGPPropagationNexthop that is never restarted, a lack of mandatory state reversion cleanup using t.Cleanup(), and a potential runtime panic in verifyBestPath due to unsafe slice access. Additionally, traffic validation is triggered prematurely, the OpenConfig path in ApplyRoutePolicyToBGPPeer is broken, non-compliant IP addresses are used, and multiple instances of gnmi.Get should be replaced with gnmi.Watch to prevent test flakiness.
| gnmi.BatchUpdate(b, gnmi.OC().NetworkInstance(niOriginate).TableConnection(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_DIRECTLY_CONNECTED, oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, oc.Types_ADDRESS_FAMILY_IPV4).Config(), tableConn1) | ||
| b.Set(t, dut2) | ||
|
|
||
| otg.StopProtocols(t) |
There was a problem hiding this comment.
In testAIGPPropagationNexthop, otg.StopProtocols(t) is called, but protocols are never restarted. This will cause subsequent test cases to fail because the OTG BGP sessions will be down, and VerifyDUTBGPEstablished will fail. It should be otg.StartProtocols(t) or at least not stopped.
| otg.StopProtocols(t) | |
| otg.StartProtocols(t) |
References
- In multi-subtest routing or BGP tests where subsequent subtests depend on routes advertised in previous subtests, do not withdraw routes at the end of each subtest. Instead, rely on a global OTG cleanup to stop protocols and withdraw all routes at the end of the test.
| func TestAigp(t *testing.T) { | ||
| dut1 := ondatra.DUT(t, "dut1") | ||
| dutTestData[0].dut = dut1 | ||
|
|
||
| dut2 := ondatra.DUT(t, "dut2") | ||
| dutTestData[1].dut = dut2 | ||
|
|
||
| ate := ondatra.ATE(t, "ate") | ||
|
|
||
| // Configure network instances on DUT1 and DUT2 | ||
| configureNetworkInstances(t, dutTestData) | ||
|
|
||
| // Configure DUT1 and DUT2 | ||
| configureDut(t, dutTestData) | ||
| port1DstMac = gnmi.Get(t, dut1, gnmi.OC().Interface(dutTestData[0].lagName[0]).Ethernet().MacAddress().State()) | ||
|
|
||
| // Configure on OTG | ||
| otgConfig := configureOTG(t, ate) |
There was a problem hiding this comment.
The test configures network instances, interfaces, routing policies, BGP, and ISIS on both DUTs, but does not register any cleanup operations using t.Cleanup() to revert these changes. This violates the 'Mandatory State Reversion' and 'Use t.Cleanup()' rules in the repository style guide.
References
- Tests must always leave the system in the exact original state it was in prior to the test execution, and all cleanup operations must be registered using
t.Cleanup(). (link) - To adhere to the mandatory state reversion policy and prevent device state pollution, ensure that
t.Cleanupexplicitly deletes all applied configurations rather than just deleting the VRFs. - Always register cleanup operations using 't.Cleanup()' before executing configuration pushes or destructive operations.
| update := getResponse.GetNotification()[0].GetUpdate()[0] | ||
| val := update.GetVal() | ||
| bestPaths := val.Value.(*gpb.TypedValue_UintVal).UintVal |
There was a problem hiding this comment.
The code accesses getResponse.GetNotification()[0].GetUpdate()[0] directly without checking if the slices are nil or empty. This can cause a runtime panic if the response is empty. Please add appropriate safety checks.
notifications := getResponse.GetNotification()
if len(notifications) == 0 || len(notifications[0].GetUpdate()) == 0 {
t.Fatalf("gNMI GetResponse is empty or missing updates")
}
update := notifications[0].GetUpdate()[0]
val := update.GetVal()| otg.StartTraffic(t) | ||
| validateTrafficFlows(t, otg, otgConfig, otgConfig.Flows().Items()) |
There was a problem hiding this comment.
In testAIGPAttributeValidation, validateTrafficFlows is called immediately after otg.StartTraffic(t) without waiting for the traffic to finish transmitting. Since StartTraffic is non-blocking, this will cause the test to fail because the traffic has not completed. Please add a wait or watch for traffic to complete.
References
- Do not implement custom polling loops that repeatedly start and stop traffic to verify 0% packet loss, as this causes traffic churn and flaky packet counting. Instead, start traffic continuously and use standard helpers like
otgutils.ExpectedTrafficLosswhich internally usegnmi.Watchto wait for the loss to stabilize.
| } else { | ||
| t.Errorf("OC is not supported for vendor %s", dut.Vendor()) | ||
| } |
There was a problem hiding this comment.
In ApplyRoutePolicyToBGPPeer, if AIGPRouteMetricNotSupported is false, the code fails the test with t.Errorf("OC is not supported...") instead of implementing the OpenConfig configuration. This completely breaks the OpenConfig path.
References
- In test helper functions or test cases, do not catch configuration push errors to silently fall back to a different configuration. Instead, explicitly fail the test and handle vendor-specific variations using platform deviations.
| attr: &attrs.Attributes{ | ||
| Desc: "DUT2 Loopback 50", | ||
| IPv4: "198.60.50.2", | ||
| IPv6: "2001:db8:50::2", |
There was a problem hiding this comment.
The IP address 198.60.50.2 is outside the allowed RFC 5737 blocks (192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24) and 198.18.0.0/15. This violates the 'Network Assignments' style guide rule.
| IPv6: "2001:db8:50::2", | |
| IPv4: "198.19.50.2", |
References
- Use RFC 5737 blocks or 100.64.0.0/10, 198.18.0.0/15 for IPv4 network assignments. (link)
| networkInstance: testInstanceParams, | ||
| } | ||
|
|
||
| ateIPv4Prefixes = []string{"198.51.210.0", "198.51.220.0"} |
There was a problem hiding this comment.
The IP addresses 198.51.210.0 and 198.51.220.0 are outside the allowed RFC 5737 blocks and 198.18.0.0/15. This violates the 'Network Assignments' style guide rule.
| ateIPv4Prefixes = []string{"198.51.210.0", "198.51.220.0"} | |
| ateIPv4Prefixes = []string{"198.18.100.0", "198.18.110.0"} |
References
- Use RFC 5737 blocks or 100.64.0.0/10, 198.18.0.0/15 for IPv4 network assignments. (link)
| sent := gnmi.Get(t, dut, | ||
| gnmi.OC().NetworkInstance(ni).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Bgp().Neighbor(nbrAddr).Messages().Sent().State(), | ||
| ) | ||
| if sent.GetUPDATE() == 0 { | ||
| t.Errorf("bgp neighbor %s in NI %s has sent zero UPDATE messages", nbrAddr, ni) | ||
| } |
There was a problem hiding this comment.
verifyBGPUpdatesSentNonZero uses gnmi.Get to query the BGP update messages sent counter immediately. This can lead to flaky tests because the counter might still be 0 when queried. It should use gnmi.Watch to wait for the counter to become non-zero, adhering to the 'Querying Counters' rule.
| sent := gnmi.Get(t, dut, | |
| gnmi.OC().NetworkInstance(ni).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Bgp().Neighbor(nbrAddr).Messages().Sent().State(), | |
| ) | |
| if sent.GetUPDATE() == 0 { | |
| t.Errorf("bgp neighbor %s in NI %s has sent zero UPDATE messages", nbrAddr, ni) | |
| } | |
| _, ok := gnmi.Watch(t, dut, | |
| gnmi.OC().NetworkInstance(ni).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Bgp().Neighbor(nbrAddr).Messages().Sent().State(), | |
| 30*time.Second, | |
| func(val *ygnmi.Value[*oc.NetworkInstance_Protocol_Bgp_Neighbor_Messages_Sent]) bool { | |
| sent, present := val.Val() | |
| return present && sent.GetUPDATE() > 0 | |
| }, | |
| ).Await(t) | |
| if !ok { | |
| t.Errorf("bgp neighbor %s in NI %s has sent zero UPDATE messages", nbrAddr, ni) | |
| } |
References
- Avoid using gnmi.Get for telemetry paths where some vendors only support streaming telemetry. Instead, use gnmi.Watch.
| status := gnmi.Get(t, dut, gnmi.OC().Interface(intfName).OperStatus().State()) | ||
| if status != oc.Interface_OperStatus_UP { | ||
| t.Errorf("interface %s on %s: want UP, got %v", intfName, dut.Name(), status) | ||
| } |
There was a problem hiding this comment.
verifyInterfaceOperStatus uses gnmi.Get to check the interface operational status immediately. This can cause flakiness if the interface takes a few seconds to come up. It should use gnmi.Watch to wait for the status to become UP.
| status := gnmi.Get(t, dut, gnmi.OC().Interface(intfName).OperStatus().State()) | |
| if status != oc.Interface_OperStatus_UP { | |
| t.Errorf("interface %s on %s: want UP, got %v", intfName, dut.Name(), status) | |
| } | |
| _, ok := gnmi.Watch(t, dut, gnmi.OC().Interface(intfName).OperStatus().State(), 30*time.Second, func(val *ygnmi.Value[oc.E_Interface_OperStatus]) bool { | |
| status, present := val.Val() | |
| return present && status == oc.Interface_OperStatus_UP | |
| }).Await(t) | |
| if !ok { | |
| t.Errorf("interface %s on %s: did not become UP", intfName, dut.Name()) | |
| } |
References
- Use 'gnmi.Await' to wait for operational state convergence before querying state with 'gnmi.Get' immediately after pushing configuration, ensuring test stability and reliability.
|
|
||
| // Configure DUT1 and DUT2 | ||
| configureDut(t, dutTestData) | ||
| port1DstMac = gnmi.Get(t, dut1, gnmi.OC().Interface(dutTestData[0].lagName[0]).Ethernet().MacAddress().State()) |
There was a problem hiding this comment.
The code uses gnmi.Get to retrieve the MAC address of the LAG interface immediately after configuration. This can return an empty string if the MAC address is not yet populated in the state, causing traffic flow configuration to fail. It should use gnmi.Watch to wait for a non-empty MAC address.
macVal, ok := gnmi.Watch(t, dut1, gnmi.OC().Interface(dutTestData[0].lagName[0]).Ethernet().MacAddress().State(), 30*time.Second, func(val *ygnmi.Value[string]) bool {
mac, present := val.Val()
return present && mac != ""
}).Await(t)
if !ok {
t.Fatalf("Failed to get MAC address for interface %s", dutTestData[0].lagName[0])
}
port1DstMac, _ = macVal.Val()References
- Use 'gnmi.Await' to wait for operational state convergence before querying state with 'gnmi.Get' immediately after pushing configuration, ensuring test stability and reliability.
Temporary draft PR duplicating the exact changes from #5375 to verify what is flagged by Gemini Code Assist under the current
.gemini/styleguide.md.Original PR: #5375
Readme: https://github.com/openconfig/featureprofiles/blob/main/feature/bgp/otg_tests/aigp_test/README.md