You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »





package com.example.kotlinbootlabs.actor.cluster

class ClusterActorTest {

    companion object {
        private lateinit var testKit: ActorTestKit
        private lateinit var manualTime: ManualTime

        @BeforeAll
        @JvmStatic
        fun setup() {
            val config = ManualTime.config().withFallback(ConfigFactory.defaultApplication())
            testKit = ActorTestKit.create(config)
            manualTime = ManualTime.get(testKit.system())
        }

        @AfterAll
        @JvmStatic
        fun teardown() {
            testKit.shutdownTestKit()
        }
    }

    @Test
    fun testClusterHelloActorA() {
        val probe = testKit.createTestProbe<HelloActorAResponse>()
        val actorA = testKit.spawn(ClusterHelloActorA.create())

        actorA.tell(HelloA("Hello", probe.ref))
        probe.expectMessage(HelloAResponse("Kotlin"))
    }

    @Test
    fun testClusterHelloActorB() {
        val probe = testKit.createTestProbe<HelloActorBResponse>()
        val actorB = testKit.spawn(ClusterHelloActorB.create())

        actorB.tell(HelloB("Hello", probe.ref))
        probe.expectMessage(HelloBResponse("Kotlin"))
    }

    @Test
    fun testClusterHelloActorAandB() {
        val probeA = testKit.createTestProbe<HelloActorAResponse>()
        val probeB = testKit.createTestProbe<HelloActorBResponse>()
        val actorA = testKit.spawn(ClusterHelloActorA.create())
        val actorB = testKit.spawn(ClusterHelloActorB.create())

        actorA.tell(HelloA("Hello", probeA.ref))
        probeA.expectMessage(HelloAResponse("Kotlin"))

        actorB.tell(HelloB("Hello", probeB.ref))
        probeB.expectMessage(HelloBResponse("Kotlin"))
    }
}





 두개의 노드로 클러스터를 구성하고 싶습니다.

첫번째 노드는 Seed담당과 HelloActorA 를 
두번째 노드는 HelloActorB를 

그리고 리모트로 구성되었지만 클러스터내에서 HelloActorA가 HelloActorB에게 이벤트를 전송하는 기능을 검증

위 내용을 반영해 코드개선





  • No labels