Skip to content

[cli] add lease info to srp server host and srp server service - #12589

Merged
jwhui merged 1 commit into
openthread:mainfrom
abtink:cli/srp-lease-info
Mar 3, 2026
Merged

[cli] add lease info to srp server host and srp server service#12589
jwhui merged 1 commit into
openthread:mainfrom
abtink:cli/srp-lease-info

Conversation

@abtink

@abtink abtink commented Feb 28, 2026

Copy link
Copy Markdown
Member

This commit adds lease and remaining lease information to the output of srp server host and srp server service CLI commands.

The information includes:

  • lease: The total lease time in seconds.
  • key-lease: The total key lease time in seconds.
  • remaining lease: The remaining lease time in seconds (with millisecond precision).
  • remaining key-lease: The remaining key lease time in seconds (with millisecond precision).

A new utility method OutputMsecDurationInSec() is added to Utils class to format durations in milliseconds as seconds with a fractional part.

The SRP server host and service output parsers in
tests/scripts/thread-cert/node.py, tests/toranj/cli/cli.py, and tools/otci/otci/otci.py are updated to correctly handle the new fields for both active and deleted entries.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 improves the visibility into the SRP server's lease management by extending the CLI output for hosts and services to include comprehensive lease and remaining lease details. This enhancement provides users with critical timing information directly from the command line, facilitating better monitoring and debugging of SRP server operations. The changes also ensure that automated testing and external tools can accurately parse and utilize this new data.

Highlights

  • Enhanced CLI Output for SRP Server: The srp server host and srp server service CLI commands now display detailed lease and remaining lease information, including total lease time, key lease time, and their remaining durations with millisecond precision.
  • New Utility for Duration Formatting: A new utility method, OutputMsecDurationInSec(), has been introduced in the Utils class to format millisecond durations into seconds with a fractional part (e.g., 12.047).
  • Updated Test and Tool Parsers: The Python-based output parsers in tests/scripts/thread-cert/node.py, tests/toranj/cli/cli.py, and tools/otci/otci/otci.py have been updated to correctly handle and extract the newly added lease fields for both active and deleted SRP server entries.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/cli/README_SRP_SERVER.md
    • Updated example outputs for srp server host and srp server service commands to reflect the newly added lease and remaining lease information.
  • src/cli/cli_srp_server.cpp
    • Modified SrpServer::Process<Cmd("host")> to retrieve and output lease information for hosts, including for deleted entries.
    • Modified SrpServer::Process<Cmd("service")> to retrieve and output lease information for services, including for deleted entries.
    • Added SrpServer::OutputLeaseInfo helper function to standardize the output of lease details.
  • src/cli/cli_srp_server.hpp
    • Declared the new OutputLeaseInfo method within the SrpServer class.
  • src/cli/cli_utils.cpp
    • Implemented Utils::OutputMsecDurationInSec to format millisecond durations into seconds with three decimal places.
  • src/cli/cli_utils.hpp
    • Declared the new OutputMsecDurationInSec method within the Utils class, along with its documentation.
  • tests/scripts/thread-cert/node.py
    • Updated srp_server_get_hosts to parse and extract lease, key-lease, remaining lease, and remaining key-lease fields from CLI output for both active and deleted hosts.
    • Updated srp_server_get_services to parse and extract remaining lease and remaining key-lease fields for both active and deleted services, and adjusted the loop count for parsing service properties.
  • tests/toranj/cli/cli.py
    • Updated srp_server_get_hosts to parse and extract lease, key-lease, remaining lease, and remaining key-lease fields from CLI output for both active and deleted hosts.
    • Updated srp_server_get_services to parse and extract remaining lease and remaining key-lease fields for both active and deleted services, and adjusted the loop count for parsing service properties.
  • tools/otci/otci/otci.py
    • Modified __parse_srp_server_services to correctly handle and store remaining lease and remaining key-lease fields as strings during parsing.
Activity
  • No human activity has been recorded on this pull request yet.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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 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.

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

This pull request enhances the srp server host and srp server service CLI commands by adding lease and remaining lease information to their output. A new utility method OutputMsecDurationInSec is introduced for formatting time durations. The changes are well-implemented, and the corresponding test parsers in Python are updated to accommodate the new fields. My review includes a couple of suggestions to improve the robustness of the test parsers.

