akka.remote.testkit.MultiNodeSpecCallbacks Scala Examples
The following examples show how to use akka.remote.testkit.MultiNodeSpecCallbacks.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
Example 1
Source File: ProxyMultiJvm.scala From 006877 with MIT License | 5 votes |
package aia.channels // multi-jvm:test-only aia.channels.ReliableProxySampleSpec 로 시작할것 import org.scalatest.{WordSpecLike, BeforeAndAfterAll, MustMatchers} import akka.testkit.ImplicitSender import akka.actor.{Props, Actor} import akka.remote.testkit.MultiNodeSpecCallbacks import akka.remote.testkit.MultiNodeConfig import akka.remote.testkit.MultiNodeSpec trait STMultiNodeSpec extends MultiNodeSpecCallbacks with WordSpecLike with MustMatchers with BeforeAndAfterAll { override def beforeAll() = multiNodeSpecBeforeAll() override def afterAll() = multiNodeSpecAfterAll() } object ReliableProxySampleConfig extends MultiNodeConfig { val client = role("Client") val server = role("Server") testTransport(on = true) } class ReliableProxySampleSpecMultiJvmNode1 extends ReliableProxySample class ReliableProxySampleSpecMultiJvmNode2 extends ReliableProxySample import akka.remote.transport.ThrottlerTransportAdapter.Direction import scala.concurrent.duration._ import concurrent.Await import akka.contrib.pattern.ReliableProxy class ReliableProxySample extends MultiNodeSpec(ReliableProxySampleConfig) with STMultiNodeSpec with ImplicitSender { import ReliableProxySampleConfig._ def initialParticipants = roles.size "A MultiNodeSample" must { "wait for all nodes to enter a barrier" in { enterBarrier("startup") } "send to and receive from a remote node" in { runOn(client) { enterBarrier("deployed") val pathToEcho = node(server) / "user" / "echo" val echo = system.actorSelection(pathToEcho) val proxy = system.actorOf( ReliableProxy.props(pathToEcho, 500.millis), "proxy") proxy ! "message1" expectMsg("message1") Await.ready( testConductor.blackhole( client, server, Direction.Both), 1 second) echo ! "DirectMessage" proxy ! "ProxyMessage" expectNoMsg(3 seconds) Await.ready( testConductor.passThrough( client, server, Direction.Both), 1 second) expectMsg("ProxyMessage") echo ! "DirectMessage2" expectMsg("DirectMessage2") } runOn(server) { system.actorOf(Props(new Actor { def receive = { case msg: AnyRef => { sender() ! msg } } }), "echo") enterBarrier("deployed") } enterBarrier("finished") } } }
Example 2
Source File: STMultiNodeSpec.scala From lagom with Apache License 2.0 | 5 votes |
package com.lightbend.lagom.internal.cluster import akka.remote.testkit.MultiNodeSpecCallbacks import org.scalatest.BeforeAndAfterAll import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AnyWordSpecLike trait STMultiNodeSpec extends MultiNodeSpecCallbacks with AnyWordSpecLike with Matchers with BeforeAndAfterAll { override def beforeAll(): Unit = { super.beforeAll() multiNodeSpecBeforeAll() } override def afterAll(): Unit = { multiNodeSpecAfterAll() super.afterAll() } }
Example 3
Source File: STMultiNodeSpec.scala From akka-persistence-couchbase with Apache License 2.0 | 5 votes |
package com.lightbend.lagom.javadsl.persistence.multinode import akka.remote.testkit.MultiNodeSpecCallbacks import org.scalatest.BeforeAndAfterAll import org.scalatest.Matchers import org.scalatest.WordSpecLike trait STMultiNodeSpec extends MultiNodeSpecCallbacks with WordSpecLike with Matchers with BeforeAndAfterAll { override def beforeAll(): Unit = { super.beforeAll() multiNodeSpecBeforeAll() } override def afterAll(): Unit = { multiNodeSpecAfterAll() super.afterAll() } }
Example 4
Source File: STMultiNodeSpec.scala From akka-persistence-couchbase with Apache License 2.0 | 5 votes |
package com.lightbend.lagom.scaladsl.persistence.multinode import akka.remote.testkit.MultiNodeSpecCallbacks import org.scalatest.BeforeAndAfterAll import org.scalatest.Matchers import org.scalatest.WordSpecLike trait STMultiNodeSpec extends MultiNodeSpecCallbacks with WordSpecLike with Matchers with BeforeAndAfterAll { override def beforeAll(): Unit = { super.beforeAll() multiNodeSpecBeforeAll() } override def afterAll(): Unit = { multiNodeSpecAfterAll() super.afterAll() } }
Example 5
Source File: STMultiNodeSpec.scala From fusion-data with Apache License 2.0 | 5 votes |
package sample.multinode import akka.remote.testkit.{ MultiNodeSpec, MultiNodeSpecCallbacks } import org.scalatest.{ BeforeAndAfterAll, Matchers, WordSpecLike } import scala.language.implicitConversions trait STMultiNodeSpec extends MultiNodeSpecCallbacks with WordSpecLike with Matchers with BeforeAndAfterAll { self: MultiNodeSpec => override protected def beforeAll(): Unit = { super.beforeAll() multiNodeSpecBeforeAll() } override protected def afterAll(): Unit = { multiNodeSpecAfterAll() super.afterAll() } // Might not be needed anymore if we find a nice way to tag all logging from a node implicit override def convertToWordSpecStringWrapper(s: String): WordSpecStringWrapper = new WordSpecStringWrapper(s"$s (on node '${self.myself.name}', $getClass)") }
Example 6
Source File: LithiumMultiNodeSpec.scala From lithium with Apache License 2.0 | 5 votes |
package com.swissborg.lithium import akka.actor.{ActorSystem, Address} import akka.cluster.Cluster import akka.cluster.MemberStatus._ import akka.remote.testconductor.RoleName import akka.remote.testkit.{MultiNodeConfig, MultiNodeSpec, MultiNodeSpecCallbacks} import akka.testkit.ImplicitSender import org.scalatest.BeforeAndAfterAll import org.scalatest.concurrent.{Eventually, IntegrationPatience} import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AnyWordSpecLike abstract class LithiumMultiNodeSpec(val config: MultiNodeConfig) extends MultiNodeSpec(config) with MultiNodeSpecCallbacks with AnyWordSpecLike with Matchers with BeforeAndAfterAll with ImplicitSender with Eventually with IntegrationPatience { override def beforeAll(): Unit = multiNodeSpecBeforeAll() override def afterAll(): Unit = multiNodeSpecAfterAll() private val addresses: Map[RoleName, Address] = roles.map(r => r -> node(r).address).toMap protected def addressOf(roleName: RoleName): Address = addresses(roleName) protected def waitToBecomeUnreachable(roleNames: RoleName*): Unit = awaitCond(allUnreachable(roleNames: _*)) protected def waitForSurvivors(roleNames: RoleName*): Unit = awaitCond(allSurvivors(roleNames: _*)) protected def waitForUp(roleNames: RoleName*): Unit = awaitCond(allUp(roleNames: _*)) protected def waitForSelfDowning(implicit system: ActorSystem): Unit = awaitCond(downedItself) protected def waitForAllLeaving(roleNames: RoleName*): Unit = awaitCond(allLeaving(roleNames: _*)) protected def waitExistsAllDownOrGone(groups: Seq[Seq[RoleName]]): Unit = awaitCond(existsAllDownOrGone(groups)) private def allUnreachable(roleNames: RoleName*): Boolean = roleNames.forall( role => Cluster(system).state.unreachable.exists(_.address === addressOf(role)) ) private def allSurvivors(roleNames: RoleName*): Boolean = roleNames.forall(role => Cluster(system).state.members.exists(_.address === addressOf(role))) private def allUp(roleNames: RoleName*): Boolean = roleNames.forall( role => Cluster(system).state.members.exists(m => m.address === addressOf(role) && m.status === Up) ) private def existsAllDownOrGone(groups: Seq[Seq[RoleName]]): Boolean = groups.exists(group => allLeaving(group: _*)) private def downedItself(implicit system: ActorSystem): Boolean = { val selfAddress = Cluster(system).selfAddress Cluster(system).state.members .exists( m => m.address === selfAddress && (m.status === Exiting || m.status === Down || m.status === Removed) ) } private def allLeaving(roleNames: RoleName*): Boolean = roleNames.forall { role => val members = Cluster(system).state.members val unreachable = Cluster(system).state.unreachable val address = addressOf(role) unreachable.isEmpty && // no unreachable members (members.exists(m => m.address === address && (m.status === Down || m.status === Exiting)) || // member is down !members.exists(_.address === address)) // member is not in the cluster } }