make use of auto port selection in tests

This commit is contained in:
Patrik Nordwall 2016-05-18 09:22:22 +02:00
parent 96b697d92f
commit 935ab0d82e
8 changed files with 16 additions and 79 deletions

View file

@ -25,24 +25,6 @@ object PiercingShouldKeepQuarantineSpec extends MultiNodeConfig {
akka.remote.artery.enabled = on
""")))
def aeronPort(roleName: RoleName): Int =
roleName match {
case `first` 20561 // TODO yeah, we should have support for dynamic port assignment
case `second` 20562
}
nodeConfig(first) {
ConfigFactory.parseString(s"""
akka.remote.artery.port = ${aeronPort(first)}
""")
}
nodeConfig(second) {
ConfigFactory.parseString(s"""
akka.remote.artery.port = ${aeronPort(second)}
""")
}
class Subject extends Actor {
def receive = {
case "getuid" sender() ! AddressUidExtension(context.system).addressUid

View file

@ -31,24 +31,6 @@ object RemoteQuarantinePiercingSpec extends MultiNodeConfig {
akka.remote.artery.enabled = on
""")))
def aeronPort(roleName: RoleName): Int =
roleName match {
case `first` 20551 // TODO yeah, we should have support for dynamic port assignment
case `second` 20552
}
nodeConfig(first) {
ConfigFactory.parseString(s"""
akka.remote.artery.port = ${aeronPort(first)}
""")
}
nodeConfig(second) {
ConfigFactory.parseString(s"""
akka.remote.artery.port = ${aeronPort(second)}
""")
}
class Subject extends Actor {
def receive = {
case "shutdown" context.system.terminate()

View file

@ -45,24 +45,6 @@ object RemoteRestartedQuarantinedSpec extends MultiNodeConfig {
akka.remote.artery.enabled = on
""")))
def aeronPort(roleName: RoleName): Int =
roleName match {
case `first` 20541 // TODO yeah, we should have support for dynamic port assignment
case `second` 20542
}
nodeConfig(first) {
ConfigFactory.parseString(s"""
akka.remote.artery.port = ${aeronPort(first)}
""")
}
nodeConfig(second) {
ConfigFactory.parseString(s"""
akka.remote.artery.port = ${aeronPort(second)}
""")
}
class Subject extends Actor {
def receive = {
case "shutdown" context.system.terminate()

View file

@ -265,6 +265,8 @@ private[remote] class ArteryTransport(_system: ExtendedActorSystem, _provider: R
messageDispatcher = new MessageDispatcher(system, provider)
runInboundStreams()
log.info("Remoting started; listening on address: {}", defaultAddress)
}
private def startMediaDriver(): Unit = {

View file

@ -13,14 +13,15 @@ import com.typesafe.config.ConfigFactory
object HandshakeFailureSpec {
val Seq(portA, portB) = SocketUtil.temporaryServerAddresses(2, "localhost", udp = true).map(_.getPort)
// need the port before systemB is started
val portB = SocketUtil.temporaryServerAddress("localhost", udp = true).getPort
val commonConfig = ConfigFactory.parseString(s"""
akka {
actor.provider = "akka.remote.RemoteActorRefProvider"
remote.artery.enabled = on
remote.artery.hostname = localhost
remote.artery.port = $portA
remote.artery.port = 0
remote.handshake-timeout = 2s
}
""")
@ -47,7 +48,6 @@ class HandshakeFailureSpec extends AkkaSpec(HandshakeFailureSpec.commonConfig) w
within(10.seconds) {
awaitAssert {
println(s"# identify $sel") // FIXME
sel ! "hello2"
expectMsg(1.second, "hello2")
}

View file

@ -13,14 +13,15 @@ import com.typesafe.config.ConfigFactory
object HandshakeRetrySpec {
val Seq(portA, portB) = SocketUtil.temporaryServerAddresses(2, "localhost", udp = true).map(_.getPort)
// need the port before systemB is started
val portB = SocketUtil.temporaryServerAddress("localhost", udp = true).getPort
val commonConfig = ConfigFactory.parseString(s"""
akka {
actor.provider = "akka.remote.RemoteActorRefProvider"
remote.artery.enabled = on
remote.artery.hostname = localhost
remote.artery.port = $portA
remote.artery.port = 0
remote.handshake-timeout = 10s
}
""")

View file

@ -7,31 +7,24 @@ import scala.concurrent.duration._
import akka.actor.{ Actor, ActorIdentity, ActorSystem, Deploy, ExtendedActorSystem, Identify, Props, RootActorPath }
import akka.testkit.{ AkkaSpec, ImplicitSender }
import com.typesafe.config.ConfigFactory
import RemoteSendConsistencySpec._
import akka.actor.Actor.Receive
import akka.testkit.SocketUtil
object RemoteSendConsistencySpec {
val Seq(portA, portB) = SocketUtil.temporaryServerAddresses(2, "localhost", udp = true).map(_.getPort)
val commonConfig = ConfigFactory.parseString(s"""
val config = ConfigFactory.parseString(s"""
akka {
actor.provider = "akka.remote.RemoteActorRefProvider"
remote.artery.enabled = on
remote.artery.hostname = localhost
remote.artery.port = $portA
remote.artery.port = 0
}
""")
val configB = ConfigFactory.parseString(s"akka.remote.artery.port = $portB")
.withFallback(commonConfig)
}
class RemoteSendConsistencySpec extends AkkaSpec(commonConfig) with ImplicitSender {
class RemoteSendConsistencySpec extends AkkaSpec(RemoteSendConsistencySpec.config) with ImplicitSender {
val systemB = ActorSystem("systemB", RemoteSendConsistencySpec.configB)
val systemB = ActorSystem("systemB", system.settings.config)
val addressB = systemB.asInstanceOf[ExtendedActorSystem].provider.getDefaultAddress
println(addressB)
val rootB = RootActorPath(addressB)

View file

@ -30,37 +30,32 @@ import akka.stream.scaladsl.Source
import akka.stream.testkit.scaladsl.TestSink
import akka.testkit.AkkaSpec
import akka.testkit.ImplicitSender
import akka.testkit.SocketUtil
import akka.testkit.TestActors
import akka.testkit.TestProbe
import com.typesafe.config.ConfigFactory
object SystemMessageDeliverySpec {
val Seq(portA, portB) = SocketUtil.temporaryServerAddresses(2, "localhost", udp = true).map(_.getPort)
val commonConfig = ConfigFactory.parseString(s"""
val config = ConfigFactory.parseString(s"""
akka {
actor.provider = "akka.remote.RemoteActorRefProvider"
remote.artery.enabled = on
remote.artery.hostname = localhost
remote.artery.port = $portA
remote.artery.port = 0
}
akka.actor.serialize-creators = off
akka.actor.serialize-messages = off
""")
val configB = ConfigFactory.parseString(s"akka.remote.artery.port = $portB")
.withFallback(commonConfig)
}
class SystemMessageDeliverySpec extends AkkaSpec(SystemMessageDeliverySpec.commonConfig) with ImplicitSender {
class SystemMessageDeliverySpec extends AkkaSpec(SystemMessageDeliverySpec.config) with ImplicitSender {
import SystemMessageDeliverySpec._
val addressA = UniqueAddress(
system.asInstanceOf[ExtendedActorSystem].provider.getDefaultAddress,
AddressUidExtension(system).addressUid)
val systemB = ActorSystem("systemB", configB)
val systemB = ActorSystem("systemB", system.settings.config)
val addressB = UniqueAddress(
systemB.asInstanceOf[ExtendedActorSystem].provider.getDefaultAddress,
AddressUidExtension(systemB).addressUid)