Skip to content

Enable unit tests to run in parallel - #630

Merged
urrsk merged 3 commits into
UniversalRobots:masterfrom
urrsk:parallelunittest
Nov 23, 2026
Merged

urrsk merged 3 commits into
UniversalRobots:masterfrom
urrsk:parallelunittest

Conversation

@urrsk

@urrsk urrsk commented Nov 18, 2026

Copy link
Copy Markdown
Member

Tests that own both ends of a connection bind port 0 and read the real
port back via getPort(), instead of sharing fixed ports. Tests that need
a refused connection hold a bound, non-listening socket (RefusedPort in
test_utils.h) rather than assuming 12321 or 12322 is free.

@urrsk urrsk added the CI label Nov 18, 2026
Copilot AI balanced review requested due to automatic review settings November 18, 2026 14:11
@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.96%. Comparing base (6172363) to head (0856ede).
⚠️ Report is 2 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/rtde/rtde_client.cpp 77.77% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #630      +/-   ##
==========================================
+ Coverage   83.40%   83.96%   +0.56%     
==========================================
  Files         127      128       +1     
  Lines        8559     8565       +6     
  Branches     3913     3914       +1     
==========================================
+ Hits         7139     7192      +53     
+ Misses        998      962      -36     
+ Partials      422      411      -11     
Flag Coverage Δ
python_scripts 49.69% <ø> (ø)
start_ursim 89.59% <ø> (+1.55%) ⬆️
unit 64.23% <88.00%> (+0.16%) ⬆️
ur20-latest 81.56% <92.00%> (+0.12%) ⬆️
ur5-3.14.3 81.30% <92.00%> (+0.09%) ⬆️
ur5e-10.11.0 77.22% <92.00%> (+0.18%) ⬆️
ur5e-10.12.0 78.05% <92.00%> (+0.07%) ⬆️
ur5e-10.7.0 76.75% <92.00%> (+0.17%) ⬆️
ur5e-5.9.4 81.48% <92.00%> (+0.06%) ⬆️
ur7e-10.13.0 ?
ur7e-10.14.0 78.84% <92.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copilot AI 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.

🟡 Changes recommended

Inserting the new port fields before reverse_ip breaks existing positional aggregate initializers of the public UrDriverConfiguration struct, causing compilation errors; they should be appended after socket_connect_timeout.

1 open issue
What changed in this PR

This PR reduces port conflicts so the library’s network unit tests can run in parallel, with supporting APIs for configurable ports and runtime port discovery.

Changes:

  • Replace fixed test ports with ephemeral ports and reserve non-listening ports for connection-refusal tests.
  • Add port configuration and accessors, and use bound ports in generated robot scripts.
  • Enable parallel CTest execution across CI platforms.
File Description
tests/​test_utils.h Add the RefusedPort helper.
tests/​test_ur_driver_tool_voltage.cpp Use dynamically assigned fake-robot and driver ports.
tests/​test_trajectory_point_interface.cpp Connect clients to the assigned interface port.
tests/​test_tcp_socket.cpp Use ephemeral ports and reserved refusal ports.
tests/​test_tcp_server.cpp Replace fixed ports with bound-port discovery.
tests/​test_stream.cpp Use dynamic connection and refusal ports.
tests/​test_script_sender.cpp Discover the script sender’s port.
tests/​test_script_command_interface.cpp Use ephemeral script-command ports.
tests/​test_rtde_writer.cpp Connect streams to dynamically assigned ports.
tests/​test_rtde_client_reconnect.cpp Preserve the assigned port across server restarts.
tests/​test_rtde_client_fake_server.cpp Discover fake RTDE server ports.
tests/​test_rtde_allocations.cpp Use an ephemeral fake RTDE port.
tests/​test_producer.cpp Use dynamic server and refusal ports.
tests/​test_pipeline.cpp Use dynamic server and refusal ports.
tests/​test_dashboard_client.cpp Pass assigned ports to dashboard clients.
tests/​test_client_connect_timeout.cpp Configure clients with ephemeral test-server ports.
tests/​fake_rtde_server.h Expose the bound server port.
src/​ur/​ur_driver.cpp Honor configured ports and publish bound script ports.
src/​ur/​dashboard_client.cpp Forward the configurable G5 dashboard port.
src/​ur/​dashboard_client_implementation_g5.cpp Initialize the configured dashboard port.
include/​ur_client_library/​ur/​ur_driver.h Add connection-port settings and a script-command port accessor.
include/​ur_client_library/​ur/​dashboard_client.h Add an optional G5 dashboard port parameter.
include/​ur_client_library/​ur/​dashboard_client_implementation_g5.h Declare configurable G5 port support.
include/​ur_client_library/​control/​script_sender.h Expose the bound script-sender port.
.github/​workflows/​win-build.yml Enable processor-count-based parallel tests on Windows.
.github/​workflows/​mac-build.yml Enable processor-count-based parallel tests on macOS.
.github/​workflows/​ci.yml Enable processor-count-based parallel tests on Linux.
.github/​workflows/​alpine-build.yml Enable processor-count-based parallel tests on Alpine.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 19, 2026 07:38

Copilot AI 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.

🟢 Approval recommended

No active review issues block the changes to isolate network-test ports and enable parallel test execution.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 19, 2026 09:02

Copilot AI 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.

🟢 Approval recommended

No active review issues are recorded for the test-port isolation and parallel CI changes.

No open issues 🎉

Review effort: Balanced

UrDriverConfiguration gains rtde_port and primary_port, and the G5 dashboard client an optional port.
Tests bind port 0 and read the real port back instead of sharing fixed ports, so no test needs a lock.
The control script now gets the ports the driver actually bound, and unit-test CI runs ctest -j.
getDataPackage() with an empty unique_ptr try-locked reconnect_mutex_ to copy the output
layout, but the background reader holds that mutex while it waits on the socket, so the
call failed at once instead of waiting for data. Copy the layout from the background read
buffer under read_mutex_ instead, as the allocating overload already does.
Copilot AI balanced review requested due to automatic review settings November 19, 2026 11:18

Copilot AI 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.

🟢 Approval recommended

No active review issues were identified in the changes supporting parallel test execution and configurable ports.

No open issues 🎉

Review effort: Balanced

@urrsk

urrsk commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

@urfeex please review this with a special focus on src/rtde/rtde_client.cpp

@urrsk
urrsk marked this pull request as ready for review November 19, 2026 13:17
@urrsk
urrsk requested a review from urfeex November 19, 2026 13:18
@mergify

mergify Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is merged.

Comment thread src/rtde/rtde_client.cpp Resolved
data_buffer0_ is set when background reading starts and kept after it stops, so its
presence does not mean the reader is running. Check background_read_running_ before
copying it when receiving into an empty pointer.
Copilot AI balanced review requested due to automatic review settings November 20, 2026 13:34

Copilot AI 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.

🔵 Needs a closer look

Human assessment is needed to evaluate parallel-test port-reuse races that can cause connections to unintended listeners or invalidate expected connection refusals on macOS.

No open issues 🎉

Review effort: Balanced

@urrsk
urrsk merged commit c53b2ff into UniversalRobots:master Nov 23, 2026
59 of 60 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants