This might not help, but I've done various different things at different 
times:
1. if you're not testing the Casandra persistence per se, but the other 
components, consider using an in-memory storage plugin. This will very fast 
and on an otherwise unused machine should not display high variability in 
wait times. So a small wait may be sufficient. if you fire up another 
PersistentActor with the same id at the end then it will try to replay the 
messages from the journal so you can check they are all there.
2. Figure out if there's a logical point at which one of the actors can 
signal "I'm done" to some run-time specified actor. Use this in your test 
with an ExpectMsg to wait until it's done. Maybe extend an  base actor 
class with some form of mock to achieve this. So I have base class actors, 
with empty return signal methods and extend them in test to make it 
actually do something. It means you go into production with a call to an 
empty method but it's small scale in the scheme of things.
3. Question whether or not the large variability in time is itself a test 
failure. I've often increased time waiting for a message only to find that 
the delay was caused by a bug of some sort.


On Thursday, September 4, 2014 4:55:43 PM UTC+1, Bartłomiej Szczepanik 
wrote:
>
> Dear Akka users,
>
> I am working on a simple CQRS framework on top of the akka persistence. I 
> am unsuccessfully trying to create a non-flaky integration test which 
> involves:
>
>    - spawning some persistent actors
>    - sending some messages to them
>    - *waiting for a while to make sure that the journal will be updated* 
> (cassandra 
>    in my case) 
>    - replay events using a direct journal reader 
>
> The problem is with the third step. Simply waiting for a while seems to be 
> not enough in some cases, even if I set a longer time (several seconds). 
> Can you recommend me a way to have a more reliable test? Can I wait somehow 
> until all persistAsync methods will be completed fully and events visible 
> in the journal?
>
> Thanks,
> Bartłomiej
>

-- 
>>>>>>>>>>      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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to