I have a test were I have a probe and a spawned an actor. In this test I load the configuration file that lists the seed nodes so:
cluster {
seed-nodes = [
"akka://WorkStealSystem@127.0.0.1:25251",
"akka://WorkStealSystem@127.0.0.1:25252"]
...
I start up the test kit as follows:
def getConfig(roles: List[String], port: Int): Config = {
ConfigFactory
.parseString(s"""
akka.remote.artery.canonical.port=$port
akka.cluster.roles = [${roles.mkString(",")}]
""")
.withFallback(ConfigFactory.load("worksteal_test"))
}
val config = getConfig(List(Consumer.ID), 25251)
val testKit = ActorTestKit(config)
When executing the tests I get:
19:26:15.550 [WorkStealSpec-akka.actor.default-dispatcher-3] INFO akka.remote.artery.tcp.ArteryTcpTransport - Remoting started with transport [Artery tcp]; listening on address [akka://WorkStealSpec@127.0.0.1:25251] with UID [-6303977730066061616]
19:26:15.560 [WorkStealSpec-akka.actor.default-dispatcher-3] INFO akka.cluster.Cluster - Cluster Node [akka://WorkStealSpec@127.0.0.1:25251] - Starting up, Akka version [2.6.9] ...
19:26:15.877 [WorkStealSpec-akka.actor.default-dispatcher-3] INFO akka.cluster.Cluster - Cluster Node [akka://WorkStealSpec@127.0.0.1:25251] - Registered cluster JMX MBean [akka:type=Cluster]
19:26:15.878 [WorkStealSpec-akka.actor.default-dispatcher-3] INFO akka.cluster.Cluster - Cluster Node [akka://WorkStealSpec@127.0.0.1:25251] - Started up successfully
19:26:15.921 [WorkStealSpec-akka.actor.default-dispatcher-3] WARN akka.serialization.Serialization(akka://WorkStealSpec) - Using the Java serializer for class [scala.collection.immutable.Vector1] which is not recommended because of performance implications. Use another serializer or disable this warning using the setting 'akka.actor.warn-about-java-serializer-usage'
19:26:15.928 [WorkStealSpec-akka.actor.default-dispatcher-3] INFO akka.cluster.sbr.SplitBrainResolver - SBR started. Config: stableAfter: 20000 ms, strategy: KeepMajority, selfUniqueAddress: UniqueAddress(akka:
I see that the cluster nodes have the name WorkStealSpec
and not the configured WorkStealSystem
. I think this causes the following messages:
19:26:16.147 [WorkStealSpec-akka.actor.default-dispatcher-28] WARN akka.remote.artery.InboundHandshake$$anon$2 - Dropping Handshake Request from [akka://WorkStealSpec@127.0.0.1:25251#-6303977730066061616] addressed to unknown local address [akka://WorkStealSystem@127.0.0.1:25251]. Local address is [akka://WorkStealSpec@127.0.0.1:25251]. Check that the sending system uses the same address to contact recipient system as defined in the 'akka.remote.artery.canonical.hostname' of the recipient system. The name of the ActorSystem must also match.
When I print out the host name I get 127.0.0.1
, so I assume the ActorSystem
name is the culprit. The name WorkStealSpec
seems to come from the JUnit test class.
So my question is: how should we set this up? Do I need a test-specific configuration file for each test case? I already use a test-specific file that has this:
include "worksteal"
// Configurations for testing only
// Force local JVM clusters to serialize. Allows us to detect serialization
// problems if we run all the actors in the same node.
akka.actor.serialize-creators = on
akka.actor.allow-java-serialization = on
akka.actor.warn-on-no-serialization-verification = on
Can one override the seeds in this file? If so were can we overwrite the name that is generated by the testKit that matches the test case class?
If an example already exists, could someone also point to it?
TIA