These are chat archives for petabridge/akka-bootcamp

15th
Mar 2017
bjxu
@bjxu
Mar 15 2017 09:19
Hi, Can some one show me how to unit test a SupervisionStrategy, e.g. some asserts that a child actor got restarted?
mwardm
@mwardm
Mar 15 2017 09:45
There's a "How do I test a SupervisorStrategy?" section on the page https://petabridge.com/blog/how-to-unit-test-akkadotnet-actors-akka-testkit/ . Does that help?
bjxu
@bjxu
Mar 15 2017 10:59
@mwardm thanks for your reply. not really. it has an example showing how to unit test the termination of an actor with ExpectTerminated(...), but it doesn't show me how to test the restart of the actor
Aaron Stannard
@Aaronontheweb
Mar 15 2017 16:37
@bjxu need to be able to force the actor to fail
in order to restart it
so you can start up an actor with the supervision strategy you want to test
and create a dummy actor who throws one of the types of exceptions you're looking to observe
and then that actor can do something like set a flag when PostRestart is called
or it can send a message to the TestActor when PostRestart is called
signalling that it did restart
bjxu
@bjxu
Mar 15 2017 16:39
@Aaronontheweb yes I thought about using sending message or using logs to test the restart of my actor
@Aaronontheweb Just wonder if there is something like ExpectTerminated(...) to check the status of the actor
Aaron Stannard
@Aaronontheweb
Mar 15 2017 16:40
Terminated messages are only sent when the actor is permanently killed
via Context.Stop or a PoisonPill
restarts are usually transparent to everyone else
except for the affected actor
bjxu
@bjxu
Mar 15 2017 16:43
ok let me try to test it by sending a message in the PostRestart function
Thanks a lot!
Aaron Stannard
@Aaronontheweb
Mar 15 2017 16:43
you're welcome