Package akka.remote.testkit
Class MultiNodeSpec
- java.lang.Object
-
- akka.testkit.TestKit
-
- akka.remote.testkit.MultiNodeSpec
-
- All Implemented Interfaces:
MultiNodeSpecCallbacks
,TestKitBase
public abstract class MultiNodeSpec extends TestKit implements MultiNodeSpecCallbacks
Constructor for using arbitrary logic to create the actor system used in the multi node spec (theConfig
passed to the creator must be used in the created actor system for the multi node tests to work)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
MultiNodeSpec.AwaitHelper<T>
-
Constructor Summary
Constructors Constructor Description MultiNodeSpec(RoleName myself, ActorSystem _system, scala.collection.immutable.Seq<RoleName> _roles, scala.Function1<RoleName,scala.collection.Seq<java.lang.String>> deployments)
MultiNodeSpec(MultiNodeConfig config)
MultiNodeSpec(MultiNodeConfig config, scala.Function1<com.typesafe.config.Config,ActorSystem> actorSystemCreator)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
afterTermination()
Override this method to do something when the whole test is terminating.protected void
atStartup()
Override this method to do something when the whole test is starting up.protected void
attachConductor(TestConductorExt tc)
<T> MultiNodeSpec.AwaitHelper<T>
awaitHelper(scala.concurrent.Awaitable<T> w)
Enrich.await()
onto all Awaitables, using remaining duration from the innermost enclosingwithin
block or QueryTimeout.static com.typesafe.config.Config
baseConfig()
void
enterBarrier(scala.collection.Seq<java.lang.String> name)
Enter the named barriers in the order given.abstract int
initialParticipants()
TO BE DEFINED BY USER: Defines the number of participants required for starting the test.protected void
injectDeployments(ActorSystem sys, RoleName role)
boolean
isNode(scala.collection.Seq<RoleName> nodes)
Verify that the running node matches one of the given nodesLoggingAdapter
log()
static int
maxNodes()
void
multiNodeSpecAfterAll()
Call this after the all test cases have run.void
multiNodeSpecBeforeAll()
void
muteDeadLetters(scala.collection.Seq<java.lang.Class<?>> messageClasses, ActorSystem sys)
ActorSystem
muteDeadLetters$default$2(scala.collection.Seq<java.lang.Class<?>> messageClasses)
protected Address
myAddress()
RoleName
myself()
ActorPath
node(RoleName role)
Query the controller for the transport address of the given node (by role name) and return that as an ActorPath for easy composition:static com.typesafe.config.Config
nodeConfig()
scala.collection.immutable.Seq<RoleName>
roles()
All registered rolesvoid
runOn(scala.collection.Seq<RoleName> nodes, scala.Function0<scala.runtime.BoxedUnit> thunk)
Execute the given block of code only on the given nodes (names according to theroleMap
).static java.lang.Integer
selfIndex()
Index of this node in the roles sequence.static java.lang.String
selfName()
Name (or IP address; must be resolvable using InetAddress.getByName) of the host this node is running on.static int
selfPort()
Port number of this node.static java.lang.String
serverName()
Name (or IP address; must be resolvable using InetAddress.getByName) of the host that the server node is running on.static int
serverPort()
Port number of the node that's running the server system.scala.concurrent.duration.FiniteDuration
shutdownTimeout()
protected ActorSystem
startNewSystem()
This method starts a new ActorSystem with the same configuration as the previous one on the current node, including deployments.TestConductorExt
testConductor()
Access to the barriers, failure injection, etc.void
testConductor_$eq(TestConductorExt x$1)
boolean
verifySystemShutdown()
Override this and returntrue
to assert that the shutdown of theActorSystem
was done properly.-
Methods inherited from class akka.testkit.TestKit
akka$testkit$TestKitBase$_setter_$testActor_$eq, akka$testkit$TestKitBase$_setter_$testKitSettings_$eq, awaitCond, awaitCond$default$3, awaitCond$default$4, lastMessage, lastMessage_$eq, now, shutdownActorSystem, shutdownActorSystem$default$2, shutdownActorSystem$default$3, system, testActor, testActorId, testKitSettings
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface akka.testkit.TestKitBase
awaitAssert, awaitAssert$default$2, awaitAssert$default$3, awaitCond, awaitCond$default$2, awaitCond$default$3, awaitCond$default$4, checkMissingAndUnexpected, childActorOf, childActorOf, childActorOf, childActorOf, end_$eq, expectMsg, expectMsg, expectMsg, expectMsg_internal, expectMsg_internal$default$3, expectMsgAllClassOf, expectMsgAllClassOf, expectMsgAllConformingOf, expectMsgAllConformingOf, expectMsgAllOf, expectMsgAllOf, expectMsgAllOf_internal, expectMsgAnyClassOf, expectMsgAnyClassOf, expectMsgAnyClassOf_internal, expectMsgAnyOf, expectMsgAnyOf, expectMsgAnyOf_internal, expectMsgClass, expectMsgClass, expectMsgClass_internal, expectMsgPF, expectMsgPF$default$1, expectMsgPF$default$2, expectMsgType, expectMsgType, expectNoMessage, expectNoMessage, expectNoMsg, expectNoMsg, expectNoMsg_internal, expectTerminated, expectTerminated$default$2, fishForMessage, fishForMessage$default$1, fishForMessage$default$2, fishForSpecificMessage, fishForSpecificMessage$default$1, fishForSpecificMessage$default$2, format, ignoreMsg, ignoreNoMsg, internalExpectMsgAllClassOf, internalExpectMsgAllConformingOf, lastSender, lastWasNoMsg_$eq, msgAvailable, now, receiveN, receiveN, receiveN_internal, receiveOne, receiveWhile, receiveWhile$default$1, receiveWhile$default$2, receiveWhile$default$3, remaining, remainingOr, remainingOrDefault, remainingOrDilated, setAutoPilot, shutdown, shutdown$default$1, shutdown$default$2, shutdown$default$3, testActorName, unwatch, watch, within, within
-
-
-
-
Constructor Detail
-
MultiNodeSpec
public MultiNodeSpec(RoleName myself, ActorSystem _system, scala.collection.immutable.Seq<RoleName> _roles, scala.Function1<RoleName,scala.collection.Seq<java.lang.String>> deployments)
-
MultiNodeSpec
public MultiNodeSpec(MultiNodeConfig config, scala.Function1<com.typesafe.config.Config,ActorSystem> actorSystemCreator)
-
MultiNodeSpec
public MultiNodeSpec(MultiNodeConfig config)
-
-
Method Detail
-
maxNodes
public static int maxNodes()
-
selfName
public static java.lang.String selfName()
Name (or IP address; must be resolvable using InetAddress.getByName) of the host this node is running on.-Dmultinode.host=host.example.com
InetAddress.getLocalHost.getHostAddress is used if empty or "localhost" is defined as system property "multinode.host".
- Returns:
- (undocumented)
-
selfPort
public static int selfPort()
Port number of this node. Defaults to 0 which means a random port.-Dmultinode.port=0
- Returns:
- (undocumented)
-
serverName
public static java.lang.String serverName()
Name (or IP address; must be resolvable using InetAddress.getByName) of the host that the server node is running on.-Dmultinode.server-host=server.example.com
- Returns:
- (undocumented)
-
serverPort
public static int serverPort()
Port number of the node that's running the server system. Defaults to 4711.-Dmultinode.server-port=4711
- Returns:
- (undocumented)
-
selfIndex
public static java.lang.Integer selfIndex()
Index of this node in the roles sequence. The TestConductor is started in “controller” mode on selfIndex 0, i.e. there you can inject failures and shutdown other nodes etc.-Dmultinode.index=0
- Returns:
- (undocumented)
-
nodeConfig
public static com.typesafe.config.Config nodeConfig()
-
baseConfig
public static com.typesafe.config.Config baseConfig()
-
myself
public RoleName myself()
-
log
public LoggingAdapter log()
-
awaitHelper
public <T> MultiNodeSpec.AwaitHelper<T> awaitHelper(scala.concurrent.Awaitable<T> w)
Enrich.await()
onto all Awaitables, using remaining duration from the innermost enclosingwithin
block or QueryTimeout.- Parameters:
w
- (undocumented)- Returns:
- (undocumented)
-
multiNodeSpecBeforeAll
public final void multiNodeSpecBeforeAll()
- Specified by:
multiNodeSpecBeforeAll
in interfaceMultiNodeSpecCallbacks
-
multiNodeSpecAfterAll
public final void multiNodeSpecAfterAll()
Description copied from interface:MultiNodeSpecCallbacks
Call this after the all test cases have run. NOT after every test case.- Specified by:
multiNodeSpecAfterAll
in interfaceMultiNodeSpecCallbacks
-
shutdownTimeout
public scala.concurrent.duration.FiniteDuration shutdownTimeout()
-
verifySystemShutdown
public boolean verifySystemShutdown()
Override this and returntrue
to assert that the shutdown of theActorSystem
was done properly.- Returns:
- (undocumented)
-
atStartup
protected void atStartup()
Override this method to do something when the whole test is starting up.
-
afterTermination
protected void afterTermination()
Override this method to do something when the whole test is terminating.
-
roles
public scala.collection.immutable.Seq<RoleName> roles()
All registered roles- Returns:
- (undocumented)
-
initialParticipants
public abstract int initialParticipants()
TO BE DEFINED BY USER: Defines the number of participants required for starting the test. This might not be equals to the number of nodes available to the test.Must be a
def
:def initialParticipants = 5
- Returns:
- (undocumented)
-
testConductor
public TestConductorExt testConductor()
Access to the barriers, failure injection, etc. The extension will have been started either in Conductor or Player mode when the constructor of MultiNodeSpec finishes, i.e. do not call the start*() methods yourself!- Returns:
- (undocumented)
-
testConductor_$eq
public void testConductor_$eq(TestConductorExt x$1)
-
runOn
public void runOn(scala.collection.Seq<RoleName> nodes, scala.Function0<scala.runtime.BoxedUnit> thunk)
Execute the given block of code only on the given nodes (names according to theroleMap
).- Parameters:
nodes
- (undocumented)thunk
- (undocumented)
-
isNode
public boolean isNode(scala.collection.Seq<RoleName> nodes)
Verify that the running node matches one of the given nodes- Parameters:
nodes
- (undocumented)- Returns:
- (undocumented)
-
enterBarrier
public void enterBarrier(scala.collection.Seq<java.lang.String> name)
Enter the named barriers in the order given. Use the remaining duration from the innermost enclosingwithin
block or the defaultBarrierTimeout
- Parameters:
name
- (undocumented)
-
node
public ActorPath node(RoleName role)
Query the controller for the transport address of the given node (by role name) and return that as an ActorPath for easy composition:val serviceA = system.actorSelection(node("master") / "user" / "serviceA")
- Parameters:
role
- (undocumented)- Returns:
- (undocumented)
-
muteDeadLetters
public void muteDeadLetters(scala.collection.Seq<java.lang.Class<?>> messageClasses, ActorSystem sys)
-
muteDeadLetters$default$2
public ActorSystem muteDeadLetters$default$2(scala.collection.Seq<java.lang.Class<?>> messageClasses)
-
attachConductor
protected void attachConductor(TestConductorExt tc)
-
injectDeployments
protected void injectDeployments(ActorSystem sys, RoleName role)
-
myAddress
protected Address myAddress()
-
startNewSystem
protected ActorSystem startNewSystem()
This method starts a new ActorSystem with the same configuration as the previous one on the current node, including deployments. It also creates a new TestConductor client and registers itself with the conductor so that it is possible to use barriers etc. normally after this method has been called.NOTICE: you MUST start a new system before trying to enter a barrier or otherwise using the TestConductor after having terminated this node’s system.
- Returns:
- (undocumented)
-
-