Re: [akka-user] unit testing persistence recovery

2014-07-03 Thread Konrad Malawski
Hello Tim!
The PersistentActor is not the guy with the lock, it’s the (LevelDB)
journal.

You only need 1 actor system running (and one journal) to test what you
want, example:

class MyPersistentActor(override val persistenceId: String) extends
PersistentActor {
  // … persist events, handle recovery...
}

// test:
val act = sys.actorOf(Props[MyPersistentActor](“id-1212"))
act ! “persist-me-1”
act ! “persist-me-2” // persist(){} those

val act2 = sys.actorOf(Props[MyPersistentActor](“id-1212”))
// recovery kicks in, because they get the same persistenceId

act ! “what’s the last persist-me-### you got?”
expectMsg(“persist-me-2”) // because recovery

I hope this helps, happy hakking!
​
-- 
Konrad 'ktoso' Malawski
hAkker @ typesafe
http://akka.io

-- 
>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] unit testing persistence recovery

2014-07-03 Thread Konrad Malawski
Small typo, I meant act2 ! "what's the last persist-me-### you got? in the
second-to-last line.
​
-- 
Cheers, k

-- 
>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] unit testing persistence recovery

2014-07-03 Thread Tim Pigden
Thanks
Ok - just to make sure I've got this straight.
If I start a new PeristentActor with the same id as an existing one it will
just start in recovery mode regardless of the other one - right?


On 3 July 2014 13:16, Konrad Malawski  wrote:

> Small typo, I meant act2 ! "what's the last persist-me-### you got? in
> the second-to-last line.
> ​
> --
> Cheers, k
>



-- 
Tim Pigden
Optrak Distribution Software Limited
+44 (0)1992 517100
http://www.linkedin.com/in/timpigden
http://optrak.com
Optrak Distribution Software Ltd is a limited company registered in England
and Wales.
Company Registration No. 2327613 Registered Offices: Suite 6,The Maltings,
Hoe Lane, Ware, SG12 9LR England
This email and any attachments to it may be confidential and are intended
solely for the use of the individual to whom it is addressed. Any views or
opinions expressed are solely those of the author and do not necessarily
represent those of Optrak Distribution Software Ltd. If you are not the
intended recipient of this email, you must neither take any action based
upon its contents, nor copy or show it to anyone. Please contact the sender
if you believe you have received this email in error.

-- 
>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] unit testing persistence recovery

2014-07-03 Thread Konrad Malawski
If I start a new PeristentActor with the same id as an existing one it will
just start in recovery mode regardless of the other one - right?

Yes, it'll recover that persistent state.
The other thing you could do is to act ! “boom” it to make it restart,
which also triggers the replay.

Refer to our tests for more ideas on PersistentActor testing:
https://github.com/akka/akka/blob/release-2.3/akka-persistence/src/test/scala/akka/persistence/PersistentActorSpec.scala
​
-- 
Konrad 'ktoso' Malawski
hAkker @ typesafe
http://akka.io

-- 
>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.