Hello all,
In order to test that no unaccounted-for serialization changes have happen
before we deploy our service, I need some way for us to *attempt* to
deserialize all currently stored events in our event journal and snapshots.
Currently, we just use the local leveldb plugin with local snapshot
storage, which has been totally adequate for our purpose.
I'm trying to do this by using a PersistenceQuery, but I'm totally unable
to get the persistence query to actually... return anything. My code is
pasted below. The things hidden behind the "PersistentTestKit" object just
handle some data cleaning before the tests, etc, and when I call
getNewConfig, that's just modifying the akka config to use the location of
the stored journal/snapshots we want to test against.
As you can see, I added a simple persistent actor just to test if I could
get the query to return events from something not even related to the
existing data, and even it doesn't show up in the query (nothing does).
This is the output:
Recover persisted a thing! // As many times as I've already run the test,
as expected.
Recover RecoveryCompleted
Persisting a thing!
Found persistence IDs:
Found persistence IDs:
Found persistence IDs:
Clearly, I'm missing something, but I'm not sure what. If I inspect the
config given to the system, everything looks right. The storage locations
are right, the plugins are right, etc. Can someone point me in the right
direction?
Alternatively, is there a better way to do this? I will happily do
something else entirely if PersistenceQuery isn't the right fit.
object PersistCompatIT {
val persistBackupLoc = ".exported_state"
val dumpFile = new File(PersistentTestKit.findRoot(),
persistBackupLoc).getAbsoluteFile
val absPathToBackup = dumpFile.toPath.toString
val systemConfig = PersistentTestKit.getNewConfig(true, (cfg) => {
cfg.withValue("akka.persistence.snapshot-store.local.dir",
ConfigValueFactory
.fromAnyRef(s"$absPathToBackup/boxsrv-snapshots/local-snapshots"))
.withValue("akka.persistence.journal.leveldb.dir",
ConfigValueFactory.fromAnyRef(s"$absPathToBackup/boxsrv-journal/leveldb-journal"))
})
val lamePersistActorID = "imastupidpersistactor"
class LamePersistActor extends PersistentActor {
override def receiveRecover: Receive = {
case m: Any => println(s"Recover $m")
}
override def receiveCommand: Receive = {
case 'whoapersist =>
println("Persisting a thing!")
persist("persisted a thing!") { _ => () }
case m: Any => println(s"Command $m")
}
override def persistenceId: String = lamePersistActorID
}
}
/**
* Tests backwards compatibility for journaling / snapshots
*/
class PersistCompatIT extends TestKit(ActorSystem("PersistCompatSys",
PersistCompatIT.systemConfig)) with FunSuiteLike {
test("test journal backwards compatibility", EndToEndTest) {
val lameActor = system.actorOf(Props(new LamePersistActor))
lameActor ! 'whoapersist
Thread.sleep(1000)
val readJournal =
PersistenceQuery(system).readJournalFor[LeveldbReadJournal](
LeveldbReadJournal.Identifier)
implicit val mat = ActorMaterializer()(system)
for (i <- 1 to 3) {
Thread.sleep(2000)
val allPersistenceIDs = readJournal.allPersistenceIds()
val dafuq =
readJournal.eventsByPersistenceId(PersistCompatIT.lamePersistActorID)
println("Found persistence IDs:")
allPersistenceIDs.map { e =>
println(e)
e
}
dafuq.map { e =>
println(e.event)
e
}
}
}
}
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.