2012-05-28 11:06:02 +02:00
|
|
|
/**
|
2016-01-25 10:16:14 +01:00
|
|
|
* Copyright (C) 2009-2016 Typesafe Inc. <http://www.typesafe.com>
|
2012-05-28 11:06:02 +02:00
|
|
|
*/
|
|
|
|
|
package akka.cluster
|
|
|
|
|
|
2012-07-26 14:47:21 +02:00
|
|
|
import language.postfixOps
|
|
|
|
|
|
2012-05-28 11:06:02 +02:00
|
|
|
import com.typesafe.config.ConfigFactory
|
|
|
|
|
import akka.remote.testkit.MultiNodeConfig
|
|
|
|
|
import akka.remote.testkit.MultiNodeSpec
|
|
|
|
|
import akka.testkit._
|
2012-06-10 16:53:17 +02:00
|
|
|
import akka.actor._
|
2012-09-21 14:50:06 +02:00
|
|
|
import scala.concurrent.duration._
|
2012-10-30 15:08:41 +01:00
|
|
|
import scala.collection.immutable
|
2012-05-28 11:06:02 +02:00
|
|
|
|
2014-03-07 13:20:01 +01:00
|
|
|
final case class LeaderDowningNodeThatIsUnreachableMultiNodeConfig(failureDetectorPuppet: Boolean) extends MultiNodeConfig {
|
2012-05-28 15:38:39 +02:00
|
|
|
val first = role("first")
|
2012-05-28 11:06:02 +02:00
|
|
|
val second = role("second")
|
2012-05-28 15:38:39 +02:00
|
|
|
val third = role("third")
|
2012-05-28 11:06:02 +02:00
|
|
|
val fourth = role("fourth")
|
|
|
|
|
|
2012-06-10 16:53:17 +02:00
|
|
|
commonConfig(debugConfig(on = false).
|
2013-09-11 16:09:51 +02:00
|
|
|
withFallback(ConfigFactory.parseString("akka.cluster.auto-down-unreachable-after = 2s")).
|
2012-09-06 21:48:40 +02:00
|
|
|
withFallback(MultiNodeClusterSpec.clusterConfig(failureDetectorPuppet)))
|
2012-05-28 11:06:02 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-06 21:48:40 +02:00
|
|
|
class LeaderDowningNodeThatIsUnreachableWithFailureDetectorPuppetMultiJvmNode1 extends LeaderDowningNodeThatIsUnreachableSpec(failureDetectorPuppet = true)
|
|
|
|
|
class LeaderDowningNodeThatIsUnreachableWithFailureDetectorPuppetMultiJvmNode2 extends LeaderDowningNodeThatIsUnreachableSpec(failureDetectorPuppet = true)
|
|
|
|
|
class LeaderDowningNodeThatIsUnreachableWithFailureDetectorPuppetMultiJvmNode3 extends LeaderDowningNodeThatIsUnreachableSpec(failureDetectorPuppet = true)
|
|
|
|
|
class LeaderDowningNodeThatIsUnreachableWithFailureDetectorPuppetMultiJvmNode4 extends LeaderDowningNodeThatIsUnreachableSpec(failureDetectorPuppet = true)
|
2012-05-28 11:06:02 +02:00
|
|
|
|
2012-09-06 21:48:40 +02:00
|
|
|
class LeaderDowningNodeThatIsUnreachableWithAccrualFailureDetectorMultiJvmNode1 extends LeaderDowningNodeThatIsUnreachableSpec(failureDetectorPuppet = false)
|
|
|
|
|
class LeaderDowningNodeThatIsUnreachableWithAccrualFailureDetectorMultiJvmNode2 extends LeaderDowningNodeThatIsUnreachableSpec(failureDetectorPuppet = false)
|
|
|
|
|
class LeaderDowningNodeThatIsUnreachableWithAccrualFailureDetectorMultiJvmNode3 extends LeaderDowningNodeThatIsUnreachableSpec(failureDetectorPuppet = false)
|
|
|
|
|
class LeaderDowningNodeThatIsUnreachableWithAccrualFailureDetectorMultiJvmNode4 extends LeaderDowningNodeThatIsUnreachableSpec(failureDetectorPuppet = false)
|
2012-06-11 14:32:17 +02:00
|
|
|
|
2012-09-06 21:48:40 +02:00
|
|
|
abstract class LeaderDowningNodeThatIsUnreachableSpec(multiNodeConfig: LeaderDowningNodeThatIsUnreachableMultiNodeConfig)
|
|
|
|
|
extends MultiNodeSpec(multiNodeConfig)
|
2012-06-04 23:21:28 +02:00
|
|
|
with MultiNodeClusterSpec {
|
|
|
|
|
|
2012-09-06 21:48:40 +02:00
|
|
|
def this(failureDetectorPuppet: Boolean) = this(LeaderDowningNodeThatIsUnreachableMultiNodeConfig(failureDetectorPuppet))
|
|
|
|
|
|
|
|
|
|
import multiNodeConfig._
|
2012-05-28 11:06:02 +02:00
|
|
|
|
2012-10-01 20:08:21 +02:00
|
|
|
muteMarkingAsUnreachable()
|
|
|
|
|
|
2012-05-28 11:06:02 +02:00
|
|
|
"The Leader in a 4 node cluster" must {
|
|
|
|
|
|
|
|
|
|
"be able to DOWN a 'last' node that is UNREACHABLE" taggedAs LongRunningTest in {
|
2012-06-05 14:13:44 +02:00
|
|
|
awaitClusterUp(first, second, third, fourth)
|
2012-05-28 11:06:02 +02:00
|
|
|
|
2012-06-18 11:54:44 +02:00
|
|
|
val fourthAddress = address(fourth)
|
2015-06-24 14:31:25 +02:00
|
|
|
|
|
|
|
|
enterBarrier("before-exit-fourth-node")
|
2012-06-05 14:13:44 +02:00
|
|
|
runOn(first) {
|
2012-05-28 11:06:02 +02:00
|
|
|
// kill 'fourth' node
|
2013-04-23 16:44:14 +02:00
|
|
|
testConductor.exit(fourth, 0).await
|
2012-06-15 14:39:47 +02:00
|
|
|
enterBarrier("down-fourth-node")
|
2012-05-28 11:06:02 +02:00
|
|
|
|
2012-06-10 16:53:17 +02:00
|
|
|
// mark the node as unreachable in the failure detector
|
2012-06-11 14:32:17 +02:00
|
|
|
markNodeAsUnavailable(fourthAddress)
|
2012-06-10 16:53:17 +02:00
|
|
|
|
2012-05-28 11:06:02 +02:00
|
|
|
// --- HERE THE LEADER SHOULD DETECT FAILURE AND AUTO-DOWN THE UNREACHABLE NODE ---
|
|
|
|
|
|
2013-03-05 21:05:11 +01:00
|
|
|
awaitMembersUp(numberOfMembers = 3, canNotBePartOfMemberRing = Set(fourthAddress), 30.seconds)
|
2012-05-28 11:06:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
runOn(fourth) {
|
2012-06-15 14:39:47 +02:00
|
|
|
enterBarrier("down-fourth-node")
|
2012-05-28 11:06:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
runOn(second, third) {
|
2012-06-15 14:39:47 +02:00
|
|
|
enterBarrier("down-fourth-node")
|
2012-05-28 11:06:02 +02:00
|
|
|
|
2013-03-05 21:05:11 +01:00
|
|
|
awaitMembersUp(numberOfMembers = 3, canNotBePartOfMemberRing = Set(fourthAddress), 30.seconds)
|
2012-05-28 11:06:02 +02:00
|
|
|
}
|
2012-06-05 14:13:44 +02:00
|
|
|
|
2012-06-15 14:39:47 +02:00
|
|
|
enterBarrier("await-completion-1")
|
2012-05-28 11:06:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"be able to DOWN a 'middle' node that is UNREACHABLE" taggedAs LongRunningTest in {
|
2012-06-18 11:54:44 +02:00
|
|
|
val secondAddress = address(second)
|
2012-05-28 11:06:02 +02:00
|
|
|
|
2012-06-15 14:39:47 +02:00
|
|
|
enterBarrier("before-down-second-node")
|
2012-06-05 14:13:44 +02:00
|
|
|
runOn(first) {
|
2012-05-28 11:06:02 +02:00
|
|
|
// kill 'second' node
|
2013-04-23 16:44:14 +02:00
|
|
|
testConductor.exit(second, 0).await
|
2012-06-15 14:39:47 +02:00
|
|
|
enterBarrier("down-second-node")
|
2012-05-28 11:06:02 +02:00
|
|
|
|
2012-06-10 16:53:17 +02:00
|
|
|
// mark the node as unreachable in the failure detector
|
2012-06-11 14:32:17 +02:00
|
|
|
markNodeAsUnavailable(secondAddress)
|
2012-06-10 16:53:17 +02:00
|
|
|
|
2012-05-28 11:06:02 +02:00
|
|
|
// --- HERE THE LEADER SHOULD DETECT FAILURE AND AUTO-DOWN THE UNREACHABLE NODE ---
|
|
|
|
|
|
2013-03-05 21:05:11 +01:00
|
|
|
awaitMembersUp(numberOfMembers = 2, canNotBePartOfMemberRing = Set(secondAddress), 30.seconds)
|
2012-05-28 11:06:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
runOn(second) {
|
2012-06-15 14:39:47 +02:00
|
|
|
enterBarrier("down-second-node")
|
2012-05-28 11:06:02 +02:00
|
|
|
}
|
|
|
|
|
|
2012-05-30 17:17:09 +02:00
|
|
|
runOn(third) {
|
2012-06-15 14:39:47 +02:00
|
|
|
enterBarrier("down-second-node")
|
2012-05-28 11:06:02 +02:00
|
|
|
|
2013-03-05 21:05:11 +01:00
|
|
|
awaitMembersUp(numberOfMembers = 2, canNotBePartOfMemberRing = Set(secondAddress), 30 seconds)
|
2012-05-28 11:06:02 +02:00
|
|
|
}
|
2012-06-05 14:13:44 +02:00
|
|
|
|
2012-06-15 14:39:47 +02:00
|
|
|
enterBarrier("await-completion-2")
|
2012-05-28 11:06:02 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|