added wait for port up before checking bgp neighborship#5391
added wait for port up before checking bgp neighborship#5391mnp-juniper wants to merge 3 commits intoopenconfig:mainfrom
Conversation
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 addresses a race condition occurring after system reboots in the AFT reboot test suite. By explicitly verifying that the interface has reached an operational UP status before attempting to validate BGP sessions, the change ensures that the test environment is fully initialized, thereby increasing the reliability of the test execution. 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 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 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. Footnotes
|
Pull Request Functional Test Report for #5391 / 117f68dVirtual Devices
Hardware Devices
|
There was a problem hiding this comment.
Code Review
This pull request adds a check to ensure the network interface is operational after a reboot before verifying BGP sessions. The review feedback correctly identifies an incorrect usage of the gnmi.Await function, which does not support a timeout argument in its standard signature, and suggests using gnmi.Watch(...).Await(t) instead. The feedback also recommends increasing the timeout to 12 minutes and verifying multiple ports to improve test robustness.
| dutPort := tc.dut.Port(t, port1Name).Name() | ||
| t.Log("Waiting for interface to come up before checking BGP neighborship after reboot...") | ||
| gnmi.Await(t, dut, gnmi.OC().Interface(dutPort).OperStatus().State(), 12*time.Minute, oc.Interface_OperStatus_UP) |
There was a problem hiding this comment.
The gnmi.Await function does not support a timeout argument in its standard signature. To wait for a condition with a specific timeout, you should use gnmi.Watch(...).Await(t).
Additionally:
- Use tc.dut instead of dut for consistency within the test case.
- The timeout is increased to 12 minutes to align with the PR description and ensure the convergence timeout is sufficiently long for a reboot scenario, per repository guidelines.
- Note that awaiting intermediate interface states may be redundant if a subsequent final state (like BGP) is also awaited, though it can assist in debugging.
| dutPort := tc.dut.Port(t, port1Name).Name() | |
| t.Log("Waiting for interface to come up before checking BGP neighborship after reboot...") | |
| gnmi.Await(t, dut, gnmi.OC().Interface(dutPort).OperStatus().State(), 12*time.Minute, oc.Interface_OperStatus_UP) | |
| for _, port := range []string{port1Name, port2Name} { | |
| dutPort := tc.dut.Port(t, port).Name() | |
| t.Logf("Waiting for interface %s to come up before checking BGP neighborship after reboot...", dutPort) | |
| _, ok := gnmi.Watch(t, tc.dut, gnmi.OC().Interface(dutPort).OperStatus().State(), 12*time.Minute, func(val *ygnmi.Value[oc.E_Interface_OperStatus]) bool { | |
| v, ok := val.Val() | |
| return ok && v == oc.Interface_OperStatus_UP | |
| }).Await(t) | |
| if !ok { | |
| t.Fatalf("Interface %s did not come up within timeout", dutPort) | |
| } | |
| } |
References
- In tests that inject artificial latency or involve reboots, convergence timeouts must be sufficiently long to account for the added delay and prevent premature test failure.
- Avoid redundant gnmi.Await calls. Awaiting a final state (e.g., interfaces being up) can make an earlier await for an intermediate state (e.g., breakout mode completion) unnecessary.
Issue:
After the system reboot the script is checking for bgp neighborship while the interface is still coming up.
Fix:
Added a wait time upto 12 minutes for the interface to come up