feature/Improve Pekko find available port

This commit is contained in:
Marko Milić 2025-12-18 12:39:55 +01:00
parent 45538d0393
commit 4dda540f38
3 changed files with 63 additions and 23 deletions

View File

@ -7,7 +7,14 @@ import code.util.Helper
object ObpActorConfig {
val localHostname = "127.0.0.1"
def localPort = Helper.findAvailablePort()
def localPort = {
val systemPort = APIUtil.getPropsAsIntValue("pekko.remote.artery.canonical.port", 0)
if (systemPort == 0) {
Helper.findAvailablePort()
} else {
systemPort
}
}
val akka_loglevel = APIUtil.getPropsValue("remotedata.loglevel").openOr("INFO")
@ -64,12 +71,16 @@ object ObpActorConfig {
}
}
remote {
enabled-transports = ["org.apache.pekko.remote.netty.tcp"]
netty {
tcp {
send-buffer-size = 50000000
receive-buffer-size = 50000000
maximum-frame-size = 52428800
artery {
transport = tcp
canonical.hostname = """ + localHostname + """
canonical.port = 0
bind.hostname = """ + localHostname + """
bind.port = 0
advanced {
maximum-frame-size = 52428800
buffer-pool-size = 128
maximum-large-frame-size = 52428800
}
}
}
@ -80,8 +91,12 @@ object ObpActorConfig {
s"""
${commonConf}
pekko {
remote.netty.tcp.hostname = ${localHostname}
remote.netty.tcp.port = 0
remote.artery {
canonical.hostname = ${localHostname}
canonical.port = 0
bind.hostname = ${localHostname}
bind.port = 0
}
}
"""
@ -89,8 +104,12 @@ object ObpActorConfig {
s"""
${commonConf}
pekko {
remote.netty.tcp.hostname = ${localHostname}
remote.netty.tcp.port = ${localPort}
remote.artery {
canonical.hostname = ${localHostname}
canonical.port = ${localPort}
bind.hostname = ${localHostname}
bind.port = ${localPort}
}
}
"""
}

View File

@ -67,12 +67,16 @@ object AkkaConnectorActorConfig {
}
}
remote {
enabled-transports = ["org.apache.pekko.remote.netty.tcp"]
netty {
tcp {
send-buffer-size = 50000000
receive-buffer-size = 50000000
maximum-frame-size = 52428800
artery {
transport = tcp
canonical.hostname = "127.0.0.1"
canonical.port = 0
bind.hostname = "127.0.0.1"
bind.port = 0
advanced {
maximum-frame-size = 52428800
buffer-pool-size = 128
maximum-large-frame-size = 52428800
}
}
}
@ -83,8 +87,12 @@ object AkkaConnectorActorConfig {
s"""
${commonConf}
pekko {
remote.netty.tcp.hostname = ${localHostname}
remote.netty.tcp.port = 0
remote.artery {
canonical.hostname = ${localHostname}
canonical.port = 0
bind.hostname = ${localHostname}
bind.port = 0
}
}
"""
@ -92,8 +100,12 @@ object AkkaConnectorActorConfig {
s"""
${commonConf}
pekko {
remote.netty.tcp.hostname = ${localHostname}
remote.netty.tcp.port = ${localPort}
remote.artery {
canonical.hostname = ${localHostname}
canonical.port = ${localPort}
bind.hostname = ${localHostname}
bind.port = ${localPort}
}
}
"""
@ -101,8 +113,12 @@ object AkkaConnectorActorConfig {
s"""
${commonConf}
pekko {
remote.netty.tcp.hostname = ${remoteHostname}
remote.netty.tcp.port = ${remotePort}
remote.artery {
canonical.hostname = ${remoteHostname}
canonical.port = ${remotePort}
bind.hostname = ${remoteHostname}
bind.port = ${remotePort}
}
}
"""
}

View File

@ -60,6 +60,11 @@ trait ServerSetup extends FeatureSpec with SendServerRequests
setPropsValues("berlin_group_mandatory_headers" -> "")
setPropsValues("berlin_group_mandatory_header_consent" -> "")
// Set system properties to force Pekko to use random available ports
// This prevents conflicts when both RunWebApp and tests are running
System.setProperty("pekko.remote.artery.canonical.port", "0")
System.setProperty("pekko.remote.artery.bind.port", "0")
val server = TestServer
def baseRequest = host(server.host, server.port)
val secured = APIUtil.getPropsAsBoolValue("external.https", false)