Fix to ensure that at least one fc is active when total fcs < 3#5259
Fix to ensure that at least one fc is active when total fcs < 3#5259aks03dev wants to merge 1 commit 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 refines the test for sampled backplane capacity counters by addressing an edge case where the test could inadvertently shut down all Fabric Cards (FCs) in systems with a small number of FCs. The changes ensure that the test always maintains at least one active FC, thereby preserving the validity of the test scenario and preventing unintended system states. Additionally, a check was added to ensure the test only runs when a sufficient number of FCs are available. 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
|
There was a problem hiding this comment.
Code Review
This pull request enhances the TestOnChangeBackplaneCapacityCounters test by adding a pre-condition to skip the test if fewer than two fabric cards are available. It also introduces logic to ensure that at least one fabric card remains active during the test by capping the number of cards to be disabled. A review comment suggests improving the robustness of this capping logic by using a >= comparison instead of == for better future-proofing and clarity.
| if fc == len(fabrics) { | ||
| fc = len(fabrics) - 1 | ||
| t.Logf("Capping fabric cards to disable at %d to keep at least 1 active", fc) | ||
| } |
There was a problem hiding this comment.
For robustness and to better express the intent of never disabling all fabric cards, it's slightly better to use >= instead of == in your condition. While with the current logic fc cannot be greater than len(fabrics) for 2 or more fabrics, using >= makes the condition's purpose—to prevent shutting down all cards—more explicit and robust against potential future changes to the calculation of fc.
| if fc == len(fabrics) { | |
| fc = len(fabrics) - 1 | |
| t.Logf("Capping fabric cards to disable at %d to keep at least 1 active", fc) | |
| } | |
| if fc >= len(fabrics) { | |
| fc = len(fabrics) - 1 | |
| t.Logf("Capping fabric cards to disable at %d to keep at least 1 active", fc) | |
| } |
|
/fptest all |
Brief Description
Previously, for setups with fewer than 3 FCs, the existing shutdown formula could end up shutting down all FCs.
The number of FCs to shut down was calculated as:
n/2 + 1For example, when
n = 2:2/2 + 1 = 2This shuts down both FCs, which would not be a valid test scenario
Change Made
Updated the logic so that if the calculated shutdown count would bring down all FCs, the test shuts down
n - 1FCs instead.