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._
|
|
|
|
|
|
2012-06-20 11:06:47 +02:00
|
|
|
object ClusterAccrualFailureDetectorMultiJvmSpec extends MultiNodeConfig {
|
2012-05-28 13:48:58 +02:00
|
|
|
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-06-20 11:06:47 +02:00
|
|
|
class ClusterAccrualFailureDetectorMultiJvmNode1 extends ClusterAccrualFailureDetectorSpec with AccrualFailureDetectorStrategy
|
|
|
|
|
class ClusterAccrualFailureDetectorMultiJvmNode2 extends ClusterAccrualFailureDetectorSpec with AccrualFailureDetectorStrategy
|
|
|
|
|
class ClusterAccrualFailureDetectorMultiJvmNode3 extends ClusterAccrualFailureDetectorSpec with AccrualFailureDetectorStrategy
|
2012-01-28 15:34:46 +01:00
|
|
|
|
2012-06-20 11:06:47 +02:00
|
|
|
abstract class ClusterAccrualFailureDetectorSpec
|
|
|
|
|
extends MultiNodeSpec(ClusterAccrualFailureDetectorMultiJvmSpec)
|
2012-06-04 11:58:09 +02:00
|
|
|
with MultiNodeClusterSpec {
|
2012-06-11 16:48:19 +02:00
|
|
|
|
2012-06-20 11:06:47 +02:00
|
|
|
import ClusterAccrualFailureDetectorMultiJvmSpec._
|
2012-01-28 15:34:46 +01:00
|
|
|
|
2012-06-20 11:06:47 +02:00
|
|
|
"A heartbeat driven Failure Detector" must {
|
2012-01-28 15:34:46 +01:00
|
|
|
|
2012-06-20 11:06:47 +02:00
|
|
|
"receive heartbeats so that all member nodes in the cluster are marked 'available'" taggedAs LongRunningTest in {
|
2012-06-05 14:13:44 +02:00
|
|
|
awaitClusterUp(first, second, third)
|
2012-01-28 15:34:46 +01:00
|
|
|
|
2012-06-20 11:06:47 +02:00
|
|
|
5.seconds.dilated.sleep // let them heartbeat
|
2012-06-15 14:37:51 +02:00
|
|
|
cluster.failureDetector.isAvailable(first) must be(true)
|
|
|
|
|
cluster.failureDetector.isAvailable(second) must be(true)
|
|
|
|
|
cluster.failureDetector.isAvailable(third) must be(true)
|
2012-06-04 11:58:09 +02:00
|
|
|
|
2012-06-15 14:39:47 +02:00
|
|
|
enterBarrier("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-06-20 11:06:47 +02:00
|
|
|
enterBarrier("third-shutdown")
|
|
|
|
|
|
2012-05-28 13:48:58 +02:00
|
|
|
runOn(first, second) {
|
2012-05-29 08:46:00 +02:00
|
|
|
// remaning nodes should detect failure...
|
2012-06-20 11:06:47 +02:00
|
|
|
awaitCond(!cluster.failureDetector.isAvailable(third), 15.seconds)
|
2012-05-29 08:46:00 +02:00
|
|
|
// other connections still ok
|
2012-06-15 14:37:51 +02:00
|
|
|
cluster.failureDetector.isAvailable(first) must be(true)
|
|
|
|
|
cluster.failureDetector.isAvailable(second) must be(true)
|
2012-02-18 17:48:07 +01:00
|
|
|
}
|
2012-06-04 11:58:09 +02:00
|
|
|
|
2012-06-15 14:39:47 +02:00
|
|
|
enterBarrier("after-2")
|
2012-02-18 17:48:07 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|