intellij idea - Scalatest / Sbt / Akka-TestKit Issue in Testing Persistent Actor -
i'm running test akka testkit on persistent actor.
an odd problem facing that, despite me, cleaning persistent folders before or after each test, when run full test suite sbt, persistent folders seems not removed. problem, because 1 test scenario next, data persisted carried. when next scenario start, actor recover data previous scenario, falsify test.
this happens when run sbt. if run intellij, not have problem, test scenario ran perfectly
please see below persistencespec mixin on test.
abstract class persistencespec(system: actorsystem) extends testkit(system) implicitsender featurespeclike matchers givenwhenthen beforeandafterall beforeandaftereach persistencecleanup { def this(name: string, config: config) = this(actorsystem(name, config)) override protected def beforeall() = deletestoragelocations() override protected def afterall() = { deletestoragelocations() testkit.shutdownactorsystem(system) } override protected def beforeeach() : unit = { deletestoragelocations() super.beforeeach() } override protected def aftereach(): unit = { super.aftereach() deletestoragelocations() } def killactors(actors: actorref*) = { actors.foreach { actor => watch(actor) system.stop(actor) expectterminated(actor) } } } trait persistencecleanup { def system: actorsystem val storagelocations = list( "akka.persistence.journal.leveldb.dir", "akka.persistence.journal.leveldb-shared.store.dir", "akka.persistence.snapshot-store.local.dir").map { s => new file(system.settings.config.getstring(s)) } def deletestoragelocations(): unit = { storagelocations.foreach{ dir => try(fileutils.deletedirectory(dir)) match { case success(e) => system.log.debug(s"deleting: ${dir.getname} success: ${e} ") case failure(e) => system.log.debug(s"deleting: ${dir.getname} failure: ${e} ") } } } }
to me not working beforeeach or aftereach.
is there know issue ? isn't odd intellij runs without issue? has idea on ? please share experience, solutions or ideas.
Comments
Post a Comment