Commit Graph

739 Commits

Author SHA1 Message Date
Abtin Keshavarzian c221dae3e4 [test] ensure v1_2_test_backbone_router_service.py uses correct seqno (#11621)
This commit ensures `v1_2_test_backbone_router_service.py` uses the
correct logic for checking the next seq number.
2025-06-23 07:39:48 -07:00
Yakun Xu c8714060ea [test] stabilize Cert_5_1_05_RouterAddressTimeout (#11564)
With the router restoration, longer delay is expected. This commit
defines the router restoration delay and apply it on the unstable test
case Cert_5_1_05_RouterAddressTimeout.
2025-06-10 22:09:33 +09:00
Yakun Xu 6191d3b139 [otci] support reliable transport (#11575)
This commit adds reliable transport in OTCI and switch the OTCI tests to
use the reliable simulation transport.
2025-06-06 09:11:34 -07:00
Yakun Xu 1662ca8001 [simulation] add reliable virtual time transport (#11029)
This commit adds a reliable transport based on SEQPACKET unix socket to
simulation platform and use this for tests on simulation platform.
2025-06-04 23:32:25 -07:00
Yakun Xu 5201231daa [test] fix warning of escape in regex string (#11566) 2025-06-04 13:35:36 -07:00
Abtin Keshavarzian f560c35fab [test] relax checks in test_publish_meshcop_service (#11526)
This commit updates `test_publish_meshcop_service` to relax the checks
when verifying mDNS browse response. Specifically, after `br1` is factory
reset, the Border Agent and other functions are not given the chance
to stop properly and remove previously registered mDNS entries. This
can result in stale entries remaining in the mDNS cache, leading to
more service entries appearing in `browse` results. This commit
relaxes the check from `assertEqual` to `assertGreaterEqual`,
allowing the test to pass when additional entries are observed.
2025-05-22 19:17:23 -07:00
Jonathan Hui be879f198d [nat64] remove support for ipv4only.arpa (#11481)
Thread Specification is transitioning from RFC 7050 to RFC 8781 for
discovering the NAT64 prefix. This commit removes RFC 7050 behavior.
2025-05-08 10:45:43 -07:00
Abtin Keshavarzian ae940e6df8 [border-agent] update "ConnectionMode" in state bitmap when stopped (#11462)
This commit updates how the "ConnectionMode" field is set in the
Border Agent State Bitmap, which is advertised as the value of the
`sb` TXT key. In particular, when the Border Agent service is stopped
and therefore not accepting any connections, the value of this field
is now set to `kConnectionModeDisabled` to indicate this.

This commit also updates and enhances `test_border_agent` to validate
the State Bitmap entry in the TXT data, covering cases where the
device role changes or ePSKc support is enabled/disabled.
2025-04-30 07:45:21 -07:00
Abtin Keshavarzian 20aefc2215 [dnssd] support generic record queries via discovery proxy and SRP (#11357)
This commit enhances the OpenThread DNSSD name server/resolver and its
native Discovery Proxy to support queries for arbitrary record
types.

To enable this, a new set of `otPlatDnssd` APIs are introduced for
generic `RecordQuerier`. These APIs mirror the existing APIs in the
OpenThread native mDNS module, allowing direct use of the native mDNS
implementation.

The discovery proxy implementation is updated to start and stop the
mDNS `RecordQuerier` when receiving a query for an arbitrary record
type, passing the first response record back to the client.

The unit tests `test_dnssd_discovery_proxy` and `test_dns_client`
are updated to cover all the newly added behaviors in discovery proxy.
2025-04-23 12:14:05 -07:00
Jonathan Hui 4be7e8baa2 [tests] allow service bind9 stop to fail (#11438) 2025-04-23 10:05:30 -07:00
Abtin Keshavarzian 8c30b93fee [cli] add srp server port command to retrieve SRP server port (#11373)
This commit adds the `srp server port` CLI command, which maps to the
`otSrpServerGetPort()` API. This new command is now used in
`thread-cert/node.py` to implement `get_srp_server_port()`, allowing
direct retrieval of the SRP server port instead of indirectly parsing
the network data entry.
2025-03-31 14:07:37 -07:00
Abtin Keshavarzian ce7fad1c01 [test] fix get_srp_server_port() to handle the version field (#11368)
This commit fixes `get_srp_server_port()` in `thread-cert/node.py`.
This function parses Network Data service entries, searching for an
SRP/DNS unicast (non-preferred) entry, and then attempts to parse the
published port number of the SRP server by examining the last  bytes
of the "server data".

The SRP/DNS unicast entry was previously updated to optionally include
a "version" field at the end of the "server data". This update caused
the port number parsing to fail, as the code did not account for the
extra byte corresponding to the version field.

This commit resolves this issue by ensuring that the two bytes are
correctly read and interpreted as the port number, regardless of the
presence of the version field.
2025-03-27 13:32:14 -07:00
Yang Song a41490ea40 [posix] update Posix::Resolver to support RDNSS-discovered recursive DNS servers (#11342)
Key Changes:
* Server Prioritization: RDNSS-discovered servers are prioritized
  based on their advertised lifetime. Servers with longer lifetimes
  are preferred.
* Recursive DNS Server List: The resolver maintains a list of
  recursive DNS servers, which now includes servers learned via RDNSS.
* DNS Query Integration: The resolver uses the RDNSS-learned servers
  when forwarding DNS queries upstream.
* Border Routing Integration: The RDNSS callback is registered to the
  border routing module.

Minor Changes:
* The unused function `Transaction *GetTransaction(int aFd)` is
  removed.
2025-03-24 08:29:15 -07:00
Yang Song a8fef54bf6 [tests] improves the accuracy of service status check (#11352)
Previously, the code relied on the return code of the `service radvd
status` command to determine if `radvd` was running. This was
unreliable because the command could succeed even if the service was
not actually active.

The `is_radvd_running` function now parses the output of `service
radvd status` and specifically checks for the line "running" to
confirm that the service is truly running.
2025-03-20 08:30:49 -05:00
Thomas ba6a803ed5 [otci] update to support more commands (#11015)
* otci now supports all commands the Thread Test Harness requires
* improve typehinting across the board
* fixes some typos
2025-03-18 22:53:22 -05:00
Abtin Keshavarzian d7f36da681 [test] relax BR tests that expect a single address on mDNS resolve (#11254)
This commit relaxes the tests that assume mDNS resolve would provide a
single IPv6 answer and explicitly check and require one address. This
behavior of the mDNS API is improved/changed in the `ot-br-posix`
implementation, allowing multiple addresses to be collected and
passed in the "resolved" callback.

 This commit updates the `_assert_dig_result_matches()` function to
 have an additional parameter, `allow_extra_answer`, which is then
 used in specific test steps.
2025-02-18 08:06:15 -08:00
Handa Wang 95d90a0aa6 [tests] extend the waiting time in test_mdns_restart for SRP server to start (#11244)
Fixes the flakiness after enable the OpenThread Core Advertising Proxy.
2025-02-12 10:32:28 -08:00
Handa Wang fd2e06d413 [tests] deal with the No Such Record lines in the output of dns-sd (#11223)
When resolving a hostname, `dns-sd` may output a line saying `No Such
Record` with an all-zero address which should be discarded.
2025-02-07 11:04:43 -08:00
Handa Wang 3385437695 [tests] reduce waiting time in the test of registering 500 SRP services (#11222)
Previously there's a delay for every router (10 seconds) and child (3
seconds) for it to start. The serialized waiting times are
unnecessary. This commit removes such waitings to speed up the test
case. This is especially useful in the BR test
`test_srp_register_500_services_br.py` which uses non-virtual time.
2025-02-07 10:53:14 -08:00
Abtin Keshavarzian bdb394eb3b [border-agent] introduce BorderAgent::EphemeralKeyManager (#11166)
This commit introduces the `BorderAgent::EphemeralKeyManager` class,
which manages the use of the ephemeral key by the Border Agent.

The `EphemeralKeyManager` uses its own DTLS transport and CoAP secure
sessions. This allows the `EphemeralKeyManager` and the `BorderAgent`
service (which uses PSKc) to be enabled and used in parallel.
Previously, a single transport and session was shared between these
functions, requiring the normal BA service (with PSKc) to be stopped
before the ephemeral key could be used.

This is a fundamental change and improvement to the ephemeral key and
Border Agent functionality. Therefore some existing `otBorderAgent`
APIs need to be modified. For example, `otBorderAgentGetState()`,
which returned the Border Agent state to indicate whether there were
any active sessions, is no longer meaningful, as different
sessions/transports are now used for PSKc and ephemeral key, and
there can be multiple sessions. This commit intentionally renames and
changes the `otBorderAgent` public APIs, specifically all those
related to ephemeral key use, to highlight the fundamental change in
behavior. While this can cause backward incompatibility, it requires
app layer code that used the previous APIs to be updated to take into
account the new behavior.

This commit also updates `nexus/test_border_agent`, adding new tests
to validate the new behavior (e.g., BA service and ephemeral key
parallel sessions). It also includes and validates the Border Agent
counter updates under different scenarios (this enhances and replaces
`test_ephemeral_key_counters.py`).
2025-02-04 09:34:08 -05:00
Maciej Baczmański d7a266856f [diag] handle errors of TransmitPacket() (#11076)
`TransmitPacket()` should return an error from platform Radio
implementation, as for example Radio can be in incorrect state.

If error occurs, increase `mSentErrorInvalidStatePackets` stat.

Add wrong state case to tests and fix `diag repeat stop` called
too lata.

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
2025-01-09 10:47:40 -08:00
Handa Wang 12a10cb056 [continuous-integration] print summary for thread-cert test cases (#11129)
Previously, it prints a line `PASS x FAIL y ...` when all the runs of
a test case complete. However, such messages could be hard to find
when multiple test runs fail so the messages are interspersed between
other logs.

This commit moves such messages to the end of the output. This makes
it easier to notice which test cases are failed. Also it will list the
failed iterations, which is useful when MULTIPLY > 1.
2025-01-08 10:46:21 -08:00
Zhanglong Xia 3470934f74 [diag] remove redundant messages output by the diag module (#11118) 2025-01-06 21:36:57 -08:00
Zhanglong Xia 173cb61379 [diag] count the number of packets that are sent succeed and failed (#11108)
When using the `diag frame -c xxxx` command to enable the CSMA-CA when
transmitting the frame, the command `diag send` won't output any message
the CCA failure happens. It is difficult for users to know whether
the CSMA-CA is actually effective via diag commands.

This commit counts the number of packets that are sent succeed and failed,
outputs the transmision failure reason and do not re-transmit the frame
after it fails to send.
2025-01-03 16:44:02 -08:00
Abtin Keshavarzian 4c378f798d [netdata] add version number to DNS/SRP service entries (#10752)
This commit adds a version field (`uint8_t`) to DNS/SRP Anycast and
Unicast Service entries in `NetworkData::Service::Manager`.

For Unicast entries, the version the version field is placed after
the existing fields, specifically after the IPv6 address and port number fields.
For Anycast entries it is added as the in server data as part of the
Server TLV.

When processing Network Data service entries, the version field is
optional and if absent, version number zero is assumed.

The `NetworkData::Publisher` now considers entries with the same or
higher version number when deciding whether to add or remove its own
entry, preferring those with a higher version.

In SRP client, when `AutoStart` mode is used and if there are multiple
Unicast, Service entries, the client prefers the one with larger
version number.

When selecting an anycast entry, the existing rules regarding sequence
numbers are still used. If multiple entries with the same sequence
number exist, the client will assume the minimum version number among
all such entries.

This commit also updates the `test_network_data` unit test, validating
the new format and related methods.

`test_netdata_publisher.py` is also updated to check service entries
with different version numbers.
2024-12-23 18:59:06 -08:00
Maciej Baczmański 33c9e67a9e [diag] refactor command processing to remove redundant code (#11055)
All diagnostic commands (instead of `diag start`) should fail if
device is not in diagnostic mode. Previously it was verified by
each command's process method (with a missing check in
`ProcessEcho` and `ProcessGpio`). This commit moves the check
directly to `ProcessCmd` and cleans up redundant code.

Additionally clean the documentation and align the code as for
some commands `status 0x00` was added on success and for some not.

Move `AppendErrorResult()` to `ProcessCmd()` as well.

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
2024-12-18 13:52:33 -08:00
Yakun Xu ca318d2936 [test] make test_diag less flaky (#11008)
This commit expects echo of diag commands to make sure the command is
received by the node when waiting for the expected output. This helps
make this test less flaky.
2024-12-09 14:43:00 -08:00
Abtin Keshavarzian 7b72e97782 [srp-server] use kNetifThreadInternal for UDP socket (#10992)
This commit updates `Srp::Server` to associate its UDP socket with
`kNetifThreadInternal`, ensuring that received messages are from the
internal Thread network interface (i.e., from devices within the
Thread mesh).
2024-12-05 18:53:24 -08:00
Handa Wang ee6fbbae05 [tests] fix test_upstream_dns.py (#10883)
There's a CI failure that the BR sends the query to 8.8.8.8 as the
upstream DNS server and responded to the DNS client. This is undesired
behavior. We want the BR to query our test DNS server instead.

The issue happened because 8.8.8.8 is already an entry in
`/etc/resolv.conf`. To avoid querying it, we should fully overwrite
the `/etc/resolv.conf` to ensure the BR queries the test DNS server.

There's another issue that `bind9` service was also running on the BR
node which taken over all incoming DNS queries. `bind9` should only
run on the upstream DNS server node. I'll try fix this in a more
generic way later.
2024-10-31 08:14:43 -07:00
Handa Wang d88b63d192 [posix] bind the resolver's UDP socket to the infra network interface (#10864)
This commit fixes an issue in DNS recursive resolver that it didn't
bind its socket to the infra network interface. This may cause the DNS
message to be sent on an unexpected network interface, depending on
the routing table of the platform.

This commit also updates the test case `test_upstream_dns.py` to make
the upstream DNS server run on a different node. Previously the
upstream DNS server ran on the same node as the BR which is a
limitation of this test case.
2024-10-29 07:54:55 -07:00
Mia Yang 230c155652 [test] add retain_active_session option for ePSKc deactivate API (#10829) 2024-10-16 11:28:13 -07:00
Abtin Keshavarzian 19b2d6bbc4 [mle] simplify router/leader role restoration upon reset (#10798)
This commit introduces the `RouterRoleRestorer` class, nested within
`MleRouter`, to manage router/leader role restoration after an MLE
operation restart (e.g., a device reboot) by sending multicast Link
Requests. This class simplifies the code and centralizes role
restoration logic.

Specific changes:

- A new member variable `mLastSavedRole` is added to track the last
  attached role (saved in non-volatile memory). This is used by
  `RouterRoleRestorer` to determine the number of Link Request
  attempts. This variable replaces the previous `mWasLeader`, which
  was only updated after a reboot and would not account for role
  changes afterward.
- The `AttachTimer` is now used for role restoration instead of the
  retransmission timer, as role restoration always occurs while the
  device is detached and before any attach attempts.
- The `kLinkRequestTimeout` is used for the last attempt before
  considering restoration failure.
- The `mChallengeTimeout` mechanism is now removed (in earlier Thread
  specification versions, multicast Link Requests could be used while
  the device was attached, but this is no longer used or needed).
- `test-012-reset-recovery.py` is updated to validate the role
  restoration behavior. `test_detach` is also updated and fixed.
2024-10-10 21:47:34 -07:00
Jonathan Hui a79ca11642 [github-actions] use setup-python action (#10797) 2024-10-09 07:50:16 -07:00
Song GUO 7971508587 [thread-cert] create internet directory for NAT64 and PD tests (#10794) 2024-10-08 20:22:55 -07:00
Song GUO 7cd179e23a [routing-manager] stop PD if there is another prefix with higher preference in netdata (#10289)
This commit adds a new IDLE state to PdPrefixManager.

PdPrefixManager enters idle state when PD is enabled and there is
already a BR requesting PD prefix. When there are multiple BRs
publishing PD prefix at the same time, the one with lexcial smaller
prefix wins.
2024-09-29 23:27:30 -07:00
Abtin Keshavarzian 67b8f5c821 [routing-manager] set SNAC Router Flag in emitted RA (#10695)
This commit updates the `RouteingManager` to set the newly
allocated "SNAC Router Flag" (bit 6) in emitted RA messages from
Thread BR. The flag is also parsed and tracked in received RA
messages.

This replaces the previous model where an experimental flag bit
in "Flags Extension Option" indicated a "stub router". This commit
also removes the `STUB_ROUTER_FLAG_IN_EMITTED_RA_ENABLE` confg
(no longer optional/experimental) and renames `mStubRouterFlag` to
`mSnacRouterFlag`.
2024-09-16 13:33:32 -07:00
Yang Sun 97a3f7648f [trel] add cli to get TREL UDP port (#10702)
The test software for certification currently uses the mDNS packets of
trel service responses to find out the trel port, and then use the port
number to determine which packets in a capture should be decoded as TREL
packets. However this may not be reliable since it depends on when the
capture starts. Added a cli to get trel port, so this can be used by
a THCI function.
2024-09-13 09:54:33 -07:00
Jonathan Hui 2f51cababf [github-actions] migrate version 1.3 checks to 1.4 (#10694) 2024-09-11 07:25:32 -07:00
Yakun Xu c0690e78fc [build] set default Thread version to 1.4 (#10690)
This commit updates the default Thread version to 1.4, so that most
latest features will be enabled by default. This commit also explicitly
enable the epskc feature just like other features in the build script.
2024-09-10 13:39:38 -07:00
Handa Wang e19c775ce3 [doc] fix typos in comments (#10664)
Done by `script/code-spell` with some manual fixes.
2024-09-02 14:05:54 -07:00
Jason Zhang 4465c9b57a [tests] optimize multi-ail test case to run three BRs on two infra link (#10637)
This commit:
1. update the topology to make 3 BRs running on 2 AILs;
2. specify the test name as `test_multi_backbone_infra`, which is
  focusing on verifying the multiple backbone framework works good
3. fix bug that previously pinging throught ethernet does not actually
   work.

For 3, previous `br1.ping(br2_infra_link_local, interface=br1_infra_link_local)`
actually send ping command via ot-ctl instead of the docker bash. The
new `br1.ping(br2_onlink_ula, backbone=True)` actually send a docker
bash command to ping another node via ethernet. Here we choose to use
onlink ULA address (9100::) instead of the link local address because
only "ping [link-local-addr]%eth0" (by specifying the zone index) can
work for link-local address, but this is not currently supported by
`LinuxHost.ping_ether()` method.
2024-08-27 09:41:55 -07:00
Abtin Keshavarzian 8f2ddf93c3 [thread-cert] relax TLV type checks in pktverify (#10627)
This commit modifies thread-cert scripts utilizing `pktverify` to
adopt a more flexible approach to TLV type checking. Specifically, it
replaces strict equality (`==`) or strict subset (`<`) checks with a
subset or equal check (`<=`) when verifying the presence of TLVs in a
message. This adjustment ensures that test scripts adhere to the
principle of ignoring extra or unknown TLVs, thereby future-proofing
them against potential protocol updates that might introduce new
TLVs.
2024-08-27 08:18:45 -07:00
Yang Sun 24e930654e [epskc] add API for ePSKc telemetry (#10608)
Adds API to get border agent counters which include counters for
ePSKc, PSKc and coap messages.
2024-08-21 23:02:44 -07:00
Jason Zhang b5c57e6ad7 [thread-cert] wrap command br peers and br routers (#10613)
This commit adds functions to read peer BRs and routers on infra link by
wrapping the ot-ctl command `br peers` and `br routers`.

`test_multi_ail.py` is also updated to test the new added functions.
2024-08-16 07:23:53 -07:00
Jason Zhang 93e838102c [thread-cert] support to get link-local address of the infra interface (#10603)
This commit targets to support getting infra link-local address of a
OtbrNode in docker test, which is usefully for future test cases.

The test_multi_ail.py is also updated to test the new method added.
2024-08-15 07:35:18 -07:00
Abtin Keshavarzian 1645880b8e [dsnsd-server] support handling of "A record" queries (#10364)
This commit adds support for responding to "A record" queries in the
DNS-SD server and discovery proxy.

If the query matches a host registered with the SRP server, the host's
IPv6 addresses are returned in the Additional Data section of the
response. If the query is resolved by the proxy, the `otPlatDnssd`
APIs are used to start/stop IPv4 address resolvers for the hostname
on the infrastructure network.

The `test_dnssd_discovery_proxy` unit test is updated to validate the
new functionality.
2024-08-14 12:40:48 -07:00
Mia Yang fa26102fe5 [test] verify ephemeral key settings and _meshcop-e (#10537) 2024-08-13 21:40:40 -07:00
Jason Zhang 509596fe2c [test] fix potential backbone name conflict when running cert suite (#10596)
### Background

https://github.com/openthread/openthread/pull/10550 introduced a new
way to support multiple backbone nework in otbr docker test. Though it
works good while running a single test, a bug exists when running
cert-suite, which runs a batch of tests in parallel.

cert-suite allocates the name of the backbone interfaces dynamically
by setting env PORT_OFFSET for each test, so there is potentially
conflict exists if we hard code the `backbone_network` name in
TOPOLOGY. This PR is targeting to fix this potential naming conflict.

### Fix

We fix it by assigning a number for `backbone_network_id` in each BR
definition in TOPOLOGY, instead of setting a fixed `backbone network`
name. The final backbone network name is decided by both `PORT_OFFSET`
env and the number of `backbone_network` (in
`backbone{PORT_OFFSET}.{backbone_network}` format)

For example, if `PORT_OFFSET` is 0 and `backbone_network_id` is 1,
then backbone network name will be `backbone0.1`. For the tests that
only use one backbone network and the `backbone_network_id` is not
given, the backbone network name is by default
`backbone{PORT_OFFSET}.0`.

### New test case format
```
class NewTestCase(thread_cert.TestCase):
    ...
    BR = 1
    ...
    TOPOLOGY = {
        BR: {
            ...
            'is_otbr': True,
            'backbone_network_id': <backbone-id>,
            ...
        }
        ...
    }
    ...
```

`<backbone-id>` is any integer from 0, for each BR inside a single
test, if `<backbone-id>` is different, the BR use different backbone
interfaces; the same `<backbone-id>` inside a single test case means
the same backbone network interface.

`'backbone_network_id': <backbone-id>` is optional for single backbone
test cases, when it's not given while defining a otbr node, the
backbone is default as `backbone{PORT_OFFSET}.0`.

For developers, if you are defining a new test which has multiple
backbone interfaces, please ensure `backbone_network_id` is explicitly
defined in each BR, otherwize an error is reported.
2024-08-13 09:21:43 -07:00
Jason Zhang 28b6011433 [thread-cert] print elapsed time of each test when running cert suite (#10593)
This is helpful to know the exact time that each test take when running
bunch of tests in cert suite.
2024-08-09 14:55:36 -07:00
Jason Zhang 67717618b7 [test] support multiple backbone interfaces in otbr docker test (#10550)
In previous otbr docker tests, when creating docker containers, all the
containers(otbr nodes) are connected to the same docker network bridge `backbone0`
(when the env PORT_OFFSET is not set or set to 0), this means all the
otbr nodes are connected to the same infrastructures.

This commit adds support to enable user to config otbr instance
infrastructures seperately in `TOPOLOGY` when defining test cases, this
provides flexibility to run multi-ail related test cases.

The format to define backbone interface per node is:

```
class NewTestCase(thread_cert.TestCase):
    ...
    BR = 1
    ...
    TOPOLOGY = {
        BR: {
            ...
	    'is_otbr': True,
	    'backbone': <backbone-name>,
	    ...
	}
	...
    }
    ...
```

`'backbone': <backbone-name>` is optional, when it's not given when
defining a otbr node, the backbone is default as
`BACKBONE_DOCKER_NETWORK_NAME`. The `<backbone-name>` is suggested to be
defined as `backbone[0-9]` to make it more easy to read and understand.

This commit also adds test_multi_ail.py as an example test case to use
this new method, this test case checks the two otbr nodes are connected
to the different infra and are in the same Thread mesh network.
2024-08-08 07:44:26 -07:00