2015-01-19 10:03:40 +01:00
|
|
|
/**
|
2016-02-23 12:58:39 +01:00
|
|
|
* Copyright (C) 2009-2016 Lightbend Inc. <http://www.lightbend.com>
|
2015-01-19 10:03:40 +01:00
|
|
|
*/
|
|
|
|
|
package akka.remote
|
|
|
|
|
|
|
|
|
|
import scala.concurrent.duration._
|
|
|
|
|
import akka.actor.Actor
|
|
|
|
|
import akka.actor.ActorIdentity
|
|
|
|
|
import akka.actor.ActorRef
|
|
|
|
|
import akka.actor.Identify
|
|
|
|
|
import akka.actor.Props
|
|
|
|
|
import akka.remote.transport.ThrottlerTransportAdapter.Direction
|
|
|
|
|
import akka.testkit._
|
|
|
|
|
import testkit.{ STMultiNodeSpec, MultiNodeConfig, MultiNodeSpec }
|
|
|
|
|
import akka.actor.PoisonPill
|
2016-06-02 07:21:47 +02:00
|
|
|
import com.typesafe.config.ConfigFactory
|
2015-01-19 10:03:40 +01:00
|
|
|
|
2016-06-02 07:21:47 +02:00
|
|
|
class AttemptSysMsgRedeliveryMultiJvmSpec(artery: Boolean) extends MultiNodeConfig {
|
2015-01-19 10:03:40 +01:00
|
|
|
|
|
|
|
|
val first = role("first")
|
|
|
|
|
val second = role("second")
|
|
|
|
|
val third = role("third")
|
|
|
|
|
|
2016-06-02 07:21:47 +02:00
|
|
|
commonConfig(debugConfig(on = false).withFallback(
|
|
|
|
|
ConfigFactory.parseString(s"""
|
|
|
|
|
akka.remote.artery.enabled = $artery
|
|
|
|
|
""")))
|
2015-01-19 10:03:40 +01:00
|
|
|
|
|
|
|
|
testTransport(on = true)
|
|
|
|
|
|
2016-06-02 07:21:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class AttemptSysMsgRedeliveryMultiJvmNode1 extends AttemptSysMsgRedeliverySpec(
|
|
|
|
|
new AttemptSysMsgRedeliveryMultiJvmSpec(artery = false))
|
|
|
|
|
class AttemptSysMsgRedeliveryMultiJvmNode2 extends AttemptSysMsgRedeliverySpec(
|
|
|
|
|
new AttemptSysMsgRedeliveryMultiJvmSpec(artery = false))
|
|
|
|
|
class AttemptSysMsgRedeliveryMultiJvmNode3 extends AttemptSysMsgRedeliverySpec(
|
|
|
|
|
new AttemptSysMsgRedeliveryMultiJvmSpec(artery = false))
|
|
|
|
|
|
2016-06-02 20:44:27 +02:00
|
|
|
// FIXME this is failing with Artery
|
|
|
|
|
//class ArteryAttemptSysMsgRedeliveryMultiJvmNode1 extends AttemptSysMsgRedeliverySpec(
|
|
|
|
|
// new AttemptSysMsgRedeliveryMultiJvmSpec(artery = true))
|
|
|
|
|
//class ArteryAttemptSysMsgRedeliveryMultiJvmNode2 extends AttemptSysMsgRedeliverySpec(
|
|
|
|
|
// new AttemptSysMsgRedeliveryMultiJvmSpec(artery = true))
|
|
|
|
|
//class ArteryAttemptSysMsgRedeliveryMultiJvmNode3 extends AttemptSysMsgRedeliverySpec(
|
|
|
|
|
// new AttemptSysMsgRedeliveryMultiJvmSpec(artery = true))
|
2016-06-02 07:21:47 +02:00
|
|
|
|
|
|
|
|
object AttemptSysMsgRedeliverySpec {
|
2015-01-19 10:03:40 +01:00
|
|
|
class Echo extends Actor {
|
|
|
|
|
def receive = {
|
|
|
|
|
case m ⇒ sender ! m
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-02 07:21:47 +02:00
|
|
|
abstract class AttemptSysMsgRedeliverySpec(multiNodeConfig: AttemptSysMsgRedeliveryMultiJvmSpec)
|
|
|
|
|
extends MultiNodeSpec(multiNodeConfig)
|
2015-01-19 10:03:40 +01:00
|
|
|
with STMultiNodeSpec with ImplicitSender with DefaultTimeout {
|
2016-06-02 07:21:47 +02:00
|
|
|
import multiNodeConfig._
|
|
|
|
|
import AttemptSysMsgRedeliverySpec._
|
2015-01-19 10:03:40 +01:00
|
|
|
|
|
|
|
|
def initialParticipants = roles.size
|
|
|
|
|
|
|
|
|
|
"AttemptSysMsgRedelivery" must {
|
|
|
|
|
"redeliver system message after inactivity" taggedAs LongRunningTest in {
|
|
|
|
|
system.actorOf(Props[Echo], "echo")
|
|
|
|
|
enterBarrier("echo-started")
|
|
|
|
|
|
|
|
|
|
system.actorSelection(node(first) / "user" / "echo") ! Identify(None)
|
|
|
|
|
val firstRef: ActorRef = expectMsgType[ActorIdentity].ref.get
|
|
|
|
|
system.actorSelection(node(second) / "user" / "echo") ! Identify(None)
|
|
|
|
|
val secondRef: ActorRef = expectMsgType[ActorIdentity].ref.get
|
|
|
|
|
enterBarrier("refs-retrieved")
|
|
|
|
|
|
|
|
|
|
runOn(first) {
|
|
|
|
|
testConductor.blackhole(first, second, Direction.Both).await
|
|
|
|
|
}
|
|
|
|
|
enterBarrier("blackhole")
|
|
|
|
|
|
|
|
|
|
runOn(first, third) {
|
|
|
|
|
watch(secondRef)
|
|
|
|
|
}
|
|
|
|
|
runOn(second) {
|
|
|
|
|
watch(firstRef)
|
|
|
|
|
}
|
|
|
|
|
enterBarrier("watch-established")
|
|
|
|
|
|
|
|
|
|
runOn(first) {
|
|
|
|
|
testConductor.passThrough(first, second, Direction.Both).await
|
|
|
|
|
}
|
|
|
|
|
enterBarrier("pass-through")
|
|
|
|
|
|
|
|
|
|
system.actorSelection("/user/echo") ! PoisonPill
|
|
|
|
|
|
|
|
|
|
runOn(first, third) {
|
|
|
|
|
expectTerminated(secondRef, 10.seconds)
|
|
|
|
|
}
|
|
|
|
|
runOn(second) {
|
|
|
|
|
expectTerminated(firstRef, 10.seconds)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enterBarrier("done")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|