2012-05-27 19:21:38 +02:00
|
|
|
/**
|
2013-01-09 01:47:48 +01:00
|
|
|
* Copyright (C) 2009-2013 Typesafe Inc. <http://www.typesafe.com>
|
2012-05-27 19:21:38 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package akka.cluster
|
|
|
|
|
|
|
|
|
|
import com.typesafe.config.ConfigFactory
|
|
|
|
|
import akka.remote.testkit.MultiNodeConfig
|
|
|
|
|
import akka.remote.testkit.MultiNodeSpec
|
|
|
|
|
import akka.testkit._
|
|
|
|
|
|
|
|
|
|
object JoinTwoClustersMultiJvmSpec extends MultiNodeConfig {
|
|
|
|
|
val a1 = role("a1")
|
|
|
|
|
val a2 = role("a2")
|
|
|
|
|
val b1 = role("b1")
|
|
|
|
|
val b2 = role("b2")
|
|
|
|
|
val c1 = role("c1")
|
|
|
|
|
val c2 = role("c2")
|
|
|
|
|
|
2012-09-06 21:48:40 +02:00
|
|
|
commonConfig(debugConfig(on = false).withFallback(MultiNodeClusterSpec.clusterConfigWithFailureDetectorPuppet))
|
2012-05-27 19:21:38 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-06 21:48:40 +02:00
|
|
|
class JoinTwoClustersMultiJvmNode1 extends JoinTwoClustersSpec
|
|
|
|
|
class JoinTwoClustersMultiJvmNode2 extends JoinTwoClustersSpec
|
|
|
|
|
class JoinTwoClustersMultiJvmNode3 extends JoinTwoClustersSpec
|
|
|
|
|
class JoinTwoClustersMultiJvmNode4 extends JoinTwoClustersSpec
|
|
|
|
|
class JoinTwoClustersMultiJvmNode5 extends JoinTwoClustersSpec
|
|
|
|
|
class JoinTwoClustersMultiJvmNode6 extends JoinTwoClustersSpec
|
2012-05-27 19:21:38 +02:00
|
|
|
|
2012-06-04 23:21:28 +02:00
|
|
|
abstract class JoinTwoClustersSpec
|
|
|
|
|
extends MultiNodeSpec(JoinTwoClustersMultiJvmSpec)
|
|
|
|
|
with MultiNodeClusterSpec {
|
|
|
|
|
|
2012-05-27 19:21:38 +02:00
|
|
|
import JoinTwoClustersMultiJvmSpec._
|
|
|
|
|
|
|
|
|
|
"Three different clusters (A, B and C)" must {
|
|
|
|
|
|
|
|
|
|
"be able to 'elect' a single leader after joining (A -> B)" taggedAs LongRunningTest in {
|
2012-05-27 19:46:42 +02:00
|
|
|
// make sure that the node-to-join is started before other join
|
|
|
|
|
runOn(a1, b1, c1) {
|
2012-06-04 23:21:28 +02:00
|
|
|
startClusterNode()
|
2012-05-27 19:46:42 +02:00
|
|
|
}
|
2012-06-19 17:10:03 +02:00
|
|
|
enterBarrier("first-started")
|
2012-05-27 19:21:38 +02:00
|
|
|
|
|
|
|
|
runOn(a1, a2) {
|
2012-06-18 11:54:44 +02:00
|
|
|
cluster.join(a1)
|
2012-05-27 19:21:38 +02:00
|
|
|
}
|
|
|
|
|
runOn(b1, b2) {
|
2012-06-18 11:54:44 +02:00
|
|
|
cluster.join(b1)
|
2012-05-27 19:21:38 +02:00
|
|
|
}
|
|
|
|
|
runOn(c1, c2) {
|
2012-06-18 11:54:44 +02:00
|
|
|
cluster.join(c1)
|
2012-05-27 19:21:38 +02:00
|
|
|
}
|
|
|
|
|
|
2013-03-05 21:05:11 +01:00
|
|
|
awaitMembersUp(numberOfMembers = 2)
|
2012-05-27 19:21:38 +02:00
|
|
|
|
|
|
|
|
assertLeader(a1, a2)
|
|
|
|
|
assertLeader(b1, b2)
|
|
|
|
|
assertLeader(c1, c2)
|
|
|
|
|
|
2012-06-19 17:10:03 +02:00
|
|
|
enterBarrier("two-members")
|
2012-05-30 19:32:10 +02:00
|
|
|
|
2012-05-27 19:21:38 +02:00
|
|
|
runOn(b2) {
|
2012-06-18 11:54:44 +02:00
|
|
|
cluster.join(a1)
|
2012-05-27 19:21:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
runOn(a1, a2, b1, b2) {
|
2013-03-05 21:05:11 +01:00
|
|
|
awaitMembersUp(numberOfMembers = 4)
|
2012-05-27 19:21:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assertLeader(a1, a2, b1, b2)
|
|
|
|
|
assertLeader(c1, c2)
|
|
|
|
|
|
2012-06-19 17:10:03 +02:00
|
|
|
enterBarrier("four-members")
|
2012-05-27 19:21:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"be able to 'elect' a single leader after joining (C -> A + B)" taggedAs LongRunningTest in {
|
|
|
|
|
|
|
|
|
|
runOn(b2) {
|
2012-06-18 11:54:44 +02:00
|
|
|
cluster.join(c1)
|
2012-05-27 19:21:38 +02:00
|
|
|
}
|
|
|
|
|
|
2013-03-05 21:05:11 +01:00
|
|
|
awaitMembersUp(numberOfMembers = 6)
|
2012-05-27 19:21:38 +02:00
|
|
|
|
|
|
|
|
assertLeader(a1, a2, b1, b2, c1, c2)
|
2012-05-30 19:32:10 +02:00
|
|
|
|
2012-06-19 17:10:03 +02:00
|
|
|
enterBarrier("six-members")
|
2012-05-27 19:21:38 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|