Comment thread tests/scripts/thread-cert/node.py
Comment thread tests/toranj/cli/cli.py
@github-actions

github-actions Bot commented Feb 28, 2026

Copy link
Copy Markdown

Merging #12589 into main

name branch text data bss total
ot-cli-ftd 9682126 482120 860 66540 549520
8eb42e0 482120 860 66540 549520
+/- +0 +0 +0 +0
ot-ncp-ftd 9682126 448036 764 61776 510576
8eb42e0 448036 764 61776 510576
+/- +0 +0 +0 +0
ot-cli-mtd 9682126 374608 764 50972 426344
8eb42e0 374608 764 50972 426344
+/- +0 +0 +0 +0
ot-ncp-mtd 9682126 355740 764 46240 402744
8eb42e0 355740 764 46240 402744
+/- +0 +0 +0 +0
ot-cli-ftd-br 9682126 598152 868 136596 735616
8eb42e0 598408 868 136596 735872
+/- +256 +0 +0 +256
ot-rcp 9682126 63328 568 20804 84700
8eb42e0 63328 568 20804 84700
+/- +0 +0 +0 +0
Library files
name branch text data bss total
libopenthread-ftd.a 9682126 249784 95 40319 290198
8eb42e0 249784 95 40319 290198
+/- +0 +0 +0 +0
libopenthread-cli-ftd.a 9682126 61694 0 8091 69785
8eb42e0 61727 0 8091 69818
+/- +33 +0 +0 +33
libopenthread-ncp-ftd.a 9682126 33581 0 5948 39529
8eb42e0 33581 0 5948 39529
+/- +0 +0 +0 +0
libopenthread-mtd.a 9682126 168219 0 24783 193002
8eb42e0 168219 0 24783 193002
+/- +0 +0 +0 +0
libopenthread-cli-mtd.a 9682126 41403 0 8059 49462
8eb42e0 41436 0 8059 49495
+/- +33 +0 +0 +33
libopenthread-ncp-mtd.a 9682126 25805 0 5948 31753
8eb42e0 25805 0 5948 31753
+/- +0 +0 +0 +0
libopenthread-ftd-br.a 9682126 366685 100 110335 477120
8eb42e0 366685 100 110335 477120
+/- +0 +0 +0 +0
libopenthread-cli-ftd-br.a 9682126 80741 0 8131 88872
8eb42e0 80934 0 8131 89065
+/- +193 +0 +0 +193
libopenthread-rcp.a 9682126 9944 0 5060 15004
8eb42e0 9944 0 5060 15004
+/- +0 +0 +0 +0
libopenthread-radio.a 9682126 19707 0 238 19945
8eb42e0 19707 0 238 19945
+/- +0 +0 +0 +0

@codecov

codecov Bot commented Mar 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.50%. Comparing base (07e79ba) to head (d96549a).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12589      +/-   ##
==========================================
+ Coverage   75.30%   75.50%   +0.20%     
==========================================
  Files         696      695       -1     
  Lines       96239    94061    -2178     
==========================================
- Hits        72469    71020    -1449     
+ Misses      23770    23041     -729     
Files with missing lines Coverage Δ
src/cli/cli_srp_server.cpp 83.95% <100.00%> (+2.90%) ⬆️
src/cli/cli_srp_server.hpp 100.00% <ø> (ø)
src/cli/cli_utils.cpp 92.18% <100.00%> (-0.22%) ⬇️
src/cli/cli_utils.hpp 96.92% <ø> (ø)

... and 143 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 cli/srp-lease-info branch from f3ef881 to a9035ab Compare March 2, 2026 19:31
@abtink
abtink marked this pull request as ready for review March 2, 2026 19:32
@abtink

abtink commented Mar 2, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@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

This pull request enhances the SRP server CLI by adding lease and remaining lease information to the srp server host and srp server service commands. A new utility function is introduced for formatting time durations, and the relevant test and tool parsers are updated to accommodate these new fields. The changes are well-structured, but I found a critical syntax error in one of the test script parsers that needs to be fixed.

Note: Security Review is unavailable for this PR.

Comment thread tests/scripts/thread-cert/node.py Outdated
@abtink
abtink force-pushed the cli/srp-lease-info branch from a9035ab to f62f25e Compare March 2, 2026 19:50
@abtink

