This is an automated email from the ASF dual-hosted git repository.
He-Pin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko.git
The following commit(s) were added to refs/heads/main by this push:
new ca4b3aec02 test: retry temporary port bind in RemotingSpec
lazy-connect test (#3015)
ca4b3aec02 is described below
commit ca4b3aec02280be4133f6ddeb9266291937aae61
Author: He-Pin(kerr) <[email protected]>
AuthorDate: Sun Jun 7 02:45:58 2026 +0800
test: retry temporary port bind in RemotingSpec lazy-connect test (#3015)
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
---
.../org/apache/pekko/remote/classic/RemotingSpec.scala | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git
a/remote/src/test/scala/org/apache/pekko/remote/classic/RemotingSpec.scala
b/remote/src/test/scala/org/apache/pekko/remote/classic/RemotingSpec.scala
index 335af689dd..0fb42195e8 100644
--- a/remote/src/test/scala/org/apache/pekko/remote/classic/RemotingSpec.scala
+++ b/remote/src/test/scala/org/apache/pekko/remote/classic/RemotingSpec.scala
@@ -836,17 +836,10 @@ class RemotingSpec extends PekkoSpec(RemotingSpec.cfg)
with ImplicitSender with
try {
muteSystem(thisSystem)
val thisProbe = new TestProbe(thisSystem)
- val thisSender = thisProbe.ref
thisSystem.actorOf(Props[Echo2](), "echo")
- val otherAddress = temporaryServerAddress()
- val otherConfig = ConfigFactory.parseString(s"""
- pekko.remote.classic.netty.tcp.port = ${otherAddress.getPort}
- """).withFallback(config)
- val otherSelection =
-
thisSystem.actorSelection(s"pekko.tcp://other-system@localhost:${otherAddress.getPort}/user/echo")
- otherSelection.tell("ping", thisSender)
- thisProbe.expectNoMessage(1.seconds)
- val otherSystem = ActorSystem("other-system", otherConfig)
+ // selectionAndBind retries on a fresh port, since the
temporaryServerAddress can be taken
+ // by the time the new actor system binds (see #1679)
+ val (otherSystem, _) = selectionAndBind(config, thisSystem, thisProbe)
try {
muteSystem(otherSystem)
thisProbe.expectNoMessage(2.seconds)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]