Stabilise InmemPersistentActorSpec (#30499)
This commit is contained in:
parent
71263db0cc
commit
cb97ae1240
1 changed files with 15 additions and 10 deletions
|
|
@ -11,13 +11,13 @@ import scala.concurrent.Await
|
|||
import scala.concurrent.duration._
|
||||
import scala.util.Random
|
||||
import scala.util.control.NoStackTrace
|
||||
|
||||
import scala.annotation.nowarn
|
||||
import com.typesafe.config.{ Config, ConfigFactory }
|
||||
|
||||
import com.typesafe.config.{ Config, ConfigFactory }
|
||||
import akka.actor._
|
||||
import akka.persistence.PersistentActorSpec._
|
||||
import akka.testkit.{ EventFilter, ImplicitSender, TestLatch, TestProbe }
|
||||
import org.scalatest.concurrent.Eventually
|
||||
|
||||
object PersistentActorSpec {
|
||||
|
||||
|
|
@ -944,7 +944,7 @@ object PersistentActorSpec {
|
|||
}
|
||||
}
|
||||
|
||||
abstract class PersistentActorSpec(config: Config) extends PersistenceSpec(config) with ImplicitSender {
|
||||
abstract class PersistentActorSpec(config: Config) extends PersistenceSpec(config) with ImplicitSender with Eventually {
|
||||
|
||||
import PersistentActorSpec._
|
||||
|
||||
|
|
@ -1210,13 +1210,18 @@ abstract class PersistentActorSpec(config: Config) extends PersistenceSpec(confi
|
|||
expectMsg(5)
|
||||
}
|
||||
"be able to opt-out from stashing messages until all events have been processed" in {
|
||||
val persistentActor = asyncPersistPersistentActor
|
||||
persistentActor ! Cmd("x")
|
||||
persistentActor ! Cmd("y")
|
||||
expectMsg("x")
|
||||
expectMsg("y") // "y" command was processed before event persisted
|
||||
expectMsg("x-1")
|
||||
expectMsg("y-2")
|
||||
// There's a race between "y" and "x-1", but only if we receive "y" we will prove
|
||||
// that commands are processed before events have been persisted. Therefore, we
|
||||
// retry until eventually...
|
||||
eventually {
|
||||
val persistentActor = asyncPersistPersistentActor
|
||||
persistentActor ! Cmd("x")
|
||||
persistentActor ! Cmd("y")
|
||||
expectMsg("x")
|
||||
expectMsg("y") // "y" command was processed before event persisted
|
||||
expectMsg("x-1")
|
||||
expectMsg("y-2")
|
||||
}
|
||||
}
|
||||
"support multiple persistAsync calls for one command, and execute them 'when possible', not hindering command processing" in {
|
||||
val persistentActor = asyncPersistThreeTimesPersistentActor
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue