Package org.apache.pekko.remote.testkit
Class MultiNodeSpec
java.lang.Object
org.apache.pekko.testkit.TestKit
org.apache.pekko.remote.testkit.MultiNodeSpec
- All Implemented Interfaces:
MultiNodeSpecCallbacks,TestKitBase
Note: To be able to run tests with everything ignored or excluded by tags
you must not use
testconductor, or helper methods that use testconductor,
from the constructor of your test class. Otherwise the controller node might
be shutdown before other nodes have completed and you will see errors like:
AskTimeoutException: sending to terminated ref breaks promises. Using lazy
val is fine.-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionMultiNodeSpec(RoleName myself, ActorSystem _system, scala.collection.immutable.Seq<RoleName> _roles, scala.Function1<RoleName, scala.collection.immutable.Seq<String>> deployments) MultiNodeSpec(MultiNodeConfig config) MultiNodeSpec(MultiNodeConfig config, scala.Function1<com.typesafe.config.Config, ActorSystem> actorSystemCreator) Constructor for using arbitrary logic to create the actor system used in the multi node spec (theConfigpassed to the creator must be used in the created actor system for the multi node tests to work) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidOverride this method to do something when the whole test is terminating.protected voidOverride this method to do something when the whole test is starting up.protected void<T> MultiNodeSpec.AwaitHelper<T>awaitHelper(scala.concurrent.Awaitable<T> w) Enrich.await()onto all Awaitables, using remaining duration from the innermost enclosingwithinblock or QueryTimeout.static com.typesafe.config.ConfigconfigureNextPortIfFixed(com.typesafe.config.Config config) voidenterBarrier(scala.collection.immutable.Seq<String> name) Enter the named barriers in the order given.voidenterBarrier(scala.concurrent.duration.FiniteDuration max, scala.collection.immutable.Seq<String> name) Enter the named barriers in the order given.abstract intTO BE DEFINED BY USER: Defines the number of participants required for starting the test.protected voidinjectDeployments(ActorSystem sys, RoleName role) booleanVerify that the running node matches one of the given nodeslog()static intmaxNodes()Number of nodes node taking part in this test.final voidCall this after the all test cases have run.final voidCall this before the start of the test run.voidmuteDeadLetters(scala.collection.immutable.Seq<Class<?>> messageClasses, ActorSystem sys) muteDeadLetters$default$2(scala.collection.immutable.Seq<Class<?>> messageClasses) protected Addressmyself()Query the controller for the transport address of the given node (by role name) and return that as an ActorPath for easy composition:scala.collection.immutable.Seq<RoleName>roles()All registered rolesvoidrunOn(scala.collection.immutable.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 IntegerIndex of this node in the roles sequence.static StringselfName()Name (or IP address; must be resolvable using InetAddress.getByName) of the host this node is running on.static intselfPort()Port number of this node.static StringName (or IP address; must be resolvable using InetAddress.getByName) of the host that the server node is running on.static intPort number of the node that's running the server system.scala.concurrent.duration.FiniteDurationprotected ActorSystemThis method starts a new ActorSystem with the same configuration as the previous one on the current node, including deployments.static inttcpPort()TCP Port number to be used when running tests on TCP.Access to the barriers, failure injection, etc.voidstatic scala.Option<Object>udpPort()UDP Port number to be used when running tests on UDP.booleanOverride this and returntrueto assert that the shutdown of theActorSystemwas done properly.Methods inherited from class org.apache.pekko.testkit.TestKit
awaitCond, awaitCond$default$3, awaitCond$default$4, now, shutdownActorSystem, shutdownActorSystem$default$2, shutdownActorSystem$default$3, system, testActorMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.pekko.testkit.TestKitBase
assertForDuration, assertForDuration$default$3, 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_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, testKitSettings, unwatch, watch, within, within
-
Constructor Details
-
MultiNodeSpec
public MultiNodeSpec(RoleName myself, ActorSystem _system, scala.collection.immutable.Seq<RoleName> _roles, scala.Function1<RoleName, scala.collection.immutable.Seq<String>> deployments) -
MultiNodeSpec
public MultiNodeSpec(MultiNodeConfig config, scala.Function1<com.typesafe.config.Config, ActorSystem> actorSystemCreator) Constructor for using arbitrary logic to create the actor system used in the multi node spec (theConfigpassed to the creator must be used in the created actor system for the multi node tests to work) -
MultiNodeSpec
-
-
Method Details
-
maxNodes
public static int maxNodes()Number of nodes node taking part in this test.-Dmultinode.max-nodes=4 -
selfName
Name (or IP address; must be resolvable using InetAddress.getByName) of the host this node is running on.-Dmultinode.host=host.example.comInetAddress.getLocalHost.getHostAddress is used if empty or "localhost" is defined as system property "multinode.host".
-
tcpPort
public static int tcpPort()TCP Port number to be used when running tests on TCP. 0 means a random port.-Dmultinode.port=0 -
udpPort
UDP Port number to be used when running tests on UDP. 0 means a random port.-Dmultinode.udp.port=0 -
selfPort
public static int selfPort()Port number of this node.This is defined in function of property
multinode.protocol. If set to 'udp', udpPort will be used. If unset or any other value, it will default to tcpPort. -
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 -
serverPort
public static int serverPort()Port number of the node that's running the server system. Defaults to 4711.-Dmultinode.server-port=4711 -
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 -
configureNextPortIfFixed
public static com.typesafe.config.Config configureNextPortIfFixed(com.typesafe.config.Config config) -
myself
-
log
-
awaitHelper
Enrich.await()onto all Awaitables, using remaining duration from the innermost enclosingwithinblock or QueryTimeout. -
multiNodeSpecBeforeAll
public final void multiNodeSpecBeforeAll()Description copied from interface:MultiNodeSpecCallbacksCall this before the start of the test run. NOT before every test case.- Specified by:
multiNodeSpecBeforeAllin interfaceMultiNodeSpecCallbacks
-
multiNodeSpecAfterAll
public final void multiNodeSpecAfterAll()Description copied from interface:MultiNodeSpecCallbacksCall this after the all test cases have run. NOT after every test case.- Specified by:
multiNodeSpecAfterAllin interfaceMultiNodeSpecCallbacks
-
shutdownTimeout
public scala.concurrent.duration.FiniteDuration shutdownTimeout() -
verifySystemShutdown
public boolean verifySystemShutdown()Override this and returntrueto assert that the shutdown of theActorSystemwas done properly. -
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
All registered roles -
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 -
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! -
testConductor_$eq
-
runOn
public void runOn(scala.collection.immutable.Seq<RoleName> nodes, scala.Function0<scala.runtime.BoxedUnit> thunk) Execute the given block of code only on the given nodes (names according to theroleMap). -
isNode
Verify that the running node matches one of the given nodes -
enterBarrier
Enter the named barriers in the order given. Use the remaining duration from the innermost enclosingwithinblock or the defaultBarrierTimeout. -
enterBarrier
public void enterBarrier(scala.concurrent.duration.FiniteDuration max, scala.collection.immutable.Seq<String> name) Enter the named barriers in the order given. Use the remaining duration from the innermost enclosingwithinblock or the passedmaxtimeout.Note that the
maxtimeout is scaled using Duration.dilated, which uses the configuration entry "pekko.test.timefactor". -
node
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") -
muteDeadLetters
public void muteDeadLetters(scala.collection.immutable.Seq<Class<?>> messageClasses, ActorSystem sys) -
muteDeadLetters$default$2
public ActorSystem muteDeadLetters$default$2(scala.collection.immutable.Seq<Class<?>> messageClasses) -
attachConductor
-
injectDeployments
-
myAddress
-
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.
-