Skip to content

test: retry temporary port bind in RemotingSpec lazy-connect test#3015

Open
He-Pin wants to merge 1 commit into
mainfrom
fix/remoting-spec-address-in-use
Open

test: retry temporary port bind in RemotingSpec lazy-connect test#3015
He-Pin wants to merge 1 commit into
mainfrom
fix/remoting-spec-address-in-use

Conversation

@He-Pin
Copy link
Copy Markdown
Member

@He-Pin He-Pin commented May 29, 2026

Motivation

RemotingSpec "allow other system to connect even if it's not there at first" intermittently fails at ActorSystem startup with Address already in use (#1679).

The test allocates a port via temporaryServerAddress() and then binds a new ActorSystem to it; the port can be claimed by another process between allocation and bind.

Modification

Reuse the existing selectionAndBind helper — already used by the sibling "be able to connect to system even if it's not there at first" test — which retries on a fresh port when the bind fails with Failed to bind.

Result

The lazy-connect test no longer races temporary port allocation; it still passes locally.

[info] - must allow other system to connect even if it's not there at first (5 seconds, 454 milliseconds)
[info] Tests: succeeded 1, failed 0
[info] All tests passed.

Tests

remote/testOnly org.apache.pekko.remote.classic.RemotingSpec -- -z "allow other system to connect even if" — passes. scalafmt run on the changed file. Test-only change.

References

Fixes #1679

Motivation:
RemotingSpec "allow other system to connect even if it's not there at first"
intermittently fails at ActorSystem startup with "Address already in use"
(issue #1679). The test allocates a port via temporaryServerAddress() and
then binds a new ActorSystem to it; the port can be claimed by another
process between allocation and bind.

Modification:
Reuse the existing selectionAndBind helper (already used by the sibling
"be able to connect to system even if it's not there at first" test), which
retries on a fresh port when the bind fails with "Failed to bind".

Result:
The lazy-connect test no longer races temporary port allocation; it still
passes locally.

References:
Fixes #1679
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.

Failed: Address already in use

1 participant