Rename mySelf in MultiNodeSpec to myself
This commit is contained in:
parent
bffb14b022
commit
24212f14bc
4 changed files with 15 additions and 84 deletions
|
|
@ -49,10 +49,10 @@ abstract class LeaderElectionSpec extends MultiNodeSpec(LeaderElectionMultiJvmSp
|
|||
}
|
||||
testConductor.enter("first-started")
|
||||
|
||||
if (mySelf != controller) {
|
||||
if (myself != controller) {
|
||||
cluster.join(firstAddress)
|
||||
awaitUpConvergence(numberOfMembers = roles.size)
|
||||
cluster.isLeader must be(mySelf == roles.head)
|
||||
cluster.isLeader must be(myself == roles.head)
|
||||
}
|
||||
testConductor.enter("after")
|
||||
}
|
||||
|
|
@ -63,7 +63,7 @@ abstract class LeaderElectionSpec extends MultiNodeSpec(LeaderElectionMultiJvmSp
|
|||
val leader = currentRoles.head
|
||||
val aUser = currentRoles.last
|
||||
|
||||
mySelf match {
|
||||
myself match {
|
||||
|
||||
case `controller` ⇒
|
||||
testConductor.enter("before-shutdown")
|
||||
|
|
@ -82,13 +82,13 @@ abstract class LeaderElectionSpec extends MultiNodeSpec(LeaderElectionMultiJvmSp
|
|||
cluster.down(leaderAddress)
|
||||
testConductor.enter("after-down", "completed")
|
||||
|
||||
case _ if currentRoles.tail.contains(mySelf) ⇒
|
||||
case _ if currentRoles.tail.contains(myself) ⇒
|
||||
// remaining cluster nodes, not shutdown
|
||||
testConductor.enter("before-shutdown", "after-shutdown", "after-down")
|
||||
|
||||
awaitUpConvergence(currentRoles.size - 1)
|
||||
val nextExpectedLeader = currentRoles.tail.head
|
||||
cluster.isLeader must be(mySelf == nextExpectedLeader)
|
||||
cluster.isLeader must be(myself == nextExpectedLeader)
|
||||
|
||||
testConductor.enter("completed")
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ trait MultiNodeClusterSpec { self: MultiNodeSpec ⇒
|
|||
* out of all nodes in the cluster. First
|
||||
* member in the cluster ring is expected leader.
|
||||
*/
|
||||
def assertLeader(nodesInCluster: RoleName*): Unit = if (nodesInCluster.contains(mySelf)) {
|
||||
def assertLeader(nodesInCluster: RoleName*): Unit = if (nodesInCluster.contains(myself)) {
|
||||
nodesInCluster.length must not be (0)
|
||||
val expectedLeader = roleOfLeader(nodesInCluster)
|
||||
cluster.isLeader must be(ifNode(expectedLeader)(true)(false))
|
||||
|
|
|
|||
|
|
@ -1,69 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2009-2012 Typesafe Inc. <http://www.typesafe.com>
|
||||
*/
|
||||
package akka.cluster
|
||||
|
||||
import akka.actor.ActorSystem
|
||||
import akka.util._
|
||||
import akka.util.duration._
|
||||
|
||||
import akka.testkit.AkkaSpec
|
||||
import akka.testkit.TestEvent._
|
||||
import akka.testkit.EventFilter
|
||||
|
||||
import com.typesafe.config.{ Config, ConfigFactory }
|
||||
|
||||
object ClusterSpec {
|
||||
val testConf: Config = ConfigFactory.parseString("""
|
||||
akka {
|
||||
event-handlers = ["akka.testkit.TestEventListener"]
|
||||
loglevel = "WARNING"
|
||||
stdout-loglevel = "WARNING"
|
||||
actor {
|
||||
default-dispatcher {
|
||||
executor = "fork-join-executor"
|
||||
fork-join-executor {
|
||||
parallelism-min = 8
|
||||
parallelism-factor = 2.0
|
||||
parallelism-max = 8
|
||||
}
|
||||
}
|
||||
}
|
||||
remote.netty.hostname = localhost
|
||||
cluster {
|
||||
failure-detector.threshold = 3
|
||||
auto-down = on
|
||||
}
|
||||
}
|
||||
""")
|
||||
}
|
||||
|
||||
abstract class ClusterSpec(_system: ActorSystem) extends AkkaSpec(_system) {
|
||||
case class PortPrefix(port: Int) {
|
||||
def withPortPrefix: Int = (portPrefix.toString + port.toString).toInt
|
||||
}
|
||||
|
||||
implicit def intToPortPrefix(port: Int) = PortPrefix(port)
|
||||
|
||||
def portPrefix: Int
|
||||
|
||||
def this(config: Config) = this(ActorSystem(AkkaSpec.getCallerName, config.withFallback(ClusterSpec.testConf)))
|
||||
|
||||
def this(s: String) = this(ConfigFactory.parseString(s))
|
||||
|
||||
def this() = this(ActorSystem(AkkaSpec.getCallerName, ClusterSpec.testConf))
|
||||
|
||||
def awaitConvergence(nodes: Iterable[Cluster], maxWaitTime: Duration = 60 seconds) {
|
||||
val deadline = maxWaitTime.fromNow
|
||||
while (nodes map (_.convergence.isDefined) exists (_ == false)) {
|
||||
if (deadline.isOverdue) throw new IllegalStateException("Convergence could no be reached within " + maxWaitTime)
|
||||
Thread.sleep(1000)
|
||||
}
|
||||
nodes foreach { n ⇒ println("Converged: " + n.self + " == " + n.convergence.isDefined) }
|
||||
}
|
||||
|
||||
override def atStartup {
|
||||
system.eventStream.publish(Mute(EventFilter[java.net.ConnectException]()))
|
||||
system.eventStream.publish(Mute(EventFilter[java.nio.channels.ClosedChannelException]()))
|
||||
}
|
||||
}
|
||||
|
|
@ -77,13 +77,13 @@ abstract class MultiNodeConfig {
|
|||
|
||||
def deployOnAll(deployment: String): Unit = _allDeploy :+= deployment
|
||||
|
||||
private[testkit] lazy val mySelf: RoleName = {
|
||||
private[testkit] lazy val myself: RoleName = {
|
||||
require(_roles.size > MultiNodeSpec.selfIndex, "not enough roles declared for this test")
|
||||
_roles(MultiNodeSpec.selfIndex)
|
||||
}
|
||||
|
||||
private[testkit] def config: Config = {
|
||||
val configs = (_nodeConf get mySelf).toList ::: _commonConf.toList ::: MultiNodeSpec.nodeConfig :: AkkaSpec.testConf :: Nil
|
||||
val configs = (_nodeConf get myself).toList ::: _commonConf.toList ::: MultiNodeSpec.nodeConfig :: AkkaSpec.testConf :: Nil
|
||||
configs reduce (_ withFallback _)
|
||||
}
|
||||
|
||||
|
|
@ -128,13 +128,13 @@ object MultiNodeSpec {
|
|||
|
||||
}
|
||||
|
||||
abstract class MultiNodeSpec(val mySelf: RoleName, _system: ActorSystem, roles: Seq[RoleName], deployments: RoleName ⇒ Seq[String])
|
||||
abstract class MultiNodeSpec(val myself: RoleName, _system: ActorSystem, roles: Seq[RoleName], deployments: RoleName ⇒ Seq[String])
|
||||
extends AkkaSpec(_system) {
|
||||
|
||||
import MultiNodeSpec._
|
||||
|
||||
def this(config: MultiNodeConfig) =
|
||||
this(config.mySelf, ActorSystem(AkkaSpec.getCallerName, config.config), config.roles, config.deployments)
|
||||
this(config.myself, ActorSystem(AkkaSpec.getCallerName, config.config), config.roles, config.deployments)
|
||||
|
||||
/*
|
||||
* Test Class Interface
|
||||
|
|
@ -165,13 +165,13 @@ abstract class MultiNodeSpec(val mySelf: RoleName, _system: ActorSystem, roles:
|
|||
* to the `roleMap`).
|
||||
*/
|
||||
def runOn(nodes: RoleName*)(thunk: ⇒ Unit): Unit = {
|
||||
if (nodes exists (_ == mySelf)) {
|
||||
if (nodes exists (_ == myself)) {
|
||||
thunk
|
||||
}
|
||||
}
|
||||
|
||||
def ifNode[T](nodes: RoleName*)(yes: ⇒ T)(no: ⇒ T): T = {
|
||||
if (nodes exists (_ == mySelf)) yes else no
|
||||
if (nodes exists (_ == myself)) yes else no
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -198,9 +198,9 @@ abstract class MultiNodeSpec(val mySelf: RoleName, _system: ActorSystem, roles:
|
|||
|
||||
private val controllerAddr = new InetSocketAddress(nodeNames(0), 4711)
|
||||
if (selfIndex == 0) {
|
||||
testConductor.startController(initialParticipants, mySelf, controllerAddr).await
|
||||
testConductor.startController(initialParticipants, myself, controllerAddr).await
|
||||
} else {
|
||||
testConductor.startClient(mySelf, controllerAddr).await
|
||||
testConductor.startClient(myself, controllerAddr).await
|
||||
}
|
||||
|
||||
// now add deployments, if so desired
|
||||
|
|
@ -210,7 +210,7 @@ abstract class MultiNodeSpec(val mySelf: RoleName, _system: ActorSystem, roles:
|
|||
}
|
||||
private val replacements = roles map (r ⇒ Replacement("@" + r.name + "@", r))
|
||||
private val deployer = system.asInstanceOf[ExtendedActorSystem].provider.deployer
|
||||
deployments(mySelf) foreach { str ⇒
|
||||
deployments(myself) foreach { str ⇒
|
||||
val deployString = (str /: replacements) {
|
||||
case (base, r @ Replacement(tag, _)) ⇒
|
||||
base.indexOf(tag) match {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue