Skip to content

[Test] Eliminate OPC UA sink port allocation race - #18817

Merged
jt2594838 merged 1 commit into
masterfrom
fix/opcua-sink-test-port-race
Oct 10, 2026
Merged

jt2594838 merged 1 commit into
masterfrom
fix/opcua-sink-test-port-race

Conversation

@Caideyipi

Copy link
Copy Markdown
Collaborator

Description

OpcUaSinkTest probes ephemeral ports with ServerSocket(0) and closes the sockets before starting the Milo servers. The quality and normal sinks allocate their port pairs independently, so both can receive the same TCP port, or another process can claim a released port before startup. The second customize() then fails with BindException: Address already in use and No endpoints bound.

Bind the test servers directly to TCP port 0 so the OS allocates each listening port during bind. Use distinct configured HTTPS port values to distinguish independent servers in the sink's shared-server map; the current TCP-only transport does not bind HTTPS. The lifecycle test keeps the same key for both sinks, preserving the existing sharing and conflict checks. Reuse the quality-parameter helper and remove the port-probing helpers.

Validation

  • Windows, JDK 17: mvn clean test -pl library-pipe/opc-ua-sink -Dtest.port.closed=true -Ddevelocity.off=true passed: 29 tests, 0 failures, 0 errors, 1 existing performance-test skip.
  • Ran mvn surefire:test -pl library-pipe/opc-ua-sink -Dtest=OpcUaSinkTest -Dtest.port.closed=true -Ddevelocity.off=true 10 times: all 40 test executions passed, with no endpoint-binding errors.
  • Spotless and Checkstyle passed.

This PR has:

  • been self-reviewed.
  • modified existing tests.
  • added comments explaining the port allocation and shared-server keys.
Key changed/added classes

OpcUaSinkTest

@codecov

codecov Bot commented Oct 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 45.85%. Comparing base (21d53dd) to head (3073250).

Additional details and impacted files
@@            Coverage Diff            @@
##             master   #18817   +/-   ##
=========================================
  Coverage     45.84%   45.85%           
  Complexity      712      712           
=========================================
  Files          5498     5498           
  Lines        397462   397462           
  Branches      51733    51733           
=========================================
+ Hits         182228   182256   +28     
+ Misses       215234   215206   -28     

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

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

@jt2594838
jt2594838 merged commit f16e5b3 into master Oct 10, 2026
36 of 42 checks passed
@jt2594838
jt2594838 deleted the fix/opcua-sink-test-port-race branch October 10, 2026 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants