2012-05-31 14:47:43 +02:00
|
|
|
/**
|
|
|
|
|
* Copyright (C) 2009-2012 Typesafe Inc. <http://www.typesafe.com>
|
|
|
|
|
*/
|
|
|
|
|
package akka.cluster
|
|
|
|
|
|
|
|
|
|
import com.typesafe.config.ConfigFactory
|
|
|
|
|
import akka.remote.testkit.MultiNodeConfig
|
|
|
|
|
import akka.remote.testkit.MultiNodeSpec
|
|
|
|
|
import akka.testkit._
|
2012-06-29 13:33:20 +02:00
|
|
|
import scala.concurrent.util.duration._
|
2012-05-31 14:47:43 +02:00
|
|
|
|
2012-06-08 15:03:11 +02:00
|
|
|
object SingletonClusterMultiJvmSpec extends MultiNodeConfig {
|
2012-05-31 14:47:43 +02:00
|
|
|
val first = role("first")
|
|
|
|
|
val second = role("second")
|
|
|
|
|
|
2012-06-08 13:44:40 +02:00
|
|
|
commonConfig(debugConfig(on = false).
|
2012-05-31 14:47:43 +02:00
|
|
|
withFallback(ConfigFactory.parseString("""
|
|
|
|
|
akka.cluster {
|
2012-06-25 21:07:44 +02:00
|
|
|
auto-join = on
|
2012-06-11 16:48:19 +02:00
|
|
|
auto-down = on
|
2012-05-31 14:47:43 +02:00
|
|
|
failure-detector.threshold = 4
|
|
|
|
|
}
|
|
|
|
|
""")).
|
|
|
|
|
withFallback(MultiNodeClusterSpec.clusterConfig))
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-11 16:53:55 +02:00
|
|
|
class SingletonClusterWithFailureDetectorPuppetMultiJvmNode1 extends SingletonClusterSpec with FailureDetectorPuppetStrategy
|
|
|
|
|
class SingletonClusterWithFailureDetectorPuppetMultiJvmNode2 extends SingletonClusterSpec with FailureDetectorPuppetStrategy
|
2012-06-11 16:48:19 +02:00
|
|
|
|
2012-06-11 16:53:55 +02:00
|
|
|
class SingletonClusterWithAccrualFailureDetectorMultiJvmNode1 extends SingletonClusterSpec with AccrualFailureDetectorStrategy
|
|
|
|
|
class SingletonClusterWithAccrualFailureDetectorMultiJvmNode2 extends SingletonClusterSpec with AccrualFailureDetectorStrategy
|
2012-06-11 16:48:19 +02:00
|
|
|
|
2012-06-11 16:53:55 +02:00
|
|
|
abstract class SingletonClusterSpec
|
|
|
|
|
extends MultiNodeSpec(SingletonClusterMultiJvmSpec)
|
2012-06-11 16:48:19 +02:00
|
|
|
with MultiNodeClusterSpec {
|
2012-05-31 14:47:43 +02:00
|
|
|
|
2012-06-08 15:03:11 +02:00
|
|
|
import SingletonClusterMultiJvmSpec._
|
2012-05-31 14:47:43 +02:00
|
|
|
|
|
|
|
|
"A cluster of 2 nodes" must {
|
|
|
|
|
|
2012-06-25 21:07:44 +02:00
|
|
|
"become singleton cluster when started with 'auto-join=on' and 'seed-nodes=[]'" taggedAs LongRunningTest in {
|
|
|
|
|
startClusterNode()
|
|
|
|
|
awaitUpConvergence(1)
|
|
|
|
|
cluster.isSingletonCluster must be(true)
|
|
|
|
|
|
|
|
|
|
enterBarrier("after-1")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"not be singleton cluster when joined with other node" taggedAs LongRunningTest in {
|
2012-06-05 14:13:44 +02:00
|
|
|
awaitClusterUp(first, second)
|
2012-05-31 14:47:43 +02:00
|
|
|
cluster.isSingletonCluster must be(false)
|
2012-06-01 11:37:44 +02:00
|
|
|
assertLeader(first, second)
|
2012-06-04 11:58:09 +02:00
|
|
|
|
2012-06-25 21:07:44 +02:00
|
|
|
enterBarrier("after-2")
|
2012-05-31 14:47:43 +02:00
|
|
|
}
|
|
|
|
|
|
2012-05-31 22:17:34 +02:00
|
|
|
"become singleton cluster when one node is shutdown" taggedAs LongRunningTest in {
|
2012-05-31 14:47:43 +02:00
|
|
|
runOn(first) {
|
2012-06-18 11:54:44 +02:00
|
|
|
val secondAddress = address(second)
|
2012-06-01 10:44:58 +02:00
|
|
|
testConductor.shutdown(second, 0)
|
2012-06-11 16:48:19 +02:00
|
|
|
|
|
|
|
|
markNodeAsUnavailable(secondAddress)
|
|
|
|
|
|
2012-05-31 14:47:43 +02:00
|
|
|
awaitUpConvergence(numberOfMembers = 1, canNotBePartOfMemberRing = Seq(secondAddress), 30.seconds)
|
|
|
|
|
cluster.isSingletonCluster must be(true)
|
2012-06-01 11:37:44 +02:00
|
|
|
assertLeader(first)
|
2012-05-31 14:47:43 +02:00
|
|
|
}
|
|
|
|
|
|
2012-06-25 21:07:44 +02:00
|
|
|
enterBarrier("after-3")
|
2012-05-31 14:47:43 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|