pekko/akka-cluster/src/test/scala/akka/cluster/ClusterDeployerSpec.scala

83 lines
2.6 KiB
Scala
Raw Normal View History

2012-08-30 13:41:01 +02:00
/**
2013-01-09 01:47:48 +01:00
* Copyright (C) 2009-2013 Typesafe Inc. <http://www.typesafe.com>
2012-08-30 13:41:01 +02:00
*/
package akka.cluster
import akka.testkit._
import akka.actor._
import akka.routing._
import com.typesafe.config._
import akka.cluster.routing.ClusterRouterConfig
import akka.cluster.routing.ClusterRouterSettings
2012-08-30 13:41:01 +02:00
object ClusterDeployerSpec {
val deployerConf = ConfigFactory.parseString("""
akka.actor.provider = "akka.cluster.ClusterActorRefProvider"
akka.actor.deployment {
/user/service1 {
2012-08-30 13:41:01 +02:00
router = round-robin
nr-of-instances = 20
cluster.enabled = on
cluster.max-nr-of-instances-per-node = 3
cluster.allow-local-routees = off
}
/user/service2 {
dispatcher = mydispatcher
mailbox = mymailbox
router = round-robin
nr-of-instances = 20
cluster.enabled = on
cluster.allow-local-routees = off
cluster.routees-path = "/user/myservice"
2012-08-30 13:41:01 +02:00
}
}
akka.remote.netty.tcp.port = 0
2012-08-30 13:41:01 +02:00
""", ConfigParseOptions.defaults)
class RecipeActor extends Actor {
def receive = { case _ }
}
}
@org.junit.runner.RunWith(classOf[org.scalatest.junit.JUnitRunner])
class ClusterDeployerSpec extends AkkaSpec(ClusterDeployerSpec.deployerConf) {
"A RemoteDeployer" must {
"be able to parse 'akka.actor.deployment._' with specified cluster lookup routee settings" in {
val service = "/user/service1"
val deployment = system.asInstanceOf[ActorSystemImpl].provider.deployer.lookup(service.split("/").drop(1))
deployment must not be (None)
deployment must be(Some(
Deploy(
service,
deployment.get.config,
ClusterRouterConfig(RoundRobinRouter(20), ClusterRouterSettings(
totalInstances = 20, maxInstancesPerNode = 3, allowLocalRoutees = false, useRole = None)),
ClusterScope,
Deploy.NoDispatcherGiven,
Deploy.NoMailboxGiven)))
}
"be able to parse 'akka.actor.deployment._' with specified cluster deploy routee settings" in {
2012-08-30 13:41:01 +02:00
val service = "/user/service2"
val deployment = system.asInstanceOf[ActorSystemImpl].provider.deployer.lookup(service.split("/").drop(1))
deployment must not be (None)
deployment must be(Some(
Deploy(
service,
deployment.get.config,
ClusterRouterConfig(RoundRobinRouter(20), ClusterRouterSettings(
totalInstances = 20, routeesPath = "/user/myservice", allowLocalRoutees = false, useRole = None)),
ClusterScope,
"mydispatcher",
"mymailbox")))
2012-08-30 13:41:01 +02:00
}
}
2013-01-09 01:47:48 +01:00
}