Made LeaderDowningNodeThatIsUnreachableSpec make use of the new FailureDetectorPuppet as a sample of how to use it.

Signed-off-by: Jonas Bonér <jonas@jonasboner.com>
This commit is contained in:
Jonas Bonér 2012-06-10 16:53:17 +02:00
parent a4499b06bb
commit 0030fa1b52

View file

@ -7,7 +7,7 @@ import com.typesafe.config.ConfigFactory
import akka.remote.testkit.MultiNodeConfig
import akka.remote.testkit.MultiNodeSpec
import akka.testkit._
import akka.actor.Address
import akka.actor._
import akka.util.duration._
object LeaderDowningNodeThatIsUnreachableMultiJvmSpec extends MultiNodeConfig {
@ -16,12 +16,9 @@ object LeaderDowningNodeThatIsUnreachableMultiJvmSpec extends MultiNodeConfig {
val third = role("third")
val fourth = role("fourth")
commonConfig(debugConfig(on = true).
commonConfig(debugConfig(on = false).
withFallback(ConfigFactory.parseString("""
akka.cluster {
auto-down = on
failure-detector.threshold = 4
}
akka.cluster.auto-down = on
""")).
withFallback(MultiNodeClusterSpec.clusterConfig))
}
@ -37,10 +34,20 @@ class LeaderDowningNodeThatIsUnreachableSpec
import LeaderDowningNodeThatIsUnreachableMultiJvmSpec._
// Set up the puppet failure detector
lazy val failureDetector = new FailureDetectorPuppet(system = system)
lazy val clusterNode = new Cluster(system.asInstanceOf[ExtendedActorSystem], failureDetector)
override def cluster = clusterNode
lazy val firstAddress = node(first).address
lazy val secondAddress = node(second).address
lazy val thirdAddress = node(third).address
lazy val fourthAddress = node(fourth).address
"The Leader in a 4 node cluster" must {
"be able to DOWN a 'last' node that is UNREACHABLE" taggedAs LongRunningTest in {
val fourthAddress = node(fourth).address
awaitClusterUp(first, second, third, fourth)
runOn(first) {
@ -48,6 +55,9 @@ class LeaderDowningNodeThatIsUnreachableSpec
testConductor.shutdown(fourth, 0)
testConductor.enter("down-fourth-node")
// mark the node as unreachable in the failure detector
failureDetector markAsDown fourthAddress
// --- HERE THE LEADER SHOULD DETECT FAILURE AND AUTO-DOWN THE UNREACHABLE NODE ---
awaitUpConvergence(numberOfMembers = 3, canNotBePartOfMemberRing = Seq(fourthAddress), 30.seconds)
@ -67,7 +77,6 @@ class LeaderDowningNodeThatIsUnreachableSpec
}
"be able to DOWN a 'middle' node that is UNREACHABLE" taggedAs LongRunningTest in {
val secondAddress = node(second).address
testConductor.enter("before-down-second-node")
runOn(first) {
@ -75,6 +84,9 @@ class LeaderDowningNodeThatIsUnreachableSpec
testConductor.shutdown(second, 0)
testConductor.enter("down-second-node")
// mark the node as unreachable in the failure detector
failureDetector markAsDown secondAddress
// --- HERE THE LEADER SHOULD DETECT FAILURE AND AUTO-DOWN THE UNREACHABLE NODE ---
awaitUpConvergence(numberOfMembers = 2, canNotBePartOfMemberRing = Seq(secondAddress), 30.seconds)