Skip to content

[nexus] add mechanism to emulate node reset - #11662

Merged
jwhui merged 1 commit into
openthread:mainfrom
abtink:nexus/reset-node
Jul 8, 2025
Merged

[nexus] add mechanism to emulate node reset#11662
jwhui merged 1 commit into
openthread:mainfrom
abtink:nexus/reset-node

Conversation

@abtink

@abtink abtink commented Jul 2, 2025

Copy link
Copy Markdown
Member

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 the Nexus simulation platform. This method is designed to emulate a node reset by reinitializing the ot::Instance while 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 as Alarm, Mdns, Radio, and Trel. 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 Node class by extracting common platform-related members into a new Platform base class. The Node class now inherits from Platform, 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_reset test. This test leverages the newly implemented Node::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

  1. 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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/nexus/platform/nexus_node.cpp
@size-report

size-report Bot commented Jul 2, 2025

Copy link
Copy Markdown

Size Report of OpenThread

Merging #11662 into main(cef5ec9).

name branch text data bss total
ot-cli-ftd main 478104 860 66524 545488
#11662 478104 860 66524 545488
+/- 0 0 0 0
ot-ncp-ftd main 443972 764 61768 506504
#11662 443972 764 61768 506504
+/- 0 0 0 0
libopenthread-ftd.a main 245142 95 40302 285539
#11662 245142 95 40302 285539
+/- 0 0 0 0
libopenthread-cli-ftd.a main 60743 0 8083 68826
#11662 60743 0 8083 68826
+/- 0 0 0 0
libopenthread-ncp-ftd.a main 33257 0 5948 39205
#11662 33257 0 5948 39205
+/- 0 0 0 0
ot-cli-mtd main 371152 764 50988 422904
#11662 371152 764 50988 422904
+/- 0 0 0 0
ot-ncp-mtd main 352276 764 46256 399296
#11662 352276 764 46256 399296
+/- 0 0 0 0
libopenthread-mtd.a main 163779 0 24790 188569
#11662 163779 0 24790 188569
+/- 0 0 0 0
libopenthread-cli-mtd.a main 41134 0 8059 49193
#11662 41134 0 8059 49193
+/- 0 0 0 0
libopenthread-ncp-mtd.a main 25785 0 5948 31733
#11662 25785 0 5948 31733
+/- 0 0 0 0
ot-cli-ftd-br main 575296 868 134036 710200
#11662 575296 868 134036 710200
+/- 0 0 0 0
libopenthread-ftd-br.a main 346145 100 107782 454027
#11662 346145 100 107782 454027
+/- 0 0 0 0
libopenthread-cli-ftd-br.a main 75862 0 8115 83977
#11662 75862 0 8115 83977
+/- 0 0 0 0
ot-rcp main 63184 568 20804 84556
#11662 63184 568 20804 84556
+/- 0 0 0 0
libopenthread-rcp.a main 9932 0 5060 14992
#11662 9932 0 5060 14992
+/- 0 0 0 0
libopenthread-radio.a main 19269 0 238 19507
#11662 19269 0 238 19507
+/- 0 0 0 0

@codecov

codecov Bot commented Jul 2, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.63%. Comparing base (4781ada) to head (a050f13).
Report is 2 commits behind head on main.

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     

see 261 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@abtink
abtink force-pushed the nexus/reset-node branch from f59787b to 4a91144 Compare July 3, 2025 21:22
@abtink
abtink marked this pull request as ready for review July 3, 2025 21:24
@jwhui
jwhui requested a review from Copilot July 7, 2025 20:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) and Node::Reset to clear state and reinitialize the OpenThread Instance
  • Implements test_full_network_reset.cpp test 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>

Comment thread tests/nexus/test_full_network_reset.cpp Outdated
Comment thread tests/nexus/test_full_network_reset.cpp Outdated
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.
@jwhui
jwhui force-pushed the nexus/reset-node branch from 1502592 to a050f13 Compare July 8, 2025 20:43
@jwhui
jwhui merged commit a2fb36c into openthread:main Jul 8, 2025
101 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants