Skip to content

Commit a21806e

Browse files
committed
test: log warn message (ReplicationFailed)
1 parent 390afb2 commit a21806e

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/test/scala/lerna/akka/entityreplication/raft/RaftActorLeaderSpec.scala

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package lerna.akka.entityreplication.raft
22

33
import akka.Done
4+
import akka.actor.testkit.typed.scaladsl.LoggingTestKit
5+
import akka.actor.typed.scaladsl.adapter._
46
import akka.actor.{ ActorRef, ActorSystem }
57
import akka.testkit.{ TestKit, TestProbe }
68
import com.typesafe.config.ConfigFactory
@@ -24,6 +26,7 @@ import scala.concurrent.duration.DurationInt
2426
class RaftActorLeaderSpec extends TestKit(ActorSystem()) with RaftActorSpecBase with Inside {
2527

2628
import RaftActor._
29+
private implicit val typedSystem: akka.actor.typed.ActorSystem[Nothing] = system.toTyped
2730

2831
private[this] val entityId = NormalizedEntityId.from("test-entity")
2932
private[this] val shardId = NormalizedShardId.from("test-shard")
@@ -630,7 +633,7 @@ class RaftActorLeaderSpec extends TestKit(ActorSystem()) with RaftActorSpecBase
630633
} should contain theSameElementsAs (Set(follower1Index, follower2Index))
631634
}
632635

633-
"reply ReplicationFailed to replicationActor if replication is in progress" in {
636+
"reply ReplicationFailed to replicationActor and log warn message if replication is in progress" in {
634637
val replicationActor1 = TestProbe()
635638
val replicationActor2 = TestProbe()
636639
val entityId1 = NormalizedEntityId("test-1")
@@ -661,14 +664,19 @@ class RaftActorLeaderSpec extends TestKit(ActorSystem()) with RaftActorSpecBase
661664
)
662665
replicationActor2.expectNoMessage()
663666

664-
leader ! Replicate(
665-
event = "c",
666-
replicationActor1.ref,
667-
entityId1,
668-
entityInstanceId,
669-
originSender = system.deadLetters,
670-
)
671-
replicationActor1.expectMsg(ReplicationFailed)
667+
LoggingTestKit
668+
.warn(
669+
"Failed to replicate the event (java.lang.String) since an uncommitted event exists for the entity (entityId: test-1). Replicating new events is allowed after the event is committed",
670+
).expect {
671+
leader ! Replicate(
672+
event = "c", // java.lang.String
673+
replicationActor1.ref,
674+
entityId1,
675+
entityInstanceId,
676+
originSender = system.deadLetters,
677+
)
678+
replicationActor1.expectMsg(ReplicationFailed)
679+
}
672680
}
673681
}
674682

0 commit comments

Comments
 (0)