Skip to content

test: centralize test helpers and remove fixed ports from Zenoh test suites#2573

Merged
OlivierHecart merged 14 commits into
eclipse-zenoh:mainfrom
ZettaScaleLabs:update_zenoh_ext_test
Apr 24, 2026
Merged

test: centralize test helpers and remove fixed ports from Zenoh test suites#2573
OlivierHecart merged 14 commits into
eclipse-zenoh:mainfrom
ZettaScaleLabs:update_zenoh_ext_test

Conversation

@evshary

@evshary evshary commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Description

This PR introduces a shared zenoh-test crate and uses it to clean up test setup across zenoh, zenoh-ext, and io/zenoh-transport. The main goal is to remove hardcoded ports and reduce port-collision failures during parallel test execution.

What does this PR do?

  • Adds a new workspace crate: commons/zenoh-test
    • Extracts reusable test utilities from zenoh/tests/common/mod.rs
    • Documents the helper patterns in commons/zenoh-test/README.md
  • Refactors existing tests to use the shared helpers instead of ad hoc local utilities
  • Renames the TCP helper to make its scope explicit
    • get_free_port() -> get_free_tcp_port()
    • adds get_free_udp_port() for UDP-based transport tests
  • Updates crate-local zenoh tests to avoid fixed ports
    • zenoh/src/tests/session.rs
    • zenoh/src/tests/link_weights.rs
    • zenoh/src/tests/interceptor_cache.rs
  • Updates zenoh-ext tests to use dynamic port allocation and the new helper crate
    • including advanced.rs and liveliness.rs
  • Updates io/zenoh-transport tests to replace fixed TCP/UDP/WS/TLS/QUIC ports with dynamic allocation
    • includes endpoints.rs
    • includes the remaining unicast/multicast transport tests under io/zenoh-transport/tests

Related Issues

#2526


🏷️ Label-Based Checklist

Based on the labels applied to this PR, please complete these additional requirements:

Labels: enhancement

✨ Enhancement Requirements

Since this PR enhances existing functionality:

  • Enhancement scope documented - Clear description of what is being improved
  • Minimum necessary code - Implementation is as simple as possible, doesn't overcomplicate the system
  • Backwards compatible - Existing code/APIs still work unchanged
  • No new APIs added - Only improving existing functionality
  • Tests updated - Existing tests pass, new test cases added if needed
  • Performance improvement measured - If applicable, before/after metrics provided
  • Documentation updated - Existing docs updated to reflect improvements
  • User impact documented - How users benefit from this enhancement

Remember: Enhancements should not introduce new APIs or breaking changes.

Instructions:

  1. Check off items as you complete them (change - [ ] to - [x])
  2. The PR checklist CI will verify these are completed

This checklist updates automatically when labels change, but preserves your checked boxes.

evshary added 6 commits April 17, 2026 11:15
Signed-off-by: ChenYing Kuo <evshary@gmail.com>
Move get_locators_from_session and get_locators_from_session_sync out of
TestSessions into free functions since they don't use self. Also add
crate-level docs, doc comments on all public items, make TIMEOUT public,
remove stale #![allow(dead_code)], and drop unused zenoh-protocol dep.

Signed-off-by: ChenYing Kuo <evshary@gmail.com>
Replace TestSessions::get_locators_from_session(_sync) calls with the
newly extracted free functions across adminspace, low_pass, open_time,
session, and unicity test files.

Signed-off-by: ChenYing Kuo <evshary@gmail.com>
Rewrite commons/zenoh-test/README.md to reflect the current API
(free functions + TestSessions) and delete the now-stale
zenoh/tests/README.md whose content has been superseded.

Signed-off-by: ChenYing Kuo <evshary@gmail.com>
Refactored tests in zenoh-ext/tests/advanced.rs to use TestSessions for peer-to-peer cases and get_free_port() for reconnect cases. This prevents port collisions during parallel test execution.
Refactored tests in zenoh-ext/tests/liveliness.rs to use TestSessions custom configurations, preventing port collisions during parallel test execution.

Signed-off-by: ChenYing Kuo <evshary@gmail.com>
@evshary evshary added the enhancement Existing things could work better label Apr 17, 2026
evshary added 2 commits April 17, 2026 15:15
Applied rustfmt to various test files across zenoh and zenoh-ext to ensure consistent formatting and resolve import ordering warnings.

Signed-off-by: ChenYing Kuo <evshary@gmail.com>
Signed-off-by: ChenYing Kuo <evshary@gmail.com>
@evshary
evshary requested a review from OlivierHecart April 17, 2026 09:25
Signed-off-by: ChenYing Kuo <evshary@gmail.com>
@evshary
evshary force-pushed the update_zenoh_ext_test branch from 36907f3 to 5a4724c Compare April 18, 2026 00:33
Signed-off-by: ChenYing Kuo <evshary@gmail.com>
@evshary
evshary force-pushed the update_zenoh_ext_test branch from 5a4724c to 5426f8c Compare April 18, 2026 00:50
@codecov

codecov Bot commented Apr 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.65517% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.75%. Comparing base (d12952d) to head (85f3b63).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
commons/zenoh-test/src/lib.rs 89.65% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2573      +/-   ##
==========================================
+ Coverage   74.70%   74.75%   +0.04%     
==========================================
  Files         399      400       +1     
  Lines       59535    59716     +181     
==========================================
+ Hits        44478    44640     +162     
- Misses      15057    15076      +19     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

evshary added 3 commits April 24, 2026 06:08
Signed-off-by: ChenYing Kuo <evshary@gmail.com>
Signed-off-by: ChenYing Kuo <evshary@gmail.com>
Signed-off-by: ChenYing Kuo <evshary@gmail.com>
@evshary evshary changed the title refactor(test): introduce zenoh-test crate and implement dynamic port allocation for zenoh-ext refactor(test): introduce zenoh-test crate and implement dynamic port allocation for the remaining tests (zenoh-ext, zenoh, io) Apr 24, 2026
@evshary evshary changed the title refactor(test): introduce zenoh-test crate and implement dynamic port allocation for the remaining tests (zenoh-ext, zenoh, io) test: centralize test helpers and remove fixed ports from Zenoh test suites Apr 24, 2026
Signed-off-by: ChenYing Kuo <evshary@gmail.com>
@evshary
evshary force-pushed the update_zenoh_ext_test branch from 48f227e to 85f3b63 Compare April 24, 2026 03:35
@OlivierHecart
OlivierHecart merged commit 7792ebb into eclipse-zenoh:main Apr 24, 2026
28 checks passed
@OlivierHecart
OlivierHecart deleted the update_zenoh_ext_test branch April 24, 2026 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Existing things could work better

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants