[nexus] add mechanism to emulate node reset - #11662
Conversation
There was a problem hiding this comment.
Summary of Changes
Hello @abtink, 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 significantly enhances the Nexus simulation platform by introducing a robust and comprehensive mechanism to emulate a node reset. This capability is vital for thoroughly testing network resilience and recovery scenarios. The changes involve adding explicit reset functionalities across core platform components and a structural refactoring of the node class, culminating in a new, large-scale test case that simulates a full network reset.
Highlights
- Node Reset Mechanism: I've introduced a new
Node::Reset()method within theNexussimulation platform. This method is designed to emulate a node reset by reinitializing theot::Instancewhile carefully preserving non-volatile settings (mSettings) and ensuring various platform components (Radio, Alarm, mDNS, Trel) are properly reset to their initial states. - Platform Component Reset: To support the comprehensive node reset, I've added explicit
Reset()methods to key platform components such asAlarm,Mdns,Radio, andTrel. These methods are responsible for clearing the transient state of each component, ensuring a clean re-initialization during a node reset. - Code Refactoring for Clarity: I've refactored the
Nodeclass by extracting common platform-related members into a newPlatformbase class. TheNodeclass now inherits fromPlatform, which improves code organization, enhances modularity, and simplifies the management of platform components during the reset process. - New Network Reset Test: A significant addition is the new
test_full_network_resettest. This test leverages the newly implementedNode::Reset()functionality to simulate a full, simultaneous reset of 200 nodes in a large network. It then measures and logs the time required for the network to stabilize and all nodes to rejoin a healthy partition, providing valuable insights into network resilience.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| 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 issue 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 is currently in preview and 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 to provide feedback.
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
-
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. ↩
There was a problem hiding this comment.
Code Review
The pull request introduces a mechanism to emulate node reset within the Nexus test framework, along with a new test case to validate network stabilization after a full reset. The refactoring of platform components into a Platform base class enhances modularity. However, a critical issue exists in the Node::Reset implementation regarding the reinitialization of the ot::Instance base class, which could lead to resource leaks.
Size Report of OpenThread
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #11662 +/- ##
==========================================
+ Coverage 71.02% 74.63% +3.61%
==========================================
Files 614 641 +27
Lines 95037 98507 +3470
==========================================
+ Hits 67500 73525 +6025
+ Misses 27537 24982 -2555 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a mechanism to emulate a full node reset in Nexus and adds an associated test to measure network stabilization time after reset.
- Adds
Reset()implementations for platform components (radio, trel, mdns, alarm) andNode::Resetto clear state and reinitialize the OpenThreadInstance - Implements
test_full_network_reset.cpptest that resets all nodes, rejoins them, and logs time to stabilization - Registers the new test in
CMakeLists.txt
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/nexus/test_full_network_reset.cpp | New test to emulate and time a full network reset |
| tests/nexus/platform/nexus_trel.hpp | Declared Trel::Reset() |
| tests/nexus/platform/nexus_trel.cpp | Implemented Trel::Reset() |
| tests/nexus/platform/nexus_radio.hpp | Declared Radio::Reset() |
| tests/nexus/platform/nexus_radio.cpp | Implemented Radio::Reset() |
| tests/nexus/platform/nexus_node.hpp | Declared Node::Reset() |
| tests/nexus/platform/nexus_node.cpp | Implemented Node::Reset() to clear state and reinit |
| tests/nexus/platform/nexus_mdns.hpp | Declared Mdns::Reset() |
| tests/nexus/platform/nexus_mdns.cpp | Implemented Mdns::Reset() |
| tests/nexus/platform/nexus_alarm.hpp | Refactored Alarm ctor to call Reset() |
| tests/nexus/CMakeLists.txt | Added full_network_reset to test suite |
Comments suppressed due to low confidence (1)
tests/nexus/test_full_network_reset.cpp:29
- The '<stdarg.h>' header appears unused; consider removing it to reduce unnecessary dependencies.
#include <stdarg.h>
This commit adds a new mechanism to emulate a node reset on `Nexus::Node`. This is realized by resetting all platform components while ensuring the non-volatile `mSettings` remains unchanged, then reinitializing the `ot::Instance` by invoking its constructor. This is used to add a new `test_full_network_reset` test, which emulates a full simultaneous reset of all nodes in a large network, tracking how long it takes for the network to stabilize after the reset event.
This commit adds a new mechanism to emulate a node reset on
Nexus::Node. This is realized by resetting all platform components while ensuring the non-volatilemSettingsremains unchanged, then reinitializing theot::Instanceby invoking its constructor.This is used to add a new
test_full_network_resettest, which emulates a full simultaneous reset of all nodes in a large network, tracking how long it takes for the network to stabilize after the reset event.