Adjusted tests to latest testconductor, remote deploy still fails. See #2069
This commit is contained in:
parent
a211e4daf6
commit
12ff07f025
2 changed files with 97 additions and 118 deletions
|
|
@ -1,21 +1,19 @@
|
|||
/**
|
||||
* Copyright (C) 2009-2011 Typesafe Inc. <http://www.typesafe.com>
|
||||
* Copyright (C) 2009-2012 Typesafe Inc. <http://www.typesafe.com>
|
||||
*/
|
||||
package akka.remote
|
||||
|
||||
import com.typesafe.config.ConfigFactory
|
||||
|
||||
import akka.actor.Actor
|
||||
import akka.actor.ActorRef
|
||||
import akka.actor.Props
|
||||
import akka.dispatch.Await
|
||||
import akka.pattern.ask
|
||||
import akka.remote.testconductor.TestConductor
|
||||
import akka.testkit.DefaultTimeout
|
||||
import akka.testkit.ImplicitSender
|
||||
import akka.util.Duration
|
||||
import com.typesafe.config.ConfigFactory
|
||||
import akka.remote.testkit.MultiNodeConfig
|
||||
import akka.remote.testkit.MultiNodeSpec
|
||||
import akka.testkit._
|
||||
|
||||
object SimpleRemoteMultiJvmSpec extends AbstractRemoteActorMultiJvmSpec {
|
||||
override def NrOfNodes = 2
|
||||
object SimpleRemoteMultiJvmSpec extends MultiNodeConfig {
|
||||
|
||||
class SomeActor extends Actor with Serializable {
|
||||
def receive = {
|
||||
|
|
@ -23,60 +21,47 @@ object SimpleRemoteMultiJvmSpec extends AbstractRemoteActorMultiJvmSpec {
|
|||
}
|
||||
}
|
||||
|
||||
override def commonConfig = ConfigFactory.parseString("""
|
||||
akka {
|
||||
loglevel = INFO
|
||||
actor {
|
||||
provider = akka.remote.RemoteActorRefProvider
|
||||
debug {
|
||||
receive = on
|
||||
fsm = on
|
||||
}
|
||||
}
|
||||
remote {
|
||||
transport = akka.remote.testconductor.TestConductorTransport
|
||||
log-received-messages = on
|
||||
log-sent-messages = on
|
||||
}
|
||||
testconductor {
|
||||
host = localhost
|
||||
port = 4712
|
||||
}
|
||||
}""")
|
||||
commonConfig(ConfigFactory.parseString("""
|
||||
akka.loglevel = DEBUG
|
||||
akka.remote {
|
||||
log-received-messages = on
|
||||
log-sent-messages = on
|
||||
}
|
||||
akka.actor.debug {
|
||||
receive = on
|
||||
fsm = on
|
||||
}
|
||||
"""))
|
||||
|
||||
def nameConfig(n: Int) = ConfigFactory.parseString("akka.testconductor.name = node" + n).withFallback(nodeConfigs(n))
|
||||
}
|
||||
|
||||
class SimpleRemoteMultiJvmNode1 extends AkkaRemoteSpec(SimpleRemoteMultiJvmSpec.nameConfig(0)) {
|
||||
import SimpleRemoteMultiJvmSpec._
|
||||
val nodes = NrOfNodes
|
||||
val tc = TestConductor(system)
|
||||
|
||||
"lookup remote actor" in {
|
||||
Await.result(tc.startController(2), Duration.Inf)
|
||||
system.actorOf(Props[SomeActor], "service-hello")
|
||||
tc.enter("begin", "done")
|
||||
}
|
||||
val master = role("master")
|
||||
val slave = role("slave")
|
||||
|
||||
}
|
||||
|
||||
class SimpleRemoteMultiJvmNode2 extends AkkaRemoteSpec(SimpleRemoteMultiJvmSpec.nameConfig(1))
|
||||
class SimpleRemoteMultiJvmNode1 extends SimpleRemoteSpec
|
||||
class SimpleRemoteMultiJvmNode2 extends SimpleRemoteSpec
|
||||
|
||||
class SimpleRemoteSpec extends MultiNodeSpec(SimpleRemoteMultiJvmSpec)
|
||||
with ImplicitSender with DefaultTimeout {
|
||||
|
||||
import SimpleRemoteMultiJvmSpec._
|
||||
val nodes = NrOfNodes
|
||||
val tc = TestConductor(system)
|
||||
|
||||
"lookup remote actor" in {
|
||||
Await.result(tc.startClient(4712), Duration.Inf)
|
||||
tc.enter("begin")
|
||||
log.info("### begin ok")
|
||||
val actor = system.actorFor("akka://" + akkaSpec(0) + "/user/service-hello")
|
||||
log.info("### actor lookup " + akkaSpec(0) + "/service-hello")
|
||||
actor.isInstanceOf[RemoteActorRef] must be(true)
|
||||
Await.result(actor ? "identify", timeout.duration).asInstanceOf[ActorRef].path.address.hostPort must equal(akkaSpec(0))
|
||||
log.info("### actor ok")
|
||||
tc.enter("done")
|
||||
def initialParticipants = 2
|
||||
|
||||
runOn(master) {
|
||||
system.actorOf(Props[SomeActor], "service-hello")
|
||||
}
|
||||
|
||||
"Remoting" must {
|
||||
"lookup remote actor" in {
|
||||
runOn(slave) {
|
||||
val hello = system.actorFor(node(master) / "user" / "service-hello")
|
||||
hello.isInstanceOf[RemoteActorRef] must be(true)
|
||||
val masterAddress = testConductor.getAddressFor(master).await
|
||||
(hello ? "identify").await.asInstanceOf[ActorRef].path.address must equal(masterAddress)
|
||||
}
|
||||
testConductor.enter("done")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
/**
|
||||
* Copyright (C) 2009-2011 Typesafe Inc. <http://www.typesafe.com>
|
||||
* Copyright (C) 2009-2012 Typesafe Inc. <http://www.typesafe.com>
|
||||
*/
|
||||
package akka.remote.router
|
||||
|
||||
import akka.actor.{ Actor, ActorRef, Props }
|
||||
import akka.remote.AkkaRemoteSpec
|
||||
import akka.remote.AbstractRemoteActorMultiJvmSpec
|
||||
import akka.remote.RemoteActorRef
|
||||
import akka.remote.testconductor.TestConductor
|
||||
import akka.testkit._
|
||||
import akka.dispatch.Await
|
||||
import akka.pattern.ask
|
||||
import akka.util.Duration
|
||||
import com.typesafe.config.ConfigFactory
|
||||
|
||||
object DirectRoutedRemoteActorMultiJvmSpec extends AbstractRemoteActorMultiJvmSpec {
|
||||
override def NrOfNodes = 2
|
||||
import akka.actor.Actor
|
||||
import akka.actor.ActorRef
|
||||
import akka.actor.Props
|
||||
import akka.pattern.ask
|
||||
import akka.remote.RemoteActorRef
|
||||
import akka.remote.testkit.MultiNodeConfig
|
||||
import akka.remote.testkit.MultiNodeSpec
|
||||
import akka.testkit._
|
||||
|
||||
object DirectRoutedRemoteActorMultiJvmSpec extends MultiNodeConfig {
|
||||
|
||||
class SomeActor extends Actor with Serializable {
|
||||
def receive = {
|
||||
|
|
@ -23,68 +23,62 @@ object DirectRoutedRemoteActorMultiJvmSpec extends AbstractRemoteActorMultiJvmSp
|
|||
}
|
||||
|
||||
import com.typesafe.config.ConfigFactory
|
||||
override def commonConfig = ConfigFactory.parseString("""
|
||||
akka {
|
||||
loglevel = INFO
|
||||
actor {
|
||||
provider = akka.remote.RemoteActorRefProvider
|
||||
deployment {
|
||||
/service-hello.remote = %s
|
||||
}
|
||||
debug {
|
||||
receive = on
|
||||
fsm = on
|
||||
}
|
||||
}
|
||||
remote {
|
||||
transport = akka.remote.testconductor.TestConductorTransport
|
||||
log-received-messages = on
|
||||
log-sent-messages = on
|
||||
}
|
||||
testconductor {
|
||||
host = localhost
|
||||
port = 4712
|
||||
}
|
||||
}""" format akkaURIs(1))
|
||||
|
||||
def nameConfig(n: Int) = ConfigFactory.parseString("akka.testconductor.name = node" + n).withFallback(nodeConfigs(n))
|
||||
}
|
||||
|
||||
class DirectRoutedRemoteActorMultiJvmNode1 extends AkkaRemoteSpec(DirectRoutedRemoteActorMultiJvmSpec.nameConfig(0)) {
|
||||
import DirectRoutedRemoteActorMultiJvmSpec._
|
||||
val nodes = NrOfNodes
|
||||
val tc = TestConductor(system)
|
||||
|
||||
"A new remote actor configured with a Direct router" must {
|
||||
"be locally instantiated on a remote node and be able to communicate through its RemoteActorRef" in {
|
||||
Await.result(tc.startController(2), Duration.Inf)
|
||||
tc.enter("begin", "done")
|
||||
commonConfig(ConfigFactory.parseString("""
|
||||
akka.loglevel = DEBUG
|
||||
akka.remote {
|
||||
log-received-messages = on
|
||||
log-sent-messages = on
|
||||
}
|
||||
}
|
||||
akka.actor.debug {
|
||||
receive = on
|
||||
fsm = on
|
||||
}
|
||||
"""))
|
||||
|
||||
val master = role("master")
|
||||
val slave = role("slave")
|
||||
|
||||
nodeConfig(master, ConfigFactory.parseString("""
|
||||
akka.actor {
|
||||
deployment {
|
||||
/service-hello.remote = "akka://MultiNodeSpec@%s"
|
||||
}
|
||||
}
|
||||
# FIXME When using NettyRemoteTransport instead of TestConductorTransport it works
|
||||
# akka.remote.transport = "akka.remote.netty.NettyRemoteTransport"
|
||||
""".format("localhost:2553"))) // FIXME is there a way to avoid hardcoding the host:port here?
|
||||
|
||||
nodeConfig(slave, ConfigFactory.parseString("""
|
||||
akka.remote.netty.port = 2553
|
||||
"""))
|
||||
|
||||
}
|
||||
|
||||
class DirectRoutedRemoteActorMultiJvmNode2 extends AkkaRemoteSpec(DirectRoutedRemoteActorMultiJvmSpec.nameConfig(1))
|
||||
class DirectRoutedRemoteActorMultiJvmNode1 extends DirectRoutedRemoteActorSpec
|
||||
class DirectRoutedRemoteActorMultiJvmNode2 extends DirectRoutedRemoteActorSpec
|
||||
|
||||
class DirectRoutedRemoteActorSpec extends MultiNodeSpec(DirectRoutedRemoteActorMultiJvmSpec)
|
||||
with ImplicitSender with DefaultTimeout {
|
||||
|
||||
import DirectRoutedRemoteActorMultiJvmSpec._
|
||||
val nodes = NrOfNodes
|
||||
val tc = TestConductor(system)
|
||||
|
||||
def initialParticipants = 2
|
||||
|
||||
"A new remote actor configured with a Direct router" must {
|
||||
"be locally instantiated on a remote node and be able to communicate through its RemoteActorRef" in {
|
||||
Await.result(tc.startClient(4712), Duration.Inf)
|
||||
tc.enter("begin")
|
||||
|
||||
val actor = system.actorOf(Props[SomeActor], "service-hello")
|
||||
actor.isInstanceOf[RemoteActorRef] must be(true)
|
||||
runOn(master) {
|
||||
val actor = system.actorOf(Props[SomeActor], "service-hello")
|
||||
actor.isInstanceOf[RemoteActorRef] must be(true)
|
||||
|
||||
Await.result(actor ? "identify", timeout.duration).asInstanceOf[ActorRef].path.address.hostPort must equal(akkaSpec(0))
|
||||
val slaveAddress = testConductor.getAddressFor(slave).await
|
||||
(actor ? "identify").await.asInstanceOf[ActorRef].path.address must equal(slaveAddress)
|
||||
|
||||
// shut down the actor before we let the other node(s) shut down so we don't try to send
|
||||
// "Terminate" to a shut down node
|
||||
system.stop(actor)
|
||||
tc.enter("done")
|
||||
// shut down the actor before we let the other node(s) shut down so we don't try to send
|
||||
// "Terminate" to a shut down node
|
||||
system.stop(actor)
|
||||
}
|
||||
|
||||
testConductor.enter("done")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue