2012-05-31 14:47:43 +02:00
|
|
|
/**
|
2013-01-09 01:47:48 +01:00
|
|
|
* Copyright (C) 2009-2013 Typesafe Inc. <http://www.typesafe.com>
|
2012-05-31 14:47:43 +02:00
|
|
|
*/
|
|
|
|
|
package akka.cluster
|
|
|
|
|
|
|
|
|
|
import com.typesafe.config.ConfigFactory
|
|
|
|
|
import akka.remote.testkit.MultiNodeConfig
|
|
|
|
|
import akka.remote.testkit.MultiNodeSpec
|
|
|
|
|
import akka.testkit._
|
2012-09-21 14:50:06 +02:00
|
|
|
import scala.concurrent.duration._
|
2012-10-30 15:08:41 +01:00
|
|
|
import scala.collection.immutable
|
2012-05-31 14:47:43 +02:00
|
|
|
|
2012-09-06 21:48:40 +02:00
|
|
|
case class SingletonClusterMultiNodeConfig(failureDetectorPuppet: Boolean) 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
|
|
|
|
|
}
|
|
|
|
|
""")).
|
2012-09-06 21:48:40 +02:00
|
|
|
withFallback(MultiNodeClusterSpec.clusterConfig(failureDetectorPuppet)))
|
2012-05-31 14:47:43 +02:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-06 21:48:40 +02:00
|
|
|
class SingletonClusterWithFailureDetectorPuppetMultiJvmNode1 extends SingletonClusterSpec(failureDetectorPuppet = true)
|
|
|
|
|
class SingletonClusterWithFailureDetectorPuppetMultiJvmNode2 extends SingletonClusterSpec(failureDetectorPuppet = true)
|
2012-06-11 16:48:19 +02:00
|
|
|
|
2012-09-06 21:48:40 +02:00
|
|
|
class SingletonClusterWithAccrualFailureDetectorMultiJvmNode1 extends SingletonClusterSpec(failureDetectorPuppet = false)
|
|
|
|
|
class SingletonClusterWithAccrualFailureDetectorMultiJvmNode2 extends SingletonClusterSpec(failureDetectorPuppet = false)
|
2012-06-11 16:48:19 +02:00
|
|
|
|
2012-09-06 21:48:40 +02:00
|
|
|
abstract class SingletonClusterSpec(multiNodeConfig: SingletonClusterMultiNodeConfig)
|
|
|
|
|
extends MultiNodeSpec(multiNodeConfig)
|
2012-06-11 16:48:19 +02:00
|
|
|
with MultiNodeClusterSpec {
|
2012-05-31 14:47:43 +02:00
|
|
|
|
2012-09-06 21:48:40 +02:00
|
|
|
def this(failureDetectorPuppet: Boolean) = this(SingletonClusterMultiNodeConfig(failureDetectorPuppet))
|
|
|
|
|
|
|
|
|
|
import multiNodeConfig._
|
2012-05-31 14:47:43 +02:00
|
|
|
|
2012-10-01 20:08:21 +02:00
|
|
|
muteMarkingAsUnreachable()
|
|
|
|
|
|
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 {
|
|
|
|
|
awaitUpConvergence(1)
|
2012-08-16 18:28:01 +02:00
|
|
|
clusterView.isSingletonCluster must be(true)
|
2012-06-25 21:07:44 +02:00
|
|
|
|
|
|
|
|
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-08-16 18:28:01 +02:00
|
|
|
clusterView.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-10-16 17:02:13 +02:00
|
|
|
testConductor.shutdown(second, 0).await
|
2012-06-11 16:48:19 +02:00
|
|
|
|
|
|
|
|
markNodeAsUnavailable(secondAddress)
|
|
|
|
|
|
2012-12-12 11:49:20 +01:00
|
|
|
awaitUpConvergence(numberOfMembers = 1, canNotBePartOfMemberRing = Set(secondAddress), 30.seconds)
|
2012-08-16 18:28:01 +02:00
|
|
|
clusterView.isSingletonCluster must be(true)
|
2012-10-08 16:45:42 +02:00
|
|
|
awaitCond(clusterView.isLeader)
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|