Skip to content

Commit

Permalink
fix: avoid persistence run fast
Browse files Browse the repository at this point in the history
  • Loading branch information
Roiocam committed Nov 2, 2023
1 parent 47eb41f commit 87a2e5f
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,18 +172,16 @@ abstract class CurrentEventsByTagTest(config: String) extends QueryTestSpec(conf

val latch = new CountDownLatch(1)
val largeNumberOfMessage = 2000
val smallNumberOfMessage = 200
val diff = largeNumberOfMessage - smallNumberOfMessage
val journalOps = new JavaDslJdbcReadJournalOperations(system)
import system.dispatcher
withTestActors(replyToMessages = true) { (actor1, actor2, actor3) =>
def sendMessagesWithTag(tag: String, numberOfMessagesPerActor: Int): Future[Done] = {
val futures = for (actor <- Seq(actor1, actor2, actor3); i <- 1 to numberOfMessagesPerActor) yield {
// block the execution
if (i == largeNumberOfMessage) {
Future {
latch.await()
actor ? TaggedAsyncEvent(Event(i.toString), tag)
}
} else {
Future {
// block the remaining small batch events from being fired
if (i == diff) latch.await()
actor ? TaggedAsyncEvent(Event(i.toString), tag)
}
}
Expand All @@ -192,7 +190,7 @@ abstract class CurrentEventsByTagTest(config: String) extends QueryTestSpec(conf

val tag = "someTag"
// send a batch of 3 * 200
val batch1 = sendMessagesWithTag(tag, 200)
val batch1 = sendMessagesWithTag(tag, smallNumberOfMessage)
// Try to persist a large batch of events per actor. Some of these may be returned, but not all!
val batch2 = sendMessagesWithTag(tag, largeNumberOfMessage)

Expand Down

0 comments on commit 87a2e5f

Please sign in to comment.