public abstract class MultiNodeSpec extends TestKit implements MultiNodeSpecCallbacks
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.Modifier and Type | Class and Description |
---|---|
class |
MultiNodeSpec.AwaitHelper<T> |
Constructor and Description |
---|
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 (the
Config passed to the creator must be used in
the created actor system for the multi node tests to work) |
MultiNodeSpec(RoleName myself,
ActorSystem _system,
scala.collection.immutable.Seq<RoleName> _roles,
scala.Function1<RoleName,scala.collection.Seq<java.lang.String>> deployments) |
Modifier and Type | Method and Description |
---|---|
protected void |
afterTermination()
Override this method to do something when the whole test is terminating.
|
protected static void |
akka$testkit$TestKitBase$_setter_$akka$testkit$TestKitBase$$queue_$eq(java.util.concurrent.LinkedBlockingDeque<TestActor.Message> x$1) |
protected static void |
akka$testkit$TestKitBase$_setter_$testActor_$eq(ActorRef x$1) |
protected static void |
akka$testkit$TestKitBase$_setter_$testKitSettings_$eq(TestKitSettings x$1) |
static void |
akka$testkit$TestKitBase$$end_$eq(scala.concurrent.duration.Duration x$1) |
static scala.concurrent.duration.Duration |
akka$testkit$TestKitBase$$end() |
static void |
akka$testkit$TestKitBase$$lastWasNoMsg_$eq(boolean x$1) |
static boolean |
akka$testkit$TestKitBase$$lastWasNoMsg() |
static java.util.concurrent.LinkedBlockingDeque<TestActor.Message> |
akka$testkit$TestKitBase$$queue() |
protected void |
atStartup()
Override this method to do something when the whole test is starting up.
|
protected void |
attachConductor(TestConductorExt tc) |
static void |
awaitAssert(scala.Function0<java.lang.Object> a,
scala.concurrent.duration.Duration max,
scala.concurrent.duration.Duration interval) |
static scala.concurrent.duration.Duration |
awaitAssert$default$2() |
static scala.concurrent.duration.Duration |
awaitAssert$default$3() |
static void |
awaitCond(scala.Function0<java.lang.Object> p,
scala.concurrent.duration.Duration max,
scala.concurrent.duration.Duration interval,
java.lang.String message) |
static scala.concurrent.duration.Duration |
awaitCond$default$2() |
static scala.concurrent.duration.Duration |
awaitCond$default$3() |
static java.lang.String |
awaitCond$default$4() |
<T> MultiNodeSpec.AwaitHelper<T> |
awaitHelper(scala.concurrent.Awaitable<T> w)
Enrich
.await() onto all Awaitables, using remaining duration from the innermost
enclosing within block or QueryTimeout. |
static com.typesafe.config.Config |
baseConfig() |
static ActorRef |
childActorOf(Props props) |
static ActorRef |
childActorOf(Props props,
java.lang.String name) |
static ActorRef |
childActorOf(Props props,
java.lang.String name,
SupervisorStrategy supervisorStrategy) |
static ActorRef |
childActorOf(Props props,
SupervisorStrategy supervisorStrategy) |
void |
enterBarrier(scala.collection.Seq<java.lang.String> name)
Enter the named barriers in the order given.
|
static <T> T |
expectMsg(scala.concurrent.duration.FiniteDuration max,
java.lang.String hint,
T obj) |
static <T> T |
expectMsg(scala.concurrent.duration.FiniteDuration max,
T obj) |
static <T> T |
expectMsg(T obj) |
static <T> scala.collection.immutable.Seq<T> |
expectMsgAllClassOf(scala.concurrent.duration.FiniteDuration max,
scala.collection.Seq<java.lang.Class<? extends T>> obj) |
static <T> scala.collection.immutable.Seq<T> |
expectMsgAllClassOf(scala.collection.Seq<java.lang.Class<? extends T>> obj) |
static <T> scala.collection.immutable.Seq<T> |
expectMsgAllConformingOf(scala.concurrent.duration.FiniteDuration max,
scala.collection.Seq<java.lang.Class<? extends T>> obj) |
static <T> scala.collection.immutable.Seq<T> |
expectMsgAllConformingOf(scala.collection.Seq<java.lang.Class<? extends T>> obj) |
static <T> scala.collection.immutable.Seq<T> |
expectMsgAllOf(scala.concurrent.duration.FiniteDuration max,
scala.collection.Seq<T> obj) |
static <T> scala.collection.immutable.Seq<T> |
expectMsgAllOf(scala.collection.Seq<T> obj) |
static <C> C |
expectMsgAnyClassOf(scala.concurrent.duration.FiniteDuration max,
scala.collection.Seq<java.lang.Class<? extends C>> obj) |
static <C> C |
expectMsgAnyClassOf(scala.collection.Seq<java.lang.Class<? extends C>> obj) |
static <T> T |
expectMsgAnyOf(scala.concurrent.duration.FiniteDuration max,
scala.collection.Seq<T> obj) |
static <T> T |
expectMsgAnyOf(scala.collection.Seq<T> obj) |
static <C> C |
expectMsgClass(java.lang.Class<C> c) |
static <C> C |
expectMsgClass(scala.concurrent.duration.FiniteDuration max,
java.lang.Class<C> c) |
static <T> T |
expectMsgPF(scala.concurrent.duration.Duration max,
java.lang.String hint,
scala.PartialFunction<java.lang.Object,T> f) |
static <T> scala.concurrent.duration.Duration |
expectMsgPF$default$1() |
static <T> java.lang.String |
expectMsgPF$default$2() |
static <T> T |
expectMsgType(scala.reflect.ClassTag<T> t) |
static <T> T |
expectMsgType(scala.concurrent.duration.FiniteDuration max,
scala.reflect.ClassTag<T> t) |
static void |
expectNoMsg() |
static void |
expectNoMsg(scala.concurrent.duration.FiniteDuration max) |
static Terminated |
expectTerminated(ActorRef target,
scala.concurrent.duration.Duration max) |
static scala.concurrent.duration.Duration |
expectTerminated$default$2() |
static java.lang.Object |
fishForMessage(scala.concurrent.duration.Duration max,
java.lang.String hint,
scala.PartialFunction<java.lang.Object,java.lang.Object> f) |
static scala.concurrent.duration.Duration |
fishForMessage$default$1() |
static java.lang.String |
fishForMessage$default$2() |
static void |
ignoreMsg(scala.PartialFunction<java.lang.Object,java.lang.Object> f) |
static void |
ignoreNoMsg() |
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 nodes
|
static void |
lastMessage_$eq(TestActor.Message x$1) |
static TestActor.Message |
lastMessage() |
static ActorRef |
lastSender() |
LoggingAdapter |
log() |
static int |
maxNodes()
Number of nodes node taking part in this test.
|
static boolean |
msgAvailable() |
void |
multiNodeSpecAfterAll()
Call this after the all test cases have run.
|
void |
multiNodeSpecBeforeAll()
Call this before the start of the test run.
|
void |
muteDeadLetters(scala.collection.Seq<java.lang.Class<?>> messageClasses,
ActorSystem sys) |
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() |
static scala.concurrent.duration.FiniteDuration |
now() |
static scala.collection.immutable.Seq<java.lang.Object> |
receiveN(int n) |
static scala.collection.immutable.Seq<java.lang.Object> |
receiveN(int n,
scala.concurrent.duration.FiniteDuration max) |
static java.lang.Object |
receiveOne(scala.concurrent.duration.Duration max) |
static <T> scala.collection.immutable.Seq<T> |
receiveWhile(scala.concurrent.duration.Duration max,
scala.concurrent.duration.Duration idle,
int messages,
scala.PartialFunction<java.lang.Object,T> f) |
static <T> scala.concurrent.duration.Duration |
receiveWhile$default$1() |
static <T> scala.concurrent.duration.Duration |
receiveWhile$default$2() |
static <T> int |
receiveWhile$default$3() |
static scala.concurrent.duration.FiniteDuration |
remaining() |
static scala.concurrent.duration.FiniteDuration |
remainingOr(scala.concurrent.duration.FiniteDuration duration) |
static scala.concurrent.duration.FiniteDuration |
remainingOrDefault() |
scala.collection.immutable.Seq<RoleName> |
roles()
All registered roles
|
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 the
roleMap ). |
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.
|
static void |
setAutoPilot(TestActor.AutoPilot pilot) |
static void |
shutdown(ActorSystem actorSystem,
scala.concurrent.duration.Duration duration,
boolean verifySystemShutdown) |
static ActorSystem |
shutdown$default$1() |
static scala.concurrent.duration.Duration |
shutdown$default$2() |
static boolean |
shutdown$default$3() |
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.
|
static ActorSystem |
system() |
static ActorRef |
testActor() |
protected static java.lang.String |
testActorName() |
TestConductorExt |
testConductor()
Access to the barriers, failure injection, etc.
|
static TestKitSettings |
testKitSettings() |
static ActorRef |
unwatch(ActorRef ref) |
boolean |
verifySystemShutdown()
Override this and return
true to assert that the
shutdown of the ActorSystem was done properly. |
static ActorRef |
watch(ActorRef ref) |
static <T> T |
within(scala.concurrent.duration.FiniteDuration min,
scala.concurrent.duration.FiniteDuration max,
scala.Function0<T> f) |
static <T> T |
within(scala.concurrent.duration.FiniteDuration max,
scala.Function0<T> f) |
awaitCond, lastMessage, shutdownActorSystem, system, testActor, testActorId, testKitSettings
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
awaitAssert, awaitCond, checkMissingAndUnexpected, childActorOf, childActorOf, childActorOf, childActorOf, expectMsg_internal, expectMsg, expectMsg, expectMsg, expectMsgAllClassOf, expectMsgAllClassOf, expectMsgAllConformingOf, expectMsgAllConformingOf, expectMsgAllOf_internal, expectMsgAllOf, expectMsgAllOf, expectMsgAnyClassOf_internal, expectMsgAnyClassOf, expectMsgAnyClassOf, expectMsgAnyOf_internal, expectMsgAnyOf, expectMsgAnyOf, expectMsgClass_internal, expectMsgClass, expectMsgClass, expectMsgPF, expectMsgType, expectMsgType, expectNoMsg_internal, expectNoMsg, expectNoMsg, expectTerminated, fishForMessage, format, ignoreMsg, ignoreNoMsg, internalExpectMsgAllClassOf, internalExpectMsgAllConformingOf, lastSender, msgAvailable, now, receiveN_internal, receiveN, receiveN, receiveOne, receiveWhile, remaining, remainingOr, remainingOrDefault, remainingOrDilated, setAutoPilot, shutdown, testActorName, unwatch, watch, within, within
public MultiNodeSpec(RoleName myself, ActorSystem _system, scala.collection.immutable.Seq<RoleName> _roles, scala.Function1<RoleName,scala.collection.Seq<java.lang.String>> deployments)
public MultiNodeSpec(MultiNodeConfig config, scala.Function1<com.typesafe.config.Config,ActorSystem> actorSystemCreator)
Config
passed to the creator must be used in
the created actor system for the multi node tests to work)config
- (undocumented)actorSystemCreator
- (undocumented)public MultiNodeSpec(MultiNodeConfig config)
public static int maxNodes()
-Dmultinode.max-nodes=4
public static java.lang.String selfName()
-Dmultinode.host=host.example.com
InetAddress.getLocalHost.getHostAddress is used if empty or "localhost" is defined as system property "multinode.host".
public static int selfPort()
-Dmultinode.port=0
public static java.lang.String serverName()
-Dmultinode.server-host=server.example.com
public static int serverPort()
-Dmultinode.server-port=4711
public static java.lang.Integer selfIndex()
-Dmultinode.index=0
public static com.typesafe.config.Config nodeConfig()
public static com.typesafe.config.Config baseConfig()
public static ActorRef lastSender()
protected static java.lang.String testActorName()
public static void ignoreMsg(scala.PartialFunction<java.lang.Object,java.lang.Object> f)
public static void ignoreNoMsg()
public static void setAutoPilot(TestActor.AutoPilot pilot)
public static scala.concurrent.duration.FiniteDuration now()
public static scala.concurrent.duration.FiniteDuration remainingOrDefault()
public static scala.concurrent.duration.FiniteDuration remaining()
public static scala.concurrent.duration.FiniteDuration remainingOr(scala.concurrent.duration.FiniteDuration duration)
public static boolean msgAvailable()
public static void awaitCond(scala.Function0<java.lang.Object> p, scala.concurrent.duration.Duration max, scala.concurrent.duration.Duration interval, java.lang.String message)
public static void awaitAssert(scala.Function0<java.lang.Object> a, scala.concurrent.duration.Duration max, scala.concurrent.duration.Duration interval)
public static <T> T within(scala.concurrent.duration.FiniteDuration min, scala.concurrent.duration.FiniteDuration max, scala.Function0<T> f)
public static <T> T within(scala.concurrent.duration.FiniteDuration max, scala.Function0<T> f)
public static <T> T expectMsg(T obj)
public static <T> T expectMsg(scala.concurrent.duration.FiniteDuration max, T obj)
public static <T> T expectMsg(scala.concurrent.duration.FiniteDuration max, java.lang.String hint, T obj)
public static <T> T expectMsgPF(scala.concurrent.duration.Duration max, java.lang.String hint, scala.PartialFunction<java.lang.Object,T> f)
public static Terminated expectTerminated(ActorRef target, scala.concurrent.duration.Duration max)
public static java.lang.Object fishForMessage(scala.concurrent.duration.Duration max, java.lang.String hint, scala.PartialFunction<java.lang.Object,java.lang.Object> f)
public static <T> T expectMsgType(scala.reflect.ClassTag<T> t)
public static <T> T expectMsgType(scala.concurrent.duration.FiniteDuration max, scala.reflect.ClassTag<T> t)
public static <C> C expectMsgClass(java.lang.Class<C> c)
public static <C> C expectMsgClass(scala.concurrent.duration.FiniteDuration max, java.lang.Class<C> c)
public static <T> T expectMsgAnyOf(scala.collection.Seq<T> obj)
public static <T> T expectMsgAnyOf(scala.concurrent.duration.FiniteDuration max, scala.collection.Seq<T> obj)
public static <C> C expectMsgAnyClassOf(scala.collection.Seq<java.lang.Class<? extends C>> obj)
public static <C> C expectMsgAnyClassOf(scala.concurrent.duration.FiniteDuration max, scala.collection.Seq<java.lang.Class<? extends C>> obj)
public static <T> scala.collection.immutable.Seq<T> expectMsgAllOf(scala.collection.Seq<T> obj)
public static <T> scala.collection.immutable.Seq<T> expectMsgAllOf(scala.concurrent.duration.FiniteDuration max, scala.collection.Seq<T> obj)
public static <T> scala.collection.immutable.Seq<T> expectMsgAllClassOf(scala.collection.Seq<java.lang.Class<? extends T>> obj)
public static <T> scala.collection.immutable.Seq<T> expectMsgAllClassOf(scala.concurrent.duration.FiniteDuration max, scala.collection.Seq<java.lang.Class<? extends T>> obj)
public static <T> scala.collection.immutable.Seq<T> expectMsgAllConformingOf(scala.collection.Seq<java.lang.Class<? extends T>> obj)
public static <T> scala.collection.immutable.Seq<T> expectMsgAllConformingOf(scala.concurrent.duration.FiniteDuration max, scala.collection.Seq<java.lang.Class<? extends T>> obj)
public static void expectNoMsg()
public static void expectNoMsg(scala.concurrent.duration.FiniteDuration max)
public static <T> scala.collection.immutable.Seq<T> receiveWhile(scala.concurrent.duration.Duration max, scala.concurrent.duration.Duration idle, int messages, scala.PartialFunction<java.lang.Object,T> f)
public static scala.collection.immutable.Seq<java.lang.Object> receiveN(int n)
public static scala.collection.immutable.Seq<java.lang.Object> receiveN(int n, scala.concurrent.duration.FiniteDuration max)
public static java.lang.Object receiveOne(scala.concurrent.duration.Duration max)
public static void shutdown(ActorSystem actorSystem, scala.concurrent.duration.Duration duration, boolean verifySystemShutdown)
public static ActorRef childActorOf(Props props, java.lang.String name, SupervisorStrategy supervisorStrategy)
public static ActorRef childActorOf(Props props, SupervisorStrategy supervisorStrategy)
public static scala.concurrent.duration.Duration awaitCond$default$2()
public static scala.concurrent.duration.Duration awaitCond$default$3()
public static java.lang.String awaitCond$default$4()
public static scala.concurrent.duration.Duration awaitAssert$default$2()
public static scala.concurrent.duration.Duration awaitAssert$default$3()
public static <T> scala.concurrent.duration.Duration expectMsgPF$default$1()
public static <T> java.lang.String expectMsgPF$default$2()
public static scala.concurrent.duration.Duration expectTerminated$default$2()
public static scala.concurrent.duration.Duration fishForMessage$default$1()
public static java.lang.String fishForMessage$default$2()
public static <T> scala.concurrent.duration.Duration receiveWhile$default$1()
public static <T> scala.concurrent.duration.Duration receiveWhile$default$2()
public static <T> int receiveWhile$default$3()
public static ActorSystem shutdown$default$1()
public static scala.concurrent.duration.Duration shutdown$default$2()
public static boolean shutdown$default$3()
public static ActorSystem system()
public static TestKitSettings testKitSettings()
public static java.util.concurrent.LinkedBlockingDeque<TestActor.Message> akka$testkit$TestKitBase$$queue()
public static TestActor.Message lastMessage()
public static void lastMessage_$eq(TestActor.Message x$1)
public static ActorRef testActor()
public static scala.concurrent.duration.Duration akka$testkit$TestKitBase$$end()
public static void akka$testkit$TestKitBase$$end_$eq(scala.concurrent.duration.Duration x$1)
public static boolean akka$testkit$TestKitBase$$lastWasNoMsg()
public static void akka$testkit$TestKitBase$$lastWasNoMsg_$eq(boolean x$1)
protected static void akka$testkit$TestKitBase$_setter_$testKitSettings_$eq(TestKitSettings x$1)
protected static final void akka$testkit$TestKitBase$_setter_$akka$testkit$TestKitBase$$queue_$eq(java.util.concurrent.LinkedBlockingDeque<TestActor.Message> x$1)
protected static void akka$testkit$TestKitBase$_setter_$testActor_$eq(ActorRef x$1)
public RoleName myself()
public LoggingAdapter log()
public <T> MultiNodeSpec.AwaitHelper<T> awaitHelper(scala.concurrent.Awaitable<T> w)
.await()
onto all Awaitables, using remaining duration from the innermost
enclosing within
block or QueryTimeout.w
- (undocumented)public final void multiNodeSpecBeforeAll()
MultiNodeSpecCallbacks
multiNodeSpecBeforeAll
in interface MultiNodeSpecCallbacks
public final void multiNodeSpecAfterAll()
MultiNodeSpecCallbacks
multiNodeSpecAfterAll
in interface MultiNodeSpecCallbacks
public scala.concurrent.duration.FiniteDuration shutdownTimeout()
public boolean verifySystemShutdown()
true
to assert that the
shutdown of the ActorSystem
was done properly.protected void atStartup()
protected void afterTermination()
public scala.collection.immutable.Seq<RoleName> roles()
public abstract int initialParticipants()
Must be a def
:
def initialParticipants = 5
public TestConductorExt testConductor()
public void runOn(scala.collection.Seq<RoleName> nodes, scala.Function0<scala.runtime.BoxedUnit> thunk)
roleMap
).nodes
- (undocumented)thunk
- (undocumented)public boolean isNode(scala.collection.Seq<RoleName> nodes)
nodes
- (undocumented)public void enterBarrier(scala.collection.Seq<java.lang.String> name)
within
block or the default BarrierTimeout
name
- (undocumented)public ActorPath node(RoleName role)
val serviceA = system.actorSelection(node("master") / "user" / "serviceA")
role
- (undocumented)public void muteDeadLetters(scala.collection.Seq<java.lang.Class<?>> messageClasses, ActorSystem sys)
protected void attachConductor(TestConductorExt tc)
protected void injectDeployments(ActorSystem sys, RoleName role)
protected Address myAddress()
protected ActorSystem startNewSystem()
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.