abtink commented Mar 2, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@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

This pull request is well-structured, adding lease and remaining lease information to the srp server host and srp server service CLI commands. The C++ changes are clean, introducing a helper function OutputLeaseInfo to avoid code duplication and improve maintainability. The documentation and test scripts are updated accordingly to reflect these changes. I've added a few suggestions in the Python test scripts to make the parsing logic more robust.

I am having trouble creating individual review comments. Click here to see my feedback.

tests/scripts/thread-cert/node.py (1182-1183)

medium

Using split(':', 1) is more robust for parsing key-value pairs, as it ensures that only the first colon is used as a delimiter. This prevents potential parsing errors if the value itself contains a colon.

                    key_value = lines.pop(0).strip().split(':', 1)
                    host[key_value[0].strip()] = key_value[1].strip()

tests/scripts/thread-cert/node.py (1193-1194)

medium

Using split(':', 1) is more robust for parsing key-value pairs, as it ensures that only the first colon is used as a delimiter. This prevents potential parsing errors if the value itself contains a colon.

                key_value = lines.pop(0).strip().split(':', 1)
                host[key_value[0].strip()] = key_value[1].strip()

tests/scripts/thread-cert/node.py (1254-1255)

medium

Using split(':', 1) is more robust for parsing key-value pairs, as it ensures that only the first colon is used as a delimiter. This prevents potential parsing errors if the value itself contains a colon.

                    key_value = lines.pop(0).strip().split(':', 1)
                    service[key_value[0].strip()] = key_value[1].strip()

tests/scripts/thread-cert/node.py (1262-1263)

medium

Using split(':', 1) is more robust for parsing key-value pairs, as it ensures that only the first colon is used as a delimiter. This prevents potential parsing errors if the value itself contains a colon.

                key_value = lines.pop(0).strip().split(':', 1)
                service[key_value[0].strip()] = key_value[1].strip()

tests/toranj/cli/cli.py (742-743)

medium

Using split(':', 1) is more robust for parsing key-value pairs, as it ensures that only the first colon is used as a delimiter. This prevents potential parsing errors if the value itself contains a colon.

                    key_value = outputs.pop(0).strip().split(':', 1)
                    host[key_value[0].strip()] = key_value[1].strip()

tests/toranj/cli/cli.py (751-752)

medium

Using split(':', 1) is more robust for parsing key-value pairs, as it ensures that only the first colon is used as a delimiter. This prevents potential parsing errors if the value itself contains a colon.

                key_value = outputs.pop(0).strip().split(':', 1)
                host[key_value[0].strip()] = key_value[1].strip()

tests/toranj/cli/cli.py (804-805)

medium

Using split(':', 1) is more robust for parsing key-value pairs, as it ensures that only the first colon is used as a delimiter. This prevents potential parsing errors if the value itself contains a colon.

                    key_value = outputs.pop(0).strip().split(':', 1)
                    service[key_value[0].strip()] = key_value[1].strip()

tests/toranj/cli/cli.py (811-812)

medium

Using split(':', 1) is more robust for parsing key-value pairs, as it ensures that only the first colon is used as a delimiter. This prevents potential parsing errors if the value itself contains a colon.

                key_value = outputs.pop(0).strip().split(':', 1)
                service[key_value[0].strip()] = key_value[1].strip()

This commit adds lease and remaining lease information to the output
of `srp server host` and `srp server service` CLI commands.

The information includes:
- `lease`: The total lease time in seconds.
- `key-lease`: The total key lease time in seconds.
- `remaining lease`: The remaining lease time in seconds (with
  millisecond precision).
- `remaining key-lease`: The remaining key lease time in seconds
  (with millisecond precision).

A new utility method `OutputMsecDurationInSec()` is added to `Utils`
class to format durations in milliseconds as seconds with a
fractional part.

The SRP server host and service output parsers in
`tests/scripts/thread-cert/node.py`, `tests/toranj/cli/cli.py`, and
`tools/otci/otci/otci.py` are updated to correctly handle the new
fields for both active and deleted entries.
@abtink
abtink force-pushed the cli/srp-lease-info branch from f62f25e to d96549a Compare March 2, 2026 20:18
@jwhui
jwhui merged commit cf1d23c into openthread:main Mar 3, 2026
114 of 115 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.

2 participants