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>
|
2012-05-28 11:06:02 +02:00
|
|
|
*/
|
2018-04-24 16:03:55 +01:00
|
|
|
|
2012-05-28 11:06:02 +02:00
|
|
|
package akka.cluster
|
|
|
|
|
|
2020-04-27 20:32:18 +08:00
|
|
|
import scala.concurrent.duration._
|
2012-07-26 14:47:21 +02:00
|
|
|
|
2012-05-28 11:06:02 +02:00
|
|
|
import com.typesafe.config.ConfigFactory
|
2020-04-27 20:32:18 +08:00
|
|
|
import language.postfixOps
|
|
|
|
|
|
2012-05-28 11:06:02 +02:00
|
|
|
import akka.remote.testkit.MultiNodeConfig
|
|
|
|
|
import akka.remote.testkit.MultiNodeSpec
|
|
|
|
|
import akka.testkit._
|
|
|
|
|
|
2019-03-11 10:38:24 +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")
|
|
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
commonConfig(
|
|
|
|
|
debugConfig(on = false)
|
2019-10-03 14:08:43 +02:00
|
|
|
.withFallback(ConfigFactory.parseString("""
|
|
|
|
|
akka.cluster.downing-provider-class = akka.cluster.testkit.AutoDowning
|
|
|
|
|
akka.cluster.testkit.auto-down-unreachable-after = 2s"""))
|
2019-03-11 10:38:24 +01:00
|
|
|
.withFallback(MultiNodeClusterSpec.clusterConfig(failureDetectorPuppet)))
|
2012-05-28 11:06:02 +02:00
|
|
|
}
|
|
|
|
|
|
2019-03-11 10:38:24 +01: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)
|
|
|
|
|
|
|
|
|
|
class LeaderDowningNodeThatIsUnreachableWithAccrualFailureDetectorMultiJvmNode1
|
|
|
|
|
extends LeaderDowningNodeThatIsUnreachableSpec(failureDetectorPuppet = false)
|
|
|
|
|
class LeaderDowningNodeThatIsUnreachableWithAccrualFailureDetectorMultiJvmNode2
|
|
|
|
|
extends LeaderDowningNodeThatIsUnreachableSpec(failureDetectorPuppet = false)
|
|
|
|
|
class LeaderDowningNodeThatIsUnreachableWithAccrualFailureDetectorMultiJvmNode3
|
|
|
|
|
extends LeaderDowningNodeThatIsUnreachableSpec(failureDetectorPuppet = false)
|
|
|
|
|
class LeaderDowningNodeThatIsUnreachableWithAccrualFailureDetectorMultiJvmNode4
|
|
|
|
|
extends LeaderDowningNodeThatIsUnreachableSpec(failureDetectorPuppet = false)
|
|
|
|
|
|
|
|
|
|
abstract class LeaderDowningNodeThatIsUnreachableSpec(
|
|
|
|
|
multiNodeConfig: LeaderDowningNodeThatIsUnreachableMultiNodeConfig)
|
|
|
|
|
extends MultiNodeSpec(multiNodeConfig)
|
|
|
|
|
with MultiNodeClusterSpec {
|
|
|
|
|
|
|
|
|
|
def this(failureDetectorPuppet: Boolean) =
|
|
|
|
|
this(LeaderDowningNodeThatIsUnreachableMultiNodeConfig(failureDetectorPuppet))
|
2012-09-06 21:48:40 +02:00
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|