2018-10-29 17:19:37 +08:00
|
|
|
/*
|
2020-01-02 07:24:59 -05:00
|
|
|
* Copyright (C) 2009-2020 Lightbend Inc. <https://www.lightbend.com>
|
2015-01-19 10:03:40 +01:00
|
|
|
*/
|
2018-04-24 16:03:55 +01:00
|
|
|
|
2015-01-19 10:03:40 +01:00
|
|
|
package akka.cluster
|
|
|
|
|
|
|
|
|
|
import scala.concurrent.duration._
|
2020-04-27 20:32:18 +08:00
|
|
|
|
2015-01-19 10:03:40 +01:00
|
|
|
import akka.actor.Actor
|
|
|
|
|
import akka.actor.ActorIdentity
|
|
|
|
|
import akka.actor.ActorRef
|
|
|
|
|
import akka.actor.Identify
|
2020-04-27 20:32:18 +08:00
|
|
|
import akka.actor.PoisonPill
|
2015-01-19 10:03:40 +01:00
|
|
|
import akka.actor.Props
|
2020-04-27 20:32:18 +08:00
|
|
|
import akka.remote.testkit.{ MultiNodeConfig, MultiNodeSpec }
|
2015-01-19 10:03:40 +01:00
|
|
|
import akka.remote.transport.ThrottlerTransportAdapter.Direction
|
|
|
|
|
import akka.testkit._
|
|
|
|
|
|
|
|
|
|
object AttemptSysMsgRedeliveryMultiJvmSpec extends MultiNodeConfig {
|
|
|
|
|
|
|
|
|
|
val first = role("first")
|
|
|
|
|
val second = role("second")
|
|
|
|
|
val third = role("third")
|
|
|
|
|
|
|
|
|
|
commonConfig(debugConfig(on = false).withFallback(MultiNodeClusterSpec.clusterConfig))
|
|
|
|
|
|
|
|
|
|
testTransport(on = true)
|
|
|
|
|
|
|
|
|
|
class Echo extends Actor {
|
|
|
|
|
def receive = {
|
2020-08-10 12:54:38 +02:00
|
|
|
case m => sender() ! m
|
2015-01-19 10:03:40 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class AttemptSysMsgRedeliveryMultiJvmNode1 extends AttemptSysMsgRedeliverySpec
|
|
|
|
|
class AttemptSysMsgRedeliveryMultiJvmNode2 extends AttemptSysMsgRedeliverySpec
|
|
|
|
|
class AttemptSysMsgRedeliveryMultiJvmNode3 extends AttemptSysMsgRedeliverySpec
|
|
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
class AttemptSysMsgRedeliverySpec
|
|
|
|
|
extends MultiNodeSpec(AttemptSysMsgRedeliveryMultiJvmSpec)
|
|
|
|
|
with MultiNodeClusterSpec
|
|
|
|
|
with ImplicitSender
|
|
|
|
|
with DefaultTimeout {
|
2015-01-19 10:03:40 +01:00
|
|
|
import AttemptSysMsgRedeliveryMultiJvmSpec._
|
|
|
|
|
|
|
|
|
|
"AttemptSysMsgRedelivery" must {
|
|
|
|
|
"reach initial convergence" taggedAs LongRunningTest in {
|
|
|
|
|
awaitClusterUp(first, second, third)
|
|
|
|
|
|
|
|
|
|
enterBarrier("after-1")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"redeliver system message after inactivity" taggedAs LongRunningTest in {
|
2020-04-27 17:31:16 +07:00
|
|
|
system.actorOf(Props[Echo](), "echo")
|
2015-01-19 10:03:40 +01:00
|
|
|
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")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|