2012-02-18 17:48:07 +01:00
|
|
|
/**
|
|
|
|
|
* Copyright (C) 2009-2012 Typesafe Inc. <http://www.typesafe.com>
|
|
|
|
|
*/
|
|
|
|
|
package akka.cluster
|
2012-01-28 15:34:46 +01:00
|
|
|
|
2012-05-28 13:48:58 +02:00
|
|
|
import com.typesafe.config.ConfigFactory
|
|
|
|
|
import akka.remote.testkit.MultiNodeConfig
|
|
|
|
|
import akka.remote.testkit.MultiNodeSpec
|
2012-02-18 17:48:07 +01:00
|
|
|
import akka.util.duration._
|
2012-05-28 13:48:58 +02:00
|
|
|
import akka.testkit._
|
|
|
|
|
|
|
|
|
|
object GossipingAccrualFailureDetectorMultiJvmSpec extends MultiNodeConfig {
|
|
|
|
|
val first = role("first")
|
|
|
|
|
val second = role("second")
|
|
|
|
|
val third = role("third")
|
2012-01-28 15:34:46 +01:00
|
|
|
|
2012-05-28 13:48:58 +02:00
|
|
|
commonConfig(debugConfig(on = false).
|
2012-06-04 23:32:27 +02:00
|
|
|
withFallback(ConfigFactory.parseString("akka.cluster.failure-detector.threshold = 4")).
|
2012-05-28 13:48:58 +02:00
|
|
|
withFallback(MultiNodeClusterSpec.clusterConfig))
|
|
|
|
|
}
|
2012-01-28 15:34:46 +01:00
|
|
|
|
2012-05-28 13:48:58 +02:00
|
|
|
class GossipingAccrualFailureDetectorMultiJvmNode1 extends GossipingAccrualFailureDetectorSpec
|
|
|
|
|
class GossipingAccrualFailureDetectorMultiJvmNode2 extends GossipingAccrualFailureDetectorSpec
|
|
|
|
|
class GossipingAccrualFailureDetectorMultiJvmNode3 extends GossipingAccrualFailureDetectorSpec
|
2012-01-28 15:34:46 +01:00
|
|
|
|
2012-05-28 13:48:58 +02:00
|
|
|
abstract class GossipingAccrualFailureDetectorSpec extends MultiNodeSpec(GossipingAccrualFailureDetectorMultiJvmSpec)
|
2012-06-04 11:58:09 +02:00
|
|
|
with MultiNodeClusterSpec {
|
2012-05-28 13:48:58 +02:00
|
|
|
import GossipingAccrualFailureDetectorMultiJvmSpec._
|
2012-01-28 15:34:46 +01:00
|
|
|
|
2012-05-28 13:48:58 +02:00
|
|
|
override def initialParticipants = 3
|
2012-01-28 15:34:46 +01:00
|
|
|
|
2012-05-28 13:48:58 +02:00
|
|
|
lazy val firstAddress = node(first).address
|
|
|
|
|
lazy val secondAddress = node(second).address
|
|
|
|
|
lazy val thirdAddress = node(third).address
|
2012-01-28 15:34:46 +01:00
|
|
|
|
2012-05-28 13:48:58 +02:00
|
|
|
"A Gossip-driven Failure Detector" must {
|
2012-01-28 15:34:46 +01:00
|
|
|
|
2012-05-29 08:46:00 +02:00
|
|
|
"receive gossip heartbeats so that all member nodes in the cluster are marked 'available'" taggedAs LongRunningTest in {
|
2012-05-28 13:48:58 +02:00
|
|
|
// make sure that the node-to-join is started before other join
|
|
|
|
|
runOn(first) {
|
2012-06-04 23:21:28 +02:00
|
|
|
startClusterNode()
|
2012-05-28 13:48:58 +02:00
|
|
|
}
|
|
|
|
|
testConductor.enter("first-started")
|
2012-01-28 15:34:46 +01:00
|
|
|
|
2012-05-28 13:48:58 +02:00
|
|
|
cluster.join(firstAddress)
|
2012-01-28 15:34:46 +01:00
|
|
|
|
2012-05-29 08:46:00 +02:00
|
|
|
5.seconds.dilated.sleep // let them gossip
|
2012-05-28 13:48:58 +02:00
|
|
|
cluster.failureDetector.isAvailable(firstAddress) must be(true)
|
|
|
|
|
cluster.failureDetector.isAvailable(secondAddress) must be(true)
|
|
|
|
|
cluster.failureDetector.isAvailable(thirdAddress) must be(true)
|
2012-06-04 11:58:09 +02:00
|
|
|
|
|
|
|
|
testConductor.enter("after-1")
|
2012-05-28 13:48:58 +02:00
|
|
|
}
|
|
|
|
|
|
2012-05-29 08:46:00 +02:00
|
|
|
"mark node as 'unavailable' if a node in the cluster is shut down (and its heartbeats stops)" taggedAs LongRunningTest in {
|
2012-05-28 13:48:58 +02:00
|
|
|
runOn(first) {
|
|
|
|
|
testConductor.shutdown(third, 0)
|
2012-02-18 17:48:07 +01:00
|
|
|
}
|
2012-01-28 15:34:46 +01:00
|
|
|
|
2012-05-28 13:48:58 +02:00
|
|
|
runOn(first, second) {
|
2012-05-29 08:46:00 +02:00
|
|
|
// remaning nodes should detect failure...
|
|
|
|
|
awaitCond(!cluster.failureDetector.isAvailable(thirdAddress), 10.seconds)
|
|
|
|
|
// other connections still ok
|
2012-05-28 13:48:58 +02:00
|
|
|
cluster.failureDetector.isAvailable(firstAddress) must be(true)
|
|
|
|
|
cluster.failureDetector.isAvailable(secondAddress) must be(true)
|
2012-02-18 17:48:07 +01:00
|
|
|
}
|
2012-06-04 11:58:09 +02:00
|
|
|
|
|
|
|
|
testConductor.enter("after-2")
|
2012-02-18 17:48:07 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|