Repository navigation
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 standardizes the cleanup process across various feature profiles tests by migrating from 'defer' to 't.Cleanup'. This change ensures that DUT configurations, including AAA settings, network instances, and vendor-specific CLI overrides, are consistently reverted regardless of test outcomes, thereby improving testbed stability and reducing cross-test interference. 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 comprehensive cleanup handlers (t.Cleanup) across various test suites (including AAA, credentialz, gRIBI, policy forwarding, and system logging/NTP) to ensure that modified configurations are reverted and the shared testbed is restored to its original state. While these additions align with the repository's mandatory state reversion guidelines, the reviewer noted that unconditionally deleting the entire NTP configuration in system_ntp_test.go can wipe out pre-existing NTP servers on shared devices. It is recommended to capture and restore the original NTP configuration instead of performing a flat deletion.
e7b427d to
5c20849
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request systematically introduces robust cleanup routines using t.Cleanup across various test suites (including AAA, NTP, logging, and gRIBI tests) to ensure that any modified configurations or added users are reverted upon test completion. This aligns with the repository's mandatory state reversion guidelines. One critical feedback item is provided regarding the NTP test cleanup, where unconditionally deleting the entire loopback interface config (lo0 on Juniper) can disrupt shared testbeds and lock out management access; it is recommended to target only the specific subinterface instead.
5c20849 to
14d34e4
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request systematically introduces t.Cleanup handlers across multiple test suites (including acctz, credentialz, gribi, policy_forwarding, security, and system logging tests) to ensure proper cleanup and state reversion of DUT configurations (both gNMI and CLI) upon test completion. This directly aligns with the repository's mandatory state reversion guidelines. There are no review comments provided, and I have no additional feedback to offer as the changes are correct and follow the style guide.
363e078 to
d75d19f
Compare
d75d19f to
e90f1b1
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request improves test reliability and state cleanup across various feature tests (gNSI, gRIBI, and system logging) by registering cleanup operations using t.Cleanup() to ensure the DUT is restored to its original state. The changes include batching delete operations, moving cleanup registrations earlier in tests, and reverting specific device configurations. The review feedback suggests replacing defer with t.Cleanup() for flushing and closing the gRIBI client in the MPLS-in-UDP test to align with the repository's style guide.
| defer c.Close(t) | ||
| defer c.FlushAll(t) |
There was a problem hiding this comment.
In alignment with the repository style guide and the goal of this PR, persistent state cleanup on the DUT (such as flushing and closing the gRIBI client) should be registered using t.Cleanup() rather than defer. This ensures that the cleanup is guaranteed to run even if the test fails or panics early, and avoids potential LIFO ordering issues with multiple defers.
| defer c.Close(t) | |
| defer c.FlushAll(t) | |
| t.Cleanup(func() { | |
| c.FlushAll(t) | |
| c.Close(t) | |
| }) |
References
- All cleanup operations, whether for gNMI configurations or raw CLI commands, must be registered using t.Cleanup() to guarantee they are executed even if the test fails or panics early. (link)
- Always register cleanup operations using 't.Cleanup()' before executing configuration pushes or destructive operations to ensure that the cleanup routine is safely queued and will execute to restore the system state even if the operation fails.
Ensure featureprofiles tests restore persistent DUT AAA users, gNSI credentialz/acctz policies, system logging selectors, and gRIBI state via
t.Cleanup/deferso failed or interrupted test runs do not leave testbeds in an unhealthy state:feature/gnsi/credentialz,internal/security/credz):internal/security/credz/credz.go: Registert.Cleanupincredz.SetupUserto delete created OpenConfig AAA test users on exit.feature/gnsi/credentialz/tests/hiba_authentication/hiba_authentication_test.go: Registert.CleanupbeforeRotateAuthenticationTypesandRotateTrustedUserCAso SSH authentication policies and authorized principal checks are restored even if subtests fail early.feature/gnsi/credentialz/tests/host_certificates/host_certificates_test.go: Registert.Cleanupto restore authentication artifacts on exit.feature/gnsi/credentialz/tests/ssh_password_login_disallowed/ssh_password_login_disallowed_test.go: Registert.CleanupbeforeRotateAuthenticationTypesso password/pubkey/keyboard-interactive SSH authentication types are restored even if subtests fail early.feature/gnsi/acctz):feature/gnsi/acctz/tests/AccountingAuthenErrorMulti/accounting_authen_error_multi_test.go: FixsetupTestUser(which previously queued agnmi.BatchDeleteonto an unapplied batch) andconfigureTacacsAAAWithLocalFallbackto delete the test user andTACACSserver group on the DUT viagnmi.Deleteint.Cleanup.feature/gnsi/acctz/tests/record_payload_truncation/record_payload_truncation_test.go: Batchacctz-test-ni-*network-instance deletions int.Cleanupusinggnmi.SetBatch.feature/system/logging):feature/system/logging/otg_tests/console_vty_file/console_vty_file_test.go: Snapshot/system/logging/configbefore test modifications and restore or delete it insidefptest.NonFatalint.Cleanup.feature/gribi):feature/gribi/mpls_in_udp/otg_tests/mpls_in_udp/mpls_in_udp_test.go: Registerdefer c.FlushAll(t)alongsidedefer c.Close(t)so gRIBI AFT entries are flushed before closing the client even if the test exits early.feature/gribi/otg_tests/hashing_test/hashing_test.go: Registert.Cleanupto revert Nokiaper-complex-randomizationload-balancing hash option tofalse.